akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=205;
int n,q[N],d[N],col[N],ans; bool g[N][N];
inline char get_digit(void)
{
	char ch; while (ch=getchar(),ch!='0'&&ch!='1'); return ch;
}
inline bool BFS(CI st)
{
	RI H=0,T=1,i; for (q[1]=st,i=1;i<=n;++i) col[i]=-1,d[i]=1e9;
	col[st]=0; d[st]=1; while (H<T)
	{
		int now=q[++H]; for (i=1;i<=n;++i) if (g[now][i])
		{
			if (!~col[i]) col[i]=col[now]^1,d[i]=d[now]+1,q[++T]=i;
			else if (col[now]==col[i]) return 0; else d[i]=min(d[i],d[now]+1);
		}
	}
	for (i=1;i<=n;++i) ans=max(ans,d[i]); return 1;
}
int main()
{
	RI i,j; for (scanf("%d",&n),i=1;i<=n;++i)
	for (j=1;j<=n;++j) g[i][j]=get_digit()-48;
	for (i=1;i<=n;++i) if (!BFS(i)) return puts("-1"),0;
	return printf("%d",ans),0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
cities = [tuple(map(int, input().split())) for _ in range(N)]

distance = 0
for c in itertools.combinations(range(N), 2):
    c1, c2 = c
    distance += ((cities[c1][0] - cities[c2][0]) ** 2 + (cities[c1][1] - cities[c2][1]) ** 2) **0.5

answer = 2 * distance / N

print(answer)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  string S; cin >> S;
  rep(i, 1, S.size()) {
    int len = S.size() - i;
    if(len % 2) continue;
    string s = S.substr(0, len / 2);
    string t = S.substr(len / 2, len / 2);
    if(s == t) {
      cout << s.size()* 2 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

no = input()
l = []

for i in range(no):
    a = list(raw_input())
    a.sort()
    l.append("".join(a))

l.sort(key=len)

ans = ""

for mini_char in l[0]:
    is_find = True
    for i, c in enumerate(l[1:]):
        res = l[i].find(mini_char)

        if res == -1:
            is_find = False
            break
        else:
            l[i] = l[i][:res] + l[i][res + 1:]

    if is_find == True:
        ans += mini_char

print ans


Measured memory_bytes: 2568
a, b, m = map(int,str(input()).split())
a_cost_map = map(int,str(input()).split())
a_cost = list(a_cost_map)
b_cost_map = map(int,str(input()).split())
b_cost = list(b_cost_map)

coupons_map = [str(input()).split() for i in range(m)]
coupons_map_all =  [[int(coupons_map[i][t]) for t in range(len(coupons_map[i]))] for i in range(len(coupons_map))]

minimum = min(a_cost) + min(b_cost)
for coupon in coupons_map_all:
    coupon_use = (a_cost[coupon[0]-1] +  b_cost[coupon[1]-1] - coupon[2]) 
    if minimum > coupon_use:
        minimum = coupon_use
print(minimum)


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

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

  auto print = [&](int i, int j) {
    if (n % 2 == 0) {
      return i + j != n + 1;
    } else {
      return i + j != n;
    }
  };

  int m = n * (n - 1) / 2 - n / 2;
  cout << m << endl;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (print(i, j)) {
        cout << i << " " << j << endl;
      }
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long int ll;

int mp[1000][26];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    for(int i=0;i<n;i++){
        mp[i/500][s[i]-'a']++;
    } 
    while(q--){
        int t; cin >> t;
        if(t==1){
            int x; cin >> x;
            x--;
            char c; cin >> c;
            mp[x/500][s[x]-'a']--;
            mp[x/500][c-'a']++;
            s[x]=c;
        }else{
            int l,r; cin >> l >> r;
            l--;
            int ans=0;
            for(int j=0;j<26;j++){
                bool pp=0;
                for(int k=0;k<n/500+1;k++){
                    if(l<=k*500&&(k+1)*500<=r){
                        if(mp[k][j]>0){
                            ans++;
                            pp=1;
                            break;
                        }
                    }
                }
                if(pp)continue;
                for(int k=0;k<n/500+1;k++){
                    if(l<=k*500&&(k+1)*500<=r){
                        continue;
                    }
                    else{
                        bool ok=0;
                        if(l>=k*500){
                            for(int p=l;p<min(r,(k+1)*500);p++){
                                if(s[p]==(char)('a'+j)){
                                    ans++;
                                    ok=1;
                                }
                                if(ok)break;
                            }
                            if(ok)break;
                        }
                        else{
                            for(int p=500*k;p<min(r,(k+1)*500);p++){
                                if(s[p]==(char)('a'+j)){
                                    ans++;
                                    ok=1;
                                }
                                if(ok)break;
                            }
                            if(ok)break;
                        }
                    }
                }
            }
            printf("%d\n",ans);
        }
    }
}


Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll a,b;
    cin >> a >> b;
    if((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    Map<String, Integer> map = new HashMap<>();
    String[] list = new String[] {"AC", "WA", "TLE", "RE"};
    for (int i = 0; i < list.length; i++) {
      map.put(list[i], 0);
    }
    for (long i = 0; i < n; i++) {
      String s = sc.next();
      map.put(s, map.get(s) + 1);
    }
    for (int i = 0; i < list.length; i++) {
      System.out.print(list[i]);
      System.out.print(" x ");
      System.out.println(map.get(list[i]));
    }
  }
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int tc()
	{
		int c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		return c;
	}
}
using ae86::ty;
using ae86::tc;

const int _ = 1503 , inf = 0x3f3f3f3f;

int n,val[_][_],sv[_][_]={0},xl[_][_],xr[_][_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			val[i][j]=tc();
			if(!isdigit(val[i][j]))val[i][j]=0;
			else val[i][j]-=48;
		}

	lint ans=0;
	for(int i=n;i>=1;i--)
		for(int j=n;j>=1;j--)
		{
			if(val[i][j])
			{
				if(val[i+1][j] && val[i][j+1])
				{
					int temp=sv[i+1][j]+sv[i][j+1],nowr=0;
					xl[j][i]=j,xr[j][i]=xr[j+1][i];
					for(int k=i+1;k<=n;k++)
					{
						if(xr[j][k]>=xl[j+1][k] && xl[j+1][k]>nowr)temp-=sv[k][xl[j+1][k]];
						nowr=max(nowr,xr[j][k]);
						xl[j][k]=min(xl[j][k],xl[j+1][k]),xr[j][k]=max(xr[j][k],xr[j+1][k]);
					}
					sv[i][j]=temp;	
				}
				else if(val[i+1][j])
				{
					xl[j][i]=xr[j][i]=j,sv[i][j]=sv[i+1][j];
				}
				else if(val[i][j+1])
				{
					for(int k=i;k<=n;k++)xl[j][k]=xl[j+1][k],xr[j][k]=xr[j+1][k];
					xl[j][i]=j,sv[i][j]=sv[i][j+1];
				}
				else xl[j][i]=xr[j][i]=j;
				ans+=1ll*sv[i][j]*val[i][j],sv[i][j]+=val[i][j];
			}
			else for(int k=i;k<=n;k++)xl[j][k]=inf,xr[j][k]=-inf;
		}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 20736
#include <iostream>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i<(n); i++)
using namespace std;
using P = pair<int,int>;
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i<(n); i++)
using namespace std;
using P = pair<int,int>;
#include <vector>
#include <algorithm>
#include <stdlib.h>


int main() {
    long long n, distance, counter = 0;
    cin >> n >> distance;
    for(int i = 0; i<n; i++){
        long long x,y;
       cin >> x>>y;
       if((abs((x*x)+(y*y))) <= (distance*distance)){
           counter ++;
       }
    }
    cout <<counter;


    return 0;

}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 200003;
int n, a[N], b[N];
LL ans;
priority_queue<pii> pq;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%d", a + i);
	for(Rint i = 1;i <= n;i ++){
		scanf("%d", b + i);
		if(a[i] != b[i]) pq.push(MP(b[i], i));
	}
	while(!pq.empty()){
		pii now = pq.top(); pq.pop();
		int i = now.se, pre = (now.se + n - 2) % n + 1, suf = now.se % n + 1, step = (b[i] - a[i]) / (b[pre] + b[suf]);
		if(!step){puts("-1"); return 0;}
		ans += step; b[i] -= step * (b[pre] + b[suf]);
		if(a[i] != b[i]) pq.push(MP(b[i], i));
	}
	printf("%lld", ans);
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

//メモリ置き場
i64 n;
i64 m;
i64 dat[100050];
i64 sum[100050];

//inputします
void input() {
	cin >> n >> m;
	ff(i, 0, n) {
		cin >> dat[i];
	}
	sort(dat, dat + 100050);
	reverse(dat, dat + 100050);
	sum[0] = dat[0];
	ff(i, 1, n) {
		sum[i] = sum[i - 1] + dat[i];
	}
}

//二分探索の時の正誤判定
bool cond(i64 xx) {
	i64 cont = 0;
	i64 st = 0;
	ffrvs(i, n - 1, 0) {
		while (st < n && dat[st] + dat[i] >= xx)st++;
		cont += st;
	}
	if (cont <= m)return 1;//個数がm以下になったらtrue
	else return 0;
}

//二分探索マシーン
i64 binary(i64 xx, i64 yy) {//初めてtrueになる場所をreturnします。
	i64 left = xx;//falseと分かっている範囲の右側を近づける
	i64 right = yy;//trueと分かっている範囲の左側を近づける
	if (cond(right) == 0)return -1;//右端でもfalseなら解なし
	if (cond(left) == 1)return 0;//最初から該当してたら0をreturn
	while (right >= left) {
		if (right - left == 1)return right;
		i64 mid = left + (right - left) / 2;
		if (cond(mid) == 1) right = mid;
		else left = mid;
	}
	return -2;
}

int main() {
	input();
	i64 p = binary(2, 200001) - 1;
	//和がp以上になる個数はmであるかmより少し多い
	i64 ans = 0;
	i64 tm = 0;
	i64 t = 0;
	ffrvs(i, n - 1, 0) {
		while (tm<n && dat[tm] + dat[i]>p)tm++;
		t += tm;
		ans += sum[tm - 1];
		ans += dat[i] * tm;
	}
	ans += (m - t) * p;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a, b, c, d, k = 0, flag = 1;
    
    scanf("%d %d", &a, &b);
    
    while(a > k || b > k){
        if(a - k > 0 && b - k > 0 && a - k == b - k){
            flag = 0;
            break;
        }
        if(a - k < 0){
            c = -1 * (a - k);
        }
        if(b - k < 0){
            d = -1 * (b - k);
        }
        
        if(a - k < 0 && b - k < 0 && c == d){
            flag = 0;
            break;
        }
        
        if(a - k < 0 && b - k > 0 && c == b - k){
            flag = 0;
            break;
        }
        
        if(a - k > 0 && b - k < 0 && a - k == d){
            flag = 0;
            break;
        }
        k = k + 1;
    }
    if(flag == 0){
        printf("%d\n", k);
    }else{
        printf("IMPOSSIBLE\n");
    }
    
}


Measured memory_bytes: 1668
lst = input().split()

W = int(lst[0])
H = int(lst[1])
N = int(lst[2])

field = [([0] * W)] * H

L = []

for i in range(N):
   L = input().split()
   if L[2] == '1':
      for j in range(H):
         for k in range(int(L[0])):
            field[j][k] = 1
   elif L[2] == '2':
      for j in range(H):
         for k in range(int(L[0]), W):
            field[j][k] = 1
   elif L[2] == '3':
      for j in range(int(L[1])):
         field[j] = [1] * W
   elif L[2] == '4':
      for j in range(int(L[1]), H):
         field[j] = [1] * W

ans = 0

for s in field:
   ans += s.count(0)

print(ans)

Measured memory_bytes: 9232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Deque;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int[] board = new int[9];
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        for(int i = 0; i<9; i++){
            if(i==3||i==6) st = new StringTokenizer(br.readLine(), " ");
            board[i] = Integer.parseInt(st.nextToken());
        }
        final Deque<state> q = new ArrayDeque<state>();
        final BitSet cl = new BitSet(362880);
        q.add(new state(board, 0));
        cl.set(hash(board));
        int minstep = -1;
        while(!q.isEmpty()){
            final state stat = q.remove();
            if(hash(stat.board)==46233){
                minstep = stat.step;
                break;
            }
            int f;
            for(f = 0; f<9&&stat.board[f]!=0; f++);
            if(f%3!=0){
                final int[] next = Arrays.copyOf(stat.board, stat.board.length);
                next[f] = next[f-1];
                next[f-1] = 0;
                final int h = hash(next);
                if(!cl.get(h)){
                    cl.set(h);
                    q.add(new state(next, stat.step+1));
                }
            }
            if(f%3!=2){
                final int[] next = Arrays.copyOf(stat.board, stat.board.length);
                next[f] = next[f+1];
                next[f+1] = 0;
                final int h = hash(next);
                if(!cl.get(h)){
                    cl.set(h);
                    q.add(new state(next, stat.step+1));
                }
            }
            if(f>2){
                final int[] next = Arrays.copyOf(stat.board, stat.board.length);
                next[f] = next[f-3];
                next[f-3] = 0;
                final int h = hash(next);
                if(!cl.get(h)){
                    cl.set(h);
                    q.add(new state(next, stat.step+1));
                }
            }
            if(f<6){
                final int[] next = Arrays.copyOf(stat.board, stat.board.length);
                next[f] = next[f+3];
                next[f+3] = 0;
                final int h = hash(next);
                if(!cl.get(h)){
                    cl.set(h);
                    q.add(new state(next, stat.step+1));
                }
            }
        }
        System.out.println(minstep);
    }
    private static int hash(int[] board){
        int h = board[0];
        for(int i = 1; i<8; i++){
            h *= 9-i;
            h += board[i];
            for(int j = 0; j<i; j++){
                if(board[j]<board[i]) --h;
            }
        }
        return h;
    }
}

