akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
string S[1000000];

bool balanced(string s){
  int opened = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '('){
      opened ++;
    } else if(s[i] == ')'){
      if(opened == 0){
        return false;
      }
      opened --;
    }
  }
  if(opened != 0){
    return false;
  }
  return true;
}

int right_open(string s){
  int opened = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '('){
      opened ++;
    } else if(s[i] == ')'){
      if(opened > 0){
        opened --;
      }
    }
  }
  return opened;
}

int left_open(string s){
  int opened = 0;
  for(int i = s.size() - 1; i >= 0; i--){
    if(s[i] == ')'){
      opened ++;
    } else  if(s[i] == '('){
      if(opened > 0){
        opened --;
      }
    }
  }
  return opened;
}

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }

  vector <int> right_opens;
  vector <int> left_opens;
  vector <pair<int, int> > both_opens_pos;
  vector <pair<int, int> > both_opens_neg;
  for(int i = 0; i < N; i++){
    int right = right_open(S[i]);
    int left = left_open(S[i]);
    if(right == 0 && left == 0){
      continue;
    }
    if(left == 0){
      right_opens.push_back(right);
    } else if(right == 0){
      left_opens.push_back(left);
    } else {
      if(right - left >= 0){
        both_opens_pos.push_back(make_pair(left, right));
      } else {
        both_opens_neg.push_back(make_pair(left, right));
      }
    }
  }

  sort(both_opens_pos.begin(), both_opens_pos.end());
  sort(both_opens_neg.begin(), both_opens_neg.end());
  reverse(both_opens_neg.begin(), both_opens_neg.end());

  int cur_opens = 0;
  for(int i = 0; i < right_opens.size(); i++){
    cur_opens += right_opens[i];
  }
  for(int i = 0; i < both_opens_pos.size(); i++){
    cur_opens -= both_opens_pos[i].first;
    if(cur_opens < 0){
      cout << "No" << endl;
      return 0;
    }
    cur_opens += both_opens_pos[i].second;
  }

  for(int i = 0; i < both_opens_neg.size(); i++){
    cur_opens -= both_opens_neg[i].first;
    if(cur_opens < 0){
      cout << "No" << endl;
      return 0;
    }
    cur_opens += both_opens_neg[i].second;
  }

  for(int i = 0; i < left_opens.size(); i++){
    cur_opens -= left_opens[i];
  }

  if(cur_opens != 0){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 10007;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int n=0;str s="";
int dp[1002][(1<<3)];
int mem[1002];
int f(int num,int bit){
    if(dp[num][bit]>-1){
        return dp[num][bit];
    }
    if(num==0){
        if((bit&1)&&((bit>>mem[0])&1)){
            //cout << bit << endl;
            return dp[num][bit]=1;
        }else{
            return dp[num][bit]=0;
        }
    }else{
        int ans=0;
        rep(i,1,(1<<3)){
            if((i>>mem[num-1])&1){
                int a=(bit&i);
                //cout << a << endl;
                //cout << a << " " << bit << " " << i << endl;
                if(__builtin_popcount(a)>0)ans+=f(num-1,i);
                ans%=Mod;
            }
        }
        return dp[num][bit]=(ans%Mod);
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    rep(i,0,1002)rep(j,0,(1<<3))dp[i][j]=-1;
    rep(i,0,n){
        if(s[i]=='J')mem[i]=0;
        else if(s[i]=='O')mem[i]=1;
        else mem[i]=2;
    }
    int ans=0;
    rep(i,1,(1<<3)){
        if((i>>mem[n-1])&1){
            //cout << "a";
            ans+=f((n-1),i);
            ans%=Mod;
        }
    }
    cout << ans%Mod << endl;
    return 0;
}

Measured memory_bytes: 3240
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)


"""
解説を読んで

最終的に行き着く数をXとする
XはA,B,Cの最大値または最大値＋１のどちらかである。
そうすると、3X - (A+B+C)を2で割った時に余り0となるようなXを求めれば良い
それはA,B,Cの最大値またはそれにプラス１した値である。

"""
A, B, C = LI()
X = max(A,B,C)
result1 = 3*X - (A+B+C)
result2 = 3*(X+1) - (A+B+C)
if result1%2 == 0:
    print(int(result1/2))
else:
    print(int(result2/2))


Measured memory_bytes: 5460
#include<iostream>
#include<iomanip>
#include<stdio.h>

using namespace std;

int main()
{
    int m,f,r,sum;
    while(1){
        sum = 0;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        sum = m + f;
        if(m == -1 || f == -1 || sum < 30) cout << "F" << endl;
        else if(sum >= 80) cout << "A" << endl;
        else if(sum >= 65 && sum < 80) cout << "B" << endl;
        else if(sum >= 50 && sum < 65 || r >= 50) cout << "C" << endl;
        else if(sum >= 30 && sum < 50 && r < 50) cout << "D" << endl;
    }


    return 0;
}


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

int main(){
    long long n,k; 
    long long d[1000],pro[1000]={0},tot=1,a[1000]={0};
     int p,i,j;
     cin >> n >> k;
     long long ans=n;
     for(i=1;i<=k;i++){
      cin >> d[i];
      pro[d[i]]=1;
     } 
     for(i=0;i<=10;i++){
         if(pro[i]==0){
            p=i;
            break;
        } 
    }
    while(n){
       a[tot++]=n%10;
       n/=10;
     }
    for(i=tot-1; i>=1; i--){
       if(pro[a[i]]==1){
          while(pro[a[i]]==1){
            a[i]=a[i]+1;
            if(a[i]==10){
              a[i]=p;
              i = i+1;
              a[i]=a[i]+1;
            }
          if(i==tot){
             a[i]=1;
          while(pro[a[i]]==1){
             a[i]+=1;
           }
       cout << a[tot];
       for(j=tot-1; j>=1; j--)
          cout << p;
          cout << "\n";
          return 0;
     }
   }
      k=i;
      for(j=tot-1; j>=1; j--){
         if(j>=k)
           cout << a[i];
         else
           cout << p;
         if(j==1)
           return 0;
       }
     } 
   } 
   cout << ans << "\n";
   return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1001][1001];
string s,t;
int n,m,a,ans;
int main(){
  cin>>a;
  for(int b=0;b<a;b++){
    cin>>s>>t;
    for(int i=0;i<=1000;i++)
      for(int j=0;j<=1000;j++)
    dp[i][j]=0;
    m=s.size();
    n=t.size();
    ans=0;
    for(int i=1;i<=m;i++){
      for(int j=1;j<=n;j++){
    if(s[i-1]==t[j-1]){
      dp[i][j]=dp[i-1][j-1]+1;
    }else{
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
      }
    } 
    cout<<dp[m][n]<<endl;
  }
  return 0;
}


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

class Program
    {
        static void Main(string[] args)
        {
            //?????°??????
            int[] scorelist=new int[3];
            int totalscore = 0;
            bool flag = false;
            string[] getdata;
            var achievement = new List<string>();


            while (true)
            {
                //????????£??\
                getdata = Console.ReadLine().Split();
                foreach (var item in getdata.Select((v, i) => new { Value = v, Index = i }))
                {
                    scorelist[item.Index] = int.Parse(item.Value);
                }
                totalscore = scorelist[0] + scorelist[1];

                //???????????¶
                if (scorelist[0] == -1 && scorelist[1] == -1 && scorelist[2] == -1)
                {
                    break;
                }

                //???????±????
                if ((scorelist[0] == -1 || scorelist[1]==-1) || totalscore < 30) {
                    achievement.Add("F");
                }
                else
                {
                    if (totalscore >= 80&&flag==false)
                    {
                        flag = true;
                        achievement.Add("A");
                    }
                    if (totalscore >= 65 && totalscore < 80&&flag==false)
                    {
                        flag = true;
                        achievement.Add("B");
                    }
                    if (((totalscore >= 50) && (totalscore < 65)) || scorelist[2] >= 50&&flag==false)
                    {
                        flag = true;
                        achievement.Add("C");
                    }
                    if (flag == false)
                    {
                        achievement.Add("D");
                    }
                }

                flag = false;                
            }

            foreach(string print in achievement){
                Console.WriteLine(print);
            }
            Console.Read();
        }
    }

Measured memory_bytes: 9288
#!python3

# input
N, Z, W = list(map(int, input().split()))
A = list(map(int, input().split()))


def main():
    ans = abs(A[-1] - W)
    ans = max(ans, abs(A[-1] - A[-2])) if N > 1 else ans
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    long long res=0;
    scanf("%d%d",&n,&k);
    if(k&1){printf("%lld",1ll*(n/k)*(n/k)*(n/k));return 0;}
    res=1ll*(n/k)*(n/k)*(n/k);
    n-=(k>>1);
    if(n>=0)res+=1ll*(n/k+1)*(n/k+1)*(n/k+1);
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 3828
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int ans = 0;
		
		if(k % 2 ==1) {
		ans =(k+1)*(k-1)/4;
		}
		if(k % 2 == 0) {
		ans =(k * k)/4;
		} 
		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
string ch;
int main()
{
	cin >> ch;
	int len = ch.size();
	for (int i = 0; i < len; i++) {
		if (ch[i] == 'C') {
			for (int j = i; j < len; j++) {
				if (ch[j] == 'F') {
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())

f=False
for _ in range(k):
  if b<=a:
    b*=2
  elif c<=b:
    c*=2
  if c>b>a:
    f=True
    break

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

Measured memory_bytes: 61700
/* ABC146-A
   Takatan */

#include<stdio.h>
#include<string.h>
int main(void){
    char day[4];

    scanf( "%s" , day);
    if(strcmp(day, "SUN")==0){ /* 出力曜日ごとに分ける */
        printf( "7" );
    }else if(strcmp(day, "MON")==0){
        printf( "6");
    }else if(strcmp(day, "TUE")==0){
        printf( "5");
    }else if(strcmp(day, "WED")==0){
        printf( "4");
    }else if(strcmp(day, "THU")==0){
        printf( "3");
    }else if(strcmp(day, "FRI")==0){
        printf( "2");
    }else if(strcmp(day, "SAT")==0){
        printf( "1");
    }
    printf( "\n" ); /* 改行文字出力 */
    return 0;
}

Measured memory_bytes: 128
/*  ex7-3
    toshiwaka */

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int row, column;
  char **table;

  //入力:row,column
  scanf("%d %d", &row, &column);
  
  //サイズrowのchar*型配列を動的確保
  table = (char**)calloc(row, sizeof(char*));
  if(table == NULL){
    exit(1);
  }

  //サイズcolumn+1のchar型配列を各ポインタに対して動的確保
  for(int i = 0; i < row; i++){
    table[i] = (char*)calloc(column+1, sizeof(char));
    if(table[i] == NULL){
      exit(1);
    }
  }

  //tableに代入
  for(int i = 0; i < row; i++){
    scanf("%s", table[i]);
  }

  //行判定
  //白いマスのみからなる行の各要素に＊を代入
  for(int i = 0; i < row; i++){
    for(int j = 0; j < column; j++){
      if(table[i][j] == '#') break;
      if(j == column-1){
        for(int k = 0; k < column; k++){
          table[i][k] = '*';
        }
      }
    }
  }

  //列判定
  //白いマスのみからなる列の各要素に＊を代入
  for(int i = 0; i < column; i++){
    for(int j = 0; j < row; j++){
      if(table[j][i] == '#') break;
      if(j == row-1){
        for(int k = 0; k < row; k++){
          table[k][i] = '*';
        }
      }
    }
  }

  //圧縮後のtableを出力
  for(int i = 0; i < row; i++){
    //改行判定用
    int judge = 0;
    for(int j = 0; j < column; j++){
      if(table[i][j] != '*'){
        printf("%c", table[i][j]);
        judge = 1;
      }
    }
    //行の全要素が*だった場合は以下は行われない
    if(judge == 1) putchar('\n');
  }

  //解放
  for(int i = 0; i < row; i++){
    free(table[i]);
  }
  free(table);

  return 0;
}

Measured memory_bytes: 1576
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string a[3];
	int n[3];
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0; i<3; i++) n[i]=a[i].size();
	bool b[3][3][6060]={};
	const int geta=2000;
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<n[i]; k++){
				for(int l=0; l<n[j]; l++){
					if(a[i][k]!='?' && a[j][l]!='?' && a[i][k]!=a[j][l]){
						b[i][j][k-l+geta]=1;
					}
				}
			}
		}
	}
	int ans=n[0]+n[1]+n[2];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			if(i==j) continue;
			for(int k=0; k<3; k++){
				if(i==k || j==k) continue;
				for(int l=0; l<=2000; l++){
					for(int m=0; m<=4000; m++){
						if(b[i][j][l+geta] || b[i][k][m+geta] || b[j][k][m-l+geta]) continue;
						ans=min(ans, max({n[i], n[j]+l, n[k]+m}));
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		int firstDigit = num%10;
		int lastDigit = num/100;
		
		if(firstDigit == lastDigit)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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


int main()
{
    int n;
    cin >> n;
    vl a(3*n);
    rep(i,3*n) cin >> a[i];

    vl l(2*n+1);
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0; i < n; ++i) {
        l[i+1] = l[i] + a[i];
        que.push(a[i]);
    }
    for(int i = n; i < 2*n; ++i) {
        ll m = que.top();
        if(a[i] > m) {
            l[i+1] = l[i] - m + a[i];
            que.pop();
            que.push(a[i]);
        } else l[i+1] = l[i];
    }

    reverse(a.begin(),a.end());
    vl r(2*n+1);
    priority_queue<ll> que2;
    for(int i = 0; i < n; ++i) {
        r[i+1] = r[i] + a[i];
        que2.push(a[i]);
    }
    for(int i = n; i < 2*n; ++i) {
        ll M = que2.top();
        if(a[i] < M) {
            r[i+1] = r[i] - M + a[i];
            que2.pop();
            que2.push(a[i]);
        } else r[i+1] = r[i];
    }

    ll res = -(1LL << 60);
    for(int i = n; i <= n*2; ++i) {
        res = max(res, l[i]-r[n*3-i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11096
#include<iostream>
#include<string>

int main(){
        int A,B,C;
        std::cin >> A;
        std::cin >> B;
        std::cin >> C;
        if(A == B && B != C || A == C && A != B || B == C && C != A)
          std::cout << "Yes";
        else
          std::cout << "No";

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
 
const int MaxN = 2e5 + 10;
LL n , m , all = -1 , Q , K;
LL pre[MaxN * 2] , last[MaxN * 2] , other[MaxN * 2];
LL dep[MaxN + 10] , p[MaxN + 10][21] ;
bool vis[MaxN + 10];
LL cost[MaxN * 2] , dis[MaxN + 10];
 
void Build(LL x , LL y , LL c)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = c;
}
 
void dfs(LL x , LL father)
{
	dep[x] = dep[father] + 1;
	p[x][0] = father;
	if(x == K) vis[x] = 1;
	for(int i = 1 ; i <= log2(n) ; i++)
		p[x][i] = p[p[x][i - 1]][i - 1];
	int ed = last[x];
	while(ed != -1){
		int dr = other[ed];
		if(dr != father) {
			if(vis[x] == 1) vis[dr] = 1;
			dis[dr] = dis[x] + cost[ed];
			dfs(dr , x);
		}
		ed = pre[ed];
	}
}
 
void swap(LL &x , LL &y)
{
	int temp;temp = x ; x = y ; y = temp;
}
 
LL Get_LCA(LL x , LL y)
{
	if(dep[x] < dep[y]) swap(x , y);
	int del = dep[x] - dep[y];
	for(int i = 0 ; i <= log2(n) ; i++)
		if(del & (1 << i)) x = p[x][i];
	if(x != y){
		for(int i = log2(n) ; i >= 0 ; i--){
			if(p[x][i] != p[y][i]){
				x = p[x][i];
				y = p[y][i];
			}
		}
		x = p[x][0];
		y = p[y][0];
	}
	return x;
}
 
void Init()
{
	all = -1;
	memset(last , -1 , sizeof(last));
	memset(dep , 0 , sizeof(dep));
	for(int i = 2 ; i <= n ; i++){
		LL a , b ;LL c;
		scanf("%lld %lld %lld", &a , &b , &c);
		Build(a , b , c);
		Build(b , a , c);
	}
}
 
LL Dis(LL x , LL y)//两点之间距离
{
	int lca = Get_LCA(x , y);
	return dep[x] + dep[y] - 2 * dep[lca];
}
 
void solve()
{
	LL sum;
	scanf("%lld %lld",&Q , &K);
	dfs(1 , -1);//为了防止有0号节点
	for(int i = 1 ; i <= Q ; i++){
		LL a , b;
		scanf("%lld %lld", &a , &b);
		//printf("%d\n",max(max(Dis(lca1 , a) , Dis(lca1 , b)) , Dis(lca1 , c)) + 1);
/*		if(vis[a] == 1 || vis[b] == 1){
			int lca1 = Get_LCA(K , a);
			int lca2 = Get_LCA(K , b);
			if(dep[lca1] > dep[lca2]) lca1 = lca2;
			sum = dis[a] + dis[b] - 2 * dis[lca1];
		}
		else if(Get_LCA(a , K) == a){
			int lca1 = Get_LCA(K , b);
			sum = dis[K] + dis[b] - 2*dis[lca1];
		}
		else if(Get_LCA(b , K) == b){
			int lca1 = Get_LCA(K , a);
			sum = dis[K] + dis[a] - 2 * dis[lca1];
		}
		else{*/
			int lca1 = Get_LCA(a , K);
			int lca2 = Get_LCA(b , K);
			sum = dis[K] + dis[a] - 2 * dis[lca1] + dis[K] + dis[b] - 2 * dis[lca2];
		printf("%lld\n",sum);
	}
}
 
int main()
{
	scanf("%d", &n);
	Init();
	solve();
	return 0;
}

Measured memory_bytes: 38528
#include <stdio.h>

void main(void){

    long a,b,c,k, i,res=0;

    scanf("%ld %ld %ld %ld", &a,&b,&c,&k);

    for(i=0;i<k;i++){
        if(a>0){
            res+=1;
            a--;
        }else if (b>0){
            b--;
        }else{
            if(c==0)
                break;
            res-=1;
            c--;
        }
    }

    printf("%ld\n", res);
}

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

string s;

int ask(int x)
{
    cout<<x<<endl;
    cin>>s;
    if(s[0]=='V')exit(0);
    if(s[0]=='M')return 1;
    return 0;
}

int n;

int main()
{
    cin>>n;
    int k=ask(0);
    int lo=1,hi=n-1,mid;
    while(hi>=lo)
    {
        mid=(hi+lo)/2;
        int x=ask(mid);
        if((x^k)==(mid&1))
        {
            lo=mid+1;
        }
        else hi=mid-1;
        //cout<<lo<<" "<<hi<<" "<<mid<<endl;
    }
    //cout<<lo<<" "<<hi;
}


Measured memory_bytes: 852
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
   A = zeros(Int, 3,3)
   B = zeros(Int, 3,3)
   flg = 0

   for ii = 1:3
      A[ii,:] = parseMap(split(readline()))
   end
   N = parseInt(readline())
   for ii = 1:N
      b = parseInt(readline())
      for jj = 1:9
         if A[jj] == b B[jj] = 1 end
      end
   end

   for ii = 1:3
      if sum(B[ii, :]) == 3 flg = 1 end
      if sum(B[:, ii]) == 3 flg = 1 end
   end
   if B[1]+B[5]+B[9] == 3 flg = 1 end
   if B[3]+B[5]+B[7] == 3 flg = 1 end

   println(flg==1 ? "Yes" : "No")
end

main()

Measured memory_bytes: 114940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll n;
string s;

int main() {
    cin >> n;
    cin >> s;
    ll count = 1;
    for(int i=1;i<n;i++){
        if(s[i-1] != s[i]){
            count++;
        }
    }
    cout << count << endl;
}



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

int main() {
  int n,n1,n2,n3,n4;
  cin >> n;
  n1 = n/1000;
  n2 = n/100 - n1*10;
  n3 = n/10 - n1*100 - n2*10;
  n4 = n - n1*1000 - n2*100 - n3*10;
  if (((n1==n2)&&(n2==n3))||((n2==n3)&&(n3==n4))){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}


ll C[15][15] = {{0}};

void gen_C(){
  C[0][0] = 1;
  C[1][0] = 1;
  C[1][1] = 1;
  FOR(i,2,15){
    C[i][0] = C[i][i] = 1;
    FOR(j,1,i-1){
      C[i][j] = C[i-1][j-1]+C[i-1][j];
    }
  }
}

ll poww(ll a){
  ll res = 1;
  ll t = 2;
  while(a > 0){
    if(a&1) res *= t;
    a >>= 1;
    t *= t;
  }
  return res;
}

ll sum = 0ll;

string s;

int main(){
  cin >> s;
  REP(i,s.size()){
    FOR(j,i+1,s.size()+1){
      int cnt = j-i;
      ll tmp = stol(s.substr(i,cnt));
      sum += tmp * poww(i-1) *poww(s.size()-j-1);
    }
  }
  cout << sum << endl;
}





Measured memory_bytes: 256
using System;

namespace Kyopuro
{
    class Program
    {
        static void Main(string[] args)
        {


            string[] a = Console.ReadLine().Split(' ');

            int N = int.Parse(a[0]);
            int M = int.Parse(a[1]);

            int i;

            int maisuu=0;

            string[][] s = new string[M][];

            int[] min= new int[M];
            int[] max= new int[M];


            for (i = 0; i < M; i++)
            {
                s[i] = Console.ReadLine().Split(' ');
                min[i] = int.Parse(s[i][0]);
                max[i] = int.Parse(s[i][1]);

            }
            Array.Sort(min);
            Array.Sort(max);


            maisuu = max[0] - min[M-1] + 1;

            if (maisuu <= 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(maisuu);

            }

        }
    }
}

Measured memory_bytes: 28840
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        char[] x = in.ns().toCharArray();
        ArrayDeque<Character> deq = new ArrayDeque<>();
        deq.add(x[0]);
        for (int i = 1; i < x.length; i++) {
            if(x[i]=='S') deq.addFirst('S');
            else{
                if(!deq.isEmpty()&&deq.peekFirst()=='S'){
                    deq.removeFirst();
                }else{
                    deq.addFirst('T');
                }
            }
        }
        out.println(deq.isEmpty()?0:deq.size());
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

int main() {
  int A,B,C,K;cin>>A>>B>>C>>K;
  for(int i=0;i<K;i++){
    if(A>=B) {B *=2;continue;}
    else if(B>=C) {C *=2;continue;}
    else break;
  }
  if(A<B&&B<C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3588
main :: IO()
main = do
    tileCharLs <- getLine
    print $ countTrueMatch $ map convertToBool tileCharLs






--[True,False,True....]とのマッチ要素数か、アンマッチ要素数のうち、小さいほうを返す。
countTrueMatch :: [Bool] -> Int
countTrueMatch ls 
    | a > div (length ls) 2		= (length ls) - a
    | otherwise					= a
    where a = countMatch ls (makeZebra True (length ls))


countMatch :: [Bool] -> [Bool] -> Int
countMatch [] _ = 0
countMatch _ [] = 0
countMatch ls1 ls2 =
    if head ls1 == head ls2
        then 1 + countMatch (tail ls1) (tail ls2)
        else countMatch (tail ls1) (tail ls2)


convertToBool :: Char -> Bool
convertToBool cha = if (cha == '1') then True else False 


makeZebra :: Bool -> Int -> [Bool]
makeZebra _ 0 = []
makeZebra firstSta len = firstSta : (makeZebra (not firstSta) (len - 1))

Measured memory_bytes: 13436
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int number = sc.nextInt();
    String slimes = sc.next();

    int total = 1;
    String first = slimes.substring(0,1);
    for(int i = 1; i < slimes.length(); i++){
      if(!(first.equals(slimes.substring(i,i+1)))){
        first = slimes.substring(i,i+1);
        total++;
      }
    }
		System.out.println(total);
	}
}

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

int main(){
   int n;
   cin >> n;
   if (n%2 == 0){
     cout << (n/2)*(n/2) <<endl;
   }
   else {
     cout << (n/2)*(n/2 + 1) << endl;
   }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, D;
	cin >> N >> D;
	int X[10][10];
	rep(i, N) rep(j, D) {
		cin >> X[i][j];
	}

	int kotae = 0;
	rep(i, N) {
		for (int j = i + 1; j < N; j++) {
			ll kei = 0;
			rep(k, D) {
				kei += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			int kari = sqrt(kei);
			if (kari * kari == kei) kotae++;
		}
	}
	co(kotae);

	Would you please return 0;
}

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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    int tmp = 0; 
    int mx = 0;

    for(int i = 0; i < len; i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            tmp++;
        }
        else{
            mx = max(mx, tmp);
            tmp = 0;
        }
    }
    mx = max(mx, tmp);
    cout << mx << "\n";
}

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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1,2,4,3);}//
    void roll_y(){ roll(0,2,5,3);}//to W
    void roll_x(){ roll(0,1,5,4);}
    void roll(int i, int j, int k, int l){//to N
      int t= f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }  
};

int getRight(Cube c1,int f1, int f2){
    for(int i=0; i<6; i++){
        for(int i=0; i<4; i++){
        if( c1.f[0] ==f1 && c1.f[1]==f2) return c1.f[2];
        c1.roll_z();
    }
    if(i%2 ==0)c1.roll_y();
    else c1.roll_x();
    }
    return -1;
}

int main(){
    Cube c;
    int f1, f2;
    
    for(int i=0; i<6; i++) cin >> c.f[i];
    int q; cin >> q;
    
    for(int i=0; i<q; i++){
        cin >> f1 >> f2;
        cout << getRight(c,f1,f2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    list <int> ls;
    int n,x;
    string cmd;
    cin>>n;
    for(int i=0;i<n;i++)
    {
       
        cin>>cmd;
        if(cmd=="insert")
        {
            cin>>x;
            ls.push_front(x);
        } 
        else if(cmd=="deleteFirst")
        {
            ls.pop_front();
        }
        else if(cmd=="deleteLast")
        {
            ls.pop_back();
        }
        else if(cmd=="delete")
        {
            cin>>x;
            for(list <int>::iterator it=ls.begin();it!=ls.end();it++)
            {
                if(x==*it)
                {
                    ls.erase(it);
                    break;
                } 
            }
        }
    }

    int i=0;
    for(list <int>::iterator it=ls.begin();it!=ls.end();it++)
    {
        if(i++)
        {
            cout<<" ";
        }
        cout<<*it;
    }
    cout<<endl;
   return 0;
}


Measured memory_bytes: 34328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b){
        cout << "delicious\n";
    }else if (x >= b-a)
    {
        cout << "safe\n";
    }else{
        cout << "dangerous\n";
    }
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
iN = int(input())
aA = [int(_) for _ in input().split()]
aA.sort()
iD = 10**9 + 7



iRet = 0
if iN % 2 == 0:
    aR = [x if x % 2 == 1 else x + 1 for x in range(iN)]
else:
    aR = [x if x % 2 == 0 else x + 1 for x in range(iN)]
if aA == aR:
    print(pow(2,iN//2,iD))
else:
    print(0)


Measured memory_bytes: 13880
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> v(N);
    rep(i,N) cin >> v[i];
    sort(All(v),greater<int>());
    double ans = 0;
    rep(i,N-1) ans += v[i]/pow(2.0,i+1);
    ans += v[N-1]/pow(2.0,N-1);
    cout << ans << nn;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a,b,c; vector<int> v(3);
	for(auto&x : v) cin >> x;
	sort(v.begin(), v.end());
	cout << v[0]*v[1]/2 << "\n";
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int base=0;
	while(base<n){
		base+=1000;
	}
	cout<<base-n<<endl;

	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>

#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a,int b){return a<b ? a:b;}

int main(){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1;
    tail = n+1;
    
    while(head!=tail){
        u=dequeue();
        c = min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0)enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    
    return 0;
}



Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n, cnt = 0;
    while(cin >> n, n){
        cnt ++;
        int d[11][11] = {};
        d[0][0] = 1;
        int f = 0, y = 0, x = 0;
        rep(i, 2, n*n + 1){
            if(f == 0){
                if(x != n - 1) x++;
                else if(y != n - 1) y++;
                else break;
                f = 1;
            }else if(f == 1){
                y++; x--;
                if(x == 0 || y == n - 1) f = 2;
            }else if(f == 2){
                if(y != n - 1) y++;
                else if(x != n - 1) x++;
                else break;
                f = 3; 
            }else if(f == 3){
                y--; x++;
                if(y == 0 || x == n - 1) f = 0;
            }
            d[y][x] = i;
        }
        cout << "Case " << cnt << ":" << endl;
        rep(i, 0, n){
            rep(j, 0, n){
                printf("%3d", d[i][j]);
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1200
//
// Created by Hideaki Imamura on 2020-03-13.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;

    int n,m,l;cin>>n>>l>>m;
    if(n+m+l==17)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}






Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

// 2??´????????´????????? (?????????0??§???????????¨)
bool is_orthogonal(P a1, P a2, P b1, P b2) {
    return EQ( dot(a1-a2, b1-b2), 0.0 );
}

// 2??´?????????????????? (?????????0??§???????????¨)
bool is_parallel(P a1, P a2, P b1, P b2) {
    return EQ( cross(a1-a2, b1-b2), 0.0);
}

int main() {
    int q; cin >> q;
    rep(i,0,q) {
        P a, b, c, d;
        cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y >> d.X >> d.Y;
        if(is_orthogonal(a, b, c, d)) cout << 1 << endl;
        else if(is_parallel(a, b, c, d)) cout << 2 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

int N, a[209], sons[209], cntSons[209], dst[209];
pair < int, int > maxd[209];
vector < int > v[109];
queue < int > cc;
const long long INF = ((1LL << 62) - 1) * 2LL + 1LL;

pair < int, int > dfs (int nod, int t, int lv)
{
    pair < int, int > ans = {lv, nod};
    for (auto it : v[nod])
        if (it != t)
        {
            pair < int, int > curr = dfs (it, nod, lv + 1);
            if (curr > ans)
                ans = curr;
        }
    return ans;
}

void computeCntSons (int d[])
{
    memset (cntSons, 0, sizeof (cntSons));
    memset (sons, 0, sizeof (sons));
    for (int i=1; i<=N; i++)
        for (auto it : v[i])
            if (d[it] > d[i])
                sons[i] ++;
    for (int i=1; i<=N; i++)
        if (sons[i] > cntSons[d[i]])
            cntSons[d[i]] = sons[i];
}

void updateAns (int root1, int root2, long long &ans, int diameter)
{
    int d[109];
    cc.push (root1), cc.push (root2);
    for (int i=1; i<=N; i++)
        d[i] = -1;
    d[root1] = d[root2] = 0;
    while (!cc.empty ())
    {
        int nod = cc.front ();
        cc.pop ();
        for (auto it : v[nod])
            if (d[it] == -1)
                d[it] = d[nod] + 1, cc.push (it);
    }
    computeCntSons (d);
    long long curr = 2;
    for (int i=0; i<diameter / 2; i++)
        if (curr > INF / cntSons[i]) curr = INF;
        else curr = 1LL * curr * cntSons[i];
    if (curr < ans)
        ans = curr;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
if (N <= 3)
{
    if (N == 2) printf ("1 2\n");
    else printf ("2 2\n");
    return 0;
}
int mini = N + 2, diameter = 0;
for (int i=1; i<=N; i++)
{
    maxd[i] = dfs (i, -1, 0);
    if (maxd[i].first < mini)
        mini = maxd[i].first;
    if (maxd[i].first > diameter)
        diameter = maxd[i].first;
}
for (int i=1; i<=N; i++)
    dst[i] = -1;
for (int i=1; i<=N; i++)
    if (maxd[i].first == mini)
        cc.push (i), dst[i] = 0;
printf ("%d ", (diameter + 2) / 2);
while (!cc.empty ())
{
    int nod = cc.front ();
    cc.pop ();
    for (auto it : v[nod])
        if (dst[it] == -1)
            dst[it] = dst[nod] + 1, cc.push (it);
}
computeCntSons (dst);
if (diameter % 2 == 1)
{
    long long ans = 2;
    for (int i=0; i<diameter / 2; i++)
        ans = 1LL * ans * cntSons[i];
    printf ("%lld\n", ans);
    return 0;
}
long long ans = 1LL;
for (int i=0; i<diameter / 2; i++)
    if (ans > INF / cntSons[i]) ans = INF;
    else ans = 1LL * ans * cntSons[i];
///I may want to increase the diameter by 1 though...
int CG = -1;
for (int i=1; i<=N; i++)
    if (dst[i] == 0)
        CG = i;
for (int bro = 1; bro <= N; bro ++)
    if (dst[bro] == 1)
        updateAns (CG, bro, ans, diameter);
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);

			BigInteger N = scanner.nextBigInteger();
			BigInteger K = scanner.nextBigInteger();

			BigInteger newN = N;

			newN = (N.remainder(K)).abs();


			N = K.subtract(newN);

			if(N.compareTo(newN) == 1) {
				System.out.println(newN);
			}else {
				System.out.println(N);
			}

	}

}


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

int main() {
	int A, B;

	cin >> A >> B;

	int ans = B * 10;

	while (floor(ans * 0.08001) != A) {
		ans++;
		if (ans > 11000) break;
	}

	if (floor(ans * 0.1001) != B) cout << "-1" << endl;
	else cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    def bfs(a,b):
        bfs_map = [1 for i in range(n)]
        bfs_map[0] = 0
        q = deque()
        q.append(0)
        s = 1
        while q:
            x = q.pop()
            for y in v[x]:
                if [x,y] != [a,b] and [x,y] != [b,a]:
                    if bfs_map[y]:
                        bfs_map[y] = 0
                        q.append(y)
                        s += 1
        return s
    n,m = LI()
    v = [deque() for i in range(n)]
    l = deque()
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
        l.append([a,b])
    ans = 0
    for a,b in l:
        s = bfs(a,b)
        if s < n:
            ans += 1
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int x[55],y[55];
map<pint,int>mp;

signed main(){
	IOS();
	int N;
	cin>>N;
	rep(i,0,N){
		cin>>x[i]>>y[i];
	}
	int ma = 0;
	rep(i,0,N){
		rep(j,0,N){
			if(i==j)continue;
			chmax(ma,++mp[{x[i]-x[j],y[i]-y[j]}]);
		}
	}
	cout<<N-ma<<endl;
}

Measured memory_bytes: 384