akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int vis[100007];
vector<int>v[100007];
vector<int>vt;
int deg[100007];
void dfs(int a,int pp,int st,int nev){
    for(auto&x:v[a]){
        if(!vis[x]&&x!=pp&&x!=nev){
            vis[x]=1;
            dfs(x,a,st,nev);
        }
    }
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a=0,b=0;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }
    int flag=0;
    for(int i=1;i<=n;i++){
        if(deg[i]%2==1){
            printf("No");
            return 0;
        }
        if(deg[i]>=6)
            flag=1;
        if(deg[i]>=4)
            vt.push_back(i);
    }
    //if(m>=n+3)
        //flag=1;
    if(flag){
        printf("Yes");
        return 0;
    }
    else{
        if(vt.size()==2){
            dfs(vt[0],-1,vt[0],vt[1]);
            if(vis[vt[0]]){//有环
                printf("Yes");
                return 0;
            }
        }
        else if(vt.size()>2){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int maxIndex = scan.nextInt();
    
    int index = 0;
    int sum = 0;
    for(int i = 0;i < a && index < maxIndex;i++,index++){
      sum += 1;
    }
    for(int j = 0;j < b && index < maxIndex;j++,index++){
    }
    for(int k = 0;k < c && index < maxIndex;k++,index++){
        sum -= 1;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
bool good(lli mid,lli n)
{
    lli ans=mid*(mid+1)/2;
    if(ans<=n)return true;
    return false;
}
void solve()
{
   int n,m;cin>>n>>m;
   pll lol[n],M[m];
   for(int i=0;i<n;i++)
   {
       cin>>lol[i].ff>>lol[i].ss;
   }
   for(int i=0;i<m;i++)cin>>M[i].ff>>M[i].ss;
   for(int i=0;i<n;i++)
   {
       lli ans=1e18+9;
       int no;
       for(int j=0;j<m;j++)
       {
           lli res=abs(lol[i].ff-M[j].ff)+abs(lol[i].ss-M[j].ss);
           if(res<ans)
           {
               ans=res;
               no=j+1;
           }
       }
       cout<<no<<endl;
   }
}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}



Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int a,b,c,bucket[101] = {0},i,count = 0;

    scanf("%d %d %d",&a,&b,&c);

    bucket[a] = 1;
    bucket[b] = 1;
    bucket[c] = 1;

    for (i = 1; i <= 100; i++)
    {
        if (bucket[i] == 1)
        {
            count ++;
        }
    }
    
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  ios::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n;
  cin >> n;
  map<string, int> mp;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mx = max(mx, ++mp[s]);
  }
  vector<string> ans;
  for (auto& e : mp) {
    if (e.second == mx) {
      ans.push_back(e.first);
    }
  }
  sort(ans.begin(), ans.end());
  for (auto& e : ans) {
    cout << e << '\n';
  }
}

Measured memory_bytes: 25584
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
  double d,o=d;
  cin >> d;
    for(int i=1;i<=d;i++){
      double x,y;
      x=i;
      y=sqrt(d*d-x*x);
      //cout << x<<":"<<y << endl;
      if(y<1.0) o=max(o,x+1);
      else o=max(o,x+y);
    }
    o=max(o,d*sqrt(2.0));
  
  printf("%.12lf\n",o);
}

Measured memory_bytes: 1240
if __name__ == '__main__':
	A,B,N = map(int,input().split())
	ans = 0
	c = 0
	if B > N:
		ans = (A*N)//B - A*(N//B)
	else:
		x = B-1
		ans = (A*x)//B - A*(x//B)

	print(ans)