class state{
    final int[] board;
    final int step;
    state(int[] board, int step){
        this.board = board;
        this.step = step;
    }
}

Measured memory_bytes: 60296
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;

#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)

#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)

#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount



// typedef __int128 bign;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define MD          1000000007
#define M 			100011
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10

ll md=MD;
ll inf=1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 


inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}

using cd=complex<double>;
const double PI=acos(-1);

inline ll rand(ll l,ll r){
	return l+rng()%(r-l+1);
}

ll a[M];
int main(){


    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p,T;string s1,s2;ll q;ll x,y;
    cin>>n;
    lp(1,n)cin>>a[i];
    p=0;
    for(i=2;i+1<=n;++i){
        vii v;
        v.pb(a[i-1]);v.pb(a[i]);v.pb(a[i+1]);
        sort(all(v));
        if(a[i]==v[1])++p;
    }cout<<p<<"\n";







    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define m 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif
	ll x, y = 100;
	cin >> x;
	ll count = 0;
	while (y < x)
	{
		ll in = y / 100;
		y = y + in;
		count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3676
int main(){
    double pai=3.141592653589;
    int n;
    scanf("%d",&n);
    for(int i=3;i<=n;i++){
        int x=i;
        if(i%3==0){
            printf(" %d",i);
        }else{
            do{
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
                x/=10;
            }
            while(x);
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        String c = scan.next();
        scan.close();

        int Rsum = 0;
        int Rcount = 0;
        for (int i = 0; i < n; i++) {
            if (c.charAt(i) == 'R') {
                Rsum++;
            }
        }
        for (int i = 0; i < Rsum; i++) {
            if (c.charAt(i) == 'R') {
                Rcount++;
            }
        }

        System.out.println(Rsum - Rcount);
    }
}


Measured memory_bytes: 40308
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
d={"AC":0,"WA":1,"TLE":2,"RE":3}
cnt=[0]*4
for _ in range(n):
    s=input().rstrip()
    cnt[d[s]]+=1
print("AC x",cnt[0])
print("WA x",cnt[1])
print("TLE x",cnt[2])
print("RE x",cnt[3])



Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll x;
  cin >> x;
  if (x >= 30) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


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

int main() {
  int n;
  vector<int> h;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    h.push_back(x);
  }

  int sum = 0;
  int ans = 0;
  while (true) {
    sum = 0;
    for (int i = 0; i < n; i++) {
      sum += h[i];
    }
    if (sum == 0) {
      break;
    }
    ans++;
    int j = 0;
    while (true) {
      if (h[j] > 0) {
        break;
      }
      j++;
    }
    int k = j;
    while (true) {
      if (h[k] == 0) {
        break;
      }
      h[k]--;
      k++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,l;
  scanf("%d %d\n",&n,&l);
  char str[n][l+1],temp[l+1];
  int i,j;
  for(i=0;i<n;i++){
    scanf("%[^\n]%*c",str[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(str[i],str[j])>0){
        strcpy(temp,str[i]);
        strcpy(str[i],str[j]);
        strcpy(str[j],temp);
      }
    }
  }
  char final_str[10001]="";
  for(i=0;i<n;i++){
    strcat(final_str,str[i]);
  }
  printf("%s",final_str);
  return 0;
}

Measured memory_bytes: 1720
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def main():
    res = 0
    l, r, d = invr()
    for i in range(l, r+1):
        if i % d == 0:
            res += 1
    print(res)


    # region fastio
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    main()


Measured memory_bytes: 10652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		//static int[] parent;
		static void Main(string[] args)
		{
			int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = input[0];
			int M = input[1];
			//input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			// 全てのゲートを通過できるカードの下限と上限
			int a = 0, b = N+1;
			for(int i=0; i<M; i++)
			{
				input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
				int L = input[0];
				int R = input[1];
				if(a < L)
					a = L;

				if(b > R)
					b = R;
			}
			// aからbまでのカードが全てのゲートを通過できるので
			int ret = b - a + 1;
			if(ret < 0) ret = 0;
			Console.WriteLine(ret + "") ;
		}
	}
}


Measured memory_bytes: 17456
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def count_junretsu(retsu):
	# 大きさNの順列を辞書順に作成し、順番にP,Qと比較する
	for i,l in enumerate(itertools.permutations(range(1,N+1))):
		if retsu == list(l):
			return(i+1)

a = count_junretsu(P)
b = count_junretsu(Q)
print(abs(a-b))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Pasta
 * JOI 11th, Pre 4
 */
public class Main {

	static final int MOD = 10000;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		//long sta, end;
		//sta = System.nanoTime();

		//
		int N, K;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		K = parseInt(line.substring(line.indexOf(' ') + 1));

		int[] plan = new int[N + 1];

		for (int i = 0; i < K; i++) {
			line = br.readLine();
			int A, B;
			A = parseInt(line.substring(0, line.indexOf(' ')));
			B = parseInt(line.substring(line.indexOf(' ') + 1));
			plan[A] = B;
		}

		int[][][] dp = new int[N + 1][4][2];

		if (plan[1] != 0) {
			dp[1][plan[1]][0] = 1;
		} else {
			dp[1][1][0] = 1;
			dp[1][2][0] = 1;
			dp[1][3][0] = 1;
		}

		for (int i = 2; i <= N; i++) {

			dp[i][1][1] += dp[i - 1][1][0];
			dp[i][2][1] += dp[i - 1][2][0];
			dp[i][3][1] += dp[i - 1][3][0];
			dp[i][1][0] += dp[i - 1][2][0] + dp[i - 1][3][0] + dp[i - 1][2][1] + dp[i - 1][3][1];
			dp[i][2][0] += dp[i - 1][1][0] + dp[i - 1][3][0] + dp[i - 1][1][1] + dp[i - 1][3][1];
			dp[i][3][0] += dp[i - 1][1][0] + dp[i - 1][2][0] + dp[i - 1][1][1] + dp[i - 1][2][1];

			for (int j = 1; j <= 3; j++) {
				for (int k = 0; k < 2; k++) {
					if (plan[i] != 0 && j != plan[i]) {
						dp[i][j][k] = 0;
					} else {
						dp[i][j][k] %= MOD;
					}
				}
			}
		}

		int ans = dp[N][1][0]
				+ dp[N][1][1]
				+ dp[N][2][0]
				+ dp[N][2][1]
				+ dp[N][3][0]
				+ dp[N][3][1];
		ans %= MOD;

		System.out.println(ans);

		//
		//end = System.nanoTime();
		//System.out.printf("%.6f ms%n", (end - sta) / 1000.0 / 1000);
	}
}

Measured memory_bytes: 24348
#include <stdio.h>

int main(void){
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    if(A-C<=D && A-C>=-1*D) printf("Yes\n");
    else if(A-B<=D && A-B>=-1*D && B-C<=D && B-C>=-1*D) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}


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

    string s, t; cin >> s >> t;
    int slen = s.length(), tlen = t.length();

    vector<bool> mps(30, false);
    for(int i=0; i<slen; ++i) mps[s[i]-'a'] = true;
    for(int i=0; i<tlen; ++i) if(mps[t[i]-'a'] == false){
        cout << "-1" << endl;
        return 0;
    }

    s = '0' + s;
    
    vector<int> pos[30];
    for(int i=1; i<=slen; ++i){
        pos[s[i]-'a'].push_back(i);
    }

    ll ans = 0;
    ll now = 0;

    for(int i=0; i<tlen; ++i){
        int c = t[i]-'a';
        auto itr = lower_bound(pos[c].begin(), pos[c].end(), now);
        if(itr == pos[c].end()){
            ans += slen;
            now = 0;
            itr = lower_bound(pos[c].begin(), pos[c].end(), now);
        }
        now = *itr;
        
        if(i == tlen-1){
            cout << ans+now << endl;
        }
        else{
            ++now;
            if(now == slen+1){
                ans += slen;
                now = 0;
            }
        }
    }
    
    return 0;
}



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

