akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int w,h;
char tbl[60][60];
bool f[2][60][60];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
void dfs(int x,int y,int c){
  f[c][y][x]=true;
  for(int i=0;i<4;++i){
    int mx = x+dx[i];
    int my = y+dy[i];
    if(mx<0 || my<0) continue;
    if(mx>=w || my>=h) continue;
    if(f[c][my][mx]) continue;
    if(tbl[my][mx]!='.') continue;
    dfs(mx,my,c);
  }
}

int main(){
  while(cin>>w>>h,w||h){
    memset(f,0,sizeof(f));
    for(int i=0;i<h;++i) cin >> tbl[i];
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j){
	if(tbl[i][j]=='B'){
	  dfs(j,i,0);
	}
	if(tbl[i][j]=='W'){
	  dfs(j,i,1);
	}
      }
    int B=0,W=0;
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j){
	if(tbl[i][j]=='.' && f[0][i][j] && !f[1][i][j]) ++B;
	if(tbl[i][j]=='.' && f[1][i][j] && !f[0][i][j]) ++W;
      }
    cout << B << " " << W << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
void bubbleSort(int *A,int N){
	int flag,j,count=0,t;
    flag=1;
    while(flag){
        flag=0;
        for(j=N-1;j>0;j--){
            if(A[j]<A[j-1]){
            	count++;
                t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
                flag=1;
            }
        }
    }
    for(j=0;j<N-1;j++) printf("%d ",A[j]);
    printf("%d\n",A[N-1]);
    printf("%d\n",count);
}
int main(void){
	int N,a,i;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		A[i]=a;
	}
	bubbleSort(A,N);
	return 0;
}



Measured memory_bytes: 1968
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    vector<int> p(x);
    for(int i=0;i<x;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans=0;
    for(int i=0;i<x;i++){
        if(i!=x-1){
            ans+=p[i];
        }else{
            ans+=p[i]/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq

N = int(input())
V = list(map(int, input().split()))

h = []
for v in V:
  heapq.heappush(h, v)

total = 0
for n in range(N - 1):
  x = heapq.heappop(h)
  y = heapq.heappop(h)
  a = (x + y) / 2
  heapq.heappush(h, a)
print(heapq.heappop(h))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,s;
    cin >> k >> s;
    int ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0 && s-x-y<=k){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  s <- T.getLine :: IO T.Text
  T.putStrLn . T.map (const 'x') $ s

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s!="AAA" && s!="BBB")
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
import numpy as np
import copy

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = [int(sys.stdin.readline()) for _ in range(N)]

    Mi = L.index(max(L))

    tmpL = copy.deepcopy(L)
    tmpL[Mi] = 0
    Mi2 = tmpL.index(max(tmpL))

    for i in range(len(L)):
        if i == Mi:
            print(L[Mi2])
            continue
        print(L[Mi])


Measured memory_bytes: 24504
#include <iostream>
#include <random>
#include <functional>
#include <ctime>
#include <set>
#include <utility>
using std::cout;
using std::endl;
using std::cin;

constexpr char dir[] = {'N','E','W','S'};

class dice{
public:
	dice(int in[6]){
		for(int i=0;i<6;i++){
			v[i]=in[i];
		}
	}
	dice(){}
	void mov(const char c){
		int buf;
		switch(c){
			case dir[0]:{
				buf = v[0];
				v[0] = v[1];
				v[1] = v[5];
				v[5] = v[4];
				v[4] = buf;
				break;
			}
			case dir[1]:{
				buf = v[0];
				v[0] = v[3];
				v[3] = v[5];
				v[5] = v[2];
				v[2] = buf;
				break;
			}
			case dir[2]:{
				buf = v[0];
				v[0] = v[2];
				v[2] = v[5];
				v[5] = v[3];
				v[3] = buf;
				break;
			}
			case dir[3]:{
				buf = v[0];
				v[0] = v[4];
				v[4] = v[5];
				v[5] = v[1];
				v[1] = buf;
				break;
			}
		}
	}
	int operator[](size_t i){return v[i];}
	bool operator==(dice d){
		for(int i=0;i<6;i++){
			if(v[i]!=d[i])return false;
		}
		return true;
	}
	bool operator!=(dice d){
		return !operator==(d);
	}
private:
	int v[6];
};

bool issame(dice d1,dice d2){
	int i=0;
	auto rgen = std::bind(std::uniform_int_distribution<>(0,3),std::mt19937(time(nullptr)));
	while(i<100){
		d1.mov(dir[rgen()]);
		if(d1==d2)return true;
		i++;
	}
	return false;
}

bool alldiff(dice d[],int n){
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(issame(d[i],d[j])) return false;
		}
	}
	return true;
}

