akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> M(N);
  for(int i = 0; i < N; i++){
    cin >> M.at(i);
  }
  
  int count = 0;
  
  for(int i = 0; i < N; i++){
    if(!(M.at(i)  == i + 1)){
      count++;
    }
  }
    if(count == 2 || count == 0){
      cout << "YES" << endl;
    }
    
   
    else{
      cout << "NO" << endl;
    }
    
}


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

int main(){
    int N,wa=0;
    cin >> N;
    vector<char> kasi(N);

    for(int i = 0;i < N;i++){
        cin >> kasi.at(i); 
    }

    vector<bool> syu(4);

    for(int i = 0;i < 4;i++)
        syu.at(i) = false;

    for(int i = 0;i < N;i++){
        switch(kasi.at(i)){
            case 'G':
            syu.at(0) = true;
            break;

            case 'W':
            syu.at(1) = true;
            break;

            case 'P':
            syu.at(2) = true;
            break;

            case 'Y':
            syu.at(3) = true;
            break; 
        }

    }

    for(int i = 0;i < 4;i++){
        if(syu.at(i))
            wa++;
    }
    if(wa == 4)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
}

Measured memory_bytes: 256
open Printf
open Scanf

let card x = if x = 1 then 14 else x

let solve a b = match compare (card a) (card b) with
    1 -> "Alice"
  | 0 -> "Draw"
  | -1 -> "Bob"
  | _ -> "Draw"

let () =
  scanf "%d %d " solve |> printf "%s\n"


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

#define MOD 1000000007

ll n,h[110];

ll f(ll l,ll r,ll foot,ll*a,ll*b){
	ll m=h[l];
	rep(i,l,r)m=min(m,h[i]);
	ll mcnt=0;
	rep(i,l,r)if(h[i]==m)mcnt++;
	
	ll aa[110],bb[110],cnt=0;
	ll left=l;
	while(left<r){
		while(left<r&&h[left]==m)left++;
		if(left==r)break;
		ll right=left;
		while(right<r&&h[right]!=m)right++;
		f(left,right,m,aa+cnt,bb+cnt);
		cnt++;
		left=right;
	}

	if(cnt){
		*a=1;
		rep(i,0,cnt)*a=*a*(aa[i]+2*bb[i])%MOD;
		*a=*a*pom(2,mcnt,MOD)%MOD;
		*b=1;
		rep(i,0,cnt)*b=*b*bb[i]%MOD;
		*a=(*a-2**b+MOD+MOD)%MOD;
		*b=*b*pom(2,m-foot,MOD)%MOD;
	}else{
		*a=(pom(2,r-l,MOD)-2+MOD)%MOD;
		*b=pom(2,m-foot,MOD);
	}
}

int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",h+i);
	ll a,b;
	f(0,n,0,&a,&b);
	printf("%lld\n",(a+b)%MOD);
	return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  private static final Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    solve(a, b, c);
  }

  private static void solve(int a, int b, int c) {
    int[] arr = new int[3];
    arr[0] = a;
    arr[1] = b;
    arr[2] = c;
    Arrays.sort(arr);
    if (Arrays.equals(arr, new int[]{5, 5, 7})) {
      System.out.println("YES");
      return;
    }
    System.out.println("NO");
  }


}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H;
	cin >> H;
	LL n = 1;
	LL ans = 0;
	while (1) {
		if (H == 0)break;
		H /= 2;
		ans += n;
		n *= 2;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		vector<PII> w(N);
		REP(i, N) cin>>w[i].SE>>w[i].FI;
		sort(ALL(w));
		ll t = 0;
		string ans = "Yes";
		REP(i, N) {
			t += w[i].SE;
			if(w[i].FI<t) ans = "No";
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w * h / 2;
  int mid = 0;
  if (w % 2 == 0 && w / 2 == x && h % 2 == 0 && h / 2 == y)
  {
    mid = 1;
  }
  cout << ans << " " << mid << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a = gete()

    if ord('a') <= ord(a) <= ord("z"):
        print("a")
    else:
        print("A")


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;


int main()
{
    ll n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> vist;
    vector<ll> seen(n);
    for(ll i = 0; i < n; i++){cin >> a[i]; a[i]--;}
    ll cnt = 0, cur = 0;

    for(cnt = 0;!seen[cur]; cnt++) {
        seen[cur] = true;
        cur = a[cur];
        if(cnt == k - 1) {
            cout << cur + 1 << endl;
            return 0;
        }
    }
    k -= cnt;
    //cerr << k << " " << endl;
    cnt = 1;
    int fin = cur;
    vist.push_back(cur);
    cur = a[cur];
    //cerr << fin << " " << cur << endl;
    while(cur != fin) {
        vist.push_back(cur);
        cur = a[cur];
        cnt++;
    }

    //for(auto i : vist)cerr << i << " ";
    cout  << vist[k % cnt] + 1 << endl;

}


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

int main(){
  string s;
  int n ;
  cin >> n;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="AC")a++;
    if(s=="WA")b++;
    if(s=="TLE")c++;
    if(s=="RE")d++;
  }
  
  cout <<"AC"<<' '<<'x'<<' '<<a<<endl;
  cout <<"WA"<<' '<<'x'<<' '<<b<<endl;
  cout <<"TLE"<<' '<<'x'<<' '<<c<<endl;
  cout <<"RE"<<' '<<'x'<<' '<<d<<endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int Length[n];
    for (int i=0;i<n;i++){
        cin >> Length[i];
    }
    int max;
    max = *max_element(Length, Length + n);
    int sum = -1*max;
    for (int i=0;i<n;i++){
        sum += Length[i];
    }
    if (max < sum){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1;i*i<=n;i++){
		if(n%i != 0) continue;
		res.push_back(i);
		if(n/i== i)continue;
		res.push_back(n/i);
	}
	return res;
}

