akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll dp[2007][2007];

int main() {
  ll N,K;
  cin >> N >> K;
  rep(i,N+1){
    dp[i][0]=1;
  }
  dp[1][1]=1;
  REP(i,2,N+1){
    rep(j,N+1){
      if(i<j){
        break;
      }
      if(j>0){
        dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
        dp[i][j]%=MOD;
      }
    }
  }
  rep(i,K){
    cout << dp[N-K+1][i+1]*dp[K-1][i]%MOD << endl;
  }
}

Measured memory_bytes: 30208
#include <stdio.h>
int main(){
 int x, y;
 while(1){
  scanf("%d %d", &x, &y);
  if(x ==0 && y ==0) break;
  if(x > y){
   printf("%d %d\n", y, x);
  }else{
   printf("%d %d\n", x, y);
  }
  }
 return 0;
}

Measured memory_bytes: 1700
n=int(input())
h=list(map(int,input().split()))

a=h[0]
flag=True
if h[0]>0:
    h[0]-=1

for i in range(1,n):
    if flag:
        if h[i]>0 and h[i]>h[i-1]:
            h[i]-=1
        
        elif h[i]>=0 and h[i]==h[i-1]:
            continue
        
        else:
            flag=False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14276
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	string S[8];
    S[0] = "";
    S[1] = "SAT";
    S[2] = "FRI";
    S[3] = "THU";
    S[4] = "WED";
    S[5] = "TUE";
    S[6] = "MON";
    S[7] = "SUN";
    string l;
    cin >> l;
    for(int i=0;i<8;i++){
        if(S[i] == l)cout << i << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char n[15];
  for(int i=0;i<12;i++) cin>>n[i];
  for(int i=0;i<4;i++) cout<<n[i];
  cout<<" ";
  for(int i=4;i<12;i++) cout<<n[i];
  cout<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll sum=min(a,d)-min(c,d-min(b,d-min(a,d))-min(a,d));
    cout<<sum;
    
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y,x = -1, y = -1, z = -1;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= (N - i); j++) {
      if ((10000 * i + 5000 * j + 1000 * (N - i - j)) == Y) {
        x = i;
        y = j;
        z = N - i - j;
        goto Found;
      }
    }
  }
  Found:
  cout << x << " " << y << " " << z << endl;
}

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

using namespace std;

#define int long long int
//#define lint long long int
#define test int t; cin>>t; while(t--)
#define mod 1000000007    
#define pb push_back

int32_t main()
{	
	string s,t;
	cin>>s>>t;
	int l=s.length();
	int ans=0;
	for(int i=0;i<l;i++)
	{
		if(s[i]!=t[i])
		ans++;
	}
	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b,x,y=0,n;
    cin>>a>>b>>x;
    if(a+b==x || a+x==b || b+x==a)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return(0);
    }

Measured memory_bytes: 256
from collections import deque

def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    d = [[float('inf')] * W for _ in range(H)]
    Q = deque([])
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                d[h][w] = 0
                Q.append([h,w])
    dh = [1,0,-1,0]
    dw = [0,1,0,-1]
    while Q:
        h,w = Q.popleft()
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if 0 <= nh < H and 0 <= nw < W:
                if A[nh][nw] == '.' and d[nh][nw] == float('inf'):
                    A[nh][nw] = '#'
                    d[nh][nw] = min(d[nh][nw], d[h][w] + 1)
                    Q.append([nh,nw])

    ans = 0
    for h in range(H):
        ans = max(ans, max(d[h]))

    print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 217624
