akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

struct edge{
    int to;
    int cost;
    edge(int a,int b){
        to = a, cost = b;
    }
};

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);

    int V,E; cin>>V>>E;
    vector<vector<ll> > G(V,vector<ll>(V,INF));
    REP(i,E){
        ll s,t,d;
        cin>>s>>t>>d;
        G[s][t] = d;
    }
    REP(i,V){
        G[i][i] = 0;
    }
    
    REP(k,V){
        REP(i,V){
            REP(j,V){
                if(G[i][k] != INF && G[k][j] != INF){
                     G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
                }
            }
        }
    }

    bool flag = true;
    REP(i,V){
        if(G[i][i] < 0){
            flag = false; break;
        }
    }
    if(flag){
        REP(i,V){
            REP(k,V){
                if(k != V-1){
                    if(G[i][k] == INF) cout << "INF" << " ";
                else cout << G[i][k] << " ";
                }
                else{
                    if(G[i][k] == INF) cout << "INF" <<endl;
                    else cout << G[i][k] << endl;
                }          
            }
        }
    }
    else{
        cout << "NEGATIVE CYCLE" << endl;
    }
}


Measured memory_bytes: 3312
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll ans = 700;
string s;

int main() {
	rd(s);
	repi(i, 0, 3) if (s[i] == 'o') ans += 100;
	wrln(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    cout << n/3 << '\n';                                                                                              
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  if(n / 100 % 11 == 0 || n % 1000 / 10 % 11 == 0 || n % 100 % 11 == 0)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> p = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		int count = 0;
		for(int i = 0; i < n; i++) {
			if(p.get(i)!=i+1) {
				count++;
			}
		}

		if(count<=2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;

double EPS = 1e-10;

bool used[30];
ll d[30], w[30];
int n;


int main(){
	ll sum;
	bool f;

	while(cin>>n && n){
		rep(i, n) cin>>d[i]>>w[i], used[i] = false;
		sum = 0LL;
		rep(i, n) sum += d[i];
		f = true;
		for(int i = 0; i < n; i++){
			int idx = -1;
			for(int j = 0; j < n; j++){
				if(!used[j]){
					if(w[j]>=sum){
						if(idx==-1) idx = j;
						else if(d[idx]<d[j]) idx = j;
					}
				}
			}
			if(idx == -1) {
				f = false;
				break;
			}
			sum-=d[idx];
			used[idx] = true;
		}
		cout<<(f?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
#include <bits/stdc++.h>

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	vector<int> dp_arr(n+1,0);
	dp_arr[0] = 0;
	for(int i = 1; i < n; i++)
	{
		if(i == 1)
		{
			dp_arr[i] = abs(arr[1]-arr[0]);
		}
		else
		{
			dp_arr[i] = min(dp_arr[i-1]+abs(arr[i]-arr[i-1]),dp_arr[i-2]+abs(arr[i]-arr[i-2]));
		}
	}
	cout << dp_arr[n-1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

class Main{
  public static void main(String[] arrgs){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int x=1,n=0;
    while(x<B){
      x = x+A-1;
      n++;
    }
    System.out.println(n);
  }
}
      

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>

 int main(void){
      int a,b,c;
      char dummy;
      int d,e,f;
      
      rewind(stdin);
      d = scanf("%d %d %d",&a,&b,&c);
     /* printf("柱の高さを３つ決めてください\n");
      printf("左 ");
      rewind(stdin);
      d = scanf("%d",&a); 
      printf("中 ");
      rewind(stdin);
      e = scanf("%d",&b); 
      printf("右 ");
      rewind(stdin);
      f = scanf("%d",&c); */
       
      if(a<1 || a>100 || b<1 || b>100 || c<1 || c>100){
        printf("柱は　１〜１００　の間で決めてください\n");
        exit(0);
        }
      
      if(b-a == c-b){
        printf("YES\n");
        return 0;
      }else{
        printf("NO\n");
        return 0;
       }
   }
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

class UnionFind {  
  public:
  vector<long long> par;
  vector<long long> rank;
 
  UnionFind(long long N) : par(N + 1), rank(N + 1){
    for(int i = 0; i < N; i++){  
      par[i] = i;
      rank[i] = 1;
    }
  }
 
  long long root(long long x){  
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
 
  long long size(long long x){  
    return rank[root(x)]; 
  }
 
  void unite(long long x, long long y){  
    long long rx = root(x); 
    long long ry = root(y);
    if (rx == ry) return;
 
    if(rank[rx] < rank[ry]){  
      par[rx] = ry; 
    } else{  
      par[ry] = rx;
      if(rank[rx] == rank[ry]) rank[rx]++; 
    }
  }
 
  bool same(long long x, long long y){  
    return root(x) == root(y); 
  }
};


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0; i < M; i++){  
    int x, y, z;
    cin >> x >> y >> z; 
    x--; y--;
    uf.unite(x, y);
  }
  unordered_set<int> s;
  for(int i = 0; i < N; i++){  
    s.insert(uf.root(i));  
  }
  cout << s.size() <<endl;
}


Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  vector<int> A(N, 0);
  vector<int> index(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    index[i] = i;
  }

  // 降順ソート
  vector<int> B(N, 0);
  B = A;
  for (int i = 0; i < N; i++) {
    for (int j = i; j > 0; j--) {
      if (B[j - 1] < B[j]) {
        swap(B[j - 1], B[j]);
        swap(index[j - 1], index[j]);
      }
    }
  }

  long dp[N + 1][N + 1];
  for (int i = 0; i < N + 1; i++) {
    dp[i][0] = 0;
  }

  int i, r;
  long a;
  long L, R;
  for (int s = 0; s < N; s++) {
    i = index[s];
    a = A[i];
    for (int l = s; l >= 0; l--) {
      r = s - l;

      L = dp[l][r] + a * abs(i - l);
      R = dp[l][r] + a * abs(N - 1 - r - i);

      if (dp[l + 1][r] < L) {
        dp[l + 1][r] = L;
      }
      dp[l][r + 1] = R;
    }
  }

  long ans = 0;
  for (int i = 0; i < N + 1; i++) {
    ans = max(ans, dp[N - i][i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 26340
#include <stdio.h>
#include <string.h>

int main (int argc,char **argv)
{
	char s1[11],s2[11],s3[11];
	
	scanf("%s%s%s",s1,s2,s3);

	
      s1[0] = s1[0] - 32;
      s2[0] = s2[0] - 32;
      s3[0] = s3[0] - 32;
	
	printf("%c%c%c\n",s1[0],s2[0],s3[0]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int n, m;
int ans = 0;

class node {
public:
	bool flag;
	vector<int> ptr;
	node() {
		flag = false;
	}
};


void f(vector<node>& graph, int i) {
	graph[i].flag = true;
	int k = 0;
	for (int j = 0; j < graph[i].ptr.size(); j++) {
		if (!graph[graph[i].ptr[j]].flag) {
			k++;
			f(graph, graph[i].ptr[j]);
		}
	}
	//端のとき
	if (k == 0) {
		bool tmp = true;
		for (int i = 0; i < n; i++) {
			if (!graph[i].flag) {
				tmp = false;
				break;
			}
		}
		if (tmp)ans++;
	}
	graph[i].flag = false;
	return;
}


int main() {
	cin >> n >> m;
	vector<node> graph(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a-1].ptr.emplace_back(b-1);
		graph[b-1].ptr.emplace_back(a-1);
	}
	
	f(graph, 0);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define MN 1000
char s[MN+5][MN+5];
int main()
{
	int n,m,a,b,i,j;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	if((n&1)&&(m&1)&&n>1&&m>1&&a>1&&b>1)
	{
		int aa=a,bb=b;
		s[n-2][m-2]='^';s[n-2][m-1]='<';s[n-2][m]='>';
		s[n-1][m-2]='v';               ;s[n-1][m]='^';
		s[n  ][m-2]='<';s[n  ][m-1]='>';s[n  ][m]='v';
		for(a-=2,i=1;i<m-3;i+=2)if(a)s[n][i]='<',s[n][i+1]='>',--a;
		for(b-=2,i=1;i<n-3;i+=2)if(b)s[i][m]='^',s[i+1][m]='v',--b;
		for(i=1;i<n;i+=2)for(j=1;j<m;j+=2)if(i<n-3||j<m-3)
			if(a)
			{
				s[i][j]='<';s[i][j+1]='>';
				if(--a)s[i+1][j]='<',s[i+1][j+1]='>',--a;
			}
			else if(b)
			{
				s[i][j]='^';s[i+1][j]='v';
				if(--b)s[i][j+1]='^',s[i+1][j+1]='v',--b;
			}
		if(a||b)memset(s,0,sizeof(s)),a=aa,b=bb;
		else
		{
			puts("YES");
			for(i=1;i<=n;puts(s[i++]+1))for(j=1;j<=m;++j)if(!s[i][j])s[i][j]='.';
			return 0;
		}
	}
	if(n&1)for(i=1;i<m;i+=2)if(a)s[n][i]='<',s[n][i+1]='>',--a;
	if(m&1)for(i=1;i<n;i+=2)if(b)s[i][m]='^',s[i+1][m]='v',--b;
	for(i=1;i<n;i+=2)for(j=1;j<m;j+=2)
		if(a)
		{
			s[i][j]='<';s[i][j+1]='>';
			if(--a)s[i+1][j]='<',s[i+1][j+1]='>',--a;
		}
		else if(b)
		{
			s[i][j]='^';s[i+1][j]='v';
			if(--b)s[i][j+1]='^',s[i+1][j+1]='v',--b;
		}
	if(a||b)return 0*puts("NO");
	puts("YES");
	for(i=1;i<=n;puts(s[i++]+1))for(j=1;j<=m;++j)if(!s[i][j])s[i][j]='.';
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  u32 N;
  cin >> N;
  vector<u32> A(N);
  ArrayInput(A);
  vector<u64> Ball(N, 0);
  for (u32 i = 0; i < N; ++i) {
    Ball[A[i] - 1]++;
  }
  u64 res = 0;
  for (u32 i = 0; i < N; ++i) {
    res += (Ball[i] * (Ball[i] - 1)) / 2;
  }
  for (u32 i = 0; i < N; ++i) {
    cout << 1 + (res - Ball[A[i] - 1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())

class Node:
    def __init__(self):
        self.parent_id = -1
        self.sib = -1
        self.left = -1
        self.right = -1
        self.deg = 0
        self.height = 0
        self.depth = 0
        self.children = []

def cal_depth (node,x):
    node.depth = x

    for children_id in node.children:
        cal_depth(nodes[children_id],x+1)

def cal_height(node):

    h1 = 0
    h2 = 0
    if node.left != -1:
       h1 = cal_height(nodes[node.left]) + 1
    if node.right != -1:
       h2 = cal_height(nodes[node.right]) +1

    node.height = max(h1,h2)

    return max(h1,h2)



nodes = []
for i in range(n):
    nodes.append(Node())

for i in range(n):
    deg = 0
    table = list(map(int,input().split()))
    node_id = table[0]
    nodes[node_id].left = table[1]
    nodes[node_id].right = table[2]
    if table[1] == -1 and table[2] == -1:
        nodes[node_id].deg = 0
    elif table[1] == -1 or table[2] == -1:
        nodes[node_id].deg = 1
        if table[1] != -1:
            nodes[table[1]].parent_id = node_id
            nodes[node_id].children.append(table[1])
        else:
            nodes[table[2]].parent_id = node_id
            nodes[node_id].children.append(table[2])
    else:
        nodes[node_id].deg = 2
        nodes[table[1]].parent_id = node_id
        nodes[table[2]].parent_id = node_id
        nodes[table[1]].sib = table[2]
        nodes[table[2]].sib = table[1]
        nodes[node_id].children.append(table[1])
        nodes[node_id].children.append(table[2])

ino_list = []
def Ino(node_id):
    if nodes[node_id].left != -1 :
        Ino(nodes[node_id].left)
    ino_list.append(node_id)
    if nodes[node_id].right != -1:
        Ino(nodes[node_id].right)

post_list =[]

def pos(node_id):
    l = nodes[node_id].left
    r = nodes[node_id].right
    if l != -1:
        pos(l)
    if r != -1:
        pos(r)
    post_list.append(node_id)


pre_list = []
def pre(node_id):
    pre_list.append(node_id)
    left = nodes[node_id].left
    right = nodes[node_id].right

    if left != -1:
        pre(left)
    if right != -1:
        pre(right)

for i in range(n):
    if nodes[i].parent_id == -1:
        pre(i)
        Ino(i)
        pos(i)
        break

pre_list = list(map(str,pre_list))

post_list = list(map(str,post_list))

ino_list = list(map(str,ino_list))


print("Preorder")
print(" ",end="")
print(' '.join(pre_list))
print("Inorder")
print(" ",end="")
print(' '.join(ino_list))
print("Postorder")
print(" ",end="")
print(' '.join(post_list))


Measured memory_bytes: 5628
#include <iostream>
#include <map>

using namespace std;



int main() {
    int n;
    char c;
    map<char, bool> mp;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> c;
        mp[c] = true;
    }

    if (mp.size() == 3) {
        cout << "Three" << endl;
    }
    else if (mp.size() == 4) {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	if (n%m==0)
	{
		cout<<-1;
		return 0;
	}
	if (n*2%m)
	{
		cout<<n*2;
		return 0;
	}
	cout<<n*3;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x >= r && x + r <= W && y >= r && y + r <= H){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int i;
	if (!n) { pc('0'); return; }
	i = 0; while (n) buf[i++] = n%10 + '0', n/=10;
	while (i--) pc(buf[i]); 
}

typedef struct { char c; int a; int id; } DATA;

int partition(DATA *a, int lo, int hi)
{
	int i, j;
	int key;
	DATA t;
	
	key = a[hi].a, i = lo-1;
	for (j = lo; j < hi; j++) {
		if (a[j].a <= key) i++, t = a[i], a[i] = a[j], a[j] = t;
	}
	t = a[++i], a[i] = a[hi], a[hi] = t;
	return i;
}

void quick_sort(DATA *a, int lo, int hi)
{
	int mi;

	if (lo < hi) {
		mi = partition(a, lo, hi);
		quick_sort(a, lo, mi-1);
		quick_sort(a, mi+1, hi);
	}
}

DATA a[100002];

int main()
{
	int N, i, f;

	N = in();
	for (i = 0; i < N; i++) {
		a[i].c = gc(), gc();
		a[i].a = in(), a[i].id = i;
	}
	quick_sort(a, 0, N-1);
	f = 0; for (i = 1; i < N; i++) {
		if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) { f = 1; break; }
	}
	puts(f? "Not stable": "Stable");
	for (i = 0; i < N; i++) {
		pc(a[i].c), pc(' '), mypr(a[i].a), pc('\n');
	}
	return 0;
}



Measured memory_bytes: 2720
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

//マクロ
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

//debug
#define dump(x) cout << #x << " = " << (x) << endl;

//ALDS1_1_D
#include <algorithm>
#include <cmath>

const int N_MAX = 200000;
int R[N_MAX];
int n;
int maxv = -1000000000;
int minv;

int main() {
    cin >> n;
    REP(i,n){
        cin >> R[i];
    }
    int minv = R[0];
    
    FOR(i,1,n){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w; scanf("%d%d", &h, &w); std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	int one = 0, two = 0, four = 0;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			std::set<std::pair<int, int>> st;
			st.insert({i, j});
			st.insert({h - i - 1, j});
			st.insert({i, w - j - 1});
			st.insert({h - i - 1, w - j - 1});

			if(st.size() == 1) one++;
			if(st.size() == 2) two++;
			if(st.size() == 4) four++;
		}
	}
	one /= 1;
	two /= 2;
	four /= 4;

	std::vector<int> cnt(26, 0);
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cnt[s[i][j] - 'a']++;

	for(auto& v: cnt) {
		while(v >= 4 and four > 0) {
			v -= 4;
			four--;
		}
	}
	for(auto& v: cnt) {
		while(v >= 2 and two > 0) {
			v -= 2;
			two--;
		}
	}
	for(auto& v: cnt) {
		while(v >= 1 and one > 0) {
			v -= 1;
			one--;
		}
	}

	bool ans = (one == 0 and two == 0 and four == 0);
	if(ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#9問目
N,Y = map(int, input().split())
A = B = C = -1
 
for i in range(N+1) :
    for j in range(N+1-i):
        k = N-i-j
        if 10000*i + 5000*j + 1000*k == Y:
            A = i
            B = j
            C = k
            break
    else:
        continue
    break
        
    
     
print(A,B,C)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	  cin>>a[i];
	 int sum=0; 
	for(int i=0;i<n;i++){
		if(a[i]==i+1){
			int t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			sum++;
		}
	}  
	for(int i=n-1;i>=0;i--){
		if(a[i]==i+1){
			int t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			sum++;
		}
	}  
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;
const int MAX=200005;

vector<pair<ll, ll>> prime_facorize(ll n){
    vector<pair<ll, ll>> res;
    for(ll i=2; i*i<=n; i++){
        if(n%i != 0) continue;
        int num = 0;
        while(n%i == 0){
            num++;
            n/=i;
        }
        res.push_back(make_pair(i, num));
    }
    if(n > 1) res.push_back(make_pair(n, 1));
    return res;
}

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }

}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(void){
    int N, M; cin >> N >> M;
    ll ans=1;
    vector<pair<ll, ll>> A = prime_facorize(M);

    COMinit();
    for(auto pa : A){
        ans = (ans * COM(pa.second + N - 1, pa.second)) % mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long int
#define N int(2e5+10)
#define mod 998244353
using namespace std;
ll seg[4 * N], lazy[4 * N], power[N], sum[N], n , d, l, r, q;
void build(int l, int h, int pos) {
	if (l == h) {
		seg[pos] = 1;
		lazy[pos] = 0;
		return;
	}
	int mid = (l + h) / 2;
	build(l, mid, 2 * pos);
	build(mid + 1, h, 2 * pos + 1);
	seg[pos] = ((seg[2 * pos] * power[h - mid]) % mod + seg[2 * pos + 1]) % mod;
	lazy[pos] = 0;
}
void pre() {
	power[0] = 1;
	sum[0] = 1;
	for (int i = 1; i <= n ; i++) {
		power[i] = (10ll * power[i - 1]) % mod;
		sum[i] = (power[i] + sum[i - 1]) % mod;
	}
	build(1, n, 1);
}
void update(int l, int h, int x, int y, int pos) {
	if (lazy[pos]) {
		seg[pos] = (lazy[pos] * sum[h - l]) % mod;
		if (l != h) {
			lazy[2 * pos] = lazy[pos];
			lazy[2 * pos + 1] = lazy[pos];
		}
		lazy[pos] = 0;
	}
	if (h < x || l > y)
		return;
	if (x <= l && h <= y) {
		seg[pos] = (d * sum[h - l]) % mod;
		if (l != h) {
			lazy[2 * pos] = d;
			lazy[2 * pos + 1] = d;
		}
		return;
	}
	int mid = (l + h) / 2;
	update(l, mid, x, y, 2 * pos);
	update(mid + 1, h, x, y, 2 * pos + 1);
	seg[pos] = ((seg[2 * pos] * power[h - mid]) % mod + seg[2 * pos + 1]) % mod;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cin >> n >> q;
	pre();
	while (q--) {
		cin >> l >> r >> d;
		update(1, n, l, r, 1);
		cout << seg[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 14980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int a[3][3];
	int b[3][3];
	rep(i,3) rep(j,3){
		cin >> a[i][j];
		b[i][j] = 0;
	}
	int n;
	cin >> n;
	rep(i,n){
		int x;
		cin >> x;
		rep(j,3) rep(k,3){
			if(a[j][k] == x){
				b[j][k] = 1;
			}
		}
	}
	int flag=0;
	if((b[0][0]+b[0][1]+b[0][2])==3)flag = 1;
	else if((b[1][0]+b[1][1]+b[1][2])==3) flag = 1;
	else if((b[2][0]+b[2][1]+b[2][2])==3) flag = 1;
	else if((b[0][0]+b[1][0]+b[2][0])==3) flag = 1;
	else if((b[0][2]+b[1][2]+b[2][2])==3) flag = 1;
	else if((b[0][1]+b[1][1]+b[2][1])==3) flag = 1;
	else if((b[0][0]+b[1][1]+b[2][2])==3) flag = 1;
	else if((b[0][2]+b[1][1]+b[2][0])==3) flag = 1;

	if(flag == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

  return 0;
}


Measured memory_bytes: 256
//Mandelbrot: z(n+1) = (z(n))^2 + c
//Rick: I programmed you to believe that
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 998244353
#define Q 1000000006
#define inf 1e18
#define N 1000005
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);



void solve(){

    ll n;
    string ans = "", alp = "zabcdefghijklmnopqrstuvwxyz";
    cin>>n;
    while(n){
        ll r = n%26;
        if(r==0) r=26;
        ans += alp[r];
        n -=r;
        n /= 26;
    }
    reverse(all(ans));
    cout<<ans;
}

signed main() {
    teevra_gati
        
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>

using namespace std;

class ModInt{
private:
  long long number;

public:
  static constexpr long long mod = 1'000'000'007;

  constexpr ModInt(const ModInt& x) : number(x.number){};

  constexpr ModInt(const long long number = 0) : number((mod + number) % mod){}

  constexpr long long get() const{
    return number;
  }

  constexpr ModInt& operator=(const ModInt& rhs) &{
    number = rhs.number;
    return *this;
  }

  constexpr ModInt operator+() const{
    return ModInt(*this);
  }

  constexpr ModInt operator-() const{
    return ModInt(mod - number);
  }

  constexpr ModInt& operator+=(const ModInt& rhs){
    number += rhs.number;
    if(number >= mod) number -= mod;
    return *this;
  }

  constexpr ModInt& operator-=(const ModInt& rhs){
    number -= rhs.number;
    if(number < 0) number += mod;
    return *this;
  }

  constexpr ModInt& operator*=(const ModInt& rhs){
    (number *= rhs.number) %= mod;
    return *this;
  }

  constexpr ModInt& operator/=(const ModInt& rhs){
    (*this) *= rhs.inverse();
    return *this;
  }

  constexpr ModInt inverse() const{
    long long a = number, m = mod, u = 1, v = 0;

    while(m){
      long long t = a / m;
      a -= t * m;
      u -= t * v;

      //swap a, m
      a ^= m;
      m ^= a;
      a ^=m;

      //swap u, v
      u ^= v;
      v ^= u;
      u ^= v;
    }

    return ModInt(u);
  }

  constexpr ModInt& operator++(){
    return *this += 1;
  }

  constexpr ModInt& operator--(){
    return *this -= 1;
  }

  constexpr ModInt operator++(int x){
    ModInt ret = *this;
    ++(*this);
    return ret;
  }

  constexpr ModInt operator--(int x){
    ModInt ret = *this;
    --(*this);
    return ret;
  }
};

constexpr ModInt operator+(const ModInt& lhs, const ModInt& rhs){
  return ModInt(lhs) += rhs;
}

constexpr ModInt operator-(const ModInt& lhs, const ModInt& rhs){
  return ModInt(lhs) -= rhs;
}

constexpr ModInt operator*(const ModInt& lhs, const ModInt& rhs){
  return ModInt(lhs) *= rhs;
}

constexpr ModInt operator/(const ModInt& lhs, const ModInt&rhs){
  return ModInt(lhs) /= rhs;
}

constexpr ModInt operator^(const ModInt& lhs, const int& rhs){
  long long b = lhs.get(), e = rhs, y = 1, mod = lhs.mod;
  bool inv = e < 0;
  if(inv) e = -e;

  while(e){
    if(e & 1) (y *= b) %= mod;

    (b *= b) %= mod;
    e >>= 1;
  }

  return (inv ? ModInt(y).inverse() : ModInt(y));
}

std::istream& operator>>(std::istream& is, ModInt& x){
  long long in;
  is >> in;
  x = in;
  return is;
}

std::ostream& operator<<(std::ostream& os, const ModInt& x){
  os << x.get();
  return os;
}

int main(){
  int N, K;
  scanf("%d%d", &N, &K);
  
  int a[N];
  for(int i = 0; i < N; i++) scanf("%d", a + i);
  
  ModInt dp[N + 1][K + 1];
  
  for(int j = 0; j <= K; j++) dp[0][j] = 1;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= K; j++){
      if(j > a[i]) dp[i + 1][j] = dp[i][j] - dp[i][j - a[i] - 1];
      else dp[i + 1][j] = dp[i][j];
      
      if(j) dp[i + 1][j] += dp[i + 1][j - 1];
    }
  }
  
  if(K) cout << (dp[N][K] - dp[N][K - 1]) << endl;
  else cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 79104
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	
	auto F_bit = new ulong[](N);
	foreach (i; 0..N)
	{
		auto F = RDR.split.to!(ulong[]);
		foreach (j, e; F)
		{
			F_bit[i] |= e << j;
		}
	}
	long[][] P;
	foreach (i; 0..N)
	{
		P ~= RDR.split.to!(long[]);
	}

	long ans = long.min;
	foreach (i; 1..0b10_000_000_000)
	{
		long income;
		foreach (j; 0..N)
		{
			auto bit = F_bit[j] & i;
			auto cnt = popcnt(cast(uint)bit);
			income  += P[j][cnt];
		}
		ans = max(ans, income);
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 380
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[100000];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		d[za]--, d[zb]--;
	}
	for (int i = 0; i < num; i++)
	{
		if (d[i] & 1)
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    
    string t;  // sの'BC'を'D'に置き換えた文字列
    rep(i, s.size()) {
        if(i < s.size()-1 && s[i] == 'B' && s[i+1] == 'C') {
            t += 'D';
            i++;
        }
        else {
            t += s[i]; 
        }
    }

    ll ans = 0;
    ll cntA = 0;
    rep(i, t.size()) {
        if(t[i] == 'A') {
            cntA++;
        }
        else if(t[i] == 'D') {
            ans += cntA;
        }
        else {
            cntA = 0;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 776
s = list(map(int, input().split('/')))
if s[0] <= 2019:
        if s[1] <= 4:
                if s[2] <= 30:
                        print('Heisei')
                else:
                        print('TBD')
        else:
                print('TBD')
else:
        print('TBD')



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(), (x).end()

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;

#define INF 1e18

int main(void) {
    ll k; cin >> k;
    vvll g[2] = {vvll(k), vvll(k)};
    rep(i, k) {
        g[1][i].push_back((i+1)%k);
        g[0][i].push_back((i*10)%k);
    }
    vll q = {1}, d(k, INF);
    ll step = 0;
    while (q.size()) {
        vll q_next, q0;
        rep(i, q.size()) if (d[q[i]] == INF) {
            ll x = q[i];
            d[x] = step;
            q_next.push_back(g[1][x][0]);
            if (d[g[0][x][0]] == INF) {
                q0.push_back(g[0][x][0]);
                d[g[0][x][0]] = step;
            }
        }
        while (q0.size()) {
            ll x = q0.back(); q0.pop_back();
            q_next.push_back(g[1][x][0]);
            if (d[g[0][x][0]] == INF) {
                q0.push_back(g[0][x][0]);
                d[g[0][x][0]] = step;
            }
        }
        swap(q, q_next);
        step++;
    }
    cout << d[0] + 1 << endl;

    return 0;
}


Measured memory_bytes: 13436
#include <iostream>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main()
{
    while(1)
    {
	int n,p,tmp=-1,from=0,f=0;
	cin >> n;
	if (n==0)break;
	rep(i,n+1)
	{
	    if (i<n)
		cin >> p;
	    else
		p = -1;
	    if (tmp+1!=p)
	    {
		if (tmp != -1)
		{
		    if (f == 1)
			cout << " ";
		    if (tmp != from)
			cout << from << "-" << tmp;
		    else
			cout << tmp;
		    f=1;
		}
		from=p;
	    }
	    tmp = p;
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    ll K;
    cin >> N >> K;
    map<int, ll> num;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        if (num.count(a)) {
            num[a] += b;
        }
        else {
            num[a] = b;
        }
    }
    for (auto p : num) {
        int a = p.first;
        ll b = p.second;
        K -= b;
        if (K <= 0) {
            cout << a << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a[101],n,x,mi=123345;
int main(){
cin>>n>>x;
for(int i=0;i<n;i++){
cin>>a[i];
x-=a[i];
mi=min(mi,a[i]);}
cout<<x/mi+n;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

using namespace std;


int main()
{
	lli n;
	cin>>n;
	
	lli res = (1000 * (n / 500)) + (5 * ((n % 500) / 5));
	
	cout<<res;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace A
{
    public class Task
    {
        public long a { get; set; }
        public long b { get; set; }
    }

    partial class Program
    {
        long n;
        List<Task> task = new List<Task>();
        public IEnumerable<string> Solve()
        {
            n = Num;
            for (int i = 0; i < n; i++)
            {
                task.Add(new Task() { a = Num, b = Num });
            }

            task = task.OrderBy(x => x.b).ToList();

            long c = 0;
            foreach (var t in task)
            {
                c += t.a;
                if (c > t.b)
                {
                    yield return "No";
                    yield break;
                }
            }

            yield return "Yes";
        }
    }

    class StartingPoint
    {
        static void Main(string[] args)
        {
            if (args?.Any() == true)
            {
                var assembly = Assembly.GetExecutingAssembly();
                var resourceName = "AtCoder.Resources.In.txt";
                var stream = assembly.GetManifestResourceStream(resourceName);
                var streamReader = new StreamReader(stream, Encoding.UTF8);
                var str = streamReader.ReadToEnd();
                var textReader = new StringReader(str);
                Console.SetIn(textReader);
            }

            try
            {
                foreach (var s in new Program().Solve())
                {
                    Console.WriteLine(s);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                if (args?.Any() != true)
                    throw e;
            }

            if (args?.Any() == true)
                Console.ReadLine();
        }
    }

    partial class Program
    {
        long[] Nums(long count) => Enumerable.Range(0, (int)count).Select(_ => Num).ToArray();
        long Num => long.Parse(Str);
        double NumD => (double)Num;

        StringBuilder sb = new StringBuilder();

        string Str => GetStr();
        string GetStr()
        {
            sb.Clear();

            int r = 0;
            bool? b = null;
            do
            {
                r = Console.Read();
                b = IsBreak(r);
            } while (b == true);

            if (b == null)
                throw new Exception("input error: unexpected end of stream");

            do
            {
                sb.Append((char)r);
                r = Console.Read();
                b = IsBreak(r);
            } while (b == false);

            return sb.ToString();
        }

        bool? IsBreak(int c)
        {
            switch (c)
            {
                case -1:
                    return null;
                case (int)' ':
                case (int)'\n':
                case (int)'\r':
                    return true;
                default:
                    return false;
            }
        }
    }
}

Measured memory_bytes: 35920
while 1:
        try:
                n = input()
        except EOFError:
                break

        x = 0
        for a in range(10):
                for b in range(10):
                        for c in range(10):
                                for d in range(10):
                                        if a+b+c+d == n:
                                                x += 1
        print x

Measured memory_bytes: 4204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,m) cin >> b[i];
  vector<vector<int>> v(n,vector<int> (m));
  rep(i,n){
    rep(j,m) cin >> v[i][j];
  }
  int cnt = 0;

  rep(i,n){
    int sum = 0;
    rep(j,m){
      sum += b[j]*v[i][j];
    }
    if (sum  + c > 0) cnt++;
  }
  cout << cnt << endl;
  

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long h;
    cin >> h;
    long long monsters = 1;
    long long ans = 0;
    while (h > 1)
    {
        ans += monsters;
        h /= 2;
        monsters *= 2;
    }
    ans += monsters;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;



int main()
{
    int a, b,c , count = 0;
    cin >> a >> b >> c;
    for(int i=a;i<=b;i++)
    {
        if(c%i==0)count ++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        unordered_map<ll,ll> m;
        ll sum=0;
        rep(i,n)
        {
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
        }
        ll q;
        cin>>q;
        while(q--)
        {
            ll b,c;
            cin>>b>>c;
            cout<<sum+(m[b]*(c-b))<<endl;
            sum=sum+(m[b]*(c-b));
            m[c]+=m[b];
            m[b]=0;
        }
    }
}

Measured memory_bytes: 7944
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0)
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
	IOS;
    int test = 1; //cin>>test;
    for(int tt = 1; tt <= test; tt++){
    	ll x, k, d;
    	cin >> x >> k >> d;
    	x = abs(x);
    	ll num = x/d;
    	if(num >= k) cout << x - (k*d) << endl;
    	else  {
    		x -= d*(num);
    		k -= num;
    		if(k%2 == 1) cout << abs(x-d) << endl;
    		else cout << x << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
int arr[100][100][3000];
int32_t main(){
    base
    int n=nxt();
    int k=nxt();
    int ar[n];
    gena(ar,n,nxt);
    arr[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int m=0;m<3000;m++){
                if(arr[i][j][m])arr[i+1][j][m]+=arr[i][j][m],arr[i+1][j+1][m+ar[i]]+=arr[i][j][m];
            }
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++)cnt+=arr[n][i][i*k];
    cout<<cnt;
    exit
}


Measured memory_bytes: 114944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define max_n 100

int r;

int main() {

	cin >> r;


	cout << r*r << endl;

	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int n,m;
vector<vector<int>> g;
vector<int> clr;

bool dfs(int now,int c){
    clr[now]=c;
    for(auto to:g[now]){
        //連結じゃないことが保証されているのでc,-c以外は出てこない
        if(clr[to]==c) return false;
        if(clr[to]==0){
            if(!dfs(to,-c)) return false;
        }
    }
    return true;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    cin>>n>>m;
    bool a[n][n]={};
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        a[u][v]=true;
        a[v][u]=true;
    }
    g.resize(n);clr.resize(n,0);
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(!a[i][j]){
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }

    rep(i,n)if(clr[i]==0){
        if(!dfs(i,i+1)){
            cout<<-1<<endl;
            return 0;
        }
    }
    int mx=*max_element(ALL(clr));
    map<int,int> c;
    rep(i,n){
        if(clr[i]<0) c[abs(clr[i])-1]--;
        else         c[clr[i]-1]++;
    }
    vector<int> cnt;
    for(auto p:c){
        cnt.push_back(abs(p.second));
    }
    map<int,bool> dp;
    dp[0]=true;
    rep(i,cnt.size()){
        map<int,bool> dpp;
        for(auto p:dp){
            int num=p.first;
            dpp[num+cnt[i]]=true;
            dpp[abs(num-cnt[i])]=true;
        }
        swap(dp,dpp);
    }
    int dif=INF;
    for(auto p:dp)chmin(dif,p.first);
    int x=(n-dif)/2;int y=x+dif;
    cout<<x*(x-1)/2+y*(y-1)/2<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  map<char,ll> S;
  string w;
  cin>>w;
  for(ll i=0;i<w.size();i++) {
S[w[i]]++;
  }
  for(auto x:S) {
if(x.second%2!=0) {
cout<<"No"<<endl;
return 0;
}
  }
  
  
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3564