akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int r;
   cin >> r;
   if(r<1200) cout << "ABC" << endl;
   else if(r<2800) cout << "ARC" << endl;
   else cout << "AGC" << endl;


   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 ll dp[100005];
int main()
{ 
  ll n;
  cin>>n;
  ll h[n],i,j,k;
  for(i=0;i<n;i++)
  {
    cin>>h[i];
  }
  for(i=1;i<n;i++)
  {
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    if(i>=2) 
    {
      dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
  }
  
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll E=0,ans=0;
    rep1(i,N){
        ans+=i*(N+1-i);
    }
    rep(i,N-1){
        ll u,v; cin>>u>>v;
        if(u>v) swap(u,v);
        
        E+=u*(N+1-v);
    }
    cout<<ans-E<<endl;
}



Measured memory_bytes: 3616
/*Kadai5_3
 saitomo*/
#include <stdio.h>
int main(void){
    int row,col,i,j;   
    scanf("%d %d", &row, &col);
    int count_row[row],count_col[col];//行と列での＃の出現の判定に使う
    char box[row][col];//マス目を読み込む
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c",&box[i][j]);
            count_row[i]=0;//値の初期化
            count_col[j]=0;
        }
    }
  for(i=0;i<row;i++){
    for(j=0;j<col;j++){
      if(box[i][j]=='#'){
        count_row[i]=1;//行または列に＃が存在すれば1となる
        count_col[j]=1;
      }
    }
  }
  for(i=0;i<row;i++){
    if(count_row[i]==1){//行中に＃があるか判定
      for(j=0;j<col;j++){
        if(count_col[j]){//列中に＃があるか判定
          printf("%c",box[i][j]);//消えない部分をプリントする
        }
      }
      printf("\n");//1行ごとに改行
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
  ll N;
  cin >> N;
  vll ans;
  while(N > 0){
    N--;
    ll tmp = N % 26;
    ans.pb(tmp);
    N /= 26;
  }
  reverse(ans.begin(),ans.end());
  for(auto s : ans){
    cout << (char)('a'+s);
  }
  
}

Measured memory_bytes: 3624
a,b,c=map(int,input().split())
x=0
if a==b==c:
    if a%2==1:print(0)
    else:print(-1)
else:
    while a%2==0 and b%2==0 and c%2==0:
        a,b,c=b//2+c//2,c//2+a//2,a//2+b//2
        x+=1
    print(x)

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val i1 = sc.nextInt()
    val i2 = sc.nextInt()
    val i3 = sc.nextInt()

    if (i1 < i2 && i2 < i3) {
        println("Yes")
    } else {
        println("No")
    }
}



Measured memory_bytes: 25632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char> (W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W ; j++){
            cin >> a.at(i).at(j);
        }
    }
    for(int i = 0; i < W+2; i++){
        printf("#");
    }
        printf("\n");
    for(int i = 0; i < H; i++){
        printf("#");
        for(int j = 0; j < W; j++){
            printf("%c",a.at(i).at(j));
        }
        printf("#\n");
    }        
    for(int i = 0; i < W+2; i++){
        printf("#");
    }
        printf("\n");  
}

Measured memory_bytes: 256
#include <cstdio>
const int MAXN = 2e5+5;
const int MOD = 998244353;
int F[MAXN];
int G[MAXN];
int P[MAXN];
int K, M, N;

