akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*
Case 1: B...A: n1
Case 2: B...X: n2
Case 3: X...A: n3
Case 4: X...Y: n4
*/

int main() {
    // freopen("data.txt", "r", stdin);
    int n;
    cin >> n;
    int n1 = 0, n2 = 0, n3 = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s[0] == 'B') {
            if (s.back() == 'A') {
                ++n1;
            } else {
                ++n2;
            }
        } else if (s.back() == 'A') {
            ++n3;
        }
        for (int i = 0; i < (int)s.size() - 1; ++i)
            if (s[i] == 'A' && s[i + 1] == 'B') ++ans;
    }

    if (n3 > 0)
        --n3;
    else if (n1 > 0)
        --n1;
    else {
        cout << ans << "\n";
        return 0;
    }

    ans += n1;
    n1 = 0;
    // You have a A at the end
    if (n2 > 0) {
        ++ans;
        --n2;
    }
    ans += min(n3, n2);
    cout << ans << "\n";
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

if (B - A) % 2 > 0:
    ans_up = (A + B - 1) // 2
    ans_down = N - (A + B - 1) // 2
    print(min(ans_up, ans_down))
else:
    print((B - A) // 2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ull i=0;i<(ull)n;++i)
ll INF = 999999999999999;
double pi = 3.141592653589793238;

vector<ll> ans;

int main(){
  ll n,m;
  cin >> n >> m;
  ans.resize(n);
  ans.assign(n,INF);
  vector<vector<ll>> rm(n);
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    rm.at(a).push_back(b);
    rm.at(b).push_back(a);
  }
  queue<ll> q;
  auto push = [&]( ll v, ll pre ){
    if( ans.at(v) != INF ) return;
    ans.at(v) = pre;
    q.push(v);
  };
  push(0,0);
  while(!q.empty()){
    ll v = q.front();q.pop();
    for(ll i=0;i<rm.at(v).size();++i){
      push(rm.at(v).at(i),v);
    }
  }
  rep(i,n){
    if( ans.at(i) == INF ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(ll i=1;i<n;++i){
    cout << ans.at(i)+1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 12944
N,M = map(int,input().split(" "))
A = [0]*N
B = [0]*M
for i in range(N):
    A[i] = input()

for i in range(M):
    B[i] = input()

n = N - M + 1

for i in range(n*n):
    j = i // n
    i %= n
    flag = True
    for k in range(M*M):
        l = k // M
        k %= M
        if A[j+l][i+k] != B[l][k]:
            flag = False
            break
    if flag:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<lint, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vec p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(all(p), greater<lint>());
    sort(all(q), greater<lint>());
    sort(all(r), greater<lint>());

    priority_queue<P> que;

    rep(i, a) {
        que.push(make_pair(p[i], 0));
    }
    rep(i, b) {
        que.push(make_pair(q[i], 1));
    }
    rep(i, c) {
        que.push(make_pair(r[i], 2));
    }

    lint res = 0;

    lint ca = 0, cb = 0;

    rep(i, x+y) {
        auto p = que.top();
        que.pop();

        if (p.second == 0) {
            ca++;
            if (ca > x) {
                i--;
                continue;
            }
        }
        if (p.second == 1) {
            cb++;
            if (cb > y) {
                i--;
                continue;
            }
        }

        res += p.first;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12908
if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))
    S = set()

    def solve(i, x):

        if i < n:
            S.add(x + A[i])
            solve(i + 1, x + A[i])
            solve(i + 1, x)

    solve(0, 0)

    q = int(input())
    for i in input().split():
        if int(i) in S:
            print('yes')
        else:
            print('no')



Measured memory_bytes: 5660
#include<iostream>
#include<queue>
#define MAX 1000000
#include<complex>
#include<vector>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef complex<int> P;
int main(){
	int n,use[1001],m,s,g,now,pre[1001],box[1001],b,x,y;
	double v[1001],d[100][100];
	vector<P> vec;
	map<int,int> na,nb;
	while(cin>>n,n){
		rep(i,n)
		rep(j,n)
		d[i][j]=MAX;
		rep(i,n){
			cin>>b>>x>>y;
			vec.push_back(P(x,y));
			na[i]=b;
			nb[b]=i;
		}
		
		rep(i,vec.size()){
			for(int j=i+1;j<vec.size();j++){
				int p,q;
				y=vec[i].imag();
				x=vec[i].real();
				p=vec[j].imag();
				q=vec[j].real();
				if((x-q)*(x-q)+(y-p)*(y-p)<=2500){
					d[i][j]=(double)sqrt((x-q)*(x-q)+(y-p)*(y-p));
					d[j][i]=(double)sqrt((x-q)*(x-q)+(y-p)*(y-p));
				}
			}
		}
		cin>>m;
		rep(i,m){
			cin>>s>>g;
			s=nb[s];g=nb[g];
			//s=na[s];g=na[g];
			for(int i=0;i<n;i++){
				pre[i]=MAX;
				v[i]=MAX;
				use[i]=0;
			}
			v[s]=0;
			pre[s]=-1;
			now=s;
			bool update=true;
			while(update){
	//			cout<<"now       "<<now<<endl;
				//cout<<now<<endl;
				update=false;
				use[now]=1;
		//		cout<<now<<"   now";
				rep(i,n){
					//cout<<d[now][i]+v[now]<<' '<<v[i];
					if(d[now][i]+v[now]<v[i]){
						v[i]=d[now][i]+v[now];
						pre[i]=now;
						
					}
	//		cout<<' '<<update<<' '<<use[i]<<endl;
				}
				double f=50000;
				rep(i,n){
					if(use[i]==0&&f>v[i]){
						now=i;
						f=v[i];
						update=true;
						
					}
				}
			}
			//cout<<now<<endl;
			if(v[g]==MAX)
			cout<<"NA"<<endl;
			else{
				deque<int> que;
				now=g;
			//	cout<<"         ";
				while(now!=-1){
					que.push_back(na[now]);
					now=pre[now];
				}
				cout<<que.back();
				que.pop_back();
				while(!que.empty()){
						cout<<' ';
					
					cout<<que.back();
					que.pop_back();
				}
				cout<<endl;
				//cout<<d[s][g]<<endl;
			}
//			rep(i,n)
	//		cout<<i<<"         fd"<<v[i]<<endl;
			//cout<<d[8][19]<<endl;
		}
		vec.clear();
		na.clear();
	}
	return 0;
}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

llong N;
int main(void) {
    cin >> N;

    vecllong A(N);

    for (llong i = 0; i < N; i++) {
        cin >> A[i];
    }

    llong ans = 0;
    llong leftIndex = 0;
    llong rightIndex = 0;
    llong sum = 0;

    while (leftIndex < N) {
        while (rightIndex < N && ((sum ^ A[rightIndex]) == (sum + A[rightIndex]))) {
            sum += A[rightIndex++];
            ans++;
        }
        sum ^= A[leftIndex++];
        ans += rightIndex - leftIndex;
    }

    cout << ans << endl;

    return 0;
}


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

const int64_t inf = (1LL << 50);

int64_t dp[200010][16];

vector<int64_t> computeScore(const std::vector<int64_t>& a) {
    int n = a.size();
    for (int x = 0; x <= 15; x++) {
        dp[n - 1][x] = 2 * x;
    }

    for (int i = n - 2; i >= 0; i--) {
        int64_t cur = a[i];
        for (int x = 0; x <= 15; x++) {
            dp[i][x] = inf;

            int64_t nxt = a[i + 1];
            int y = 0;

            while (nxt < cur) {
                nxt *= 4;
                y++;
            }

            if (y > 15) dp[i][x] = min(dp[i][x], dp[i + 1][15] + 2 * ((n - i - 1) * (y - 15) + x));
            else dp[i][x] = min(dp[i][x], dp[i + 1][y] + 2 * x);

            cur *= 4;
        }
    }
    std::vector<int64_t> score(n);
    for (int i = 0; i < n; i++) {
        score[i] = dp[i][0];
    }
    return score;
}

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

    int n;
    cin >> n;

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

    vector<int64_t> score1 = computeScore(a);

    reverse(a.begin(), a.end());

    vector<int64_t> score2 = computeScore(a);

    reverse(score2.begin(), score2.end());

    int64_t ans = (1LL << 50);

    for (int i = 0; i < n; i++) {
        ans = min(ans, i + score1[i] + (i > 0 ? score2[i - 1] : 0));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 29952
n = int(input())
num_li = list(map(int,input().split()))
 
cnt = 0
ans = 0
 
for i in range(n-1):
    if num_li[i] >= num_li[i+1]:
        cnt += 1
        ans = max(ans,cnt)
        continue
    cnt = 0

print(ans)

Measured memory_bytes: 14224
def saiki(bef,ind,b):
    global n
    if ind==n:
        #print(b)
        calc(b)
        return
    for i in range(1,m+1):
        if i<bef:
            continue
        saiki(i,ind+1,b+[i])
def calc(b):
    global q,info,ans
    aa=0
    for i in range(q):
        if b[info[i][1]-1]-b[info[i][0]-1]==info[i][2]:
            aa+=info[i][3]
    if ans<aa:
        ans=aa
n,m,q=map(int,input().split())
info=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    info.append([a,b,c,d])
ans=0
saiki(0,0,[])
print(ans)

Measured memory_bytes: 68696
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;


int main () {
	string s;
	cin >> s;
	if (s[0] == 'A')
		cout << "T";
	if (s[0] == 'T')
		cout << "A";
	if (s[0] == 'C')
		cout << "G";
	if (s[0] == 'G')
		cout << "C";

}

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

const int maxn = 200010;
int n, a[maxn], f[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        f[a[i]] = max(f[a[i]], f[a[i] - 1] + 1);
    }
    cout << n - *max_element(f + 1, f + n + 1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,n,b,c,d,i,m=0;
    string s;
    cin >> s;
    for(i=0;i<s.length();i++)
    {
        if(s[i]=='7')
            m++;


    }
    if(m==0)
    cout << "No" << endl;
    else
    cout << "Yes" << endl;




}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    string ans = "";

    rep(i,len(s)) if(i % 2 == 0) ans += s[i];
    print(ans);

    return 0;
}

Measured memory_bytes: 592
fn main() {
    proconio::input! {
        n: usize,
        a: [proconio::marker::Usize1;n],
    }
    let mut v=vec![0i64;n];
    for &a in &a {
        v[a]+=1;
    }
    let s=v.iter().map(|v|v*(v-1)/2).sum::<i64>();
    for a in a {
        let v=v[a];
        println!("{}",s-v*(v-1)/2+(v-1)*(v-2)/2);
    }
}

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

vector<vector<int>> G;

int dfs(int cur) {
    vector<int> dp;
    for(auto &to : G[cur]) dp.push_back(dfs(to));
    sort(dp.begin(), dp.end(), greater<int>());
    int res = 0;
    rep(i, 0, dp.size()) res = max(res, dp[i] + i + 1);
    return res;
}

int main() {
    int N; cin >> N;
    G.resize(N);
    rep(i, 0, N-1) {
        int a; cin >> a;
        a--;
        G[a].push_back(i + 1);
    }
    cout << dfs(0) << endl;
    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    int N = S.length();
    int dp[N][2];
    int init = S[0] - '0';
    dp[0][0] = min(init, 11-init);
    dp[0][1] = min(init+1, 10-init);
    for(int i = 1; i < N; i++){
        int dig = S[i] - '0';
        dp[i][0] = min(dp[i-1][0] + dig, dp[i-1][1] + (10-dig));
        dig++;
        dp[i][1] = min(dp[i-1][0] + dig, dp[i-1][1] + (10-dig));
    }
    cout << dp[N-1][0] << endl;
    return 0;
}

Measured memory_bytes: 9220
import collections
d={}
d["AC"]=0
d["WA"]=0
d["TLE"]=0
d["RE"]=0
n=int(input())
for i in range(n):
    s=str(input())
    d[s]+=1
#print(d)
print("AC " +"x "+ str(d["AC"]))
print("WA "+ "x "+str(d["WA"]))
print("TLE "+"x "+str(d["TLE"]))
print("RE "+ "x "+str(d["RE"]))


Measured memory_bytes: 9488
#include<stdio.h>

void bubblesort(int a[],int n){
  int i,j;
  int esc;
  for(i=1;i<n;i++){
    j = i;
    while(a[j]>a[j-1]&&j>0){
      esc = a[j];
      a[j] = a[j-1];
      a[j-1] = esc;
      j--;
    }
  }
}



int main(void){
  int a[5];
  int i;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
  }
  bubblesort(a,5);
  for(i=0;i<5;i++){
    printf("%d",a[i]);
    if(i!=4)printf(" ");
  }
  puts("");
  return 0;
}

Measured memory_bytes: 1828
#include <iostream>

using namespace std;

typedef long long ll;


int main() {
  ll t1,t2;
  ll a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;

  if(t1*a1 < t1*b1) {
    swap(a1,b1);
    swap(a2,b2);
  }
  

  ll tmp1 = t1*a1-t1*b1;
			  
  ll tmp2 = t1*a1+t2*a2-(t1*b1+t2*b2);
  if(tmp2 == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  else if (tmp2 > 0) {
    cout << 0 << endl;
    return 0;
  }

  if((tmp1 % (-tmp2)) == 0) {
      cout << (tmp1 / -tmp2) * 2 << endl;
    }
    else {
      cout << (tmp1 / -tmp2) * 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


N = 10 ** 5
primes = prime_numbers(N)
a = [1 if n in primes and (n + 1) // 2 in primes else 0 for n in range(N + 1)]
a = tuple(accumulate(a))

ans = []
Q, *LR = map(int, open(0).read().split())
for l, r in zip(*[iter(LR)] * 2):
    ans.append(a[r] - a[l - 1])

print('\n'.join(map(str, ans)))


Measured memory_bytes: 29016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin>>K>>S;
  int ans = 0;
  for(int X=0; X<=K;X++){
    for(int Y=0; Y<=K; Y++){
      int Z = S-X-Y;
      if(Z>=0&&Z<=K){
        ans ++;
      }
    }
  }
  cout<<ans<<endl;
}



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

vector<int> split(int i) {
  vector<int> ans;
  while (i > 0) {
    int digit = i % 10;
    i /= 10;
    ans.push_back(digit);
  }
  reverse(ans.begin(), ans.end());
  return ans;
}

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

  vector<pair<int, int> > rules;

  rep(i, m) {
    int s, c;
    cin >> s >> c;
    rules.push_back(make_pair(s, c));
  }

  int first = 0;
  int last = 9;

  if (n > 1) {
    first = 1;
    rep(i, n - 1) {
      first = first * 10;
      last = last * 10 + 9;
    }
  }

  for (int i = first; i <= last; i++) {
    vector<int> digits = {0};
    if (i > 0) digits = split(i);
    int count = 0;

    for (auto rule : rules) {
      if (digits[rule.first - 1] == rule.second) {
        count++;
      } else {
        break;
      }
    }

    if (count == m) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,M;
    int X[114514];
    int maxX=0;
    int F[114514]={},G[114514]={},H[114514]={};
    cin >> N >> M;
    REP(i,N){
        cin >> X[i];
        H[X[i]]++;
        maxX=max(maxX,X[i]);
    }
    REP(i,maxX+1){
        G[i%M]+=H[i]/2;
        F[i%M]+=H[i];
    }
    int Ans=0;
    Ans+=F[0]/2;
    if(M%2==0){
        Ans+=F[M/2]/2;
    }
    
    //REP(i,M){cout << G[i] << " ";}cout << endl;
    
    for(int i=1;i<(M+1)/2;i++){
        if(F[i]>F[M-i]){
            Ans+=F[M-i];
            Ans+=min(((F[i]-F[M-i])/2),G[i]);
        }else{
            Ans+=F[i];
            Ans+=min(((F[M-i]-F[i])/2),G[M-i]);
        }
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 3840
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;

signed main(){
    cin >> N >> S;
    if(N%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    rep(i, N/2){
        if(S[i] != S[N/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

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


Measured memory_bytes: 4052
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int main(){
	int h,w;
	cin >> h >> w;
	for(int i= 0;i < h;++i){
		for(int q = 0;q < w;++q){
			string s;
			cin >> s;
			if(s == "snuke"){
				cout << (char)(q + 'A') << i+1 << endl;
				return 0;
			}
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  int A;
  int count;
  int ans = 10000;
  for(int i=0; i<N; i++){
    cin >> A;
    count = 0;
    while(A%2 == 0){
      A /= 2;
      count++;
    }
    if(count < ans){
      ans = count;
    }
  }
  cout << ans << endl;
}

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

struct menu{
  int time,onetime,retime;
}r[5];

bool cmp(menu a,menu b){
  if(a.onetime>=b.onetime)return true;
  return false;
}

int main(void){
  int sumtime=0, count=0;
  for(int i=0;i<5;i++){
    cin>>r[i].time;
    r[i].onetime=r[i].time%10;
    if(r[i].onetime==0){
      sumtime+=r[i].time;
      count++;
    }
  }

  sort(r,r+5,cmp);
  for(int t=0;t<5-count-1;t++)sumtime+=(r[t].time/10+1)*10;
  sumtime+=r[5-count-1].time;
  cout<<sumtime;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main (int ac, char **av) {
  int a,b = 0;
  fscanf(stdin, "%d %d\n", &a, &b);                                                                                                                          
  fprintf(stdout, "%d %d\n", a*b, 2*a+2*b);
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  char a;
  cin>>a;
  if(a<'a'){
    COUT('A');
  }
  else COUT('a');
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int cp(int x,int y){
    return x<y?x:y;
}
int main(){
    int i=0,n,tarou=0,hanako=0;
    char str1[101],str2[101];
    scanf("%d",&n);
    while(i<n){
        scanf("%s",str1);
        scanf("%s",str2);;
        if(strcmp(str1,str2)>0){
            tarou+=3;
        }else if(strcmp(str1,str2)<0){
            hanako+=3;
        }else{
            tarou++;
            hanako++;
        }
        i++;
    }
    printf("%d %d\n",tarou,hanako);
    return 0;
}


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

int main(){
  int a,b,c,d;
  int variables;
  variables = scanf("%d %d %d %d", &a, &b, &c, &d);
  
  int start = max(a, c);
  int stop  = min(b, d);
  cout << (start < stop ? stop-start : 0) << endl;
  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const int MOD = 1000000007;

int main(){
    LL H,W,K;
    cin>>H>>W>>K;
    
    V<Vll> dp(H+1,Vll(W,0));
    dp[0][0] = 1;
    REP(i,H){
        REP(j,W){
            REP(b,1<<(W-1)){
                bool ok = true;
                REP(k,W-2) if((b & (1<<k)) && (b & (1<<k+1))) ok = false;
                if(!ok) continue;
                int nj = j;
                if(b & (1<<j)) nj = j+1;
                else if(j>0 && (b & (1<<(j-1)))) nj = j-1;
                dp[i+1][nj] = (dp[i+1][nj] + dp[i][j]) % MOD;
            }
        }
    }

    cout<<dp[H][K-1]<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

int gcd(int a, int b) {
  for (int i = a; i >= 1; --i)
    if (a % i == 0 && b % i == 0) return i;
  return 1;
}

void solve() {
  ll a, b;
  in(a, b);
  print(a*b/gcd(a,b));
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
B = []
for i in range(M):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

par = [-1]*N
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]



for i in range(M):
    unite(A[i]-1, B[i]-1)

M = 0
for i in range(N):
    M = max(M, size(i))
print(M)

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  for (int i = 0; i < d.size(); i++) {
  }
  cout << d.size() << endl;
}


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

int a[10000], b[10000];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", a + i);
	f(i, 0, n)scanf("%d", b + i);
	ll o = 0, t = 0;
	f(i, 0, n)if (a[i] > b[i])o += a[i] - b[i];
	else {
		t += b[i] - a[i] + 1 >> 1;
		if (b[i] - a[i] & 1)++o;
	}
	printf("%s\n", t >= o ? "Yes" : "No");
}

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

using namespace std;
typedef long long int ll;


int main()
{
	ll x;cin>>x;
	
	map <ll,ll> p,q;
	for(ll i=0;i<=2511;i++) {p[powl(i,5)]=i;q[powl(i,5)]=i;}
	for(ll i=-2511;i<=-1;i++){ p[powl(i,5)]=i;q[powl(i,5)]=i;}
	
	
	ll a=0,b=0;if(p[x]!=0)a=p[x];
	for(auto it:q)
	{
		if(p[it.first+x]!=0)
		{
			b=it.second;a=p[it.first+x];
		}
	}
		
	cout<<a<<" "<<b;
		
	
}


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

int cmp(const void *a, const void *b) {
    return (*(const int*)b)-(*(const int*)a);
}

int n;
int a[100];
int main() {
    cin >> n;
    int cnt=0;
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i];
    }
    qsort(a, n, sizeof(int), cmp);
    int x=+1;
    for(int i = 0 ; i < n ; i++) {
        cnt += a[i]*(x);
        x = x*(-1);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

struct edge{
    int to;
    int cost;
};


vector<ll> dist;
vector<vector<edge>> g;

void dfs(int prev, int v, ll cost){
    dist[v] = cost;

    rep(i, g[v].size()){
        edge e = g[v][i];
        if(e.to == prev){
            continue;
        }
        dfs(v, e.to, cost + e.cost);
    }
    return;

}



int main(){
    int N;
    cin >> N;
    g = vector<vector<edge>>(N);
    dist = vector<ll>(N);
    rep(i, N - 1){
        int a, b, c;
        cin >> a >> b >> c;
        a --;
        b --;
        g[a].push_back(edge{b, c});
        g[b].push_back(edge{a, c});
    }
    int Q, K;
    cin >> Q >> K;
    vector<int> xs(Q, 0);
    vector<int> ys(Q, 0);
    rep(i, Q){
        int x, y;
        cin >> x >> y;
        x --;
        y --;
        xs[i] = x;
        ys[i] = y;
    }
    K --;
    dfs(-1, K , 0);



    rep(i, Q){
        ll ans = dist[xs[i]] + dist[ys[i]];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 13568
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund
#define pb push_back

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

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

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

int sub(int a,int b)
{
	return (a-b+MOD)%MOD;
}

int add(int a,int b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,k,dp[N],h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(raand()%MOD+13893829);
	cin>>n>>k;
	for (int i=1;i<n;++i) dp[i]=MOD;
	for (int i=0;i<n;++i)
	{
		cin>>h[i];
	}
	for (int i=0;i<n-1;++i) for (int j=1;j<=k;++j)
	{
		dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
	}
	cout<<dp[n-1];
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, ans = 0;
    cin >> n;
    vector<PL> v(n);
    rep(i, n)
    {
        cin >> v[i].fi;
        v[i].se = i;
    }

    sort(all(v));

    multiset<ll> se;
    se.insert(v.back().se);
    se.insert(-1);
    se.insert(-1);
    se.insert(-1);
    se.insert(n);
    se.insert(n);
    se.insert(n);

    for (int i = n - 2; 0 <= i; i--)
    {
        ll now = v[i].se;
        ll ue = *(++se.lower_bound(now)) - *(se.lower_bound(now));
        ll st = *(--se.lower_bound(now)) - *(----se.lower_bound(now));

        ans += v[i].fi * ue * (now - *(--se.lower_bound(now)));
        ans += v[i].fi * st * (*(se.lower_bound(now)) - now);
        //ans -= v[i].fi;

        se.insert(now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void) {
  int N;
  string c;
  cin >> N >> c;

  int ans = N;
  int cnt = 0;
  int l = 0, r = N-1;
  while (l < r) {
    if (c[l]=='R') {l++; continue;}
    if (c[r]=='W') {r--; continue;}
    if (c[l]=='W' && c[r]=='R') {
      cnt++;
      l++;
      r--;
    }
  }
  ans = min(ans, cnt);

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


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPalindrome(string str)
{
	ll i,j,k,l,n;
	l=str.length();
	for(i=0;i<l/2;i++)
	{
		if(str[i]==str[l-i-1])
			continue;
		else
			return 0;
	}
	return 1;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
		string str;
		ll n,i,j,k,l,m;
		cin>>str;
		if(isPalindrome(str))
		{
			string s1="";
			n=str.length();
			for(i=0;i<(n-1)/2;i++)
				s1+=str[i];
			if(isPalindrome(s1))
			{
				string s2="";
				for(i=((n+3)/2)-1;i<n;i++)
					s2+=str[i];
				if(isPalindrome(s2))
					cout<<"Yes\n";
				else
					cout<<"No\n";
			}
			else
				cout<<"No\n";
		}
		else
		{
			cout<<"No\n";
		}
		return 0;
}
	

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

#define CAKES 4
#define DONUTS 7
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  string ans = "No";
  /* cakes の個数は 0以上, N/4以下, donuts の個数は 0以上, N/7n以下 */
  rep(i, n/4) {
    rep(j, n/7) {
      if (CAKES*i + DONUTS*j == n)
      {
        ans = "Yes";
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

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

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

  char c;
  cin >> c;

  if (c == 'A') cout << "T" << endl;
  if (c == 'T') cout << "A" << endl;
  if (c == 'G') cout << "C" << endl;
  if (c == 'C') cout << "G" << endl;
  return 0;
}

Measured memory_bytes: 3564
S = input()

L = 0
U = len(S)

while U - L > 1:
    M = (U + L) // 2

    OK = False
    for i in range(2):
        A = i
        B = M
        if A % 2 != B % 2: B -= 1

        NG = False
        for s in S:
            if s == '0':
                A -= 1
                B -= 1
            elif s == '1':
                A += 1
                B += 1
            else:
                A -= 1
                B += 1

            if A < 0: A += 2
            if B > M: B -= 2
            if A > B:
                NG = True
                break

        if not NG:
            OK = True
            break

    if OK:
        U = M
    else:
        L = M

print(U)


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
ll n, x;
struct N {
  ll b, l, u;
};
vector<N> ns;
vector<ll> ss;
ll sub = 0;

bool operator<(const N &l, const N &r) {
  return l.b * l.l + (x - l.b) * l.u > r.b * r.l + (x - r.b) * r.u;
}

bool f(ll m) {
  ll q = m / x;
  ll k = m - q * x;

  for (int i = 0; i < n; i++) {
    ll sum = 0;
    if (i < q) {
      sum = ss[q + 1] - (ns[i].b * ns[i].l + (x - ns[i].b) * ns[i].u);
    } else {
      sum = ss[q];
    }

    if (k >= ns[i].b) {
      sum += ns[i].l * ns[i].b + (k - ns[i].b) * ns[i].u;
    } else {
      sum += ns[i].l * k;
    }

    if (sum >= sub) return true;
  }

  return false;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> x;
  ns.resize(n);
  ss.resize(n + 1);
  for (int i = 0; i < n; i++) cin >> ns[i].b >> ns[i].l >> ns[i].u;
  sort(ns.begin(), ns.end());
  for (int i = 0; i < n; i++) sub += ns[i].b * ns[i].l;
  for (int i = 0; i < n; i++) ss[i + 1] = ss[i] + ns[i].b * ns[i].l + (x - ns[i].b) * ns[i].u;
  ll l = 0, r = x * n;
  if (f(0)) {
    cout << 0 << endl;
    return 0;
  }
  while (r - l > 1) {
    ll m = (l + r) / 2;
    if (f(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

struct union_find {
	int par[MAX_N];
	int Size[MAX_N];
	union_find(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			Size[i] = 1;
		}
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		if (same(x, y))return;
		Size[root(x)] += Size[root(y)];
		par[root(y)] = root(x);
	}
};


int main(){
    int n,m;
    cin>>n>>m;
    struct union_find U(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        U.unite(a,b);
    }

    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,U.Size[U.root(i)]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 5200
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  var w = {SUN:7,MON:6,TUE:5,WED:4,THU:3,FRI:2,SAT:1};
  return w[s];
}

Measured memory_bytes: 22076
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)
for i in range(n-1):
    if (A[i]+1) == (A[i+1]):
        ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 61744
s = str(input())
t = str(input())

ans = 'No'

if len(s) + 1 == len(t):
    i = 0
    for l in s:
        if l == t[i]:
            if len(s) == i + 1:
                ans = 'Yes'
            i += 1
        else:
            break;

print(ans)


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

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

typedef long long Int;
typedef pair<Int,Int> P;

Int power(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}


int main() {
    Int N, M;
    cin >> N;
    M = power(2,N);

    vector<Int> A(M);
    rep(i,M) cin >> A[i];

    vector<P> m1(M), m2(M);
    rep(i,M) {
        m1[i] = make_pair(A[i],i);
        m2[i] = make_pair(0,-1);
    }

    rep(i,N) rep(k,M) {
        if (!(k & (1<<i))) {
            Int j = (k | (1<<i));
            if (m1[k].first > m1[j].first) {
                m2[j] = m1[j];
                m1[j] = m1[k];
                if (m2[k].first > m2[j].first) {
                    m2[j] = m2[k];
                }
            }
            else if (m1[k].first == m1[j].first) {
                if (m1[k].second == m1[j].second) {
                    if (m2[k].first > m2[j].first) {
                        m2[j] = m2[k];
                    }
                }
                else {
                    m2[j] = m1[k];
                }
            }
            else if (m1[k].first > m2[j].first) {
                m2[j] = m1[k];
            }
        }
    }
    
    

    Int ans = 0;
    rep1(i,M-1) {
        ans = max(ans, m1[i].first + m2[i].first);
        cout << ans << endl;
    }



    return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define _USE_MATH_DEFINES
#define print(val) print_helper(#val, val);
#define bg begin
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void err() {cout << "-1\n";}
template <typename T>
void print_c(T & a) {
for_each(begin(a),end(a),[](auto & i){cout << i << " ";}); cout << "\n"; }
template <typename T, typename V>
void fill(T & collection, V val) {fill(begin(collection),end(collection),val);}
template <typename T>
void print_helper(string name, T val) {cout << name << ": " << val << "\n";}

int main() {
  fast_io
  int r; cin >> r;
  cout << setprecision(10) << 2*M_PI*r << "\n"; 
}


Measured memory_bytes: 3768
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
ans = 0
i = 0
while(m > 0):
    if ab[i][1] <= m:
        m -= ab[i][1]
        ans += ab[i][0] * ab[i][1]
    else:
        ans += ab[i][0] * m
        m -= ab[i][1]
    i += 1
print(ans)


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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;

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

        int c = 0;
        for (int i=0; i<n; ++i) {
            if (a[i] * n <= sum) {
                c ++;
            }
        }
        cout << c << endl;
    }
    return 0;
}


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

long long mem[105][100005];
int w[100005] , v[100005] ;
int n,cap;
long long ans=0;

int main()

{
//	mem[0]=0;
	cin>>n>>cap;
	for(int i=1;i<=n;i++)
	cin>>w[i]>>v[i];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=cap;j++)
		{
			if(j >= w[i])
			{
				mem[i][j] = max (mem[i-1][j] , v[i] + mem[i-1][j - w[i]]);
			}
			else
			mem[i][j] = mem[i-1][j];
			
			ans = max(ans , mem[i][j]);
		}
		
	//	cout<<ans<<endl;
		
	}
	
	cout<<ans;
}

Measured memory_bytes: 78592
// Itp1_4_c.java
import java.io.*;
import java.lang.Integer;
public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
loop:		while(true) {
				String in  = br.readLine() ;
				String[] eq = in.split(" ");
				int[] nums = new int[2];
				nums[0] = Integer.parseInt(eq[0]);
				nums[1] = Integer.parseInt(eq[2]);
				switch(eq[1]) {
					case "+":
					System.out.println(nums[0]+nums[1]);
					break;
					case "-":
					System.out.println(nums[0]-nums[1]);
					break;
					case "*":
					System.out.println(nums[0]*nums[1]);
					break;
					case "/":
					System.out.println(nums[0]/nums[1]);
					break;
					default:
					break loop;
				}
			}
		} catch ( IOException e ) {
			System.out.println("??¨??????????????????????????????");
		}
	}
}

Measured memory_bytes: 24224
/*
g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
main.exe
*/

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}









int main(){
    int n;
    cin >> n;
    ll f = 0;

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

    cout << f << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

ll Fac[100010], n, m;

int main()
{
	scanf("%lld%lld", &n, &m);
	for(int i = 0; i <= 100000; i++) Fac[i] = !i ? 1 : Fac[i - 1] * i % P;
	if(n == m - 1 || m == n - 1) printf("%lld\n", Fac[n] * Fac[m] % P); else
	if(n == m) printf("%lld\n", 2 * Fac[n] * Fac[m] % P); else puts("0");
	return 0;
}

Measured memory_bytes: 1024