int main() {
	// your code goes here
int N;
cin >> N;

vector <int> V(N);
vector <int> C(N);

for(int i=0;i<N;i++){
cin >> V.at(i);
}

for(int i=0;i<N;i++){
cin >> C.at(i);
}

int sum=0;

for(int i=0;i<N;i++){
if(V.at(i)>C.at(i)){
sum+=V.at(i)-C.at(i);
}

}
cout << sum << endl;







	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.function.Function;

public class Main {
    private static final char[] MOVE = {'L', 'U', 'R', 'D'};

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        final int n = scanner.nextInt();
        final int sr = scanner.nextInt();
        final int sc = scanner.nextInt();

        final String s = scanner.next();
        final String t = scanner.next();

        final int[] initialValues = {sc, sr};
        final Function<Integer, Integer> decrement = i -> i - 1;
        final Function<Integer, Integer> increment = i -> i + 1;
        final Function[] operators = {decrement, decrement, increment, increment};
        final int[] limits = {w, h};
        for (int i = 0; i < MOVE.length; i++) {
            if (!isYes(initialValues[i % 2], operators[i], operators[(i + 2) % 4], n, limits[i % 2], s, t, i)) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    private static boolean isYes(final int initialValue, final Function<Integer, Integer> expression1, final Function<Integer, Integer> expression2, final int n, final int limit, final String s, final String t, final int tSelect) {
        int tmp = initialValue;
        for (int i = 0; i < n; i++) {
            final char si = s.charAt(i);
            if (si == MOVE[tSelect]) {
                tmp = expression1.apply(tmp);
            }
            if (!isInside(tmp, limit)) {
                return false;
            }
            final char ti = t.charAt(i);
            if (ti == MOVE[(tSelect + 2) % 4] && isInside(expression2.apply(tmp), limit)) {
                tmp = expression2.apply(tmp);
            }
        }
        return true;
    }

    private static boolean isInside(final int position, final int limit) {
        return 1 <= position && position <= limit;
    }
}


Measured memory_bytes: 46184
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2019
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k > 0) {
        ans += min(k, a);
        k -= min(k, a);
    }
    if(k > 0) {
        k -= min(k, b);
    }
    if(k > 0) {
        ans -= min(k, c);
    }
    cout << ans << endl;
    return 0;
    
}