int fpm(int b, int e) {
  int r = 1;
  while (e) {
    if (e & 1) {
      r = 1LL * r * b % MOD;
    }
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return r;
}

int inv(int x) { return fpm(x, MOD-2); }

int ncr(int n, int r) {
  return 1LL * F[n] * G[n-r] % MOD * G[r] % MOD;
}

void init() {
  F[0] = 1;
  G[0] = 1;
  P[0] = 1;
  for (int i = 1; i <= N; ++i) {
    F[i] = 1LL * F[i-1] * i % MOD;
    G[i] = inv(F[i]);
    P[i] = 1LL * P[i-1] * (M - 1) % MOD;
  }
}

int main() {
  scanf(" %d%d%d", &N, &M, &K);
  init();
  int ret = 0;
  for (int i = 0; i <= K; ++i) {
    int col = 1LL * M * P[N-i-1] % MOD;
    int val = 1LL * ncr(N-1, i) * col % MOD;
    ret = (1LL * ret + val) % MOD;
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 5444
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans = 0
cnt = 1
mn = T[0]
for i in range(1,N):
    if cnt == C or mn+K < T[i]:
        ans += 1
        cnt = 1
        mn = T[i]
    else:
        cnt += 1
if cnt > 0:
    ans += 1
print(ans)


Measured memory_bytes: 7392
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = Counter(a)
c = c.most_common()
ans = 0
c.sort(key=lambda x:x[1])
for i in range(len(set(a)) - k):
    ans += c[i][1]
print(ans)

Measured memory_bytes: 41364
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
mod=10**9 + 7


for i in range(N):
  count=0
  for j in range(i+1,N):
    if A[i]>A[j]:
      count+=1
  ans+=count
count=0
for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      count+=1
ans*=K
ans+=(count%mod)*(K*(K-1)//2)%mod
print(ans%mod)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    map<char, int> mp;
    for (int i = 0; i < n; i++) mp[s[i]]++;
    cout << (mp['R'] > mp['B'] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int x;cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3652
S = input()

l = len(S)

if l % 2 == 1:
    h= l//2
    a = S[:h+1]
    b = S[h:]
else:
    h= l//2
    a=S[:h]
    b=S[h:]

b = ''.join(list(reversed(b)))
al = list(a)
bl = list(b)

c = 0
for i,p in enumerate(al):
    if(p != bl[i]):
        c = c+1
    
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,mx,s,i,j,cnt,sz,la,a[500010],b[500010],c[500010][2],hd[21][200010],
pr[21][200010],f[500010],g[500010],d[500010];
int main(){
	scanf("%d%d",&n,&m);la=m;
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	m/=2;
	while(1){
		b[cnt++]=m;
		if(!m)break;m/=2;
	}
	mx=1<<cnt;
	for(j=0;j<cnt;j++){
		//printf("%d\n",b[j]);
		hd[j][n]=n;hd[j][n+1]=n+1;
		for(i=n-1;i;i--){
			if(a[i+1]-a[i]>b[j])hd[j][i]=i;
			 else hd[j][i]=hd[j][i+1];
		}
		pr[j][1]=1;
		for(i=2;i<=n;i++){
			if(a[i]-a[i-1]>b[j])pr[j][i]=i;
			 else pr[j][i]=pr[j][i-1];
			//printf("%d %d %d\n",i,pr[j][i],hd[j][i]);
		}
		//puts("");
	}
	c[sz=1][0]=1;
	for(i=2;i<=n;i++){
		if(a[i]-a[i-1]>la)c[sz][1]=i-1,c[++sz][0]=i;
	}
	c[sz][1]=n;
	//printf("%d\n",sz);
	if(sz>20){
		for(i=1;i<=n;i++)puts("Impossible");
		return 0;
	}
	memset(g,44,sizeof(g));
	g[0]=n+1;
	for(s=0;s<mx;s++){
		//printf("%d %d %d\n",s,f[s],g[s]);
		for(i=0;i<cnt;i++)if(!(s&(1<<i))){
			f[s|(1<<i)]=min(n,max(f[s|(1<<i)],hd[i][f[s]+1]));
			g[s|(1<<i)]=max(1,min(g[s|(1<<i)],pr[i][g[s]-1]));
		}
	}
	//memset(g,44,sizeof(g));
	for(i=1;i<=sz;i++)
	 for(s=0;s<mx;s++)if(f[s]>=c[i][0]-1&&g[(mx-1)^s]<=c[i][1]+1)d[c[i][0]]++,d[c[i][1]+1]--;
	for(i=1;i<=n;i++)d[i]+=d[i-1];
	for(i=1;i<=n;i++)if(d[i])puts("Possible");
	 else puts("Impossible");
}

Measured memory_bytes: 44544
n = gets.to_i
input = Array.new
for i in 0..n-1 do
    input[i] = gets.to_i
end

sum = input.sort!.inject(:+)

if sum % 10 != 0
    puts sum
else
    for i in 0..n-1 do
        if input[i] % 10 != 0
            sum = sum - input[i]
            puts sum
            break
        
        end
    end
    if sum % 10 == 0
        puts 0
    end
    
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string a;
  long long  sum=0,n;
    cin>>a;
  n=a.size();
  for(int i=0;i<n;i++)
  {
   sum=sum+( a[i]-'0');  
    
  }
  //cout<<sum<<endl;
if(sum%9==0)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3704
H, W, K = [int(_) for _ in input().split()]

if W == 1:
    print(1)
else:
    def fib(j):
        if j == 0 or j == 1:
            return 1
        else:
            count = 0
            for num in range(2 ** (j - 1)):
                bit = str(bin(num))
                flag = 1
                for i in range(2, len(bit) - 1):
                    if bit[i] == '1' and bit[i + 1] == '1':
                        flag = 0
                count += flag
            return count
    dp = [[1] + [0] * (W - 1)]
    for j in range(1, H + 1):
        dp.append([0] * W)
        for i in range(W):
            if i == 0:
                dp[j][i] = (dp[j - 1][i] * fib(i) * fib(W - i - 1) + dp[j - 1][i + 1] * fib(i) * fib(W - i - 2)) % 1000000007
            elif i == W - 1:
                dp[j][i] = (dp[j - 1][i] * fib(i) * fib(W - i - 1) + dp[j - 1][i - 1] * fib(i - 1) * fib(W - i - 1)) % 1000000007
            else:
                dp[j][i] = (dp[j - 1][i] * fib(i) * fib(W - i - 1) + dp[j - 1][i + 1] * fib(i) * fib(W - i - 2) + dp[j - 1][i - 1] * fib(i - 1) * fib(W - i - 1)) % 1000000007
    print(dp[H][K - 1])

Measured memory_bytes: 3064
#include<cstdio>
typedef unsigned long long ull;
const int inf=1<<28;
int a[100010],len;
bool s[100010];
int Q[100010],D[100010];
ull vis[3633],vec[64][3633];
int calc(int k){
	if(*s)return 1;
	int*h=Q,*t=Q,ans=inf,pos=k+63>>6;
	for(int j=0;j<<6<k*2;j++)vis[j]=0;
	for(int j=0;j<k;j++)D[j]=inf;
	for(int i=0;i<64;i++){
		for(int j=0;j<<6<pos*64+k;j++)vec[i][j]=0;
		for(int*j=a;j<a+len;j++){
			int x=(i+*j)%k;
			vec[i][pos+(x>>6)]|=1ull<<(x&63);
			vec[i][pos*64+x-k>>6]|=1ull<<(pos*64+x-k&63);
		}
	}
	vis[0]=1;
	D[*t++=0]=0;
	for(;h<t&&D[*h]+1<ans;h++){
		if(len<=2000){
			for(int*i=a;i<a+len;i++){
				int x=(*h+*i)%k;
				if(!(vis[x>>6]>>(x&63)&1)){
					vis[x>>6]|=1ull<<(x&63);
					D[*t++=x]=D[*h]+1;
					if(D[x]+D[k-x]<ans)ans=D[x]+D[k-x];
				}
			}
	//printf("D[%d]+1=%d ans=%d len=%d\n",*h,D[*h]+1,ans,len);
		}
		else for(int j=0;j<<6<k;j++){
			ull st=vec[*h&63][pos-(*h>>6)+j]&~vis[j];
			while(st){
				int x=__builtin_ctzll(st);
				if(x+(j<<6)>=k)break;
				vis[j]|=1ull<<x;
				st-=1ull<<x;
				x+=j<<6;
				D[*t++=x]=D[*h]+1;
				if(D[x]+D[k-x]<ans)ans=D[x]+D[k-x];
			}
		}
	}
	return ans;
}
int main(){
/*
	for(int k=100000;k;k--){
		counter=0;
		int x=1;
		len=0;
		while(!s[x]){
			s[x]=1;
			a[len++]=x;
			x=x*10ll%k;
		}
		printf("%d: %d\n",k,calc(k));
		for(int*i=a;i<a+len;i++)s[*i]=0;
	}*/
	int k;scanf("%d",&k);
	int x=1;
	len=0;
	while(!s[x]){
		s[x]=1;
		a[len++]=x;
		x=x*10ll%k;
	}
	for(int i=0;i<k;i++)D[i]=inf;
	printf("%d\n",calc(k));
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(){

int a[1000];
int n;

cin>>n;
int i;
for (i=0;i<=n;i=i+1)
{cin>>a[i];}

int j;
for(j=n-1;j>-1;j=j-1)
{cout<<a[j];
    if(j>0){cout<<" ";}
    if(j==0){cout<<endl;}
}
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int n;
int exi[100][100];
vector<P> ans;
void solve() {
	cin >> n;
	int d = (n / 2) * 2;
	int sum = 1 + d;
	rep(i, d / 2) {
		Rep(j, i + 1, d / 2) {
			ans.push_back({ i + 1,j + 1 });
			ans.push_back({ i + 1 + d / 2,j + 1 + d / 2 });
		}
	}
	rep(i, d / 2) {
		int r = sum - (i + 1);
		Rep1(j, d / 2 + 1, d) {
			if (r == j)continue;
			ans.push_back({ i+1,j });
		}
	}
	if (d != n) {
		rep1(i, d) {
			ans.push_back({ i,n });
		}

	}
	cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	int a,c=0,d=0;
	cin>>a; //5
	int b[a+1];
	for(int i=1;i<=a;i++)
		cin>>b[i]; //3 6 
	for(int i=1;i<=a;i++)
	{
		if(b[i]%2==0)
		{
			if(b[i]%3==0||b[i]%5==0)
				d++;
			else
				c=1;
		}
	}
	if(c==1)
		cout<<"DENIED";
	else
		cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
# input here
_INPUT = """\
2 3 2
..#
###
"""

def main():
    H, W, K = map(int, input().split())
    grid = [input() for _ in range(H)]
    
    n = H + W
    ans = 0
    for i in itertools.product(range(2), repeat=H):
        for j in itertools.product(range(2), repeat=W):
            cnt = 0            
            for y in range(H):
                if i[y]:
                    continue
                for x in range(W):
                    if j[x]:
                        continue
                    if grid[y][x] == "#":
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 74088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int x = int.Parse(input);
            Console.WriteLine(x * x * x);
        }
    }
}


Measured memory_bytes: 15992
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 110;

int main() {
    int n;
    while(cin >> n) {
        bool flag = false;
        for(int i = 1 ; i <= n ; i++) {
            int x;
            cin >> x;
            if(x % 2 == 0) {
                if(x % 3 != 0 && x % 5 != 0) {
                    flag = true;
                }
            }
        }
        if(flag) {
            cout << "DENIED" << endl;
        } else {
            cout << "APPROVED" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#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 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字くらい使った方がいいかも
*/

int main(void){
    int N, M; cin >> N >> M;
    set<int> first, last;
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        if(a == 1) first.insert(b);
        if(b == N) last.insert(a);
    }

    set<int> inter;
    set_intersection(first.begin(), first.end(), last.begin(), last.end(), inserter(inter, inter.end()));
    if(inter.size() == 0) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;

}

Measured memory_bytes: 9600
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	var x, y int
	fmt.Scan(&s, &x, &y)

	n := len(s)
	ss := strings.Split(s, "T")

	xs := make([]string, 0)
	ys := make([]string, 0)
	for i := 0; i < len(ss); i++ {
		if i%2 == 0 {
			xs = append(xs, ss[i])
		} else {
			ys = append(ys, ss[i])
		}
	}

	dpx := make([]map[int]bool, len(xs)+1)
	for i := 0; i < len(dpx); i++ {
		dpx[i] = make(map[int]bool)
	}
	dpy := make([]map[int]bool, len(ys)+1)
	for i := 0; i < len(dpy); i++ {
		dpy[i] = make(map[int]bool)
	}

	dpx[0][0] = true
	dpy[0][0] = true

	dpx[1][len(xs[0])] = true
	for i := 1; i < len(xs); i++ {
		for j := -n; j <= n; j++ {
			if dpx[i][j] {
				dpx[i+1][j-len(xs[i])] = true
				dpx[i+1][j+len(xs[i])] = true
			}
		}
	}

	for i := 0; i < len(ys); i++ {
		for j := -n; j <= n; j++ {
			if dpy[i][j] {
				dpy[i+1][j-len(ys[i])] = true
				dpy[i+1][j+len(ys[i])] = true
			}
		}
	}

	if dpx[len(dpx)-1][x] && dpy[len(dpy)-1][y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 131744
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 4e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, a, b;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> a>> b;
	for(int x = 1; x < 10000; x++) {
		ll c = floor((double)x * 0.08);
		ll d = floor((double)x * 0.1);
		if(c==a&&d==b) return cout << x, 0;
	}
	cout << -1;
}



Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a < b:
    if v <= w:
        print('NO')
    else:
        if b - a <= t * (v - w):
            print('YES')
        else:
            print('NO')
elif a > b:
    if v <= w:
        print('NO')
    else:
        if a - b <= t * (v - w):
            print('YES')
        else:
            print('NO')

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

int main(){
    int N,count=0,a;
    cin>>N;
    
    for (int i=0;i<N;++i){
        cin >> a;
        while(a%2==0){
            a/=2;
            count+=1;
        }
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main(){ 
    int a, b; cin >> a >> b;
    if(a*b%2==1 || a*b*2%2==1 || a*b*3%2==1) cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int w,n,num[31];
int main(){
    int a,b;
    cin>>w>>n;
    for(int i=0;i<w;i++)num[i]=i+1;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        swap(num[a-1],num[b-1]);
    }
    for(int i=0;i<w;i++)cout<<num[i]<<endl;
    return 0;
}

Measured memory_bytes: 1240
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        int ab;
        int cd;
        if(a<b) {
            ab=a;
        } else {
            ab=b;
        }
        if(c<d) {
            cd=c;
        } else {
            cd=d;
        }
        System.out.println(ab+cd);
    }
}

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

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));    //n,d
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            double sum = 0;
            for(int k = 0; k < d; k++){
                sum += pow(x[j][k] - x[i][k], 2);
            }
            double det = sqrt(sum);
            if(floor(det) == det)ans++;
        }
    }
    cout << ans << endl;
}


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

//説明はなくていいはず。
//大きいお金から順にお釣りを決定していったらおk

int main(){
	int c100, c500, c1000;
	int price, pay;

	while(cin >> price >> pay, price || pay){
		pay -= price;
		c1000 = pay / 1000;
		pay %= 1000;
		c500 = pay / 500;
		pay %= 500;
		c100 = pay / 100;

		cout << c100 << " " << c500 << " " << c1000 << endl;
	}
}

Measured memory_bytes: 1160
def ascan; gets.split.map(&:to_i);end

N = gets.to_i

dp = [N]*(N+1)
dp[0] = 0

N.times do |ptr|
    0.upto(9) do |i|
        hop = 6**i
        break if ptr+hop > N
        dp[ptr+hop] = [dp[ptr+hop], dp[ptr]+1].min
    end
    1.upto(9) do |i|
        hop = 9**i
        break if ptr+hop > N
        dp[ptr+hop] = [dp[ptr+hop], dp[ptr]+1].min
    end
end

p dp[N]

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define int long long

string S;
int Q;
int reverse_count = 0;

signed main() {
  cin >> S;
  deque<char> D(S.size());
  for(int i=0, end=S.size(); i<end; i++) D[i] = S[i];
  cin >> Q;
  while(Q--) {
    int t;
    cin >> t;
    if(t==1) {
      reverse_count++;
    }
    else {
      int f; char c;
      cin >> f >> c;
      if(f==1) {
        if(reverse_count % 2) D.push_back(c);
        else D.push_front(c);
      }
      else {
        if(reverse_count % 2) D.push_front(c);
        else D.push_back(c);
      }
    }
  }
  if(reverse_count % 2) for(int i=D.size()-1; i>=0; i--) cout << D[i];
  else for(int i=0, end=D.size(); i<end; i++) cout << D[i];
  cout << endl;
}


Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC129_1
{
    class B
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var W = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var res = int.MaxValue;
            for (int i = 0; i < N - 1; i++)
            {
                var sum = 0;
                for (int j = 0; j <= i; j++)
                {
                    sum += W[j];
                }
                for (int j = i + 1; j < N; j++)
                {
                    sum -= W[j];
                }

                res = Math.Min(res, Math.Abs(sum));
            }
            Console.WriteLine(res);
        }
    }
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> G(H);

  for(int i=0; i<H ; i++)
    cin >> G.at(i);

  //vector<vector<int>> P(H, vector<int>(0));
  set<int> W_mark;
  set<int> H_mark;

  for(int i=0; i<H; i++){
    for(int j=0; j<W ; j++){
      if(G.at(i).at(j) == '#'){
        W_mark.insert(j);
        H_mark.insert(i);
      }
    }
  }

  //cout << W_mark.find(0) << endl;

  for(int i=0; i<H ; i++){
    bool line = false;
    for(int j=0; j<W ; j++){
      if(H_mark.count(i) != 0 && W_mark.count(j) != 0){
        cout << G.at(i).at(j);
        line = true;
      }
    }
    if(line) cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+5;

int n;
ll m, a[N], allcm;

ll lcm(ll x, ll y) {
  return x/__gcd(x,y)*y;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin>>n>>m;
  m*=2LL;
  allcm=1;
  for (int i=1; i<=n; ++i) {
    cin>>a[i];
    allcm=lcm(allcm, a[i]);
    if (allcm>m) {
      cout<<0;
      return 0;
    }
  }

  for (int i=1; i<=n; ++i) {
    if ((allcm/a[i])%2LL==0LL) {
      cout<<0;
      return 0;
    }
  }

  ll t=m/allcm;
  if (t%2LL==0LL) --t;
  ll res=(t+1LL)/2LL;
  cout<<res;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    char c = 'a';
    for(int i=0; i<26; i++) {
        if(find(S.begin(), S.end(), c) == S.end()) {
            cout << c << endl;
            return 0;
        }
        c++;
    }
    cout << "None" << endl;
    return 0;
}


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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, m;
  cin >> n >> m;
  int h[n];
  vector<bool> cnt(n, true);
  for(int i=0; i<n; i++) cin >> h[i];
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(h[a]<h[b]) cnt[a]=false;
    else if(h[a]>h[b]) cnt[b]=false;
    else{
      cnt[a]=false;
      cnt[b]=false;
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if(cnt[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",a*b/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, k;

int main(void){
    cin >> n >> k;
    vector<bool> r(10);
    rep(i, k){
        lli d;
        cin >> d;
        r[d] = true;
    }
    for(int i = n; i <= 10*n; i++){
        string s = to_string(i);
        bool ok = true;
        rep(j, s.size()){
            if(r[s[j]-'0']) ok = false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
const int maxn = 2e5+10;
int N;
struct node{
    string s;
    int cnt;
};
map<string,node> mp;
int main(){
    cin>>N;
    for(int i = 0;i<N;i++){
        string s;cin>>s;
        if(mp.count(s)) mp[s].cnt++;
        else mp[s] = {s,1};
    }
    int mx = 0;
    for(auto p:mp) mx = max(mx,p.second.cnt);
    for(auto p:mp){
        if(p.second.cnt == mx) cout<<p.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n, a, b;
    cin >> n >> a >> b;
    if (a + b - 1 <= n && n <= a * b) {
        for (int i = b; i >= 1; --i) cout << i << ' ';
        int h = n - a - b + 1;
        int ptr = b + 1;
        for (int i = 0; i < a - 1; ++i) {
            int sz = 1 + min(h, b - 1);
            h -= min(h, b - 1);
            for (int j = ptr + sz - 1; j >= ptr; --j) cout << j << ' ';
            ptr += sz;
        }   
        cout << '\n';
    }
    else {
        cout << "-1\n";
    }   

}   

Measured memory_bytes: 2176
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int INF = 1000000005;
using namespace std;

int main() {
    int n;
    int a[4];
    cin >> n;
    REP(i, 4) {
        a[i] = n % 10;
        n = n / 10;
    }
    string str="aaa";
    if ((a[0] == a[1] && a[1] == a[2] ) || (a[1] == a[2] && a[2] == a[3]))str = "Yes";
    else str = "No";
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main() {
  ll n, k;
  cin >> n >> k;
  ll l = 0, r = 0;
  mint ans = 1;
  REP(i, n) {
    l += i;
    r += n-i;
    if (i >= k-1) {
      ans += r-l+1;
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3624
import collections
n, u, v = map(int, input().split())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b - 1].append(a - 1)


dist = [[float('inf')] * n for i in range(2)]
visited = [[False] * n for i in range(2)]
dq = [collections.deque() for i in range(2)]

dq[0].append((0, u-1))
dq[1].append((0, v - 1))

for i in range(2):
    while dq[i]:
        d, v = dq[i].popleft()
        if visited[i][v]:
            continue
        visited[i][v] = True
        dist[i][v] = d
        for nv in graph[v]:
            if visited[i][nv]:
                continue
            dq[i].append((d + 1, nv))

dq[0].append((0, u-1))
visited = [[False] * n for i in range(2)]
i = 0
while dq[i]:
    d, v = dq[i].popleft()
    if visited[i][v]:
        continue
    visited[i][v] = True
    if dist[0][v] >= dist[1][v]:
        continue
    for nv in graph[v]:
        if visited[i][nv]:
            continue
        dq[i].append((d + 1, nv))

max_turn = 0
for i in range(n):
    if not visited[0][i]:
        continue
    max_turn = max(max_turn, dist[1][i]-1)
print(max_turn)


Measured memory_bytes: 75680
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>


using namespace std;

const int MaxN = 1e5 + 5;


int dp[MaxN] , n , k , a[MaxN];

int main(){
	memset(dp , 0x3f , sizeof dp);
	scanf("%d %d",&n ,&k);
	for(int i = 1 ; i <= n ; i++)scanf("%d",&a[i]);
	dp[1] = 0;
	for(int i = 1 ; i <= n ; i++){
		for(int j = i + 1 ; j <= min(i + k , n) ; j++){
			dp[j] = min(dp[j] , dp[i] + abs(a[i] - a[j]));
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n - m + 1; ++i) {
        for (int j = 0; j < n - m + 1; ++j) {
            bool ok = true;
            for (int k = 0; k < m; ++k) {
                if (a[i + k].substr(j, m) != b[k]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << "Yes"
                     << "\n";
                return 0;
            }
        }
    }
    cout << "No"
         << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b;
char c;
int main(){
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++){
		cin>>c;
		if(c<'0'||c>'9'){
			puts("No");
			return 0;
		}
	}
	cin>>c;
	if(c!='-'){
		puts("No");
		return 0;
	}
	for(int i=1;i<=b;i++){
		cin>>c;
		if(c<'0'||c>'9'){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef long long LL;
const int os = 2005;
const int bord = 2000;
const int md = 1e9+7;
int dp[5005][5005];
int fac[8005];
int invfac[8005];
int mark[2005][2005];
void add(int &a, int b)
{
	a += b;
	if(a>= md) a -= md;
}
void sub(int &a, int b)
{
	a -= b;
	if(a< 0) a += md;
}
int mul(int a, int b)
{
	return (1LL*a*b)%md;
}
int solve(int a, int b)
{
	if(a> bord || b> bord) return 0;
	if(dp[a+os][b+os] != -1) return dp[a+os][b+os];
	int ans = 0;
	if(a>= 1 && b>= 1) add(ans, mark[a][b]);
	add(ans, solve(a+1, b));
	add(ans, solve(a, b+1));
	return dp[a+os][b+os] = ans;
}
int mod(int a, int b)
{
	if(b == 0) return 1;
	int x = mod(a, b/2);
	int y = mul(x, x);
	if(b%2) y = mul(y, a);
	return y;
}
int inv(int x)
{
	return mod(x, md-2);
}
int main()
{
	memset(dp, -1, sizeof dp);
	//memset(cmem, -1, sizeof cmem);
	int n;
	scanf("%d", &n);
	vii all;
	fac[0] = invfac[0] = 1;
	for(int i = 1; i<= 8000; i++)
	{
		fac[i] = mul(fac[i-1], i);
		invfac[i] = mul(invfac[i-1], inv(i));
	}
	for(int i = 0; i< n; i++)
	{
		int a, b; scanf("%d %d", &a, &b);
		mark[a][b]++;
		all.pb(ii(a, b));
	}
	int res = 0;
	for(int i = 0; i< n; i++)
	{
		add(res, solve(-all[i].X, -all[i].Y));
		//printf("%d\n", solve(-all[i].X, -all[i].Y));
		sub(res, mul(fac[2*all[i].X+2*all[i].Y], mul(invfac[2*all[i].Y], invfac[2*all[i].X])));
	}
	//printf("%d\n", res);
	res = mul(res, inv(2));
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 116084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}node;
node *T;
void Insert(int);
void Inorder(node*);
void Preorder(node*);
int Find(int);
void Delete(int);
node* Successor(node*);
node* Minimum(node*);
node* Maximum(node*);
void Free(node*);
int main(){
  int n, i, key;
  char func[6];
  T = (node *)malloc(sizeof(node) * 1);
  T->parent = T->left = T->right = NULL;
  T->key = -1;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",func);
    if(strcmp(func,"insert") == 0){
      scanf("%d",&key);
      Insert(key);
    }
    else if(strcmp(func,"print") == 0){
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
    }
    else if(strcmp(func,"find") == 0){
      scanf("%d",&key);
      Find(key) ? printf("yes\n") : printf("no\n");
    }
    else if(strcmp(func,"delete") == 0){
      scanf("%d",&key);
      Delete(key);
    }
  }
  Free(T);
  return 0;
}

void Inorder(node* x){
  if(x != NULL){
    Inorder(x->left);
    printf(" %d",x->key);
    Inorder(x->right);
  }
}

void Preorder(node* x){
  if(x != NULL){
    printf(" %d",x->key);
    Preorder(x->left);
    Preorder(x->right);
  }
}

void Free(node* x){
  if(x != NULL){
    Free(x->left);
    Free(x->right);
    free(x);
  }
}

void Insert(int key){
  node *x, *y, *R;
  if(T->key == -1){
    T->key = key;
    return;
  }
  R = (node *)malloc(sizeof(node) * 1);
  R->key = key;
  R->parent = R->left = R->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  R->parent = y;
  if(R->key < y->key)
    y->left = R;
  else
    y->right = R;
}

int Find(int key){
  node *x;
  for(x=T; x != NULL;){
    if(x->key > key)
      x = x->left;
    else if(x->key < key)
      x = x->right;
    else return 1;
  }
  return 0;
}

void Delete(int key){
  node *x, *y, *z;
  for(x=T; x != NULL;){
    if(x->key > key)
      x = x->left;
    else if(x->key < key)
      x = x->right;
    else break;
  }
  z = x;
  if(z->left == NULL || z->right == NULL)
    y = z;
  else
    y = Successor(z);
  if(y->left != NULL)
    x = y->left;
  else
    x = y->right;
  if(x != NULL)
    x->parent = y->parent;
  if(y->parent == NULL)
    T = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  if(y != z)
    z->key = y->key;
}

node* Successor(node* x){
  node *y;
  if(x->right != NULL)
    return Minimum(x->right);
  y = x->parent;
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

node* Minimum(node* x){
  while(x->left != NULL)
    x = x->left;
  return x;
}

node* Maximum(node* x){
  while(x->right != NULL)
    x = x->right;
  return x;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  int count = 0;
  for (int i = 0; i < n; i++)
    if (v[i] == count + 1) count++;

  cout << ((count) ? n - count : -1) << endl;
}


Measured memory_bytes: 1024
S = input()
 
# Sの各文字は'L', 'R', 'U', 'D'のいずれかであることに注意する
# 1,3,...文字目が'L'でなく、偶数文字目が'R'でないとき 'Yes'とする
N = len(S)
ans = 'Yes'
for i in range(N):
  if (i % 2 == 0 and S[i] == 'L') or (i % 2 == 1 and S[i] == 'R'):
    ans = 'No'
    break
    
print(ans)

Measured memory_bytes: 8928
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

ll A,B,C,K;
 
int main(){
	cin>>A>>B>>C>>K;
	if(K%2==1)cout<<B-A;
	else cout<<A-B;
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m, q;
int d[4010];

struct edge{
   int to, cost;
//    edge(int to, int cost):to(to), cost(cost){}
};
vector<edge> G[4010]; 

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       rep(i, 0, n) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

vector<pair<int, P> > es; 
// vector<int> path;
int pMAX[4010][4010];
// int cost[4010][4010];

void dfs(int now, int pre, int MAX, int root){
    // cout << " " << now << " " << pre << endl;
    // path[now] = pre;
    pMAX[root][now] = MAX;
    // if(now == dest) return;
    rep(i, 0, G[now].size()){
        int next = G[now][i].to;
        if(next == pre) continue;
        // path[next] = now;       
        dfs(next, now, max(MAX, G[now][i].cost), root);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        // G[a].push_back(edge{b, c});
        // G[b].push_back(edge{a, c});
        es.push_back(pair<int, P>(c, P(a, b)));
        // cost[a][b] = c;
        // cost[b][a] = c;
    }
    sort(all(es));
    UF uf(n);
    int sum = 0, cnt = 0;
    rep(i, 0, es.size()){
        int from = es[i].second.first;
        int to = es[i].second.second;
        if(uf.same(from, to) == false){
            uf.unite(from, to);
            sum += es[i].first;
            G[from]. push_back(edge{to, es[i].first});
            G[to]. push_back(edge{from, es[i].first});
        }
    }
    // cout << sum << endl;
    rep(i, 0, n){
        // path.clear(); path.resize(n, -1);
        dfs(i, -1, 0, i);
    }
    cin >> q;
    rep(i, 0, q){
        int s, t;
        cin >> s >> t;
        s--; t--;
        // path.clear(); path.resize(n, -1);
        // dfs(s, -1, t);
        cout << sum - pMAX[s][t] << endl;
        // int MAX = 0;
        // int now = t;
        // while(now != s){
        //     int next = path[now];
        //     chmax(MAX, cost[now][next]);
        //     now = next;
        // }
        // cout << sum - MAX << endl;
        // rep(j, 0, path.size()){
        //     cout << path[j] << " ";
        // }
        // cout << endl;
        // dijkstra(s);
        // cout << d[t] << endl;
    }
}


Measured memory_bytes: 138472
program main
  implicit none
  integer i
  character(3) S 
  read(*, *) S
  !read(*, *) (L(i), i = 1,N)
  if (S == 'AAA') then
    write(*, *) 'No'
  elseif (S == 'BBB') then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  endif
end program main


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	int ma=-1;
	int out;
	while(cin>>n,n){
		int ma=-1;
		int out;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			if(b+c>ma){
				ma=b+c;
				out=a;
			}
		}
		cout<<out<<" "<<ma<<endl;
	}	
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif

	int R,G;
	cin >> R >> G;
	int ans = 2*G - R;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	set<string> st;
	rep(i, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ll long long
using namespace std;
void TxtRead(){
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
}
void TheTime(){
    ios_base::sync_with_stdio(false);
	cin.tie();
}
const int N = 3e3+5;
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793116;

string s1, s2;
int dp[N][N];

int main()
{
    //TxtRead();
    TheTime();
	
	cin>>s1>>s2;
	s1='#'+s1;
	s2='$'+s2;
	for(int i=1; i<s1.size(); i++){
		for(int j=1; j<s2.size(); j++){
			if(s1[i]==s2[j])
				dp[i][j]=max(dp[i][j], dp[i-1][j-1]+1);
			else 
				dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
		}
	}
	
	string ans="";
	int a=1, b=1, mx=0;
	for(int i=1; i<s1.size(); i++){
		for(int j=1; j<s2.size(); j++){
			if(dp[i][j]>=mx) a=i, b=j;
		}
	}
	
	while(true){
		if(a==0 || b==0) break;
		if(b==0 || dp[a][b]==dp[a-1][b]) a--;
		else if(a==0 || dp[a][b]==dp[a][b-1]) b--;
		else{
			ans+=s1[a];
			a--, b--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<'\n';
}

Measured memory_bytes: 35456
#include<iostream>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<vector>  
#include<algorithm>  
#define N 200005  
#define LL long long  
#define inf 1<<29  
#define eps 1e-7  
using namespace std;  
vector<int>v[200005];  
int get_sg(int u,int pre){  
    int ret=0;  
    for(int i=0;i<v[u].size();i++){  
        if(v[u][i]!=pre)  
            ret^=(1+get_sg(v[u][i],u));  
    }  
    return ret;  
}  
int main(){  
    int t,n;  
        scanf("%d",&n);  
        for(int i=1;i<=n;i++)  
            v[i].clear();  
        for(int i=1;i<n;i++){  
            int x,y;  
            scanf("%d%d",&x,&y);  
            v[x].push_back(y);  
            v[y].push_back(x);  
        }  
        if(get_sg(1,-1))  
            puts("Alice");  
        else  
            puts("Bob");  

    return 0;  
}  

Measured memory_bytes: 14336
import java.util.Scanner;


public class Main {
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int A = s.nextInt();
		int B = s.nextInt();
		
		System.out.println((X-A)%B);
		
		
		
	}
	
}

Measured memory_bytes: 20688
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( a <= 2 * b ) cout << 0 << endl;
	else cout << a - 2 * b << endl;
	
	return 0;
}


Measured memory_bytes: 256