Measured memory_bytes: 61572
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int s[14],h[14],c[14],d[14],i,n,x;
	char a;
	cin>>n;
	for(i=1;i<=13;i++){
		s[i]=0;
		h[i]=0;
		c[i]=0;
		d[i]=0;
	}
	for(i=1;i<=n;i++) {
		cin>>a>>x;
		if(a=='S') s[x]=1;
		else if(a=='H') h[x]=1;
		else if(a=='C') c[x]=1;
		else d[x]=1;
	}
	for(i=1;i<=13;i++){	
		if(s[i]==0) cout<<"S"<<" "<<i<<endl;
	}
	for(i=1;i<=13;i++){	
		if(h[i]==0) cout<<"H"<<" "<<i<<endl;
	}
	for(i=1;i<=13;i++){	
		if(c[i]==0) cout<<"C"<<" "<<i<<endl;
	}
	for(i=1;i<=13;i++){	
		if(d[i]==0) cout<<"D"<<" "<<i<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3104
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N = int(readline())
k, *B = map(int, readline().split())
M = sum(1 << b for b in B)
if M == 0:
    write("0:\n")
for i in range(1, 1 << N):
    if i & M == M:
        write("%d: %s\n" % (i, " ".join(str(j) for j in range(N) if i & (1 << j))))



Measured memory_bytes: 5648
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 1e4
using namespace std;

class data{
public:
	int x,y,t;
	data(){}
	data(int xx,int yy,int tt){
		x=xx;
		y=yy;
		t=tt;
	}
};

int dx[6]={0,1,1,0,-1,-1};
int dy[2][6]={
	1,0,-1,-1,-1,0,
	1,1,0,-1,0,1
};
int sx,sy,gx,gy;
int n;
int lx,ly;
int fie[2001][2001];
short dp[2001][2001][6];

int bfs(){
	for(int i=0;i<=2000;i++){
		for(int j=0;j<=2000;j++){
			for(int k=0;k<6;k++){
				dp[i][j][k]=INF;
			}
		}
	}
	queue<data> que;
	que.push(data(sx+1000,sy+1000,0));
	dp[sx+1000][sy+1000][0]=0;
	while(que.size()){
		queue<data> que2;
		while(que.size()){
			data q=que.front();
			que.pop();
			if(q.x-1000==gx && q.y-1000==gy)return dp[q.x][q.y][q.t];
			que2.push(q);
			bool flag=true;
			while(flag){
				flag=false;
				int sdir=abs((q.x-1000)*(q.y-1000)*q.t)%6;
				int nx=q.x+dx[sdir],ny=q.y+dy[q.x%2][sdir];
				if(nx>=1000-lx && nx<=lx+1000 && ny>=1000-ly && ny<=1000+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						flag=true;
						if(nx-1000==gx && ny-1000==gy)return dp[q.x][q.y][q.t];
						que2.push(data(nx,ny,(q.t+1)%6));
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t];
					}
				}
				q.x=nx;
				q.y=ny;
				q.t=(q.t+1)%6;
			}
		}
		while(que2.size()){
			data q=que2.front();
			que2.pop();
			if(dp[q.x][q.y][(q.t+1)%6]==INF){
				dp[q.x][q.y][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
				que.push(data(q.x,q.y,(q.t+1)%6));
			}
			for(int i=0;i<6;i++){
				int nx=q.x+dx[i],ny=q.y+dy[q.x%2][i];
				if(nx>=1000-lx && nx<=lx+1000 && ny>=1000-ly && ny<=1000+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
						que.push(data(nx,ny,(q.t+1)%6));
					}
				}
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d%d%d",&sx,&sy,&gx,&gy);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		fie[x+1000][y+1000]=-1;
	}
	scanf("%d%d",&lx,&ly);
	printf("%d\n",bfs());
	return 0;
}

Measured memory_bytes: 52348
#include<bits/stdc++.h>
using namespace std;
 int a[200010];
 int ans[200010];
 int main(){
 int n;
 cin>>n;
 for(int i=2;i<=n;i++)
    cin>>a[i];
 for(int i=2;i<=n;i++)
 ans[a[i]]++;
 for(int i=1;i<=n;i++)
 cout<<ans[i]<<endl;
 }


Measured memory_bytes: 5108
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K, C = list(map(int, sys.stdin.buffer.readline().split()))
S = sys.stdin.buffer.readline().decode().rstrip()

# dp1[i]: i 日目までに働ける日数
dp1 = [0] * (N + 1)
cnt = 0
rem = -1
for i, c in enumerate(S):
    if rem < 0 and c == 'o':
        cnt += 1
        rem = C
    dp1[i + 1] = cnt
    rem -= 1

# dp2[i]: i 日以降働ける日数
dp2 = [0] * (N + 1)
cnt = 0
rem = -1
for i, c in reversed(list(enumerate(S))):
    if rem < 0 and c == 'o':
        cnt += 1
        rem = C
    dp2[i] = cnt
    rem -= 1

# for a, b in zip(dp1[1:], S):
#     print(a, b)
# print()
# for a, b in zip(dp2[1:], S):
#     print(a, b)

for i, (c, cnt1, cnt2) in enumerate(zip(S, dp1, dp2[1:]), start=1):
    # print(i, c, cnt1, cnt2, cnt1 + cnt2)
    if cnt1 + cnt2 < K:
        print(i)


Measured memory_bytes: 77188
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll 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};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