int main(){
	dice d[100];
	int in[6],n;
	cin >> n;
	for (int i=0;i<n;i++) {
		for(int j=0;j<6;j++){
			cin >> in[j];
		}
		d[i]=dice(in);
	}

	cout << (alldiff(d,n)?"Yes":"No") << endl;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area +" "+length);
    }
}


Measured memory_bytes: 26244
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
const int N = 2e5 + 5;

LL a[N], tms[N], ans[N];

int main() {
  LL x;
  int n, q, top = 0;
  scanf("%d%d", &n, &q);
  a[++ top] = n;
  for (int i = 1; i <= q; i ++) {
    scanf("%lld", &x);
    while (a[top] >= x && top > 0) top --;
    a[++ top] = x;
  }
  tms[top] = 1;
  for (int i = top; i >= 1; i --) {
    LL k = a[i];
    while (k > a[1]) {
      int p = lower_bound(a + 1, a + top + 1, k) - a - 1;
      tms[p] += k / a[p] * tms[i];
      k %= a[p];
    }
    ans[k] += tms[i];
  }
  for (int i = n; i >= 1; i --) ans[i] += ans[i + 1];
  for (int i = 1; i <= n; i ++) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main()
{
	int n,maxn(0),h(0);
	char s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>s;
    	if(s=='I')h++;
    	else h--;
    	if(maxn<h)maxn=h;
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    char a;
    cin >> a;
    map<char, char> mp;
    mp['A'] = 'T';
    mp['G'] = 'C';
    mp['T'] = 'A';
    mp['C'] = 'G';
    cout << mp[a] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int n;
    std::cin >> n;
    
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    std::map<int, int> m1, m2;
    for (int i = 0; i < n; i+=2) {
        m1[v[i]]++;
    }
    for (int i = 1; i < n; i+=2) {
        m2[v[i]]++;
    }

    int m1max = 0;
    int m1no2 = 0;
    int memo1 = 0;
    for (std::map<int, int>::iterator it = m1.begin(), end = m1.end(); it != end; it++) {
        if (m1max < it->second) {
            m1max = it->second;
            memo1 = it->first;
        }
    }
    
    m1.erase(memo1);
    for (std::map<int, int>::iterator it = m1.begin(), end = m1.end(); it != end; it++) {
        if (m1no2 < it->second) {
            m1no2 = it->second;
        }
    }
    
    int m2max = 0;
    int m2no2 = 0;
    int memo2 = 0;
    for (std::map<int, int>::iterator it = m2.begin(), end = m2.end(); it != end; it++) {
        if (m2max < it->second) {
            m2max = it->second;
            memo2 = it->first;
        }
    }
    
    m2.erase(memo2);
    for (std::map<int, int>::iterator it = m2.begin(), end = m2.end(); it != end; it++) {
        if (m2no2 < it->second) {
            m2no2 = it->second;
        }
    }

    if (memo1 != memo2) {
        std::cout << n - (m1max+m2max) << std::endl;
    } else {
        std::cout << std::min(n - (m1max+m2no2), n - (m2max+m1no2)) << std::endl;
    }
    return 0;
}


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

int main() {
    int w;
    int par = 4280;
    while (cin >> w, w >= 0) {
        int payment = 1150;
        if (10 < w) payment += (min(20, w) - 10) * 125;
        if (20 < w) payment += (min(30, w) - 20) * 140;
        if (30 < w) payment += (w - 30) * 160;

        cout << par - payment << endl;
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n=(int)s.size();
    int r_count=0;
    int l_count=0;
    int change=-1;
    vector<int> ans(n,0);
    for(int i=0; i<n; i++){
        if(i==0){
            r_count++;
            continue;
        }
        if(s.at(i) == 'L'){
            if(l_count==0){
                ans.at(i-1) += (r_count+1)/2;
                ans.at(i) += r_count/2;
                change=i;
            }
            r_count=0;
            l_count++;
        }
        else{
            if(r_count==0){
                ans.at(change-1) += l_count/2;
                ans.at(change) += (l_count+1)/2;
            }
            l_count=0;
            r_count++;
        }
    }
    ans.at(change-1) += l_count/2;
    ans.at(change) += (l_count+1)/2;
    for(int i=0; i<n; i++){
        cout << ans.at(i) << ' ';
    }
    cout << endl;
}


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

using namespace std;

int main(){
    string A, B, C;
    cin >> A >> B >> C;
    
    if(A[A.length() - 1] != B[0] || B[B.length() - 1] != C[0]){
        cout << "NO\n";
    }
    else{
        cout << "YES\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int a,b,n;
  cin >> n >> a >> b;
  int res = 0;
  FOR(i,1,n+1){
    int sum = 0;
    int num = i;
    while(num > 0){
      sum += num % 10;
      num /= 10;
    }
    if(sum>=a && sum<=b){
      res += i;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;
//typedef pair<int, int> P;
//vector<long long> a(max_n);
//map<int, int> m;
static const int max_n = 1000001, max_m = 102;
static const ll  INF = 1000000000;
const long long mod = 1e18;
int ci;

int main(){
    int n, q, a;
    int b, c;
    ll sum=0;
    map<int, int> m;
    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> a;
        //m.insert(make_pair(a, i));
        m[a]++;
        sum += (ll)a;
    }
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> b >> c;
        sum += (c-b)*m[b];
        m[c] = m[c] + m[b];
        m[b] = 0;
        cout << sum << endl;
    }
    cin >> ci;
}

Measured memory_bytes: 8052
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer> list=new ArrayList<>();
		int[] set={0,2,5,5,4,5,6,3,7,6};
		int[] a=new int[m];
		String[] dp=new String[n+1];
		dp[0]="";
		for(int i = 0; i<m; i++){
			a[i]= sc.nextInt();
		}
		for(int i = 0; i<=n; i++){
			for(int j = 0; j<m; j++){
				if(i>=set[a[j]] && dp[i-set[a[j]]]!=null){
					if(check(dp[i-set[a[j]]]+a[j],dp[i])){
						dp[i]=dp[i-set[a[j]]]+a[j];
					}
				}
			}
		}
		System.out.println(dp[n]);
	}
	static boolean check(String a,String b){
		if(b==null || a.length()>b.length()){
			return true;
		}
		if(a.length()<b.length()){
			return false;
		}
		return a.compareTo(b)>0;
	}
}

Measured memory_bytes: 376912
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  if(a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  
  Int ans=0,res=0;
  for(Int i=0;i<n;i++){
    if(res+1<a[i]){
      cout<<-1<<endl;
      return 0;
    }
    if(res+1==a[i]) ans++;
    else ans+=a[i];
    res=a[i];
  }

  cout<<ans<<endl;
  return 0;
}


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

int main()
{
        int k;
        std::string s;
        std::cin >> k >> s;

        if(k >= static_cast<int>(s.size()))
                std::cout << s << std::endl;
        else{
                std::string sub = s.substr(0,k);
                sub += "...";
                std::cout << sub << std::endl;
        }

}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<set>
using namespace std;
using ll = long long;

unsigned egcd(unsigned a, unsigned b) {
  if(a < b) return egcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    for (auto &p:l) cin >>p;
    auto lm = max_element(l.begin(),l.end());

    ll overallgcd = l[0];
    for (int i=1;i<n;i++) {
        overallgcd = egcd(overallgcd,l[i]);
        if (overallgcd == 1) break;
    }
    cout << ((k <= *lm and (k%overallgcd==0)) ? "POSSIBLE" : "IMPOSSIBLE")<< endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int res = 0;
            int cnt = 0;
            for (int i = 0; i < n; ++i) {
                if (i == 0 || a[i] != a[i - 1])
                    cnt = 0;
                ++cnt;
                if (cnt % 2 == 0) {
                    ++res;
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22484
n=int(input())
s=[]
l=['M','A','R','C','H']
d={'M':0,'A':0,'R':0,'C':0,'H':0}
for _ in range(n):
  s_=input()
  if s_[0] in l:
    d[s_[0]]+=1
ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=d[l[i]]*d[l[j]]*d[l[k]]
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
static const int MAXN = 3002;
static const int MAXM = 3003;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int n, m;
char s[MAXN];
int l[MAXM], r[MAXM];
int yonder[MAXM];

int f[MAXN][MAXN] = {{ 0 }};

int main()
{
    scanf("%d%d", &n, &m); getchar();
    for (int i = 0; i < n; ++i) s[i] = getchar() - '0';
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &l[i], &r[i]); --l[i], --r[i];
        if (i > 0 && r[i] <= r[i - 1]) --m, --i;
        else if (i > 0 && l[i] == l[i - 1] && r[i] >= r[i - 1]) --m, --i, r[i] = r[i + 1];
    }

    std::fill(yonder, yonder + n, -2);
    for (int j = 0; j < l[0]; ++j) yonder[j] = j;
    for (int j = l[m - 1]; j < n; ++j) yonder[j] = std::max(j, r[m - 1]);
    for (int i = 1; i < m; ++i) {
        for (int j = l[i - 1]; j < l[i]; ++j) yonder[j] = std::max(j, r[i - 1]);
    }

    int ones = 0;
    for (int i = 0; i <= yonder[0]; ++i) ones += s[i];
    f[0][ones] = 1;
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= yonder[i - 1] - i + 1; ++j) {
            f[i][j] = f[i - 1][j];
            if (j < MAXN - 1) (f[i][j] += f[i - 1][j + 1])__;
        }
        if (yonder[i] != yonder[i - 1]) {
            int ones = 0;
            for (int j = yonder[i - 1] + 1; j <= yonder[i]; ++j) ones += s[j];
            for (int j = MAXN - 1; j >= ones; --j) f[i][j] = f[i][j - ones];
            for (int j = ones - 1; j >= 0; --j) f[i][j] = 0;
        }
    }

    printf("%d\n", (f[n - 1][0] + f[n - 1][1])_);

    return 0;
}


Measured memory_bytes: 34432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,i,j,t,k;
ll a,b,c,d,x;
char A,C,X,Y,Z;
ll ans,MAX,MIN;
ll ax[2000500];
char cx[10000];
ll dx[12];
ll bx[2000500];
const int N = (1 << 20) + 10;

int main()
{
    t=1;
    //scanf("%lld",&t);
    while(t--)
    {
        cin >> a >> b >> c;
        cout<< c << " " << a << " " << b;
    }
	return 0;
}

Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define M  1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll f(ll n,ll m,ll d){
    if(n>m){
        return I;
    }
    if(n==m){
        return d;
    }
    ll d1=f(n*2,m,d+1);
    ll d2=f(n*3,m,d+1);
    return min(d1,d2);
}
ll ma=0;
ll dis[100001]={0};
vector<ll> v[100001];
ll dfs(ll i){
    if(v[i].size()==0){
        dis[i]=1;
        return dis[i];
    }
    ll ma=0;
    if(dis[i]>0){
        return dis[i];
    }
    for(auto& ver : v[i]){
        
        ma=max(dfs(ver)+1,ma);
    }
    dis[i]=ma;
    return dis[i];

}
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
        
    ll n,m,i,j,k;
    cin>>n>>m;
    in(i,m){
        ll src,des;
        cin>>src>>des;
        v[src].pb(des);
    }
    fon(i,1,n+1){
        dfs(i);
    }
    fon(i,1,n+1){
        ma=max(ma,dis[i]);
    }
    cout<<ma-1;

}
 
 








 



Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int s[20][20];

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

    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i]) cin >> s[i][j];
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    int ans = 0;
    rep(i, (1 << n))
    {
        vector<int> v(n, 0);
        rep(j, n) if (i & (1 << j)) v[j] = 1;
        bool f = true;
        rep(j, m)
        {
            int cnt = 0;
            rep(K, k[j]) cnt += v[s[j][K] - 1];
            if ((cnt % 2) != p[j])
                f = false;
        }
        if (f)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S = input()
n = len(S)
plist = [-1]
ans = [0 for _ in range(n)]
r = 0
l = 0
for i in range(n-1):
    if S[i]=="L" and S[i+1]=="R":
        plist.append(i)
    if S[i]=="R" and S[i+1]=="L":
        plist.append(i)
plist.append(n-1)
for i in range(len(plist)-1):
    if i%2 == 0:
        a = (plist[i+1]-plist[i])
        if a%2 == 0:
           ans[plist[i+1]] += a//2
           ans[plist[i+1]+1] += a//2
        else:
           ans[plist[i+1]] += a//2+1
           ans[plist[i+1]+1] += a//2
    else:
        a = (plist[i+1]-plist[i])
        if a%2 == 0:
           ans[plist[i]] += a//2
           ans[plist[i]+1] += a//2
        else:
           ans[plist[i]] += a//2
           ans[plist[i]+1] += a//2+1
print(*ans)


Measured memory_bytes: 10432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    sort(A.begin(),A.end());
    cout << accumulate(A.begin(),A.begin()+K,0) << "\n";
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<iostream>
#include<memory.h>
using namespace std ;

int W , H ;
char table[12][12] ;
char C[] = {'R','G','B'} ;
int dx[] = {-1,0,1,0} ;
int dy[] = {0,-1,0,1} ;
int Ans ;

bool Check( char x[][12] ){
	char d = x[0][0] ;
	for( int i=0 ; i<H ; i++ ){
		for( int j=0 ; j<W ; j++ ){
			if( d != x[i][j] ) return false ;
		}
	}
	return true ;
}

bool Range( int X , int Y , int k ){
	if( Y+dy[k] < 0 || Y+dy[k] >= H || X+dx[k] < 0 || X+dx[k] >= W ){
		return false ;
	}return true ;
}

void Change( int X , int Y , char Color , char P[][12] ){
	int b = P[Y][X] ;
	P[Y][X] = Color ;
	
	for( int k=0 ; k<4 ; k++ ){
		if( Range(X,Y,k) && P[Y+dy[k]][X+dx[k]] == b ){
			Change( X+dx[k] , Y+dy[k] , Color , P ) ;
		}
	}
}

void Copy( char A[][12] , char B[][12] ){
	for( int i=0 ; i<H ; i++ ){
		for( int j=0 ; j<W ; j++ ){
			A[i][j] = B[i][j] ;
		}
	}
}

void Search( char P[][12] , int cnt , int g ){
	if( Check(P) ){
		if( Ans==-1 || Ans > cnt ) Ans = cnt ;
	}
	if( Ans != -1 && Ans <= cnt+1 ) return ;
	
	char tmp[12][12] ;
	Copy( tmp , P ) ;
	for( int i=0 ; i<3 ; i++ ){
		if( P[0][0] != C[(g+i)%3] ){
			Change( 0 , 0 , C[(g+i)%3] , P ) ;
			Search( P , cnt+1 , (g+i)%3 ) ;
			Copy( P , tmp ) ;
		}
	}
	
}

int main(){
	
	while( cin >> W >> H , W+H ){
		for( int i=0 ; i<H ; i++ ){
			for( int j=0 ; j<W ; j++ ){
				cin >> table[i][j] ;
			}
		}
		
		Ans = -1 ;
		Search(table,0,0) ;
		
		cout << Ans << endl ;
	}
	
return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define NMAX 200000
#define MOD 998244353

//senor氏の講義を受けて com_init, combi, pow_init を実装

vector<ll> fac(NMAX+1);
vector<ll> inv(NMAX+1);
vector<ll> fnv(NMAX+1);
vector<ll> power(NMAX+1);

void com_init(){
    
    fac[0]=1;
    fac[1]=1;
    inv[0]=0;
    inv[1]=1;
    fnv[0]=1;
    fnv[1]=1;
    
    for(int i=2; i<NMAX+1; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - (MOD/i) * inv[MOD%i] % MOD;
        fnv[i] = fnv[i-1] * inv[i] % MOD;
    }
    return;
}

ll combi(int n, int k){
    if(n<k)return 0;
    if(k<0 || n<0 )return 0;
    
    return fac[n] * (fnv[k]*fnv[n-k] % MOD) % MOD;
}

void pow_init(int M){
    
    power[0] = 1;
    for(int i=1; i<NMAX+1; i++){
        power[i] = power[i-1] * M % MOD;
    }
    return;
}

int main(){
    
    int n, m, k;
    
    cin >> n >> m >> k;
    
    com_init();
    pow_init(m-1);
    
    ll ans = 0;
    
    for(int i=0; i<=k; i++){
        //k=0のとき M*(M-1)^(N-1)
        //k=1のとき (N-1)C1 * M * (M-1)^(N-2)
        //一般に    (N-1)Ck * M * (M-1)^(N-1-k)
        ans += combi(n-1, i) * ( m * power[n-1-i] % MOD ) % MOD;
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 9460
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

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

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

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

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

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

int main() {
	ll n; cin >> n;
	vl x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	vl y(n);
	for (int i = 0; i < n; i++) {
        y[i] = x[i];
    }
	sort(y.begin(), y.end());
	for (int i = 0; i < n; i++) {
		if (x[i] > y[n / 2 - 1]) cout << y[n / 2 - 1] << endl;
		if (x[i] < y[n / 2]) cout << y[n / 2] << endl;
		if (x[i] == y[n / 2 - 1] && x[i] == y[n / 2]) cout << y[n / 2] << endl;
	}
}

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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  int a=A.size(),b=B.size(),sum=0;
  if(A.at(a-1)==B.at(0)){
    sum++;
  }
  if(B.at(b-1)==C.at(0)){
    sum++;
  }
  if(sum==2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if( b > 4*a) {
        cout<< "No" << endl;
        return 0;
  }
  else if( b < 2*a) {
    cout<< "No" ;
    return 0;
  }
  int x;
  if( (4*a -b) % 2 !=0 ) {
    cout<< "No" ;
    return 0;
  }
  if( (b - 2*a) % 2 !=0) {
    cout<< "No" ;
    return 0;
  }
  x = ( 4*a - b) / 2;
  int y;
  y = (b - 2*a) / 2;
  if( (x + y)  == a && (2*x + 4*y) == b ) cout<< "Yes" << endl;
  else cout<< "No" << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

void Pablo(int N)
{
    int a,b;
    int h[200],w[200];
    fill(h,h+N,0);
    fill(w,w+N,0);

    for(int i=1;i<N;i++)
    {
	cin >> a >> b;
	if(b % 2 == 0)
	{
	    b--;
	    w[i] = w[a] + b;
	    h[i] = h[a];

	}else{
	    b--;
	    b--;
	    h[i] = h[a] + b;
	    w[i] = w[a];
	}
//	cout << "h["<<i<<"] = "<<h[i] <<endl;
//	cout << "w["<<i<<"] = "<<w[i] <<endl;

    }
    int maxh=0,minh=0,maxw=0,minw=0;
    for(int i=0;i<N;i++)
    {
	maxh = max(h[i],maxh);
	minh = min(h[i],minh);
	maxw = max(w[i],maxw);
	minw = min(w[i],minw);
    }
    cout << maxw - minw +1 << " " << maxh - minh +1 << endl;

}

int main()
{
    while(true)
    {
	int N;
	cin >> N;
	if (N == 0) break;
	Pablo(N);
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int sumAC =0;
			int sumWA =0;
			int sumTLE =0;
			int sumRE =0;

			for(int i=0;i<N;i++) {
				String judge = sc.next();
				switch(judge) {
				case "AC":
					sumAC++;
					break;
				case "WA":
					sumWA++;
					break;
				case "TLE":
					sumTLE++;
					break;
				case "RE":
					sumRE++;
					break;
				}
			}
			
			System.out.println("AC x "+sumAC);
			System.out.println("WA x "+sumWA);
			System.out.println("TLE x "+sumTLE);
			System.out.println("RE x "+sumRE);		
	}	
}

Measured memory_bytes: 58972
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  int64_t MOD = 1e9+7;
  int K = 13;
  int64_t dp[S.size()][K];
  for(int i=0; i<S.size(); i++){
    for(int j=0; j<K; j++){
      dp[i][j] = 0;
    }
  }
  vector<int> amari(10);
  for(int i=0; i<10; i++){
    amari.at(i) = i;
  }
  
  for(int i=0; i<S.size(); i++){
    int x = S.at(i) - '0';
    if(i == 0){
      for(int j=0; j<10; j++){
        if(j == x || S.at(i) == '?'){
          dp[i][j] = 1;
        }
      }
    }
    else{
      for(int j=0; j<10; j++){
        if(j == x || S.at(i) == '?'){
          for(int k=0; k<K; k++){
            dp[i][(amari.at(j)+k)%K] += dp[i-1][k];
            dp[i][(amari.at(j)+k)%K] %= MOD;
          }
        }
      }
    }
    for(int j=0; j<10; j++){
      amari.at(j) *= 10;
      amari.at(j) %= K;
    }
  }
  
  /*for(int i=0; i<S.size(); i++){
    for(int j=0; j<K; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  
  cout << dp[S.size()-1][5] << endl; 
}

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

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

    // all the code goes here
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int &c : a)
    {
        cin>>c;
    }

    bool arr[k+1];
    memset(arr,0,sizeof(arr));

    for(int i = 0; i <= k; i++)
    {
        for(int c : a)
        {
            if(i >= c && !arr[i-c])
                arr[i] = true;
        }
    }

    arr[k]?cout<<"First":cout<<"Second";
    cout<<"\n";

    return 0;
}

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

int main(){
	bool prime[1000001] = {true,true};
	vector<int> ps;
	for(int i = 4;i <= 1000000;i += 2) prime[i] = true;
	for(int i = 3;i * i <= 1000000;i += 2){
		for(int j = i * 2;j <= 1000000;j += i) prime[j] = true;
	}
	for(int i = 0;i <= 1000000;i++) if(!prime[i]) ps.push_back(i);
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int i = 0;i < ps.size();i++){
			if(ps[i] > n / 2) break;
			if(upper_bound(ps.begin(),ps.end(),n - ps[i]) - lower_bound(ps.begin(),ps.end(),n - ps[i])) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

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

	cout << max(a+b,max(a-b, a*b)) << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << ((N - 2)*(B - A) + 1)*((N - 2)*(B - A) + 1 >= 0) << endl;
    

    return 0;
}

Measured memory_bytes: 3624
S = input()

N = len(S)
s = S[::-1]
a = S[:((N-1)//2)]
b = S[((N+3)//2)-1:]
c = a[::-1]
d = b[::-1]

if (S == s and a == c):
    if(b == d):
        print('Yes')
    else:
        print('No')
else:
    print('No')
    


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N,M;
    int a;
    vector<int> A = vector<int>();
    cin >> N >> M;
    for (int i = 0;i < M;i++){
        cin >> a;
        A.push_back(a);
    }
    int sum=0;
    for (int i : A){
        sum += i;
    }
    if(sum <= N){
        cout << N - sum << endl;
    }else{
        cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 3680
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define rep(i, n) for(int i = 0; i < (int)n; ++i)

using namespace std;

int main() {
  int n;
  cin >> n;
  unordered_map<int, int> cnt;
  rep(i, n) cnt[i+1] = 0;
  int tmp;
  rep(i, n-1) {
    cin >> tmp;
    cnt[tmp]++;
  }
  rep(i, n) cout << cnt[i+1] << endl;

  return 0;
}


Measured memory_bytes: 10704
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;
ll a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;

	while (true) {
		c -= b;
		if (c <= 0) {
			puts("Yes");
			return 0;
		}
		a -= d;
		if (a <= 0) {
			puts("No");
			return 0;
		}
	}

	return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var abc = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var result = 0L;

            result = abc[0] * abc[1] / 2; 

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
n=int(input())
dic={}
for i in range(n):
    ph=input()
    if ph not in dic:
        dic[ph]=1
    else:
        dic[ph]+=1

i=0
q1=-1
for p,q in sorted(dic.items(),key=lambda x: (-x[1],x[0])):
    if i>0 and q1!=q:
        break
    else:
        print(p)
        i+=1
        q1=q

Measured memory_bytes: 59224
n=int(input())
a=[list(map(int,input().split()))for _ in range(2)]

ans = [[0 for _ in range(n)]for __ in range(2)]
ans[0][0] = a[0][0]
ans[1][0] = a[0][0] + a[1][0]
for i in range(1,n):
    ans[0][i] = ans[0][i-1] + a[0][i]
    ans[1][i] = max(ans[0][i],ans[1][i-1]) + a[1][i]
print(ans[1][n-1])


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

int get_value(string S)
{
	int value = 0;
	
	for(int i = 0; i < S.size(); i++)
	{
		value = value*10 + (S[i] - '0');
	}
	
	return value;
}

int main() 
{
	string A, B;
	cin >> A >> B;
	string N = A + B;
	
	int n = get_value(N);
	int is_square = false;
	
	for(int i = 1; i*i <= n; i++)
	{
		if(i*i == n)
			is_square = true;
	}
	
	cout << (is_square ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, abc, arc;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  abc = d[d.size() / 2 - 1];
  arc = d[d.size() / 2];
  cout << arc - abc << endl;
}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int fib[50];

/*----------------------------------------------------------------*/
signed main(){

    int n;
	cin >> n;
	fib[0] = fib[1] = 1;
	rep(i,45)fib[i+2] = fib[i+1] + fib[i];
	cout << fib[n] << endl;

    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc088.contest.atcoder.jp/tasks/abc088_d


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int tap = 1;
    while (b > tap) {
        tap += a - 1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
while 1:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f < 30:
        print("F")
    elif m + f < 50 and r < 50:
        print("D")
    elif m + f < 65\
    or   m + f < 50 and r > 50:
        print("C")
    elif m + f < 80:
        print("B")
    else:
        print("A")

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
int main(){
	int n,flag,sum;
	ll sig;
	cin>>n;
	vector<int> an(n);
	rep(i,n){
		cin>>an.at(i);
	}
	flag=0;
	sig=1;
	while(sig>0){
		sum=0;
		sig=0;
		rep(k,n){
			sum+=an.at(k)%2;
			an.at(k)/=2;
			sig+=an.at(k);
			//cout<<sum<<endl;
		}
		if(sum%2==1){
			flag=1;
			break;
		}
		
	}
	if(flag==0){
		cout<<"Yes"<<endl;
	}else if(flag==1){
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a,b = map(int,input().split())
p = list(map(int, input().split()))
x = 0
y = 0
z = 0
for I in range(n):
 if p[I] <= a:
  x+=1
 elif p[I] <=b:
  y+=1
 else:
  z+=1
print(min([x,y,z]))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
int K,N;
cin >> N >> K;
int A[N];
for (int i=0;i<N;i++)
{
	cin >> A[i];
}
int a;
for(int i=0;i<N;i++)
{
	for(int j=0;j<N-i-1;j++)
	{
	   if(A[j]<A[j+1])
	   {
	   	a=A[j];
	   	A[j]=A[j+1];
	   	A[j+1]=a;
		}	
	}
}
int b=0;
for (int i=0;i<K;i++)
{
	b=b+A[i];
}
cout << b <<endl;


return 0;	
}

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

int D,N;

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

  scanf("%d %d",&D,&N);

  if(D==1){
  	int ans=0;
  	const int a=pow(100,D);
  	if(N!=100){
	  	const int ans=a*N;
	  	printf("%d\n",ans);
	}
	else{
		const int ans=a*(N+1);
	  	printf("%d\n",ans);
	}
  	return 0;
  }
  else if(D==2){
  	int ans=0;
  	const int a=pow(100,D);
  	if(N!=100){
	  	const int ans=a*N;
	  	printf("%d\n",ans);
	}
	else{
		const int ans=a*(N+1);
	  	printf("%d\n",ans);
	}
  	return 0;  	
  }
  else{
  	if(N!=100) {printf("%d\n",N);}
  	else {printf("101\n");}
  	return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long n;
	cin >> n;
	int sum = 0, ans = 0;
	int c = n;
	while (n > 0) {
		sum = sum + n % 10;
		n = n / 10;
	}
	if (c%sum == 0) cout<<"Yes" << endl;
	else cout << "No" << endl;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for (int i = 3; i <= n; i++) {
            if (i % 3 == 0) {
                System.out.print(" " + i);
            } else {
                String s = String.valueOf(i);
                if (s.contains("3")) {
                    System.out.print(" " + i);
                }
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 27804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<char> ans(0);
  while(N>=1){
    ll a=N/26;
    ll b=N%26;
    if(b==0){b=26;}
    b+=96;
    char c=b;
    ans.push_back(c);
    N/=26;
    N--;
    if(b!=122){N++;}
  }
  for(ll i=0;i<(ll)ans.size();i++){
    cout<<ans.at((ll)ans.size()-1-i);
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int res[N][N];
int n , m , K , a[N * N];
int main() {
    scanf("%d%d%d" , &n , &m , &K);
    for (int i = 0 ; i < K ; ++ i) {
        scanf("%d" , &a[i]);
    }
    for (int i = 0 , x = 0 ; i < n ; ++ i) {
        for (int j = 0 ; j < m ; ++ j) {
            while (!a[x]) {
                ++ x;
            }
            res[i][(i & 1) ? j : m - j - 1] = x + 1;
            -- a[x];
        }
    }
    for (int i = 0 ; i < n ; ++ i) {
        for (int j = 0 ; j < m ; ++ j) {
            printf("%d%c" , res[i][j] , " \n"[j + 1 == m]);
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n;
	cin >> n;
	vl p(n);
	ll ans = 0;
	rep(i, n) cin >> p[i];
	rep(i, n - 2) {
		bool f1 = p[i] < p[i + 1] && p[i + 1] < p[i + 2];
		bool f2 = p[i + 2] < p[i + 1] && p[i + 1] < p[i];
		if (f1 || f2) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::multimap;

int main(void)
{
    int32_t T, X;
    cin >> T >> X;

    cout << (double)T/X << endl;

    return 0;
}



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

int main(){
  string m;
  while(cin>>m){
    string win = "d";
    for(int i=0;i<3;i++){
      if(m[i*3]!='s' && m[i*3]==m[i*3+1] && m[i*3+1]==m[i*3+2])
	win = m[i*3];
      if(m[ i ]!='s' && m[ i ]==m[ i+3 ] && m[ i+3 ]==m[ i+6 ])
	win = m[i];
    }
    
        if(m[4]!='s' && m[0]==m[4] && m[4]==m[8])
	  win = m[4];
        if(m[4]!='s' && m[2]==m[4] && m[4]==m[6])
	  win = m[4];
	
     
	cout<<win<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
L = int(input())
mod = 10**9+7

L_ = str(L)

#dp = [[0]*2 for j in range(10**5+5)]
dp = [[0]*2 for j in range(10**5+5)]

dp[0][0] = 1

n = len(L_)
for i in range(n):
    for k in range(2):
        nd = int(L_[i])
        for d in range(2):
            ni = i+1
            nk = k
            if k == 0:
                if d > nd:
                    continue
                elif d < nd:
                    nk = 1
                else:
                    pass
            if d == 0:
                dp[ni][nk] += dp[i][k]%mod
            else:
                dp[ni][nk] += 2*dp[i][k]%mod
#print(dp[n][0])
ans = (dp[n][0]+dp[n][1])%mod
print(ans)

Measured memory_bytes: 55132
s = input()
if(s == "++++"):
    print(4)
elif(s == "----"):
    print(-4)
elif(s == "+++-" or s == "++-+" or s == "+-++" or s == "-+++"):
    print(2)
elif(s == "---+" or s == "--+-" or s == "-+--" or s == "+---"):
    print(-2)
else:
    print(0)

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n , m , k ;
	cin >> n >> m >> k ;
	rep(i,m+1){
		//i個の列はp個が黒で,(m-1)個の列は(n-p）個が黒
		for(int p = 0 ; p <= n ; p ++){
			int now ;
			now = i * p + ( m -i)*(n-p) ;
			if(now == k ){
				coY();
				return 0;
			}
		}
	}
	coN();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int r,d;
	unsigned long long int x[11];
	cin>>r>>d>>x[0];
	for(int i=1;i<=10;++i){
		x[i]=r*x[i-1]-d;
		cout<<x[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, t = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

min = a[0]
h = Hash.new(0)
for i in 1..n-1 do
    h[a[i] - min] += 1 if a[i] - min > 0
    min = a[i] if a[i] < min
end

puts h.to_a.sort {|a, b| a[0] <=> b[0]}[-1][1]


Measured memory_bytes: 22528