#include <iostream>
using namespace std;
typedef long long ll;
int n,m;
bool tbl1[200010];
bool tbl2[200010];
int main(){
  cin>>n>>m;
  bool chk = false;
  for(int i=0;i<m;++i){
    int a,b;
    cin>>a>>b;
    if(a>b)
      swap(a,b);
    if(a==1){
      tbl1[b]=true;
    }
    if(b==n){
      tbl2[a]=true;
    }
  }
  for(int i=0;i<=200000;++i)
    if(tbl1[i]&&tbl2[i])
      chk=true;
  if(chk)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
    
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	string S;
	cin>>S;
	DBG("","","","");
	if(S=="AAA" || S=="BBB")	cout<<"No"<<endl;
	else						cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <string>
using namespace std;

typedef pair<int, int> P;
vector<P> v(10);

int h, w, n;
char map[1000][1001];

const int INF = 100000000;
int d[1000][1000];

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int bfs(int t){
	queue<P> que;
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			d[j][i] = INF;
		}
	}
	que.push(v[t]);
	d[v[t].first][v[t].second] = 0;
	while(que.size()){
		P p = que.front(); que.pop();
		if(p.first == v[t+1].first && p.second == v[t+1].second) break;
		for(int i=0; i<4; i++){
			int nx = p.second + dx[i], ny = p.first + dy[i];

			if(0 <= nx && nx < w && 0 <= ny && ny < h && map[ny][nx] != 'X' && d[ny][nx] == INF){
				que.push(P(ny, nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[v[t+1].first][v[t+1].second];
}

void solve(){
	scanf("%d %d %d", &h, &w, &n);
	for(int i=0; i<h; i++){
		scanf("%s", map[i]);
	}
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(map[j][i] == 'S') v[0] = (P(j, i));
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<w; j++){
			for(int k=0; k<h; k++){
				if(map[k][j] - '0' == i+1){
					v[i+1] = (P(k, j));
				}
			}
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		ans += bfs(i);
	}
	printf("%d\n", ans);
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++){
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
}

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

#define N_MAX 100000

int q[N_MAX];

int main(void)
{
    int N,K,Q;
    int i;
    int tmp;

    for (i = 0; i < N_MAX; i++) {q[i] = 0;}

    scanf("%d %d %d", &N, &K, &Q);

    for ( i = 0; i < Q; i++) {
        scanf("%d", &tmp);
        q[tmp-1]++;
    }
    
    for (i = 0; i < N; i++) {
        if ( ( Q - q[i] ) < K ) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

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

int main(void){
    // 定義
    char s[100],x[100],y[100],z[100],a[100],b[100];
    scanf("%s",&s);
    strcpy(x,s);
    // 回文判定
    int n = strlen(s);
    int len = strlen(x);
    for (int i=0;i <= (len/2)-1;i++){
        char tmp = x[i];
        x[i] = x[len-1];
        x[len-1] = tmp;
        len--;
    }
    if (strcmp(s,x)==0){
        // 2つ目
        strncpy(y,s,(n-1)/2);
        y[(n-1)/2] = '\0';
        strcpy(z,y);
        len = strlen(y);
        for (int j=0;j <= (len/2)-1; j++){
            char tmp = z[j];
            z[j] = z[len-1];
            z[len-1] = tmp;
            len--;
        }
        if (strcmp(y,z)==0){
            // 3つ目
            strncpy(a,s-1+(n+3)/2,n+1-(n+3)/2);
            a[n+1-(n+3)/2] = '\0';
            strcpy(b,a);
            len = strlen(a);
            for (int k=0;k<=(len/2)-1;k++){
                char tmp = b[k];
                b[k] = b[len-1];
                b[len-1] = tmp;
                len--;
            }
            if(strcmp(a,b)==0){
                printf("Yes");
            }else{
                printf("No");
            }
        }else{
            printf("No");
        }
    }else{
        printf("No");
    }
}

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

/*  using namespace  */
using namespace std;

/*  local var  */

/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)

/*  typedef  */
typedef long long ll;

/*  function  */
//None

/*  main program  */
int main()
{	
	ll r,D,x,xx;
	cin>>r>>D>>x;
	xx=x;
	loop(i,10){
		cout<<r*xx-D<<endl;
		xx=r*xx-D;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s; cin >> s;
    s[5] = ' '; s[13] = ' ';
    cout << s << endl; return 0;
}


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

typedef pair<int, int> Pii;
typedef pair<string, string> Pss;

map <string, Pii> dic;

int main() {
  string str;
  Pss result;
  while ( cin >> str ) {
    dic[str].first++;
    dic[str].second = str.size();

    if ( dic[result.first].first < dic[str].first ) result.first = str;
    if ( dic[result.second].second < dic[str].second ) result.second = str;

  }

  cout << result.first << " " << result.second << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	lli A, B, C; cin >> A >> B >> C;
	lli ans = 0;

	if (A % 2 == 1 && B % 2 == 1 && C % 2 == 1)ans = min(min(A * B, B * C), A * C);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python3

s = str(input())

a = s[0:2]

b = s[2:]


def div(a):
    a = int(a)
    if a <= 12 and a >= 1:
        return "BOTH"
    else:
        return "YY"


if div(a) == div(b):
    if div(a) == "YY":
        print("NA")
    else:
        print("AMBIGUOUS")
elif div(a) == "YY":
    print("YYMM")
else:
    print("MMYY")


Measured memory_bytes: 3060
from sys import stdin
import sys

[N, M] = list(map(int, stdin.readline().rstrip().split()))

a = []
for i in range(M):
    a.append(list(map(int, stdin.readline().rstrip().split())))

city = [[] for i in range(N+1)]

for i in range(M):
    [s, d] = a[i]
    city[s].append(d)
    city[d].append(s)

for i in range(1, N+1):
    if len(city[i]) >= 0:
        print(len(city[i]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
ll dp[105][2][5];
int main(){
  rep1(i, 5){
    ll u; cin >> u;
    if(u!=i) cout << i;
  }
  return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
    long int A,B,C,D,a1,a2;
    scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
    a1=A*B;a2=C*D;
    if(a1>a2)
    printf("%ld",a1);
    else{
        if(a2>a1)
        printf("%ld",a2);
        else
        printf("%ld",a1);
    }
    return 0;
}

Measured memory_bytes: 128
S=input()
flag=True
for i in range(len(S)):
    if((i%2==0) and (S[i]=="R" or S[i]=="U" or S[i]=="D")) or ((i%2==1) and (S[i]=="L" or S[i]=="U" or S[i]=="D")):
        pass
    else:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    a,b=MI()
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
dis1=[-1 for i in range(n)]
dis2=[-1 for i in range(n)]
dis1[0]=0
dis2[-1]=0

def dfs1(x,l):
    for i in tree[x]:
        if dis1[i]>=0:
            continue
        else:
            dis1[i]=l+1
            dfs1(i,l+1)
dfs1(0,0)
#print(dis1)
def dfs2(x,l):
    for i in tree[x]:
        if dis2[i]>=0:
            continue
        else:
            dis2[i]=l+1
            dfs2(i,l+1)
dfs2(n-1,0)
#print(dis2)
count=0
for i in range(n):
    if dis1[i]<=dis2[i]:
        count+=1
    else:
        count-=1
if count<=0:
    print("Snuke")
else:
    print("Fennec")
    

        
        
        
            
        

                

Measured memory_bytes: 120436
#include <iostream>

using namespace std;

int main(){
  int n; cin >> n;
  int h[n];
  for(int i=0; i<n; ++i) cin >> h[i];
  
  int res = 0;
  bool flag = true;
  while(flag){
    flag = false;
    for(int i=0; i<n; ++i){
      if(h[i] != 0){
        --h[i];
        flag = true;
        if(i+1 == n || h[i+1] == 0) ++res;
      }
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

C = list(map(int, input().split()))
C.sort(reverse=True)

order = []
par = [-1]*n
s = []
visit = [-1]*n
s.append(0)
visit[0] = 0
while s:
    v = s.pop()
    order.append(v)
    for u in g[v]:
        if u == par[v]:
            continue
        par[u] = v
        s.append(u)

order.reverse()
ans = [0]*n
m = 0
for v in order:
    ans[v] = C.pop()
    if par[v] != -1:
        m += ans[v]
print(m)
print(*ans)

Measured memory_bytes: 50264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
 
  if (N * A > B) {
    cout << B << endl;
  }
   if (N * A < B) {
    cout << N * A << endl;
  }
     if (N * A == B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int INF=1e8;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];
    int ans=0;
    while(true){
        int tmp=0;;
        for(int i=0;i<n;i++){
            tmp=max(tmp,h[i]);
        }
        if(tmp==0) break;
        int i=0;
        while(i<n){
            if(h[i]==0) i++;
            else{
                while(h[i]!=0&&i<n){
                    h[i]--;
                    i++;
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

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

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

# ----- heapq ここから-----
import heapq
class Reverse:
    def __init__(self, val):
        self.val = val
        
    def __lt__(self, other):
        return self.val > other.val
        
    def __repr__(self):
        return repr(self.val)
    
class Heapq:
    def __init__(self, arr, desc = False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        if self.desc: return heapq.heappop(self.hq).val
        else: return heapq.heappop(self.hq)
 
    def push(self, a):
        if self.desc: heapq.heappush(self.hq, Reverse(a))
        else: heapq.heappush(self.hq, a)
 
    def top(self):
        if self.desc: self.hq[0].val
        else: return self.hq[0]
# ----- heapq ここまで-----

n = int(input())
a = list(myinput())
# print(a)

red = a[:n]
blue = a[(2*n):]

s_red = sum(red)
s_blue = sum(blue)

ans = s_red - s_blue
# print(ans)

hq_red = Heapq(red,False)
# print(red)
hq_blue = Heapq(blue,True)
# print(blue)

ans = -1*float("inf")

ls_s_red = [s_red]
for k in range(n,2*n):
    hq_red.push(a[k])
    p = hq_red.pop()
    s_red = s_red + a[k] - p  
    ls_s_red.append(s_red)
# print(ls_s_red)   

ls_s_blue = [s_blue]
for k in range(n,2*n):
    hq_blue.push(a[-(k+1)])
    p = hq_blue.pop()
    s_blue = s_blue + a[-(k+1)] - p
    ls_s_blue.append(s_blue)
ls_s_blue_sorted = ls_s_blue[::-1]
# print(ls_s_blue_sorted)

for k in range(len(ls_s_red)):
    M = ls_s_red[k] - ls_s_blue_sorted[k]
    ans = max(ans,M)

print(ans)

Measured memory_bytes: 128524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) for(int k = 0; k < 10; k++){
        int nums[] = {i, j, k};
        int cur = 0;
        for(int l = 0; l < n; l++){
            if(cur == 3) break;
            if(s[l] - '0' == nums[cur]) cur++;
        }
        if(cur==3)cnt++;
    }
    cout << cnt;
}

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

int main(){
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> a(h,vector<ll>(w));
    vector<ll> y0, x0, y1, x1;
    rep(i,h)rep(j,w) cin>>a[i][j];
    rep(i,h){
        rep(j,w){
            if(a[i][j]%2!=0){
                if(j!=w-1){
                    y0.push_back(i+1);
                    x0.push_back(j+1);
                    y1.push_back(i+1);
                    x1.push_back(j+2);
                    a[i][j]--;
                    a[i][j+1]++;
                }else if(i!=h-1){
                    y0.push_back(i+1);
                    x0.push_back(j+1);
                    y1.push_back(i+2);
                    x1.push_back(j+1);
                    a[i][j]--;
                    a[i+1][j]++;                }
            }
        }
    }
    cout<<y0.size()<<endl;
    rep(i,y0.size()) cout<<y0[i]<<' '<<x0[i]<<' '<<y1[i]<<' '<<x1[i]<<endl;
    return 0;
}

Measured memory_bytes: 8152
#include <stdio.h>
void dfs();
void dfs_visit(int);
#define N 1000
#define W 0
#define G 1
#define B 2


int num,m[N][N];
int color[N],first[N],finish[N],tt;


int main(){
  int tyouten,value,i,j,k;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      m[i][j]=0;
    }
  }
  
  for(i=0;i<num;i++){
    scanf("%d %d",&tyouten,&k);
    tyouten--;
    for(j=0;j<k;j++){
      scanf("%d",&value);
      value--;
      m[tyouten][value]=G;
    }
  }
  dfs();

  return 0;

}

void dfs(){
  int u;

  for(u=0;u<num;u++){
    color[u]=W;
  }
  tt=0;
  for(u=0;u<num;u++){
    if(color[u]==W)dfs_visit(u);
  }
  for(u=0;u<num;u++){
    printf("%d %d %d\n",u+1,first[u],finish[u]);
  }
}


void dfs_visit(int a){
  int value;
  color[a]=G;

  first[a]=++tt;
  for(value=0;value<num;value++){
    if(m[a][value]== W)continue;
    if(color[value]==W){
      dfs_visit(value);
    }
  }

  color[a]=B;
  finish[a]=++tt;
}




Measured memory_bytes: 2104
# -*- coding: utf-8 -*-

n, q  = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q):
    l[i], r[i] = map(int,input().split())


sum = [0]*(n+1)
for i in range(1,n):
    if s[i-1] == 'A' and s[i] =='C':
        sum[i+1] = sum[i] + 1
    else:
        sum[i+1] = sum[i]

#0 1 2 3 4 5 6
# A C A C A C
# 1 2 3 4 5 6

for i in range(q):
    ans = sum[r[i]]-sum[l[i]]
    print(ans)

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

int main(){
  ll l, r; cin >> l >> r;
  
  if((r-l)>=2019){
    cout << 0 << endl;
    return 0;
  }
  
  ll res = 2019;
  for(ll i=l; i<r; ++i){
    for(ll j=i+1; j<(r+1); ++j){
      res = min(res, (i*j)%2019);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <vector>
#include <queue>

using namespace std;

struct Node {
	int id;
	int d;
	int c;
};

vector<Node> G[10001];
int N, M;

typedef bool (*compare_node_type)(const Node &n1, const Node &n2);

bool compare_node_big(const Node &n1, const Node &n2)
{
	if (n1.d != n2.d)
		return n1.d > n2.d;
	if (n1.c != n2.c)
		return n1.c > n2.c;
	return n1.id > n2.id;

}

void dijistra(int src, vector<Node> &dist_v)
{
	priority_queue<Node, vector<Node>, compare_node_type> queue(compare_node_big);

	dist_v.resize(N+1);
	int i, j;
	Node node;

	for (i=1; i<=N; i++) {
		dist_v[i].d = INT_MAX;
	}
	dist_v[src].d = 0;
	dist_v[src].c = 0;
	node.id = src; node.d = 0; node.c = 0;
	queue.push(node);

	while (!queue.empty()) {
		node = queue.top(); queue.pop();
		if (node.d > dist_v[node.id].d ||
			node.c > dist_v[node.id].c)
			continue;

		int id = node.id;
		int d = node.d;

		for (i=0; i<G[id].size(); i++) {
			int nid = G[id][i].id;
			if (dist_v[nid].d > d+G[id][i].d ||
				dist_v[nid].d == d+G[id][i].d && dist_v[nid].c > G[id][i].c) {
				dist_v[nid].d = d+G[id][i].d;
				dist_v[nid].c = G[id][i].c;
				dist_v[nid].id = nid;

				queue.push(dist_v[nid]);
			}

		}


	}


}

int main()
{
	//freopen("in.txt", "r", stdin);

	while (scanf("%d%d", &N, &M)==2) {
		if (N==0 && M==0) break;
		int i, j;
		Node node;

		for (i=1; i<=N; i++)
			G[i].clear();

		for (i=0; i<M; i++) {
			int u, v, d, c;
			scanf("%d%d%d%d", &u, &v, &d, &c);
			node.id = v; node.d = d; node.c = c;
			G[u].push_back(node);
			node.id = u;
			G[v].push_back(node);

		}

		vector<Node> dist_v;

		dijistra(1, dist_v);

		int cost = 0;
		for (i=1; i<=N; i++)
			cost += dist_v[i].c;
		printf("%d\n", cost);



	}

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll D;
	cin >> D;
	if(D==25) cout << "Christmas" << endl;
	if(D==24) cout << "Christmas Eve" << endl;
	if(D==23) cout << "Christmas Eve Eve" << endl;
	if(D==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j<n-2:
            l=j+1
            r=n-1
            while r-l>1:
                c=(l+r)//2
                if p[c]>=p[i]+p[j]:
                    r=c
                else:
                    l=c
            if p[l]<p[i]+p[j]:
                ans+=l-j
            if p[r]<p[i]+p[j]:
                ans+=1
        if j==n-2:
            if p[i]+p[n-2]>p[n-1]:
                ans+=1
print(ans)


Measured memory_bytes: 44124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    int b;
    int i;
    int p;
    int q;
    cin >> a >>b;
    vector<int> array(a);
    
    i = -1;
    while (++i < b)
    {
        cin >> p >> q;
        array[p - 1]++;
        array[q - 1]++;
    }
    i = -1;
    while (++i < a)
        cout << array[i] << endl; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		int i = 0;
		while (N >= i + 1) {

			System.out.print(S.substring(i, i + 1) + T.substring(i, i + 1));
			i++;
		}
		sc.close();
	}

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3000;

int n, arr[MAXN+10];
ll dp[MAXN+10][MAXN+10];

ll solve(int l, int r)
{
    if(l>r) return 0;

    bool turn=((r-l+1)%2==n%2);
    ll &ret=dp[l][r];
    if(ret!=-1) return ret;

    if(turn)
    {
        ret=max(solve(l+1, r)+arr[l], solve(l, r-1)+arr[r]);
    }
    else
    {
        ret=min(solve(l+1, r)-arr[l], solve(l, r-1)-arr[r]);
    }

    return ret;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    memset(dp, -1, sizeof(dp));

    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d", &arr[i]);

    printf("%lld", solve(1, n));
    return 0;
}


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

typedef long long int ll;
const int N_MAX = 200005;
vector<int> A;
vector<int> B;

int main(){
    int n;
    cin >> n;
    A.push_back(0);
    B.push_back(0);
    for(int i = 1; i <= n; i++){
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    ll ans;
    if (n % 2 == 1){
        ans = B[(n+1)/2] - A[(n+1)/2] + 1;
    }
    else{
        ans = (B[n/2] - A[n/2+1]) + (B[n/2+1] - A[n/2]) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4660
<?php
  
 $menus = array();
for($i=0;$i<5;$i++){
	$menus[] = fgets(STDIN);
}

$diff_count=0;
$max=0;
$diff_list = array();

foreach($menus as $key => $menu){
  for($i=0;$i<9;$i++){
    if(($menu+$diff_count)%10==0){
      break;
    }
    $diff_count++;
 }
  $diff_list[$key] = $diff_count;
  
  $diff_count = 0;
}



asort($diff_list);



foreach($diff_list as $key => $diff){
  $sum+=$menus[$key]+$diff;
}

echo $sum-$diff_list[$key]."\n";



                  
                  
                  



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

signed main(){
	string C1, C2;
	cin >> C1 >> C2;
	swap(C2[0], C2[2]);
	if(C1 == C2){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
  int h,N;
  cin >> h >> N;
  int sum=0;
  rep(i,0,N){
      int a;
      cin >> a;
      sum += a;
  }
  if(sum>=h){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
gy = h - 1
gx = w - 1


def bfs(y, x):
    queue = deque([])
    queue.append((y, x))
    vgrid = [[float("inf")] * w for _ in range(h)]
    vgrid[y][x] = 0

    while queue:
        p = queue.popleft()
        if (p[0], p[1]) == (gy, gx):
            break
        for i in range(4):
            ny = p[0] + move[i][0]
            nx = p[1] + move[i][1]
            if 0 <= ny < h and 0 <= nx < w and vgrid[ny][nx] == float("inf") and grid[ny][nx] != "#":
                queue.append((ny, nx))
                vgrid[ny][nx] = vgrid[p[0]][p[1]] + 1

    return vgrid[gy][gx]


shortest_distance = bfs(0, 0)
if shortest_distance == float("inf"):
    print("-1")
    exit()
white = 0
for li in grid:
    white += li.count(".")
ans = white - shortest_distance - 1
print(ans)

Measured memory_bytes: 42480
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <array>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000003;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

const int N = 2000, M = 32;

char b[N];
uint64_t db[N][M], eb[N][M], a[N][M], foo[M];

inline void Set(uint64_t A[], int i) {
	A[i >> 6] |= 1LL << (i & 63);
}
uint64_t Get(uint64_t A[], int i) {
	return A[i >> 6] & 1LL << (i & 63);
}

int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	int n; ni(n);
	for (int i = 1; i < n; i++) {
		scanf("%s", b);
		F(j, i) {
			if (b[j] == '1')Set(a[i], j);
			else Set(a[j], i);
		}
	}
	for (int i = n; i--;) for (int j = i; j < n; j++) {
		if (i == j) {
			Set(db[i], i);
			Set(eb[i], i);
			continue;
		}
		bool good = false;
		F(k, M) {
			if (a[i][k] & db[j][k] & eb[i + 1][k]) {
				good = true; break;
			}
		}
		if (good)Set(db[j], i);
		good = false;
		F(k, M) {
			if (a[j][k] & db[j - 1][k] & eb[i][k]) {
				good = true; break;
			}
		}
		if (good)Set(eb[i], j);
	}
	int ans = 0;
	F(i, n) {
		if (Get(eb[0], i) && Get(db[n - 1], i))ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <string>

int main() {
    std::string s;
    int32_t k;
    std::cin >> k >> s;
    
    auto sub = s.substr(0, k);
    
    int32_t size = s.size();
    if (size > k) {
        sub.append("...");
    }
    
    std::cout << sub << std::endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    uint64_t x, y;
    cin >> x >> y;

    uint64_t z = y / x;
    uint64_t w = 0;
    while (z != 0)
    {
        z >>= 1;
        w++;
    }
    cout << w << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int min = 753;
  for(int i=0; i<S.size()-2; i++) {
    int tmp = 100 * (int(S[i])-int('0')) + 10 * (int(S[i+1])-int('0')) + 1 * (int(S[i+2])-int('0'));
    if(abs(tmp - 753) < min) {
      min = abs(tmp - 753);
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  double a,b;
  cin >> a >> b;
  cout << ceil((a+b)/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;
vector<bool> genbit(ll a){
    vector<bool> r(30);
    for(int i = 0; i < 30; i++){
        r[i] = (a  & (1ll << i));
    }
    return r;
}
bool judge (vector<bool> a, vector<bool> b){
    for(int i = 0; i < 30; i++){
        if(a[i] && b[i]){
            return false;
        }
    }
    return true;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    vector<bool> currentBit(30);
    for(int i = 0; i < 30; i++){
        currentBit[i] = false;
    }
    ll count = 0;
    queue<vector<bool>> bitQ = queue<vector<bool>>();
    for(int i = 0; i < N; i++){
        vector<bool> b = genbit(A[i]);
        while(!judge(b,currentBit)){
            auto removed = bitQ.front();bitQ.pop();
            for(int j = 0; j < 30; j++){
                if(removed[j]){
                    currentBit[j] = false;
                }
            }
        }
        bitQ.push(b);
        for(int j = 0; j < 30; j++){
            if(b[j]){
                currentBit[j] = true;
            }
        }
        count += bitQ.size();
    }
    cout << count << endl;

}


Measured memory_bytes: 16272
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char A[23];
char B[23];
char C[23];
int main(){
	scanf("%s%s%s",A,B,C);
	printf("%c%c%c\n",A[0]-32,B[0]-32,C[0]-32);
}

Measured memory_bytes: 128
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize, usize); m],
    }
    let mut d = vec![0; n];
    let mut g = vec![vec![]; n];
    for (s, t) in e {
        d[t] += 1;
        g[s].push(t);
    }
    let mut s = vec![];
    let mut ans = vec![];
    for (v, &d) in d.iter().enumerate() {
        if d == 0 {
            s.push(v);
        }
    }
    while let Some(v) = s.pop() {
        ans.push(v);
        for &u in g[v].iter() {
            d[u] -= 1;
            if d[u] == 0 {
                s.push(u);
            }
        }
    }
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    for v in ans {
        writeln!(out, "{}", v).unwrap();
    }
}

fn main() {
    run();
}



Measured memory_bytes: 7096
n,k=map(int,input().split())
# 累積和！max-min+1
csl=[]
sum=0
for i in range(n+1):
	sum+=i
	csl.append(sum)
#3 2
#[0, 1, 3, 6]
# 0 1 2 3
cnt=0
for i in range(k,n+1):
	max=csl[n]-csl[n-i]
	min=csl[i-1]
	#初めの数も含むの+1
	cnt+=(max-min+1)
	cnt%=(10**9+7)
#0~nまで全選択の+1
print(cnt+1)

Measured memory_bytes: 19344
#include <stdio.h>

int main(void)
{
	int n, a[1000];
	int soe = 0, x;
	
	scanf("%d", &n);
	
	for (x = 0; x < n; ++x){
		
		scanf(" %d", &a[soe]);
		
		++soe;
		
	}
		
		x = 1;
		
	while (x <= n){
		
		if (x == n){
			
			printf("%d\n", a[0]);
		}
		else {
			
			printf("%d ", a[n - x]);
			
		}
		++x;
		
	}
	
	
	return 0;
	
}

Measured memory_bytes: 1860
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
P=set(list(map(int,input().split())))

diff= 1000
ans = 0
for i in range(102):
  if i in P: continue
  if abs(x-i)<diff:
    diff = abs(x-i)
    #print(diff,i)
    ans = i
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

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

    vector<pair<int, int>> arms(m);
    for (auto& a : arms) {
        cin >> a.first >> a.second;
        --a.second;
    }
    sort(arms.begin(), arms.end());

    vector<int> l(n), r(n);
    iota(l.begin(), l.end(), 0);
    iota(r.begin(), r.end(), 0);

    for (auto a : arms) {
        int x = a.second, y = a.second + 1;
        l[y] = l[x];
        r[x] = r[y];
    }

    for (int i = 0; i < n; ++i) {
        cout << r[i] - l[i] + 1 << " \n"[i == n - 1];
    }
    return 0;
}



Measured memory_bytes: 5100
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int a, b, c;
    map<int, int> p;
    cin >> a >> b >> c;
    p[a]++;
    p[b]++;
    p[c]++;
    if(p[5] == 2 && p[7] == 1) puts("YES");
    else puts("NO");
}


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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			// スペース区切りの整数の入力
			var N = int.Parse(Console.ReadLine());
			var dic = new Dictionary<int, int>();
			int value = 0;
			var flag = true;

			// スペース区切りの整数の入力
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			for (int i = 0; i < N; i++)
			{
				var a = input[i];
				if(dic.TryGetValue(a,out value))
				{
					flag = false;
					break;
				}
				else
				{
					dic[a] = 1;
				}
			}

			if(flag)
			{
				Console.WriteLine("YES");
			}
			else
			{
				Console.WriteLine("NO");
			}

		}


	}
}

Measured memory_bytes: 39376
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	vector<string> ok = {
		"KIHBR",
		"AKIHBR",
		"KIHABR",
		"KIHBAR",
		"KIHBRA",
		"AKIHABR",
		"AKIHBAR",
		"AKIHBRA",
		"KIHABAR",
		"KIHABRA",
		"KIHBARA",
		"AKIHABAR",
		"AKIHABRA",
		"AKIHBARA",
		"KIHABARA",
		"AKIHABARA"
	};
	cin >> s; bool flag = false;
	for(int i = 0; i < 16; i++) {
		if(s == ok[i]) flag = true;
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B, Q) = listOfInt()
    val S = Array(A) { nextLong() }
    val T = Array(B) { nextLong() }
    repeat (Q) {
        var ans = Long.MAX_VALUE
        val X = nextLong()
        repeat(2) {
            val a : Array<Long>
            val b : Array<Long>
            if (it == 0) { a = S; b = T }
            else { a = T; b = S }
            repeat(2) {
                var aP = a.bsearch(X) + it
                if (aP == a.size) aP -= 1
                val ax = a[aP]
                repeat(2) {
                    var bP = b.bsearch(ax) + it
                    if (bP == b.size) bP -= 1
                    val bx = b[bP]
                    val d = Math.abs(X - ax) + Math.abs(bx - ax)
                    if (d < ans) ans = d
                }
            }
        }
        println(ans)
    }
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun Array<Long>.bsearch(x: Long): Int {
    var ok = 0
    var ng = this.size
    while (ng - ok > 1) {
        var m = (ok + ng) / 2
        if (this[m] <= x) ok = m else ng = m
    }
    return ok
}

Measured memory_bytes: 57188
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int answer =0;
    for(int i =0;i<s.length()-2;i++){
      if(s.substring(i,i+1).equals("A")&&s.substring(i+1,i+2).equals("B")&&s.substring(i+2,i+3).equals("C")){
                 answer=answer+1;
      }
    }
    System.out.println(answer);
    
  }
  

  
}

Measured memory_bytes: 22612
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 15 August 2020 01:36:52 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;
    while(n%100 != 1 and n>100){
        int t = n%10;
        if(t>=5 or (t==0 and (n/10)%10 != 0)){
            //cout<<n<<" "<<t<<endl;
            n-=105;
            continue;
        }
        if(t>=4){
            n-=104;
            continue;
        }
        if(t>=3){
            n-=103;
            continue;
        }
        if(t>=2){
            n-=102;
            continue;
        }
        if(t>=1){
            n-=101;
            continue;
        }
        n-=100;
    }
    //cout<<n<<endl;
    if(n%100 == 0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    ll k;
    cin >> n >> k;
    const int mx = 61;
    int to[mx][n];
    rep(i, 0, n) {
        cin >> to[0][i];
        to[0][i]--;
    }
    rep(i, 1, mx) {
        rep(j, 0, n) {
            to[i][j] = to[i - 1][to[i - 1][j]];
        }
    }
    int now = 0;
    for (int i = mx - 1; i >= 0; i--) {
        ll tmp = 1LL << i;
        if (tmp > k) continue;
        k -= tmp;
        now = to[i][now];
    }
    cout << now + 1 << endl;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

vector<int> fav[500];
queue<int> A[500];
bool used[500];

int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  REP(i,N) {
    REP(j,M) {
      int a;
      scanf("%d", &a);
      --a;
      A[i].push(a);
    }
    fav[A[i].front()].pb(i);
  }

  int result = N;
  REP(i,M-1) {
    int s = 0;
    REP(j,M) if (fav[j].size() > fav[s].size()) s = j;
    used[s] = true;
    result = min(result, (int)fav[s].size());
    for (int i: fav[s]) {
      while (used[A[i].front()]) A[i].pop();
      fav[A[i].front()].pb(i);
    }
    fav[s].clear();
  }

  printf("%d\n", result);
}


Measured memory_bytes: 1536
/*
Aldew
PROB:
CLASSIFICATION:
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#include <stack>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

//void io()
//{
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
//}

vector <int> factors(int x) {
    vector <int> result;
    int i = 1;
    while(i*i <= x) {
        if(x % i == 0) {
            result.push_back(i);
            if(x/i != i) {
                result.push_back(x/i);
            }
        }
        i++;
    }
    return result;

}

int main()
{
    io;
    ll a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;

    return 0;

}


Measured memory_bytes: 4272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Set<String> set = new HashSet<String>();
			for (int i = 0; i < n; i++) {
				set.add(br.readLine());
			}
			System.out.println(set.size());
		}
	}
}

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

using namespace std;

int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    set<int> s;
    s.insert(A);
    s.insert(B);
    s.insert(C);
    int len=s.size();
    if(len==2)
        printf("Yes\n");
    else
        printf("No\n");
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c, x = map(int, [input() for _ in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = 1e2 + 5;
char s[maxn];

int main() {

    scanf("%s", s);
    int i;
    for(i = 0; s[i]; i++)
        if(!(i%2) && s[i] == 'L') break;
        else if(i%2 && s[i] == 'R') break;
    if(s[i]) printf("No");
    else printf("Yes");
	return 0;
}

Measured memory_bytes: 256