bool IsBingo(int firstRow[3], int secondRow[3], int thirdRow[3])
{
	// Check if there is bingo in rows
	if ((firstRow[0] == -1 && firstRow[1] == -1 && firstRow[2] == -1)
	|| (secondRow[0] == -1 && secondRow[1] == -1 && secondRow[2] == -1)
	|| (thirdRow[0] == -1 && thirdRow[1] == -1 && thirdRow[2] == -1))
	{
		return true;
	}
	// Check if there is bingo in columns
	else if ((firstRow[0] == -1 && secondRow[0] == -1 && thirdRow[0] == -1)
	|| (firstRow[1] == -1 && secondRow[1] == -1 && thirdRow[1] == -1)
	|| (firstRow[2] == -1 && secondRow[2] == -1 && thirdRow[2] == -1))
	{
		return true;
	}
    // Check if there is bingo in diagonal
	else if ((firstRow[0] == -1 && secondRow[1] == -1 && thirdRow[2] == -1)
	|| (firstRow[2] == -1 && secondRow[1] == -1 && thirdRow[0] == -1))
	{
		return true;
	}
	else
	{
		return false;
	}
}

int main()
{
	int inputN, inputB, firstRow[3], secondRow[3], thirdRow[3];
	bool hasBingo = false;

	// Create a array for every row in a bingo and fill it with values
	scanf("%d %d %d", &firstRow[0], &firstRow[1], &firstRow[2]);

	scanf("%d %d %d", &secondRow[0], &secondRow[1], &secondRow[2]);

	scanf("%d %d %d", &thirdRow[0], &thirdRow[1], &thirdRow[2]);

	// Check if values in bingo are the same with the input
	// If input value and value in the bingo is the same, then makes it '-1'
	scanf("%d", &inputN);

	for (int i = 0; i < inputN; i++)
	{
		scanf("%d", &inputB);

		for (int j = 0; j < 3; j++)
		{
			if (firstRow[j] == inputB)
			{
				firstRow[j] = -1;
			}
			if (secondRow[j] == inputB)
			{
				secondRow[j] = -1;
			}
			if (thirdRow[j] == inputB)
			{
				thirdRow[j] = -1;
			}
		}
	}
	hasBingo = IsBingo(firstRow, secondRow, thirdRow);

	if (hasBingo == true)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

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

const int mxn=1e5+5;

long double dp[3000][3000];
int n;
long double p[3000];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    dp[0][1]=p[0];
    dp[0][0]=(1-p[0]);

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=(dp[i-1][j]*(1-p[i]));
            if(j>0)
                dp[i][j]+=(dp[i-1][j-1]*p[i]);
        }
    }
    long double ans=0;
    for(int i=n/2 +1 ; i<=n;i++)
        ans+=dp[n-1][i];
    cout<<setprecision(9)<<ans;
    return 0;
}


Measured memory_bytes: 140800
N,M,Q = map(int,input().split())
ar=[list(map(int,input().split())) for _ in range(Q)]

ans = 0


for i1 in range(1,M+1):
    for i2 in range(i1,M+1):
        for i3 in range(i2,M+1):
            for i4 in range(i3,M+1):
                for i5 in range(i4,M+1):
                    for i6 in range(i5,M+1):
                        for i7 in range(i6,M+1):
                            for i8 in range(i7,M+1):
                                for i9 in range(i8,M+1):
                                    for i10 in range(i9,M+1):

                                        con = 0

                                        arr = [0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]

                                        for a,b,c,d in ar:
                                            if arr[b] - arr[a] == c:
                                                con += d

                                        ans=max(ans,con)

print(ans)

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

char input[1000][1000];