Measured memory_bytes: 3692
#include<iostream>
#include<string>
using namespace std;
int main(){
  int x;
string a;
cin>>x>>a;
for(int i=0;i<a.size();i++){
  if(a[i]+x<='Z')
  a[i]=a[i]+x;
  else
    a[i]=a[i]-26+x;
}
cout<<a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        String str = sc.next();
        int[] s = new int[n];

        for (int i = 0; i < n; i++) {
            s[i] = str.charAt(i) - '0';
        }

        int[] u = new int[n+1];
        long[] modCount = new long[p];
        int ten = 1;

        for (int i = n-1 ; i >= 0; i--) {
            u[i] = (u[i+1] + s[i]*ten)%p;
            ten = (ten*10)%p;
        }

        for(int i = 0 ; i <= n ; i++){
            modCount[u[i]]++;
        }

        long ans = 0;
        if(p == 2 || p == 5){
            for(int i = n-1 ; i >= 0 ; i--){
                if((s[i]%p) == 0){
                    ans += i+1;
                }
            }
        }else{
            for(int i = 0 ; i < p ; i++){
                ans += modCount[i]*(modCount[i]-1)/2;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 28932
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))
A =[0]
for i in range(N):
    A.append(A[-1]+a[i])

Ac = collections.Counter(A)
cnt = 0
for val in Ac.values():
    cnt += val*(val-1)//2
print(cnt)


Measured memory_bytes: 44232
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d >=abs(a-c)||d>=abs(a-b)&&d>=abs(b-c)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
nCount = 0
nP = 0
nW = 0
nG = 0
nY = 0

N = int(input())
nData = []
nData  = input().rstrip().split(' ')

for i in range(N):
    sTmp = nData[i]
    if sTmp == 'P':
        nP = 1
    elif sTmp == 'W':
        nW = 1
    elif sTmp == 'G':
        nG = 1
    elif sTmp == 'Y':
        nY = 1
    
nCount = nP + nW + nG + nY

if nCount == 3:
    print('Three')
else:
    print('Four')




Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int i,j,s,n,m;
  static int a[100][100],b[100],c[100];

  scanf("%d%d",&n,&m);

  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

  for(i=0;i<m;i++)
    scanf("%d",&c[i]);

  for(i=0;i<n;i++){
    s = 0;
    for(j=0;j<m;j++)
      s += a[i][j] * c[j];
    printf("%d\n",s);
  }
  
  return 0;
}



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

