akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    int N;string S;
    cin >> N >> S;
    int cnt = 0,M = 0;
    REP(i,N){
        if(S[i] == '(') cnt++;
        else if(cnt > 0 && S[i] == ')') cnt--;
        else M++;
    }
    string L = "",R = "";
    REP(i,cnt) R += ')';
    REP(i,M) L += '(';
    cout << L + S + R << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int GCD(int a, int b) {
    if (b == 0) {
        return a;
    }
    return GCD(b, a % b);
}

int main() {
    int a, b;
    cin >> a >> b;
    int gcd = GCD(a, b);
    cout << gcd << endl;

    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.rbegin(),v.rend()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;

int main()
{
    int n,i,j,val=0,cost=0,ans=0;
    cin>>n;
    vector<int>v,c;
    for(i=0;i<n;i++)
    {
        cin>>j;
        v.pb(j);
    }
    for(i=0;i<n;i++)
    {
        cin>>j;
        c.pb(j);
    }
    for(i=0;i<n;i++)
    {
        if(v[i]>c[i])
            cost+=(v[i]-c[i]);
    }
    cout<<max(0,cost)<<endl;
    return 0;
}


Measured memory_bytes: 3548
/**
 *    author:  tourist
 *    created: 20.11.2019 13:53:05       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (x == 1) a[y - 1] |= 1;
    if (x == n) a[y - 1] |= 2;
    swap(x, y);
    if (x == 1) a[y - 1] |= 1;
    if (x == n) a[y - 1] |= 2;
  }
  for (int i = 1; i < n - 1; i++) if (a[i] == 3) { cout << "POSSIBLE" << '\n'; return 0; }
  cout << "IMPOSSIBLE" << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main()
{
    int number = 0,ive,max = 0,top = 1,num;
    cin >> number >> ive;
    int men[1000001] = {0};
    int numbers = number;
    for(int i = 0; i < ive; i++){
        cin >> number >> num;
        men[number] += num;
        if(num > 0){
            if(men[number] >= max){
                if(men[number] == max){
                    if(top > number){
                        top = number;
                        max = men[number];
                    }
                }else{
                    top = number;
                    max = men[number];
                }
                cout << top << " " << max << endl;
            }else{
                cout << top << " " << max << endl;
            }
        }else{
            if(number == top){
                if(men[number] < max){
                    max = 0;
                    top = 0;
                    for(int k = numbers; k > 0; k--){
                        if(max <= men[k]){
                            top = k;
                            max = men[k];
                        }
                    }
                    cout << top << " " << max << endl;
                }
            }else{
                cout << top << " " << max << endl;
            }
        }
    }
        return 0;
}

Measured memory_bytes: 5080
#include <stdio.h>
#include <inttypes.h>

int64_t neko;

void mofu(int64_t nyan) {
	if (neko < nyan) neko = nyan;
}

int main(void) {
	int64_t a, b, c, d;
	int i, j;
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64, &a, &b, &c, &d) != 4) return 1;
	neko = a * c;
	for (i = 0; i < 5 && a + i <= b; i++) {
		for (j = 0; j < 5 && c + j <= d; j++) mofu((a + i) * (c + j));
		for (j = 0; j < 5 && d - j >= c; j++) mofu((a + i) * (d - j));
	}
	for (i = 0; i < 5 && b - i >= a; i++) {
		for (j = 0; j < 5 && c + j <= d; j++) mofu((b - i) * (c + j));
		for (j = 0; j < 5 && d - j >= c; j++) mofu((b - i) * (d - j));
	}
	printf("%" PRId64 "\n", neko);
	return 0;
}


Measured memory_bytes: 1732
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))
#print(Alist)
#print(Blist)
#print(Clist)
N=int(input())
mylist=[]
flaglist=[0,0,0,0,0,0,0,0] #8個のフラッグリスト
for i in range(N):
    mylist.append(int(input()))
    #print(mylist)
    
for i in range(3):
    for j in range(N):
        if Alist[i]==mylist[j]:
            flaglist[0]+=1
            
for i in range(3):
    for j in range(N):
        if Blist[i]==mylist[j]:
            flaglist[1]+=1
            
            
for i in range(3):
    for j in range(N):
        if Clist[i]==mylist[j]:
            flaglist[2]+=1
#ここまで横の列

for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[3]+=1
    elif Blist[0]==mylist[i]:
        flaglist[3]+=1
    elif Clist[0]==mylist[i]:
        flaglist[3]+=1
        
for i in range(N):
    if Alist[1]==mylist[i]:
        flaglist[4]+=1
    elif Blist[1]==mylist[i]:
        flaglist[4]+=1
    elif Clist[1]==mylist[i]:
        flaglist[4]+=1

for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[5]+=1
    elif Blist[2]==mylist[i]:
        flaglist[5]+=1
    elif Clist[2]==mylist[i]:
        flaglist[5]+=1
        
for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[6]+=1
    elif Blist[1]==mylist[i]:
        flaglist[6]+=1
    elif Clist[0]==mylist[i]:
        flaglist[6]+=1
        
for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[7]+=1
    elif Blist[1]==mylist[i]:
        flaglist[7]+=1
    elif Clist[2]==mylist[i]:
        flaglist[7]+=1
        
if max(flaglist)>=3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3192
#include<stdio.h>
#define N 101
int n,g[N][N],d[N],q[N],top,tail;

int pop(void){//
int k;
k=q[top];
  if(top==N-1)top=0;
  else top++;
return k;
}

void push(int k){
 if(tail==N-1)tail=0;
 else tail++;
 q[tail-1]=k;
}
void bfs(void){
  int i,j,u,judge[n];
  q[0]=1;
  top=0;
  tail=1;
  d[1]=0;
  for(i=2;i<=n;i++){
    d[i]=-1;
    judge[i]=1;
  }
  
  while(tail!=top){
    u=pop();
    for(i=1;i<=n;i++){
      if(g[u][i]==1&&judge[i]==1){
        judge[i]=0;
        d[i]=d[u]+1;
        push(i);
      }
    }
    judge[u]=-1;
  }
}


int main(){
  int i,j,num,k,r;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      g[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d%d",&num,&k);
    for(j=1;j<=k;j++){
        scanf("%d",&r);
        g[i][r]=1;
    }
  }
  bfs();

  for(i=1;i<=n;i++){
  printf("%d %d\n",i,d[i]);
  }
  return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

const int MAXL = 128;

int query(const string& s) {
  cout << "? " << s << '\n';
  cout.flush();
  int ret;
  cin >> ret;
  return ret;
}

vector<char> charset;

string solve(int a, int b, const vector<int>& f, int L) {
  if (a == b) return "";
  if (b - a == 1) return string(f[a], charset[a]);

  int m = (a + b) / 2;
  auto A = solve(a, m, f, L);
  auto B = solve(m, b, f, L);

  string ret;
  int j = 0;
  for (int i = 0; i < (int)A.size(); ++i) {
    while (j < (int)B.size()) {
      string q = ret;
      q.push_back(B[j]);
      q += A.substr(i);
      if (query(q) == L - q.size()) {
        ret.push_back(B[j]);
        j++;
      } else {
        break;
      }
    }
    ret.push_back(A[i]);
  }
  ret += B.substr(j);
  return ret;
}

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

  for (int i = 0; i < 26; ++i) {
    charset.push_back('a' + i);
  }
  for (int i = 0; i < 26; ++i) {
    charset.push_back('A' + i);
  }
  for (int i = 0; i < 10; ++i) {
    charset.push_back('0' + i);
  }

  int M = charset.size();
  vector<int> f(M);
  for (int i = 0; i < M; ++i) {
    f[i] = MAXL - query(string(MAXL, charset[i]));
  }

  int L = accumulate(f.begin(), f.end(), 0);

  string ans = solve(0, f.size(), f, L);
  cout << "! " << ans << '\n';
  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long N;
    std::cin >> N;
    std::vector<long> X1;
    long X[200000]={};
    for(long i=0; i<N; i++){
        long Xe;
        std::cin >> Xe;
        X1.push_back(Xe);
        X[i]=Xe;
    }
    std::sort(X1.begin(),X1.end());
    long cent=X1[N/2-1];
    for(long i=0; i<N; i++){
        if(X[i]<=cent){
            std::cout << X1[N/2] << std::endl;
        }else{
            std::cout << cent << std::endl;
        }
    }
    return 0;
}

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

int main(void){
	int n, q;
	cin >> n >> q;
	set<int> st[n];
	for(int i = 0; i < n-1; ++i){
		int a, b;
		cin >> a >> b;
		a--; b--;
		st[a].insert(b);
		st[b].insert(a);
	}
	vector<long long> v(n);
	for(int i = 0; i < q; ++i){
		int p, x;
		cin >> p >> x;
		p--;
		v[p] += x;
	}
	queue<int> que;
	que.push(0);
	vector<bool> visited(n, false);
	while(!que.empty()){
		int now = que.front();
		que.pop();
		visited[now] = true;
		for(auto x : st[now]){
			if(visited[x]) continue;
			que.push(x);
			v[x] += v[now];
		}
	}
	for(int i = 0; i < n; ++i){
		cout << v[i];
		if(i != n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 32768
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  int n;
  string s;
  cin >> n >> s;
  if(n & 1 || s.substr(0, n / 2) != s.substr(n / 2, n / 2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d=a/b;
    int r=a%b;
    double f= double(a)/double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5)  << f;
    cout << endl;
}



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

int main(){
	char s[19];
	int i;
	for(i=0; i<19; i++){
		cin >> s[i];
	}
	
	for(i=0; i<5; i++){
		cout << s[i];
	}
	cout << ' ';
	for(i=6; i<13; i++){
		cout << s[i];
	}
	cout << ' ';
	for(i=14; i<19; i++){
		cout << s[i];
	}
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<60)
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll h, w;
    cin >> h >> w;
    // 右への移動量（重複あり、先頭を見れば最小を高速に求められる）
    multiset<ll> m;
    // {終点の左からの位置, 始点の左からの位置}
    set<pair<ll, ll>> s;

    // 1行分の始点をセット
    rep(i, w){
        s.insert({i, i});
        m.insert(0);
    }
    // どの始点からも到達できないk行目への対応
    m.insert(INFLL);
    s.insert({-1, -1});
    s.insert({w, w});

    // k行目のクエリを処理する場合、現在位置が[a[i], b[i]]の場合はb[i]+1まで右に移動する必要がある。
    // ただし、b[i]+1 >= wの場合は枠外として例外処理する。
    vi a(h), b(h);
    rep(i, h){
        // 0-Baseで入力
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;

        // 現在の終点が[a[i], b[i]]にあるものを更新していく
        while(1){
            // 終点がa[i]～を探す
            auto it = s.lower_bound({a[i], 0});
            // [a[i], b[i]]に収まっている更新対象が存在しない場合はループを抜ける
            if(it->first > b[i]) break;

            // 次の終点を参照し、b[i]+1以下なら統合してOKのためそのまま削除
            if(next(it)->first <= (b[i]+1)){
                // 更新対象を削除
                m.erase(m.find(it->first - it->second));
                s.erase(it);
            }
            // 次の終点を参照し、b[i]+1より大きいなら終点をb[i]+1に更新
            else{
                // 始点
                ll r = it->second;
                // 更新対象の既存情報を削除
                m.erase(m.find(it->first - it->second));
                s.erase(it);
                // 更新
                s.insert({b[i]+1, r});
                m.insert({b[i]+1-r});
            }
        }
        // k行目のクエリについて、mを参照して最小移動距離を求め、かつ下方向への移動量を加算
        ll tmp = *(m.begin()) + (i+1);
        // 候補が無い場合は-1
        if(tmp >= h+w) tmp = -1;
        cout << tmp << endl;
    }
}

Measured memory_bytes: 28212
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	int N, D, X;		cin >> N >> D >> X;
	V A(N);	VECCIN(A);
	long ans = 0;
	for(int i = 0 ; i < N ; i++){
		
      	int keep = 0;
     	while(1 + keep * A[i] <= D){
			ans += 1;
          	keep += 1;
        }
      
    }

	SCOUT(ans + X) << endl;

	return 0;
}


Measured memory_bytes: 256
S = input()
if S.count('N') > 0 and S.count('S') == 0 or S.count('N') == 0 and S.count('S') > 0 or S.count('E') > 0 and S.count('W') == 0 or S.count('E') == 0 and S.count('W') > 0:
    print('No')
else:
    print('Yes')

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

using namespace std;


int main()
{
	int a[3];
	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	sort(a, a + 3);
	if (a[2] == a[1] + a[0]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		Console.WriteLine("{0}",(char)(s[0]+1));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main(){
    int k;
    string s; 
    cin >> k;
    cin >> s;
    
    if(s.size()<=k) cout << s << endl;
    else{
        string t = s.substr(0,k);
        cout << t << "..." << endl;
    }
    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int query = 1;
int n;


void solve() 
{
	int x;
	cin >> x;
	for(int i = -1000; i <= 1000; i++)
	{
		for(int j = -1000; j <= 1000; j++)
		{
			int tempx = (i * i * i * i * i) - (j * j * j * j * j);
			if(tempx == x)
			{
				cout << i << " " << j << endl;
				return;
			}
		}
	}
}



 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

// ローリングハッシュ
// h = 2^64にすることでmod不要となる（オーバーフローしたら値が範囲内に戻る）
using ull = unsigned long long;

// sの中からtと一致する部分の各出現位置を返す関数である
vector<ll> rollingHash(string s, string t){
    
    vector<ll> index_list; //この配列に答えとなるindexたちを記録する
    
    ll SL = s.size();
    ll TL = t.size();
    
    ull b = 1e9 + 7; // hashの基数である

    // 蟻本でいう、bのm乗
    ull a = 1;
    for (int i = 0; i < TL; i++) a *= b;
    
    // sの最初のTL文字に関するハッシュ値を計算する
    ull sH = 0;
    for (int i = 0; i < TL; i++) sH = sH * b + s[i];
    
    // tの最初のTL文字に関するハッシュ値を計算する
    ull tH = 0;
    for (int i = 0; i < TL; i++) tH = tH * b + t[i];

    // sの始点を1つずつ進めながらハッシュ値をチェック
    for (int i = 0; i +TL <= SL; i++){ 
        
        if (sH == tH) index_list.push_back(i); //ハッシュ値が一致することを, Tの中にPと一致する箇所があることとみなす
        
        if (i + TL < SL) sH = sH*b + s[i+TL] - s[i] * a; // ハッシュ値の累積和を考えている
    }

    return index_list;
}

int main(){

    // input
    string s, t;
    cin >> s >> t;

    auto ans = rollingHash(s, t); //この配列に答えとなるindexたちをansへ保持する
    
    for(ll i : ans){
        cout << i << endl; //indexの値が小さい順に出力される
    }

    return 0;
}


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

int main(){
  int n,c=0; cin>>n;
  vector<ll> num(n);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll x; cin>>x;
    if(x<0){
      c++;
      x*=-1;
    }num[i]=x;
    ans+=num[i];
  }if(c%2!=0){
    sort(num.begin(),num.end());
    ans-=2*num[0];
  }
  cout<<ans<<endl;
}

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

#define INF 0x3f3f3f3f
#define MMS(x, y) memset((x), (y), sizeof(x))
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define EPS 1e-9

#define MAXN 100010

using namespace std;

int N;
unordered_map <int, int> M;

int main() {
    cin >> N;
    for (int i = 0, a; i < N; i++) {
        cin >> a;
        M[a] ++;
        M[a - 1] ++;
        M[a + 1] ++;
    }
    int maxx = 0;
    for (auto i : M) {
        maxx = max(maxx, i.second);
    }
    cout << maxx << "\n";
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


unsigned ll a, b;

void solve()
{
    cin >> a >> b;
    nout(floor(a*b));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  if(N==1){
    cout<<"Hello World"<<endl;
  }else if(N==2){
    int A,B;
    cin>>A>>B;
    cout<<A+B<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

int p[1005];
char s[1005];

int main()
{
	scanf("%s",s);
	int len = strlen(s);
	int h = 1;
	for(char i = 'a'; i <= 'z'; i++){
		int ans = 0;
		for(int j = 0; j < len; j++){
			if(s[j] == i) ans++;
		}
		p[h] = ans;
		h++;
	}
	int times = 0;
	for(int i = 1; i <= h; i++){
		if (p[i] % 2 == 0) times++;
	}
	if(times == h) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <complex>
#include <cmath>
using namespace std;
#define EPS 1.0e-10
#define PI 3.1415926535897932384 
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define RFOR(i,c) for(auto i=(c).rbegin();i!=(c).rend();++i)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())
// 実数の符号関数
inline int signum(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
//XY座標
#define X real()
#define Y imag()
// 点
typedef complex<int> P;

const int INF = 1<<28;
const int MOD = 1000000007;


P proj(P p, int rot, int rev){
	REP(i, rot){
		swap(p.X, p.Y);
		p.Y = -p.Y;
	}
	REP(i, rev	){
		p.X = -p.X;
	}
	return p;
}
int d[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

int w, h;
int Map[15][15];
int Map2[15][15];

int &get2(P p){
	return Map2[p.X][p.Y];
}

bool check(P b1, P b2, int rot, int rev){
	memcpy(Map2, Map, sizeof(Map));
	queue<P> q;
	q.push(P(0, 0));
	while(!q.empty()){
		P dir=q.front();
		q.pop();
		if(b1+dir != b2+proj(dir, rot, rev) && get2(b1+dir)==1 && get2(b2+proj(dir, rot, rev))==1){
			get2(b1+dir) = 0;
			get2(b2+proj(dir, rot, rev)) = 0;
			REP(i, 4){
				q.push(P(dir.X+d[i][0],dir.Y+d[i][1]));
			}
		}
	}
	REP(i, h+1)REP(j, w+1) if(Map2[j][i]) return 0;
	return 1;
}

bool solve(){
	vector<P> cand;
	RREP(i, h+1)RREP(j, w+1) if(Map[j][i]) cand.push_back(P(j, i));
	REP(i, cand.size())REP(j, i)REP(k, 4)REP(l, 2) if(check(cand[i], cand[j], k, l)) return 1;
	return 0;
}

main(){
	while(cin >> w >> h, w){
		memset(Map, 0, sizeof(Map));
		REP(i, h)REP(j, w) cin >> Map[j+1][i+1];
		cout << (solve()?"YES":"NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vector<int> clr(n);
  rep(i,n) cin >> clr.at(i);
  vector<long> dp(n+1,0);
  vector<long> hs(200001,0);
  dp.at(0) = 1;
  hs.at(clr.at(0)) = 1;
  for(int i=1;i<=n;i++){
    int c = clr.at(i-1);
    if(i != n){
      if(clr.at(i-1) == clr.at(i)) continue;
    }
    dp.at(i) = hs.at(c) % MOD;
    if(i == n) continue;
    hs.at(clr.at(i)) += dp.at(i);
    hs.at(clr.at(i)) %= MOD;
  }
  cout << dp.at(n) % MOD << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(n); i++)
typedef long long ll;

//// C
int main(){
    ll l, r; cin >> l >> r;
    r = min(r, l+4038);
    int ans=2018;
    for(ll i=l;i<=r;i++){
        for(ll j=i+1; j<=r; j++){
            int x = i*j%2019;
            ans = min(ans, x);
        }
    }
    cout << ans;
}

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

struct edge {
    int to;
    int w;
    edge(int to, int w) : to(to), w(w) {}
};

vector<int> color;

void dfs(vector<vector<edge>> &W, int n, int c) {
    color[n] = c;
    for (auto e : W[n]) {
        if (color[e.to] != -1) continue;
        int nc = (e.w % 2 == 0) ? c : (1 - c);
        dfs(W, e.to, nc);
    }
}

int main() {
    int N;
    cin >> N;
    vector<vector<edge>> W(N);

    REP(i, 0, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        W[u].push_back(edge(v, w));
        W[v].push_back(edge(u, w));
    }

    color.assign(N, -1);
    dfs(W, 0, 0);
    REP(i, 0, N) cout << color[i] << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Dice {
  vi face;
  void init() {
    face.resize(6);
  }
  void rotl() {
    vi newface = {face[4], face[1], face[0], face[3], face[5], face[2]};
    swap(face, newface);
  }
  void rotr() {
    vi newface = {face[2], face[1], face[5], face[3], face[0], face[4]};
    swap(face, newface);
  }
  void rotu() {
    vi newface = {face[1], face[5], face[2], face[0], face[4], face[3]};
    swap(face, newface);
  }
  void rotd() {
    vi newface = {face[3], face[0], face[2], face[5], face[4], face[1]};
    swap(face, newface);
  }
};
bool operator==(Dice d1, Dice d2) {
  return d1.face == d2.face;
}
bool operator<(Dice d1, Dice d2) {
  return d1.face < d2.face;
}
struct Elm {
  Dice dice;
  int r, c;
  int pos;
  int d;
};
bool operator<(Elm e1, Elm e2) {
  return make_tuple(e1.d, e1.r, e1.c, e1.dice, e1.pos) < make_tuple(e2.d, e2.r, e2.c, e2.dice, e2.pos);
}
vi dr = {0, 0, -1, 1};
vi dc = {-1, 1, 0, 0};
bool solve() {
  vi a(6);
  for(int i=0;i<(6);++i) {
    cin >> a[i];
  }
  Dice dice;
  dice.face = {a[0], a[1], a[3], a[4], a[2], a[5]};
  string s; cin >> s;
  for(int i=0;i<((int)(s.size()));++i) {
    if(s[i] == 'W') dice.rotl();
    else if(s[i] == 'E') dice.rotr();
    else if(s[i] == 'N') dice.rotu();
    else if(s[i] == 'S') dice.rotd();
  }
  cout << dice.face[0] << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
}



Measured memory_bytes: 3248
s = input()
s = [int(x) for x in s]
length = len(s)
a,b=[],[]
counter = 0
countera = 0
counterb =0
for index,val in enumerate(s):
  if counter == 0:
    if val == 0:
      counterb += 1
    else:
      countera += 1
  else:
    if val == 0:
      countera += 1
    else:
      counterb += 1
  counter ^= 1
print(min(countera,counterb))

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    auto cnt = vec(19, vec(19, 0LL));

    while (n--) {
        std::string s;
        std::cin >> s;

        std::string t;
        if (std::count(s.begin(), s.end(), '.') != 0) {
            while (s.back() != '.') {
                t.push_back(s.back());
                s.pop_back();
            }
            s.pop_back();
            std::reverse(t.begin(), t.end());
        }

        while ((int)t.length() < 9) t.push_back('0');

        lint x = std::stoi(s) * 1000000000LL + std::stoi(t);

        int two = 0;
        while (x % 2 == 0 && two < 18) {
            x /= 2;
            ++two;
        }

        int five = 0;
        while (x % 5 == 0 && five < 18) {
            x /= 5;
            ++five;
        }

        ++cnt[two][five];
    }

    lint ans = 0;
    for (int t1 = 0; t1 <= 18; ++t1) {
        for (int f1 = 0; f1 <= 18; ++f1) {
            for (int t2 = 0; t2 <= t1; ++t2) {
                for (int f2 = 0; f2 <= 18; ++f2) {
                    if (t1 == t2 && f1 > f2) continue;
                    if (t1 + t2 < 18 || f1 + f2 < 18) continue;

                    if (t1 == t2 && f1 == f2) {
                        ans += cnt[t1][f1] * (cnt[t1][f1] - 1) / 2;
                    } else {
                        ans += cnt[t1][f1] * cnt[t2][f2];
                    }
                }
            }
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	long double ans=0;
	for(int i=1;i<=n;i++){
		if(i>=k)	ans+=1;
		else{
			int x=i,cnt=0;
			while(x<k){
				x*=2;cnt++;
			}
			long double tmp=1;
			while(cnt--)
				tmp/=2;
			ans+=tmp;
		}
	}
	cout<<fixed<<setprecision(20)<<ans/n<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000000;
char a[maxn];
int main(){
	scanf("%s", a + 1);
	int n = strlen(a + 1);
	for (int i = 1; i <= n - 1; ++i) if (a[i] == 'A' && a[i + 1] == 'C'){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e5+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int val[N][2];
ll powM(ll b, int p,int M) {
  ll r=1;
  for(; p; b=b*b%M, p/=2)
    if(p&1)
      r=r*b%M;
  return r;
}
int dp[N];
int f(int n){
	int cnt=0;int n1=n;
	if(dp[n1])return dp[n1];
	while(n){
		cnt++,n%=__builtin_popcount(n);
	}
	return dp[n1]=cnt;
}
void solve(){
	int n;cin>>n;
	bitset<N>a;cin>>a;
	int set=a.count();
	int n1=set+1,n2=set-1;
	int ans1=0,ans2=0;
	val[0][0]=val[0][1]=1;
	rep(i,0,n-1){
		val[i+1][0]=2*val[i][0]%n1;
		if(n2!=0)val[i+1][1]=2*val[i][1]%n2;
		if(a[i]==1)ans1+=val[i][0],ans2+=val[i][1];
	}
	per(i,n-1,0){
		if(a[i]==1){
			if(n2==0){cout<<0<<" ";continue;}
			int cnt=ans2-val[i][1]+n2;
			cnt%=n2;
			cout<<1+f(cnt);
		}
		else{
			int cnt=ans1+val[i][0];
			cnt%=n1;
			cout<<1+f(cnt);
		}
		cout<<"\n";
	}
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 7528
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define vll ve<ll>
#define vpl ve<pll>
#define lr(n) for(ll i = 0; i < n; i++)
#define ltr(i, l, r) for (ll i = l; i <= r; i++)
#define rtl(i, l, r) for (ll i = r; i >= l; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define be begin
#define sz(a) (ll)(a.size())
#define con continue
#define ret return
#define endl "\n"
const ll INF = 1e18;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

// ll gcd(ll a, ll b){
// 	return b == 0 ? a : gcd(b, a % b);
// }

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }

ll vi[100001]={0};

void dfs(auto &ar, ll x){
	vi[x]=1;
	for(auto i:ar[x]){
		if(vi[i]) continue;
		dfs(ar, i);
	}
}

void solve(ll T){
	ll n,m;
	cin>>n>>m;
	ve<ve<ll>>ar(n+1);
	lr(m){
		ll x,y;
		cin>>x>>y;
		ar[x].pb(y);
		ar[y].pb(x);
	}
	ll cnt=0;
	for(ll i=1;i<=n;i++){
		if(vi[i]==1) continue;
		cnt++;
		dfs(ar, i);
	}
	cout << cnt -1 << "\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


Measured memory_bytes: 11140
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
 
int h,w,k;
vector <string> grid;
bool check(int r,int c){
  int cnt = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(r & (1 << i) || c & (1 << j))
          continue;
        if(grid[i][j] == '#')
          cnt++;
      }
    }
    return cnt == k;
}
 
int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
 
  cin >> h >> w >> k;
 
  grid.resize(h);
 
  for(int i=0;i<h;i++)
    cin >> grid[i];
 
  int ans  =0;
  for(int r=0;r<(1<<h);r++){
    for(int c=0;c<(1<<w);c++){
      if(check(r,c))
        ans++;
    }
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, M;
    int i, j;
    int MD = 0;
    cin >> N >> M;
    int a[N], b[N], c[M], d[M], Pre[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> c[i] >> d[i];
    }

    for (i = 0; i < N; i++) {
        int Min  = 1000000000;
        int Minj = 1000000000;
        for (j = 0; j < M; j++) {
            MD = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (Min > MD) {
                Min  = MD;
                Minj = j;
            }
            if (Min == MD) {
                Minj = min(Minj, j);
            }
        }
        Pre[i] = Minj + 1;
    }

    for (int i = 0; i < N; i++) {
        cout << Pre[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int vertex[4];
	int a,b;
	rep(i,4)vertex[i]=0;
	rep(i,3){
		cin>>a>>b;
		vertex[a-1]++;
		vertex[b-1]++;
	}
	int even,odd;
	even=odd=0;
	bool check=true;
	rep(i,4){
		if(vertex[i]%2)odd++;
		else even++;
	}
	if(even==2&&odd==2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]

dict_s = {
  "M" : 0,"A" : 0,"R" : 0,
  "C" : 0,"H" : 0,
}
for i in range(n):
  if(s[i][0] == "M"):
    dict_s["M"]=dict_s["M"]+1
  if(s[i][0] == "A"):
    dict_s["A"]=dict_s["A"]+1
  if(s[i][0] == "R"):
    dict_s["R"]=dict_s["R"]+1
  if(s[i][0] == "C"):
    dict_s["C"]=dict_s["C"]+1
  if(s[i][0] == "H"):
    dict_s["H"]=dict_s["H"]+1

sum_s=dict_s["M"]*dict_s["A"]*dict_s["R"]+ \
      dict_s["M"]*dict_s["A"]*dict_s["C"]+ \
      dict_s["M"]*dict_s["A"]*dict_s["H"]+ \
      dict_s["M"]*dict_s["R"]*dict_s["C"]+ \
      dict_s["M"]*dict_s["R"]*dict_s["H"]+ \
      dict_s["M"]*dict_s["C"]*dict_s["H"]+ \
      dict_s["A"]*dict_s["R"]*dict_s["C"]+ \
      dict_s["A"]*dict_s["R"]*dict_s["H"]+ \
      dict_s["A"]*dict_s["C"]*dict_s["H"]+ \
      dict_s["R"]*dict_s["C"]*dict_s["H"]
print(sum_s)

Measured memory_bytes: 9780
#include <iostream>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  bool isPoor = false;
  if (A == B && A != C) isPoor = true;
  if (A == C && A != B) isPoor = true;
  if (B == C && A != B) isPoor = true;
  if (isPoor) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
<?php
fscanf(STDIN, "%d %d %d", $n, $h, $w);
$c = 0;
for($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    if($a >= $h && $b >= $w) $c++;
}
echo $c, PHP_EOL;

Measured memory_bytes: 4856
#include<iostream>
#include<complex>
using namespace std;
int main()
{
     int k,a,b,i;
    cin >> k >> a >>b;
    for(i=a;i<=b;i++){
        if(i%k==0){
        cout << "OK";
        return 0;
    }
    }
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3632
s = input()
k = int(input())

def oneWhenEnd(s) : 
    count = 0
    for c in s : 
        if c != "1" : 
            return count
        count += 1
    return count
    
def getChar(s) : 
    for c in s : 
        if c != "1" : 
            return c
            
def f(s , k) : 
    x = oneWhenEnd(s)
    if x == 0 :
        return getChar(s)
    elif x == len(s) : 
        return 1
    else : 
        if k > x : 
            return getChar(s)
        else : 
            return 1

print(f(s , k) )   

Measured memory_bytes: 3064
N = gets.to_i
xs = gets.split.map(&:to_i)
reqs = []
N.times do |i|
    reqs[i] = [i+1, xs[i]]
end

reqs.sort_by!{|arr|arr[1]}

before_queue = []
after_queue = []
reqs.each do |i, x|
    before_queue.concat(Array.new(i - 1, i))
    after_queue.concat(Array.new(N - i, i))
end
queue = before_queue + after_queue
count = Array.new(N+1, 0)

ans = []
(1..N*N).each do |n|
    if reqs.length > 0 && reqs[0][1] == n
        i, x = reqs.shift
        ans.push(i)
        count[i] += 1
        if count[i] != i
            puts 'No'
            exit
        end
    else
        i = queue.shift
        ans.push(i)
        count[i] += 1
    end
end

puts 'Yes'
puts ans.join(' ')

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

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);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt(), K = in.nextInt();
            int[] stones = new int[N];
            for (int i = 0; i < N; i++)
                stones[i] = in.nextInt();

            int[] dp = new int[N];
            dp[0] = 0;

            for (int i = 1; i < N; i++) {
                dp[i] = Integer.MAX_VALUE;
                for (int j = 1; j <= K && (i - j) >= 0; j++) {
                    int jump = Math.abs(stones[i] - stones[i - j]) + dp[i - j];
                    dp[i] = Math.min(dp[i], jump);
                }
            }

            out.println(dp[N - 1]);
        }

    }

    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: 39340
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9+7;
const ll mod= 1e9 + 7;



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

	ll N, M,ans=0;
	cin >> N >> M;
	priority_queue<ll> que;

	FOR(i, 0, N) {
		int cur; cin >> cur;
		que.push(cur);
	}
	FOR(i, 0, M) {
		int cur = que.top(); que.pop();
		cur /= 2;
		que.push(cur);
	}
	while (!que.empty()) {
		int cur = que.top(); que.pop();
		ans += cur;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);

        String a =sc.nextLine();
        String fch;
        String answer="";

        for(int i=0;i<a.length();i++){
            fch=String.valueOf(a.charAt(i));
            if(Character.isUpperCase(a.charAt(i))){
                answer+=fch.toLowerCase();
            }else{
                answer+=fch.toUpperCase();
            }
        }

        System.out.println(answer);

        sc.close();
    }
}


Measured memory_bytes: 31884
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    cin >> s >> t;
    t.pop_back();
    if(s==t)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int need_left = 0, pointer = 0;
  for (int i=0; i<N; i++) {
    if (S[i]=='(') pointer++;
    else if (pointer==0) need_left++;
    else pointer--;
  }
  int need_right = pointer;
  string res = "";
  for (int i=0; i<need_left; i++) res += '(';
  res += S;
  for (int i=0; i<need_right; i++) res += ')';
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256