int main(void)
{
    int fl, i, j, n = 0, len, ans = 0;
    while (scanf("%s", input[n++]) != EOF);
    for (i = 0; i < n-1; i++) {
        fl = 1;
        len = strlen(input[i]);
        for (j = 0; j < len/2; j++) {
            if (len == 1) {
                break;
            }
            if (input[i][j] != input[i][len-j-1]) {
                fl = 0;
                break;
            }
        }
        if (fl) {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,a[N],f[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=2;i<=n;i++){
  	cin>>a[i];
  	f[a[i]]++;
  }

  for(int i=1;i<=n;i++)cout<<f[i]<<'\n';
 	return 0;
}

Measured memory_bytes: 5148
n, l = map(int, input().split())
a = list(map(int, input().split()))

atom = -1
for i in range(n-1):
    if l <= a[i] + a[i+1]:
        atom = i
        break
        
if atom < 0:
    print('Impossible')
else:
    print('Possible')
    for i in range(atom):
        print(i+1)
    for i in range(n-atom-1):
        print(n-1-i)

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

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

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

int W, H;
char B[30][30];

int dfs(int y, int x) {
   int ret = 1;
   B[y][x] = '#';
   rep (i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || B[ny][nx] == '#') continue;
      ret += dfs(ny, nx);
   }
   return ret;
}

int main() {
   while (1) {
      cin >> W >> H;
      if (H*W == 0) break;

      rep (i, H) cin >> B[i];

      rep (i, H) {
         rep (j, W) {
            if (B[i][j] == '@') {
               cout << dfs(i, j) << endl;
            }
         }
      }
   }

   return 0;
}


Measured memory_bytes: 3000
from collections import deque
import sys


def bfs(x1, y1, d):
    q = deque()
    q.append((d, x1, y1))

    while q:
        d, x1, y1 = q.popleft()

        M[x1][y1] = d

        if [x1, y1] == [xg, yg]:
            print(d)
            return

        for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            for k in range(1, K + 1):
                x2 = x1 + dx * k
                y2 = y1 + dy * k

                if (0 <= x2 < H) and (0 <= y2 < W):
                    if m[x2][y2] == '@':
                        break
                    elif M[x2][y2] == -1:
                        M[x2][y2] = d + 1
                        q.append((d + 1, x2, y2))
                    elif M[x2][y2] < d + 1:
                        break
                else:
                    break
    print(-1)


H, W, K = map(int, input().split())
xs, ys, xg, yg = map(int, input().split())
xs, ys, xg, yg = xs - 1, ys - 1, xg - 1, yg - 1

m = []
for i in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[-1] * W for i in range(H)]

bfs(xs, ys, 0)

Measured memory_bytes: 45184
#include <iostream>
#include <string>
#define rep(i,n) for(int i = 0; i < n;++i)
using namespace std;