void check_distance(vector<vector<int>>& distance){
    cout << endl;
    for(int ii=0; ii<distance.size(); ii++){
        for(int jj=0; jj<distance[0].size(); jj++){
            cout << distance[ii][jj];
        }
        cout << endl;
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for(auto& a : A){
        cin >> a;
    }

    vector<vector<int>> distance(H, vector<int>(W, H+W));
    vector<pair<int, int>> checked;
    for(int ii=0; ii<H; ii++){
        for(int jj=0; jj<W; jj++){
            if(A[ii][jj]=='#'){
                checked.push_back(make_pair(ii, jj));
                distance[ii][jj] = 0;
            }
        }
    }

    // check_distance(distance);
    vector<pair<int, int>> nextposs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    for(int ii=0; ii<H*W; ii++){
        int row = checked[ii].first;
        int col = checked[ii].second;
        // cout << "=====(" << row << ", " << col << ")=====" << endl;
        for(auto next_pos : nextposs){
            int new_row = row + next_pos.first;
            int new_col = col + next_pos.second;
            /*
            if(row==2 && col==5){
                cout << "find:" << new_row << ":" << new_col << endl;
            }
            */
            if(new_row < 0) continue;
            if(new_row > H-1) continue;
            if(new_col < 0) continue;
            if(new_col > W-1) continue;
            if(distance[new_row][new_col] == H+W){
                checked.push_back(make_pair(new_row, new_col));
                distance[new_row][new_col] = min(distance[new_row][new_col], distance[row][col]+1);
                // check_distance(distance);
            }
        }
    }

    // check_distance(distance);

    int result = 0;
    for(int ii=0; ii<H; ii++){
        for(int jj=0; jj<W; jj++){
            result = max(result, distance[ii][jj]);
        }
    }
    cout << result << endl;

    /*
    for(auto& c : checked){
        cout << c.first << ":" << c.second << ":" << distance[c.first][c.second] << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 15340
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  string s,t;
  cin>>s>>t;
  int n = s.size(), m = t.size();
  int dp[n + 1][m + 1];
  rep(i, m + 1) dp[0][i] = 0;
  rep(i, n + 1) dp[i][0] = 0;
  string st = "";
  rep(i, n) {
    rep(j, m) {
      if(s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
  int i = n, j = m;
  while(i > 0 && j > 0) {
    if(s[i-1] != t[j-1]) {
      if(dp[i-1][j] > dp[i][j-1]) {
        i--;
      } else {
        j--;
      }
    } else {
      st = st + s[i-1];
      i--;
      j--;
    }
  }
  reverse(st.begin(), st.end());
  cout << st << endl;

  return 0;
}


Measured memory_bytes: 35584
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=1; i<10; i++){
			if(n%i==0 && n/i<10){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	if ((a[0] == a[1] && a[0] != a[2]) || (a[0] == a[2] && a[0] != a[1])|| (a[1] == a[2] && a[0] != a[1])) { cout << "Yes" << '\n'; }
	else { cout << "No" << '\n'; }


}

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

def is_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True
    
num = 11
tmp = 0
while 1:
    if is_prime(num):
        print(num, end = " ")
        tmp += 1
    num += 10
    if n == tmp:
        exit()

Measured memory_bytes: 3060
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys
S = sys.stdin.readline().rstrip()
N = len(S)
def solve(i,c,s):
    #print(i,c,s)
    if i == N:
        return [s+c]
    ret = []
    ret.extend(solve(i+1,0,s+c*10+int(S[i])))
    ret.extend(solve(i+1,c*10+int(S[i]),s))
    return ret
#print(solve("25"))
print(sum(solve(0,0,0))//2)
#print(sum(solve(S)))

Measured memory_bytes: 67308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n){
        rep(j,n-1){
            cin >>  a[i][j];
            a[i][j]--;
        }
        reverse(all(a[i]));
    }


    queue<P> q;
    auto check = [&](int i){
        if (a[i].size() == 0) return;
        int j = a[i].back();
        int k = a[j].back();
        if (i == k) q.push(P(min(i,j), max(i,j)));
    };

    rep(i,n) check(i);
    int ans = 0;
    while(!q.empty()){
        ans++;
        set<P> st;
        while(!q.empty()){
            st.insert(q.front()); q.pop();
        }

        for(P p: st){
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(P p: st){
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }

    rep(i,n){
        if (a[i].size() != 0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7572
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

ch = Counter(h)
cw = Counter(w)

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

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

int main() {
  int n; cin >> n;
  vector<string> judge = {"AC", "WA", "TLE", "RE"};
  map<string, int> ans;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    ans[s]++;
  }
  for (int i = 0; i < 4; i++) {
    cout << judge.at(i) << " x " << ans[judge.at(i)] << endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i,j,k;
  while(n!=0){
    string str[1000];
    int d[1000]={};
    for(i=0;i<n;i++){
      cin >> str[i];
      j=0;
      while(str[i][j]=='.') j++;
      if(j==1) str[i][0]='+';
      else if(j!=0){
	str[i][j-1]='+';
      }
      d[i]=j;
      
    }
    for(i=0;i<n;i++){
      if(d[i]==0) continue;
      if(d[i+1]<=d[i]) continue;
      for(j=i+2;j<n;j++){
	
	if(d[i]==d[j]){
	  for(k=i+1;k<j;k++){
	    str[k][d[i]-1]='|';
	  }
	}
	if(d[i]>=d[j]) break;
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<str[i].size();j++) {
	if(str[i][j]=='.') str[i][j]=' ';
      }
      cout  <<str[i] << endl;
    }
    cin >> n;
  }

  return 0;
}

Measured memory_bytes: 1992
/*
	* ernestvw
	* C++
	* April 2020
	* ABC164/E
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const int OO = 1e18; // LLONG_MAX
const double eps = 1e-9;

#define TEST_CASES 0

void solve(int test_case);

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

// ---------------------------------------------------

struct Arc {
	int u, v, a, b;
};

int n, m, s;
vector<vector<Arc>> adj;
vector<int> c, d;

void dijkstra() {
	vector<vector<int>> D(n+1, veci(3001, +OO));
	D[1][s] = 0;
	PQ<pair<int, pii>> q;
	q.push({0, {1, s}});
	while(!q.empty()) {
		auto p = q.top();
		q.pop();
		int u = p.y.x, C = p.x, sil = p.y.y;
		if(D[u][sil] < C) continue;
		if(sil < 3000) {
			int nsil = min(3000LL, sil + c[u]);
			if(D[u][nsil] > D[u][sil] + d[u]) {
				D[u][nsil] = D[u][sil] + d[u];
				q.push({D[u][nsil], {u, nsil}});
			}
		}
		for(Arc a : adj[u]) if(sil >= a.a) {
			if(D[a.v][sil - a.a] > D[u][sil] + a.b) {
				D[a.v][sil - a.a] = D[u][sil] + a.b;
				q.push({D[a.v][sil - a.a], {a.v, sil-a.a}});
			}
		}
	}
	for(int i = 2; i <= n; i++) {
		int mini = +OO;
		for(int j = 0; j <= 3000; j++)
			mini = min(mini, D[i][j]);
		cout << mini << '\n';
	}
}

void solve(int test_case) {
	cin >> n >> m >> s;
	s = min(s, 3000LL);
	adj.resize(n+1);
	c.resize(n+1);
	d.resize(n+1);
	FOR(i, m){
		int u, v, a, b;
		cin>>u>>v>>a>>b;
		adj[u].pb({u, v, a, b});
		adj[v].pb({v, u, a, b});
	}
	FOR(i, n)cin>>c[i+1]>>d[i+1];
	dijkstra();
}



















































Measured memory_bytes: 7616
o = str(input())
e = str(input())
x = ''
if len(o) == len(e):
    for i in range(len(e)):
        x += o[i]
        x += e[i]
    print(x)
else:
    for i in range(len(e)):
        x += o[i]
        x += e[i]
    x += o[len(o)-1]
    print(x)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    ll a, b, c, d;cin >> a >> b >> c >> d;
    cout << (a != c ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 764
import sys
n = int(input())

if n == 0:
    print(0)
    sys.exit()

ans = []
x = 2
i = 0
while n != 0:
    if n%x!=0:
        ans.append(1)
        n = n - (-2)**i
    else:
        ans.append(0)    
    i += 1
    x *= 2 
print(''.join([ str(x) for x in ans[::-1]]))

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X==500*i+100*j+50*k:
        ans+=1
print(ans)

Measured memory_bytes: 3060