int main(){
 	ll n;
	cin>>n;
	vector<ll> a(n+1);
	for(ll i=1;i<=n;i++)cin>>a[i];
	vector<ll> c(n+1,0);
	vector<ll> b(n+1);
	vector<ll> ans;

	for(ll i=n;i>=1;i--){
	 if( a[i] == c[i]%2 ){
	  b[i] = 0;
	 }else{
	  b[i] = 1;
	  ans.push_back( i );
	  vector<ll> y = divisors( i );
	  for(auto j:y)c[j]++;
	  /*for(ll j=1;j*j<=id;j++){
	   if(id%j != 0 )continue;
	   c[j-1]++;
	   if(id/j == j ) continue;
	   c[n/j -1 ]++;
	  }*/
	 }
	}

	//ll cnt = 0;
	//for(ll i=0;i<n;i++) cnt += b[i];
	cout<<ans.size()<<endl;
	if( ans.size() >= 1 ) cout<<ans[0];
	for(ll i=1;i<ans.size();i++)cout<<' '<<ans[i];
	cout<<endl;



    return 0;
}


Measured memory_bytes: 6516
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e6+5;

int a[maxn];
int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    if(n>k)n=n%k;
    printf("%lld\n",min(k-n,n));
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define MaxN 100000+100
using namespace std;
int a[MaxN];
int my_max(int a,int b)
{
	return a>b ?a:b;
}
int main()
{
	int n;
	scanf("%d",&n);
	int fx=0;
	int sum=1;
	scanf("%d",&a[0]);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==a[i-1])
			continue;
		if(a[i]>a[i-1])
		{
			if(fx==0)
				fx=1;
			else
				if(fx==-1)
				{
					fx=0;
					sum++;
				}
			continue;
		}
		if(a[i]<a[i-1])
		{
			if(fx==0)
				fx=-1;
			else
				if(fx==1)
				{
					sum++;
					fx=0;
				}
			continue;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    string S;
    cin >> S;

    set<int> pos[26];
    for(int i=0; i<S.length(); i++){
        int id = S[i] - 'a';
        pos[id].insert(i);
    }

    int M;
    cin >> M;
    vector<int> ans;
    for(int q=0; q<M; q++){
        int type;
        cin >> type;
        if(type == 1){
            int t;
            char c;
            cin >> t >> c;
            t--;
            int id = c - 'a';

            for(int i=0; i<26; i++){
                pos[i].erase(t);
            }

            pos[id].insert(t);
        }else{
            int l, r;
            cin >> l >> r;
            l--;r--;

            int cnt = 0;
            for(int i=0; i<26; i++){
                auto s = pos[i].lower_bound(l);
                auto e = pos[i].lower_bound(r+1);
                if(s != e) cnt++;
            }
            ans.push_back(cnt);
        }
    }

    for(auto a : ans) cout << a << endl;
    
    return 0;
}