int main(){
	string a,b;
	cin >> a;
	cin >> b;

	for(int i = 0; i < a.length();++i){
		cout << a[i];
		if(i < b.length())
			cout << b[i];
	}
	cout <<endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
uf = UnionFind(n)
s = n*(n-1)//2
ans = [0]*m
for i in range(m-1,-1,-1):
  if uf.find(ab[i][0]-1) != uf.find(ab[i][1]-1):
    s -= uf.size(ab[i][0]-1)*uf.size(ab[i][1]-1)
  uf.union(ab[i][0]-1,ab[i][1]-1)
  ans[i-1] = s
ans[m-1] = n*(n-1)//2
for i in ans:
  print(i)

Measured memory_bytes: 105560
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF (i64)1e18
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for(i64 i = a; i < b; i++)
#define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto& e) p)

int main() {
  int n;
  cin >> n;
  int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  REP(i, n) {
    string s;
    cin >> s;
    if (s == "AC") c0++;
    if (s == "WA") c1++;
    if (s == "TLE") c2++;
    if (s == "RE") c3++;
  }
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;

  return 0;
}


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

int dp[100001];
const int INF = 1e9;
int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;

	cin >> n;

	fill(dp,dp+100001,INF);

	dp[0] = 0;

	for(int i=0;i<=100000;i++)
	{
		if(i+1<=100000)
		{
			dp[i+1] = min(dp[i+1],dp[i]+1);
		}
		for(int j=6; ;j*=6)
		{
			if(i+j>100000)
			{
				break;
			}
			dp[i+j] = min(dp[i+j],dp[i]+1);
		}
		for(int j=9; ;j*=9)
		{
			if(i+j>100000)
			{
				break;
			}
			dp[i+j] = min(dp[i+j],dp[i]+1);			
		}
	}

	cout << dp[n] << '\n';

	return 0;	
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

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

	for (int i = 0; i < 3; i++) {
		if (n[i]=='7') {
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 3592
using System;
//数え上げ？
//IN=2,4,5,8,の場合、それぞれの倍数のマスを++していく
//   L= 0 0 1 0 2 1 1 0 3
//index 0 1 2 3 4 5 6 7 8 
//そのあとINの数でL[i]=1ならわりきれないO(1)
//ただし入力に重複があるとCの更新に時間がかかるのでなんとかせなあかん

class Program
{
    static public readonly int m = 1000001;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] In = Console.ReadLine().Split(' ');
        int[] A = new int[n];
        for (int i = 0; i < n; i++)
        {
            A[i] = int.Parse(In[i]);
        }
        int[] C = new int[m]; //倍数count
        foreach(int x in A)
        {
            if (C[x] != 0)
            {
                C[x] = 2;
                continue;
            }
            for (int i = x; i < m; i += x) C[i]++;
        }
        int ans = 0;
        foreach(int x in A)
        {
            if (C[x] == 1) ans++;
        }
        Console.WriteLine(ans);
    }
}


//outputはあっているはずだが、TLEになる
//class Program
//{
//    static void Main(string[] args)
//    {
//        int n = int.Parse(Console.ReadLine());
//        string[] In = Console.ReadLine().Split(' ');
//        int[] A = new int[n];
//        for (int i = 0; i < n; i++)
//        {
//            A[i] = int.Parse(In[i]);
//        }
//        int cnt = n;
//        for (int i = 0; i < n; i++)
//        {
//            for (int j = 0; j < n; j++)
//            {
//                if (i == j) continue;
//                if (A[i] % A[j] == 0)
//                {
//                    cnt--;
//                    break;
//                }
//            }
//        }
//        Console.WriteLine(cnt);
//    }
//}


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

int n;

int main() {
	cin >> n;
	int a = 1;
	while (a*(a+1)/2 < n) {
		++a;
	}

	vector<int> v;
	for (int b = a; b >= 1; --b) {
		if (n >= b) {
			n -= b;
			v.push_back(b);
		}
	}

	for (int i = 0; i < v.size(); ++i)
		cout << v[i] << "\n";
}

Measured memory_bytes: 384
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n;
  double a;
  scanf("%d\n",&n);
  a=n;
  printf("%.8lf\n",a*a*a/27);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=0x3f3f3f3f;
int n,k;
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    for(int i=n;i>=0;i--){
        int t=i,s=0;
        while(t){
            s++;
            t/=10;
        }
        if(s%2) sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  k <- read <$> getLine :: IO Integer
  let base = k `div` 50
      m = k `mod` 50
      list = filter (/= base + 50 - m) [base..base+50]
  putStrLn "50"
  forM_ (init list) $ \i -> do
    putStr $ show i ++ " "
  putStrLn . show . last $ list


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
const int N=190,M=16;
int n,m,sum[N][N],dp[M+1][N][N][N];
char a[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int x=0;x<n;x++)
		scanf("%s",a[x]);
	for(int x=0;x<n;x++)
		for(int y=0;y<m;y++)
			sum[x+1][y+1]=sum[x+1][y]+sum[x][y+1]-sum[x][y]+(a[x][y]=='#'?1:0);
	for(int x=0;x<=n;x++)
	{
		for(int ya=0;ya<=m;ya++)
		{
			for(int yb=ya+1;yb<=m;yb++)
			{
				int lo=x,hi=n+1;
				while(lo+1<hi)
				{
					int mid=lo+hi>>1;
					int black=sum[x][ya]-sum[mid][ya]-sum[x][yb]+sum[mid][yb];
					if(black==0||black==(mid-x)*(yb-ya))
						lo=mid;
					else
						hi=mid;
				}
				dp[0][x][ya][yb]=lo;
			}
		}
	}
	for(int t=1;t<=M;t++)
	{
		for(int x=0;x<=n;x++)
		{
			for(int ya=0;ya<=m;ya++)
			{
				for(int yb=ya+1;yb<=m;yb++)
				{
					int &d=dp[t][x][ya][yb];
					d=dp[t-1][dp[t-1][x][ya][yb]][ya][yb];
					for(int y=ya+1;y<yb;y++)
					{
						int e=dp[t-1][x][ya][y];
						if(d>=e)
							break;
						d=max(d,min(e,dp[t-1][x][y][yb]));
					}
				}
			}
		}
	}
	int ans=M;
	for(int t=0;t<=M;t++)
		if(dp[t][0][0][m]>=n)
			ans=min(ans,t);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 455424
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int H = ni();
    	int N = ni();
    	int sum = 0;
    	for (int i = 0; i < N; i++) {
			sum += ni();
		}
    	out.println(H <= sum ? "Yes" : "No");
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 47808
N,M=map(int,input().split())
A=[-1]+[int(input()) for i in range(M)]+[N+1]
res=1
for i in range(1,len(A)):
  steps=A[i]-A[i-1]-2
  if steps<0:
    patern_nmu=0
  else:
    p,q=1,0
    for j in range(steps):
      p,q=p+q,p
    patern_nmu=p
  res*=patern_nmu
  res%=1000000007
print(res)

Measured memory_bytes: 7848
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
typedef long long int LL;
const int INF=1e9+7;
char ca[300005];
int main(){
	int n;
	int i,j,k;
	int a=0,b=0;
	int s=INF;
	cin>>n;
	cin>>ca;
	for(i=0;i<n;i++){
		if(ca[i]=='E')b++;
	}
	if(ca[0]=='E')b--;
	for(i=1;i<n;i++){
		if(a+b<s)s=a+b;
		if(ca[i-1]=='W')a++;
		if(ca[i]=='E')b--;
	}
	if(a+b<s)s=a+b;
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, L; scanf("%d %d", &N, &L);
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string ans = accumulate(S.begin(), S.end(), string());
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, K = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
#S = str(input())

for i in range(1, 8) :
  if 2**i > N :
    print (2**(i-1))
    exit()

Measured memory_bytes: 38384
package main

import "fmt"

const inf = int(10e10)

func main() {
	var n, m, r int
	fmt.Scan(&n, &m, &r)
	rs := make([]int, r)
	for i := 0; i < r; i++ {
		fmt.Scan(&rs[i])
		rs[i]--
	}
	d := make([][]int, n)
	for i := 0; i < n; i++ {
		d[i] = make([]int, n)
		for j := 0; j < n; j++ {
			d[i][j] = inf
		}
		d[i][i] = 0
	}
	var a, b, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b, &c)
		a, b = a-1, b-1
		d[a][b] = c
		d[b][a] = c
	}

	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}

	perms := permutations(rs)
	ans := int(1e10)
	for _, nums := range perms {
		sum := 0
		for i := 0; i < len(nums)-1; i++ {
			a, b := nums[i], nums[i+1]
			sum += d[a][b]
		}
		ans = min(ans, sum)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// https://stackoverflow.com/questions/30226438/generate-all-permutations-in-go
func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

using namespace std;

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

    int n;
    cin >> n;

    pair<pair<string,int>,int> spi[100];
    for (size_t i = 0; i < n; i++)
    {
        cin >> spi[i].first.first >> spi[i].first.second;
        spi[i].first.second *= -1;
        spi[i].second = i;
    }

    sort(spi, spi+n);

    for (size_t i = 0; i < n; i++)
    {
        cout << (spi[i].second + 1) << "\n";
    }
        

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<tuple>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int input, miss = 0, ans = 0;
	string inputs;
	int N, M;
	cin >> N >> M;
	vector< tuple<int, int, string> > p(M);
	vector<int> flag(N, 0);
	vector<int> pnum(N, 0);
	for (int i = 0; i < M; i++) {
		cin >> input;
		cin >> inputs;
		p[i] = make_tuple(input, i, inputs);
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < M; i++) {
		if (flag[get<0>(p[i]) - 1] == 0) {
			if (get<2>(p[i]) == "WA") {
				miss++;
				pnum[get<0>(p[i]) - 1]++;
			}
			else {
				ans++;
				flag[get<0>(p[i]) - 1] = 1;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (flag[i] == 0) {
			miss -= pnum[i];
		}
	}
	cout << ans << " " << miss << endl;
	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<string.h>
int main()
{
	char a[16],b[16],c[16];
	scanf("%s %s %s",a,b,c);
	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			int num = Integer.parseInt(br.readLine());
			ArrayList<Integer> list = new ArrayList<Integer>();

			int answer = 0;

			for (int i = 0; i < num; i++) {
				list.add(Integer.valueOf(br.readLine()));
			}

			Collections.sort(list, Collections.reverseOrder());

			Integer mochiLen = 0;
			for (Integer integer : list) {
				if (!integer.equals(mochiLen)) {
					answer++;
					mochiLen = integer;
				}
			}

			System.out.println(answer);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

}


Measured memory_bytes: 32656
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
//const long long INF = 1LL << 60;
double inf = 1e18;

int MOD = 1000000007;

#define MAX_V 1002
int V;//number of vertices
double d[MAX_V];
bool used[MAX_V];
struct edge{int to; double cost;};
vector<edge> graph[MAX_V];
void dijkstra(int s){
    rep(i,V) d[i]=inf;
    rep(i,V) used[i] = false;

    d[s]=0.0;
    for(int i=0;i<V;i++){
        int id=-1;
        for(int j=0;j<V;j++)if(!used[j]&&(id==-1||d[id]>d[j]))id=j;
        used[id]=true;
        for(int j=0;j<V;j++){
            edge e=graph[id][j];
            d[e.to]=min(d[e.to],d[id]+e.cost);
        }
    }
    return;
}


int main(){
    std::ios_base::sync_with_stdio(false);

    ll xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt;
    int n; cin >> n;

    std::vector<tuple<ll, ll, ll>> nodes;

    nodes.push_back(make_tuple(xs,ys,0));
    rep(i,n){
        ll x,y,r; cin>>x>>y>>r;
        nodes.push_back(make_tuple(x,y,r));
    }
    nodes.push_back(make_tuple(xt,yt,0));

    rep(i,n+2){ rep(j,n+2){
        double di = sqrt(pow(abs(get<0>(nodes[i])-get<0>(nodes[j])), 2.0) + pow(abs(get<1>(nodes[i])-get<1>(nodes[j])), 2.0));
        di-=get<2>(nodes[i])+get<2>(nodes[j]);
        di=max(0.0, di);
        edge e = {j, di};
        graph[i].push_back(e);
    }}


    V = n+2;
    dijkstra(0);
    cout.precision(30);
    cout<<d[n+1]<<endl;

    return 0;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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 ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> l(n);
    int ans = 0;
    rep(i,n) cin >> l[i];
    Sort(l);
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            for(int k = j + 1;k < n;k++){
                if(l[i]==l[j] || l[i]==l[k] || l[j] == l[k]) continue;
                if(l[k] < l[i] + l[j]) ans++;
                // cout << l[i] << l[j] << l[k] << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

struct edge{
  int a,b,c;
};


int N,M;
int d[200][200];
vector< edge > v;

int solve(){
  cin >> N >>M;
  for(int i=1;i<=N;++i){
    for(int j=1;j<=N;++j){
      if(i==j){ d[i][j] = 0; }
      else{ d[i][j] = 100000000;}
    }
  }
  REP(i,M){
    int a,b,c;
    cin >>a>>b>>c;
    d[a][b] = c;
    d[b][a] = c;
    v.push_back( (edge){a,b,c} );
  }
  for(int k=1;k<=N;++k){
    for(int i=1;i<=N;++i){
      for(int j=1;j<=N;++j){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j] );
      }
  	}
  }
  int use = 0;
  for( edge e: v){
    for(int s=1;s<=N;++s){
        if(d[s][e.a] + e.c == d[s][e.b]){
          ++use; break;
        }
    }
  }
  int ans = M-use;
  return ans;
}

int main(){
  cout << solve() <<"\n";
}

Measured memory_bytes: 384
n=int(input())
cnt,d=0,{}
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
    cnt=max(cnt,d[s])
ans=[]
for i in d:
    if d[i]==cnt:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)


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

using namespace std;

const int N = 123456;

int n, foo[N], key[N], answer;
vector<int> adj[N];

void dfs(int x, int f) {
  int bar = 0;
  for (auto y : adj[x]) {
    if (y != f) {
      dfs(y, x);
      bar |= foo[x] & foo[y];
      foo[x] |= foo[y];
    }
  }
  if (!foo[x]) {
    key[x] = 0;
    foo[x] = 1;
  } else {
    while ((1 << key[x]) <= bar || (foo[x] >> key[x] & 1)) {
      ++key[x];
    }
    for (int i = 0; i < key[x]; ++i) {
      foo[x] -= (foo[x] >> i & 1) << i;
    }
    foo[x] |= 1 << key[x];
    answer = max(answer, key[x]);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1, x, y; i < n; ++i) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, 0);
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 12800
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

LL f(LL x){
	if(x % 4 == 0) return x;
	else if(x % 4 == 1) return 1;
	else if(x % 4 == 2) return x + 1;
	else if(x % 4 == 3) return 0;
}

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL a, b;
	cin >> a >> b;
	
	cout << (f(a - 1) ^ f(b)) << endl;
	
	
						
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
 
memo = [x for x in s if x%10 != 0]
memo.sort()
 
if len(memo)==0:
    memo = 0
else:
    memo = min(memo)

if sum(s)%10==0:
    if memo != 0:
        print(sum(s) - memo)
    else:
        print(0)
else:
    print(sum(s))

Measured memory_bytes: 3060
def dot(a_list, b_list):
    prod = 0
    for a, b in zip(a_list, b_list):
        prod += a * b
    return prod

N, M, C = map(int, input().split())
b_list = list(map(int, input().split()))
a_lists = [list(map(int, input().split())) for _ in range(N)]

count = 0
for a_list in a_lists:
    prod = dot(a_list, b_list)
    if prod + C > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int x,y; cin >>x >>y;
  cout <<gcd(x,y) <<endl;
}



Measured memory_bytes: 3152
#include<iostream>
#define MAX_N 101
using namespace std;

int x[MAX_N], y[MAX_N], h[MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int idx;
            for (int i = 0; i < N; i++) {
                if (h[i] != 0) {
                    idx = i;
                    break;
                }
            }
            int H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);
            bool flag = true;
            for (int i = 0; i < N; i++) {
                int now_h = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
                if (now_h != h[i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int count=0;
        int nowkuchi=1;
        int wantkuchi=B;
        while(nowkuchi < wantkuchi){
            nowkuchi += A-1;
            count += 1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;

int main(){
    int N,A,B;
    int s1=0,s2=0,s3=0;
    cin >> N >> A >> B;
    for(int i=0;i<N;i++){
        int c; cin >> c;
        if(c<=A){
            s1++;
        }
        else if(c<=B){
            s2++;
        }
        else{
            s3++;
        }
    }
    int m = min(s1,s2);
    m = min(m, s3);
    cout << m;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[N][N], color[N], d[N], f[N]; 
int n, tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v = 0; v < n; v++){
    if(M[u][v] == 0)continue;
    if(color[v] == WHITE)dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  for(int u = 0; u < n; u++)color[u] = WHITE;
  tt = 0;

  for(int u = 0; u < n; u++)if(color[u] == WHITE)dfs_visit(u);
  for(int u = 0; u < n; u++)printf("%d %d %d\n",u+1,d[u],f[u]);
}


int main(){
  int u, k, v;

  scanf("%d",&n);

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++)M[i][j]=0;
  }
  
  for(int i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



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



int main(){

  int n;
  string s[107];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }

  for(int i = 0; i < n-1; i++){
    if(s[i][s[i].size()-1] != s[i+1][0]){
      cout << "No" << endl;
      return 0;
    }
  }

  sort(s,s+n);
  for(int i = 0; i < n-1; i++){
    if(s[i] == s[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>
using namespace std;
long long num[200010];
int arr[200010];
long long res[200010];
long long temp;
int main(){
    int n;
    scanf("%d", &n);
    set<int> can;
    for(int i = 0; i < n; i ++){
        scanf("%d", &arr[i]);
        num[arr[i]] ++;
        if(num[arr[i]] >= 2){
            can.insert(arr[i]);
        }
        res[i] = -1;
    }
    for(set<int>::iterator it = can.begin(); it != can.end(); it ++){
        temp += (num[*it] * (num[*it] - 1) / 2);
    }
    for(int i = 0; i < n; i ++){
        res[i] = temp;
        res[i] -= (num[arr[i]] * (num[arr[i]] - 1) / 2);
        res[i] += ((num[arr[i]] - 1) * (num[arr[i]] - 2) / 2);
        printf("%lld\n", res[i]);
    }
    return 0;
}


Measured memory_bytes: 7936