Measured memory_bytes: 24452
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

void add_map(map<int, int>& m, int val) {
  if (m.find(val) == m.end()) {
    m[val] = 1;
  } else {
    m[val]++;
  }
}

int main() {
  //
  int n;
  int ocnt = 0, ecnt = 0;
  cin >> n;
  map<int, int> odd, even;
  rep(i, n) {
    int v;
    cin >> v;
    if (i & 1) {
      add_map(odd, v);
      ocnt++;
    } else {
      add_map(even, v);
      ecnt++;
    }
  }
  vector<pii> o, e;
  for (auto& kv : odd) {
    int val = kv.first;
    int cnt = kv.second;
    o.push_back(make_pair(cnt, val));
  }
  for (auto& kv : even) {
    int val = kv.first;
    int cnt = kv.second;
    e.push_back(make_pair(cnt, val));
  }
  sort(ALL(o));
  reverse(ALL(o));
  sort(ALL(e));
  reverse(ALL(e));

  if (o.size() == 1 && e.size() == 1) {
    if (o[0].second == e[0].second) {
      cout << min(o[0].first, e[0].first) << endl;
    } else {
      cout << 0 << endl;
    }
  } else if (o.size() == 1) {
    if (o[0].second == e[0].second) {
      cout << min(ecnt - e[1].first, ocnt) << endl;
    } else {
      cout << min(ecnt - e[0].first, ocnt) << endl;
    }
  } else if (e.size() == 1) {
    if (o[0].second == e[0].second) {
      cout << min(ocnt - o[1].first, ecnt) << endl;
    } else {
      cout << min(ocnt - o[0].first, ecnt) << endl;
    }
  } else {
    if (o[0].second == e[0].second) {
      cout << n - max(o[0].first + e[1].first, o[1].first + e[0].first) << endl;
    } else {
      cout << n - o[0].first - e[0].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6136
import sys
input=sys.stdin.readline

N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
    pi, yi = [int(i) for i in input().split(" ")]
    p.append(pi)
    y.append(yi)
    if pi in yd.keys():
        yd[pi].append(yi)
    else:
        yd[pi] = [yi]

ydid = {}
for i in yd.keys():
    num = 1
    for j in sorted(yd[i]):
        ydid[j] = num
        num = num + 1

for i in range(0, M):
    print("{:06}{:06}".format(p[i], ydid[y[i]]))


Measured memory_bytes: 40472
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include <vector>
#define ll long long int
#define ve vector<int>
#define vell vector<ll>
#define pb push_back
#define mod 998244353
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;cin>>n;
set<string>s;
for(int i=0;i<n;i++)
{
	string s1;cin>>s1;
	s.insert(s1);
}
cout<<s.size();


}
 

Measured memory_bytes: 19288
N,K=map(int,input().split())
lh=list(map(int,input().split()))
ldp=[float("inf") for i in range(N)]
"""for i in range(K):
    if i<=N-1:
        ldp[i]="""
ldp[0]=0
for i in range(1,N):
    mintmp=float("inf")
    for j in range(1,K+1):
        if i-j>=0:
            mintmp=min(mintmp,ldp[i-j]+abs(lh[i]-lh[i-j]))
    ldp[i]=mintmp
#print(ldp)
print(mintmp)


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int t; cin >> t;
    while (t % 2 == 0) {
      t /= 2;
      ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int t, x; cin >> t >> x;
    double ans = double(t) / x;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'
long long x[50];
int main() {
  fast_io;
  int n;
  cin >> n;
  int highest_mag = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (abs(x[highest_mag]) < abs(x[i]))
      highest_mag = i;
  }
  if (x[highest_mag] == 0) {
    cout << 0 << endl;
    return 0;
  }
  VII ans;
  ans.PB({highest_mag, highest_mag});
  if (x[highest_mag] >= 0) {
    for (int i = 0; i < n; i++)
      if (x[i] < 0)
        ans.PB({highest_mag, i});
    // All positive strictly.
    for (int i = 1; i < n; i++)
      ans.PB({i - 1, i});
  } else {
    for (int i = 0; i < n; i++)
      if (x[i] > 0)
        ans.PB({highest_mag, i});
    // All negative strictly.
    for (int i = n - 2; i >= 0; i--) {
      ans.PB({i + 1, i});
    }
  }
  cout << SZ(ans) << endl;
  for (auto a : ans)
    cout << a.F + 1 << " " << a.S + 1 << endl;
  return 0;
}


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

int main()
{
    int meiji = 1867, taisho = 1911, showa = 1925, heisei = 1988;

    int y, m, d;
    while( cin >> y >> m >> d )
    {
        if( y <= 1867 || ( y == 1868 && m < 9 ) || ( y == 1868 && m == 9 && d < 8 ) )
            cout << "pre-meiji" << endl;
        if( ( y == 1868 && m == 9 && d >= 8 ) || ( y == 1868 && m > 9 ) || 1869 <= y && y <= 1911 || ( y == 1912 && m < 7 ) || ( y == 1912 && m == 7 && d <= 29 ) )
            cout << "meiji " << y - meiji << " " << m << " " << d << endl;
        if( ( y == 1912 && m == 7 && d >= 30 ) || ( y == 1912 && m > 7 ) || 1913 <= y && y <= 1925 || ( y == 1926 && m < 12 ) || ( y == 1926 && m == 12 && d <= 24 ) )
             cout << "taisho " << y - taisho << " " << m << " " << d << endl;
        if( ( y == 1926 && m == 12 && d >= 25 ) || ( 1927 <= y && y <= 1988 ) || ( y == 1989 && m == 1 && d <= 7 ) )
             cout << "showa " << y - showa << " " << m << " " << d << endl;
        if( ( y == 1989 && m == 1 && d >= 8 ) || ( y == 1989 && m > 1 ) || y >= 1990 )
             cout << "heisei " << y - heisei << " " << m << " " << d << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  VI xs(3);
  FOR(x,xs) {
    cin >> x;
  }
  if (xs[0] == xs[1] && xs[1] == xs[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> s = new ArrayList<>();
    for(int i = 0; i < n; i++) {
      s.add(sc.nextInt());
    }
    int q = sc.nextInt();
    List<Integer> t = new ArrayList<>();
    for(int i = 0; i < q; i++) {
      t.add(sc.nextInt());
    }
    int count = 0;
    for(int i = 0; i < q; i++) {
      int left = 0;
      int right = n - 1;
      int middle = (left + right) / 2;
      while(t.get(i).intValue() != s.get(middle).intValue()) {
        if(t.get(i) < s.get(middle)) {
          right = middle - 1;
        } else if(t.get(i) > s.get(middle)) {
          left = middle + 1;
        }
        if(right < left) {
          break;
        }
        middle = (left + right) / 2;
      }
      if(t.get(i).intValue() == s.get(middle).intValue()) {
        count++;
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 84440
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    string s;
    cin>>s;
    j=0;
    k=0;
    for(i=0;i<3;i++)
    {
        if(s[i]=='A')
        {
            j=1;
        }
        else
        {
            k=1;
        }
    }
    if(j&k)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3592
import itertools
def f(s):
 for a,b,c,d in itertools.permutations(s):
  for x,y,z in itertools.product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"{a} {x} ({b} {y} ({c} {z} {d}))",f"({a} {x} ({b} {y} {c})) {z} {d}",f"{a} {x} (({b} {y} {c}) {z} {d})"]:
    if eval(t)==10:return t
 else:return 0
for e in iter(input,'0 0 0 0'):
 s=list(map(int,e.split()));a=f(s)
 if a:print('('+a+')')
 else:print(a)


Measured memory_bytes: 5664
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s; string t;
    cin >> s >> t;
    char x = t[t.size() - 1];
    s += x;
    if (s == t) cout << "Yes" << endl;
    else cout << "No" << endl;	

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int dp[1000000];

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	std::vector<int> w(n);
	std::vector<int> s(n);
	std::vector<int> v(n);
	std::vector<int> u(n);
	for (int i = 0; i < n; ++i) cin >> w[i] >> s[i] >> v[i], u[i] = i;
	sort(u.begin(), u.end(), [&](int a, int b){ return s[a] + w[a] < s[b] + w[b]; });
	for (int i = 0; i < n; ++i)
		for (int j = s[u[i]]; j >= 0; --j)
			dp[j + w[u[i]]] = max(dp[j + w[u[i]]], dp[j] + v[u[i]]);
	for (int i = 0; i <= 20000; ++i)
		dp[0] = max(dp[0], dp[i]);
	cout << dp[0];
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {

	int N, M, X;
	cin >> N >> M >> X;

	vector<int> costs(N,0);
	vector<vector<int>> inputs(N, vector<int>(M, 0));
	for (int i = 0; i < N; i++) {
		cin >> costs[i];
		for (int j = 0; j < M; j++) {
			cin >> inputs[i][j];
		}
	}

	int min_cost = INF;
	// 1bitずつ立てながら、それぞれ処理を行ってゆくコード
	int i = 0;
	int search_bit_num = N;
	for (i = 0; i < (1 << search_bit_num); i++) { // 000-111の様にループを回す

		vector<int> score(N, 0);
		int tmp_cost = 0;
		for (int j = 0; j < search_bit_num; j++) { // 下から一桁づつ処理
			if (i & (1 << j)) { // j番目のビットが1なら
				// j番目のビットが1の時の処理
				for (int k = 0; k < M; k++) {
					score[k] += inputs[j][k];
				}
				tmp_cost += costs[j];
			}
			else {
				// j番目のビットが0の時の処理
			}
		}
		// ビット状態にかかわらず、共通して実施する処理
		int min_score = INF;
		for (int n = 0; n < M; n++) {
			min_score = min(min_score, score[n]);
		}
		if (min_score >= X) {
			min_cost = min(min_cost, tmp_cost);
		}

	}

	if (min_cost < INF) {
		cout << min_cost << endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#define NIL (-1)
using namespace std;

struct BinaryTreeNode {
	int p;//parent
	int l;//left child
	int r;//right child
	int d;//depth
	int h;//height
};

int get_sibling_id(int id, vector<BinaryTreeNode> &nodes) {
	if (nodes[id].p == NIL) return NIL;
	BinaryTreeNode &n = nodes[nodes[id].p];
	if ((n.l != id) && (n.l != NIL)) {
		return n.l;
	}
	if ((n.r != id) && (n.r != NIL)) {
		return n.r;
	}
	return NIL;
}

void print(vector<BinaryTreeNode> &nodes) {
	for (int i=0; i<nodes.size(); ++i) {
		cout << "node " << i << ": parent = ";
		cout << nodes[i].p << ", sibling = ";
		cout << get_sibling_id(i, nodes) << ", degree = "; 
		int degree = 0;
		degree += nodes[i].l != NIL;
		degree += nodes[i].r != NIL;
		cout << degree << ", depth = ";
		cout << nodes[i].d << ", height = ";
		cout << nodes[i].h << ", ";
		if (nodes[i].p == NIL) {
			cout << "root";
		} else if (degree == 0) {
			cout << "leaf";
		} else {
			cout << "internal node";
		}
		cout << endl;
	}
}

void set_depth(int id, int depth, vector<BinaryTreeNode> &nodes) {
	if (id == NIL) return;
	BinaryTreeNode &n = nodes[id];
	n.d = depth;
	set_depth(n.l, depth+1, nodes);
	set_depth(n.r, depth+1, nodes);
}

int set_height(int id, vector<BinaryTreeNode> &nodes) {
	BinaryTreeNode &n = nodes[id];
	int h1, h2;
	h1 = h2 = 0;
	if (n.l != NIL) {
		h1 = set_height(n.l, nodes) + 1;
	}
	if (n.r != NIL) {
		h2 = set_height(n.r, nodes) + 1;
	}
	return n.h = max(h1, h2);
}

int main() {
	int n;
	cin >> n;
	vector<BinaryTreeNode> nodes(n);
	for (int i=0;i<n;++i) nodes[i].p = NIL;
	// input
	for (int i=0;i<n;++i) {
		int id, left, right;
		cin >> id >> left >> right;
		nodes[id].l = left;
		nodes[id].r = right;
		if (left != NIL) nodes[left].p = id;
		if (right != NIL) nodes[right].p = id;
	}
	int root_id = -1;
	for (int i=0; i<n; ++i) {
		if (nodes[i].p == NIL) {
			root_id = i;
		}
	}
	set_depth(root_id, 0, nodes);
	set_height(root_id, nodes); 
	print(nodes);
	return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 10007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct edge {
    ll to, cost;
};
vector<int> vis, r;
vector<ll> s, mi;
vector<vector<edge>> G;
void dfs(int i, int rt) {
    r[i] = rt;
    chmin(mi[rt], s[i]);
    vis[i] = 1;
    for(auto e : G[i]) {
        if(vis[e.to]) {
            continue;
        }
        s[e.to] = s[i] + e.cost;
        dfs(e.to, rt);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    G.resize(w + 10);
    vis.resize(w + 10);
    s.resize(w + 10);
    mi.resize(w + 10, LINF);
    r.resize(w + 10);
    vector<vector<P>> v(h + 10);
    vector<vector<ll>> vv(w + 10);
    for(int i = 0; i < n; i++) {
        ll r, c, a;
        cin >> r >> c >> a;
        v[r].push_back(P(c, a));
        vv[c].push_back(a);
    }
    for(int i = 1; i <= h; i++) {
        if(v[i].size() <= 1) {
            continue;
        }
        sort(all(v[i]));
        for(int j = 1; j < v[i].size(); j++) {
            ll c = v[i][j].second - v[i][j - 1].second;
            G[v[i][j - 1].first].push_back({v[i][j].first, c});
            G[v[i][j].first].push_back({v[i][j - 1].first, -c});
        }
    }
    for(int i = 1; i <= w; i++) {
        if(!vis[i]) {
            s[i] = 0;
            dfs(i, i);
        }
    }
    bool f = true;
    for(int i = 1; i <= w; i++) {
        for(auto e : G[i]) {
            if(s[e.to] - s[i] != e.cost) {
                f = false;
            }
        }
        for(auto a : vv[i]) {
            if(mi[r[i]] + (a - s[i]) < 0) {
                f = false;
            }
        }
    }
    if(f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 18816
#include <iostream>
#include <vector>
#include <cstdlib>

int main(){
	int n;
	int d;
	int cand;
	std::cin >> n;

	std::vector<int> a(n);
	for(int i = 0; i < n; ++i){
		std::cin >> a.at(i);
	}
	
	cand = abs(a.at(0) - a.at(1));
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			d = abs(a.at(i)-a.at(j));
			if(d > cand){
				cand = d;
			}
		}
	}

	std::cout << cand << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define INF (ll)1e18 + 50
#define MAXN (int)2e5 + 50
#define fi first
#define se second
#define MOD 1000000007
#define all(v)((v).begin()), ((v).end())
#define A 911382323
#define B 972663749


set<int> ini, vis;
int vec[MAXN];

int32_t main() {
    
    ll a, b, c; cin >> a >> b >> c;
    
    ll aux = min(a, c);
    
    a -= aux; c-= aux;
    ll aux2 = min(b, c);
    b -= aux2;    
    
    cout << a << ' ' << b;
    
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  std::string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}, n;
  std::cin >> n;
  int tmp;
  for(int i = 0; i < 7; ++i) {
    if(n == s[i]) tmp = 7-i; 
  }
  std::cout << tmp;
  return 0;  
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

ll S, s_len = 0;
ll s_num[10];

void solve() {
    ll ans = 0;
    for (ll i = 0; i < pow(2, s_len - 1); i++) {
        ll sum = 0;
        string temp = to_string(s_num[s_len - 1]);
        for (ll j = 0; j < s_len - 1; j++) {
            if ((1 & i >> j) == 1) {
                sum += stol(temp);
                temp = to_string(s_num[s_len - 1 - (j + 1)]);
            } else {
                temp += to_string(s_num[s_len - 1 - (j + 1)]);
            }
        }
        sum += stol(temp);
        ans += sum;
    }
    cout << ans << endl;
}

int main() {
    cin >> S;
    while (S > 0) {
        s_num[s_len++] = S % 10;
        S /= 10;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 805
#define INF 1000000007

int n,m,k,dist[NMAX][NMAX], viz[NMAX][NMAX],answer = INF;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
pair<int,int> stiva[NMAX * NMAX], start;
char s[NMAX][NMAX];

inline bool outOfMatrix(pair<int, int> poz) {
    return (poz.x < 1 || poz.x > n || poz.y < 1 || poz.y > m);
}

void bfs(pair<int,int> start) {
    int left = 1, right = 0;;
    
    stiva[right = 1] = start;
    viz[start.x][start.y] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            dist[i][j] = INF;
    dist[start.x][start.y] = 0;
    
    while(left <= right) {
        pair<int, int> currPoz = stiva[left];
        for(int dir = 0; dir < 4; dir++) {
            pair<int,int> nextPoz = make_pair(currPoz.x + dx[dir], currPoz.y + dy[dir]);
            if(viz[nextPoz.x][nextPoz.y] || outOfMatrix(nextPoz) || s[nextPoz.x][nextPoz.y] == '#')
                continue;
            viz[nextPoz.x][nextPoz.y] = 1;
            dist[nextPoz.x][nextPoz.y] = dist[currPoz.x][currPoz.y] + 1;
            stiva[++right] = nextPoz;
        }
        left++;
    }
}

int getCost(int px, int py) {
    int D = min(px - 1, min(py - 1, min(n - px, m - py)));
    return D / k + (D % k == 0 ? 0 : 1);
}

int main (){
    
    scanf("%d%d%d\n",&n,&m,&k);
    for(int i = 1; i <= n; i++)
        scanf("%s", s[i] + 1);
    
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(s[i][j] == 'S') {
                start = make_pair(i,j);
                break;
            }
    
    if(start.x == 1 || start.x == n || start.y == 1 || start.y == m) {
        printf("0\n");
        return 0;
    }
    
    bfs(start);
    
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(dist[i][j] <= k) {
            //    printf("%d %d\n", i,j);
                answer = min(answer, getCost(i,j) + 1);
            }
            
    printf("%d\n", answer);
    
    return 0;
}



Measured memory_bytes: 10880
#include <stdio.h>
int main(){
	int ans=0,n,k,x,a,i;
	scanf("%d%d%d",&n,&k,&x);
	a=x/1000;
	if(n<=k){
		if(x%1000==0)--a;
		ans=(a+1)*n;
	}
	else if(n<=k*2){
		if(x%1000==0)ans=n*a;
		else if(x%1000>500)ans=n*(a+1);
		else ans=n*a+k;
	}
	else{
		a=x/500+1;
		if(x%500==0)--a;
		ans=a*k;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define size 200000
using namespace std;

class UnionFind {
  int par[size], rk[size];
public:
  void init() {
    for(int i = 0; i < size; i++){
      par[i] = i;
      rk[i] = 0;
    }
  }

  int find(int x) {
    if(par[x] == x)
      return x;
    return par[x] = find(par[x]);
  }

  int merge(int x, int y) {
    x = find(x);
    y = find(y);
    if(rk[x] > rk[y]) {
      par[y] = x;
    }else if(rk[x] < rk[y]) {
      par[x] = y;
    }else {
      par[y] = x;
      rk[x]++;
    }
  }
  
};

int main(){
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind train, car;

  train.init();
  car.init();
  
  for(int i = 0; i < K; i++){
    int from, to;
    cin >> from >> to;
    from -= 1;
    to -= 1;
    train.merge(from,to);
  }

  for(int i = 0; i < L; i++){
    int from, to;
    cin >> from >> to;
    from -= 1;
    to -= 1;
    car.merge(from,to);
  }
  
  pair<int ,int> cityData[size];
  unordered_map<int64_t, int> countPattern;
  for(int i = 0; i < size; i++) {
    cityData[i].first = train.find(i);
    cityData[i].second = car.find(i);
    countPattern[ (int64_t)cityData[i].first * (int64_t)200000 + (int64_t)cityData[i].second ] += 1;
  }

  for(int i = 0; i < N; i++) {
    cout << countPattern[ (int64_t)cityData[i].first * (int64_t)200000 + (int64_t)cityData[i].second ] << ' ';
  }


  
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	vector<long long> b = a;
	for (int i = 1; i < n; i++) {
		b[i] += b[i - 1];
	}

	for (int i = n - 1; i > 0; i--) {
		if (b[i - 1] * 2 < a[i]) {
			cout << n - i << endl;
			return 0;
		}
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,l,r;
main(){
  cin>>n;
  r(i,n){
    cin>>l;
    if(l%2)r++;
  }
  if((r==n&&n%2==0)||r%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main() {
    int N, Y;
    std::cin >> N >> Y;

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= (N-i); ++j) {
            const int sum = 10000 * i + 5000 * j + 1000 * (N - i - j); 
            if (sum == Y) {
                std::printf("%d %d %d\n", i, j, N - i - j);
                return 0;
            }
        }
    }

    std::printf("-1 -1 -1\n");

    return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;

	int last = -1;
	for (int i = 0, x; i < n; ++i)
	{
		cin >> x;
		if (x-1 >= last) --x;
		if (x < last)
		{
			cout << "No\n";
			return 0;
		}
		last = x;
	}

	cout << "Yes\n";

	return 0;
}


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

constexpr int INFI = 1145141919;

bool sub_bingo(int a, int b, int c){
    if(a==b && b==c){
        return 1;
    }else{
        return 0;
    }
}

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

    std::vector<std::vector<int>> A(3, std::vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            std::cin >> A.at(i).at(j);
        }
    }

    int N;
    std::cin >> N;

    for(int n=0; n<N; n++){
        int buf;
        std::cin >> buf;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(buf==A.at(i).at(j)){
                    A.at(i).at(j) = 0;
                }
            }
        }
    }

    bool flag=false;
    for(int i=0; i<3; i++){//縦
        flag = sub_bingo( A[0][i], A[1][i], A[2][i] );
        if(flag==true){
            std::cout << "Yes";
            break;
        }
        flag = sub_bingo( A[i][0], A[i][1], A[i][2] );
        if(flag==true){
            std::cout << "Yes";
            break;
        }
    }
    if(flag==false){//右下
        flag = sub_bingo( A[0][0], A[1][1], A[2][2] );
        if(flag==true){
            std::cout << "Yes";
        }
    }
    if(flag==false){//左上
        flag = sub_bingo( A[2][0], A[1][1], A[0][2] );
        if(flag==true){
            std::cout << "Yes";
        }
    }

    if(flag==false){
        std::cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

using P=pair<int,int>;
void solve(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  if(s.back()!='0')s+="0";
  else s+="1";
  vector<int>v;
  int i=0;
  while(i<n){
    if(s[i]=='0')v.pb(i);
    while(i<n&&s[i]=='0')++i;
    if(s[i]=='1')v.pb(i);
    while(i<n&&s[i]=='1')++i;
  }
  v.pb(n);
  int ans=0;
  //for(auto x:v)cout<<x<<endl;
  rep(i,v.size()){
    int sum;
    if(s[v[i]]=='0')sum=v[min((int)v.size()-1,i+k*2)]-v[i];
    else sum=v[min((int)v.size()-1,i+k*2+1)]-v[i];
    chmax(ans,sum);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	int num = 0;
	rep(i, n) {
		if (s.at(i) == 'I') num++;
		if (s.at(i) == 'D') num--;

		ans = max(ans, num);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll n,x,y,b,p;
    cin>>n;
    for(int i=0;i<n;i++){
	cin>>x>>y>>b>>p;
	ll ans=x*b+y*p;
	ll cur=(max(5LL,b)*x+max(2LL,p)*y)*4/5;
	cout<<min(ans,cur)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
N, A, B = map(int, input().split())
S = input()
n = 0
g = 0
for p in S:
    if p == "a":
        if n+1 <= A+B:
            print("Yes")
            n += 1
        else:
            print("No")
    elif p == "b":
        if n+1 <= A+B and g+1 <= B:
            print("Yes")
            n += 1
            g += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int tail[10000];
bool book[10000];
int main()
{
    int n;
    scanf("%d",&n);
    int sum = 0;
    int head=1,top=1;
    tail[head] = 0;
    while(tail[head]<=1000)
    {
        bool flag = 0;
        for(int i = 1;i<=2;++i)
        {
            int t = tail[head];
            if(i==1) t+=4;
            if(i==2) t+=7;
            if(book[t]==0)
            {
                book[t] = 1;
                tail[++top] = t;
                //cout<<top<<endl;
            }
        }
        //cout<<tail[head]<<endl;
        head++;
    }
    if(book[n]==1) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=5e5+10;
int n;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++){
        if(a[i]+a[i+1]<-a[i]-a[i+1]){
            a[i]*=-1;
            a[i+1]*=-1;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}
//x+y-a*c1==a*c2;
//x+y=a*2-x;


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

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

  if (a < b) {
    cout << max(b - (a + W), 0) << endl;
  } else {
    cout << max(a - (b + W), 0) << endl;
  }
}

Measured memory_bytes: 384