akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;


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

    map<int, int> s;
    
    irep(i, n) {
        int tmp;
        cin >> tmp;
        if(1 <= tmp && tmp <= 399) { 
            s[0]++;
        } else if(400 <= tmp && tmp <= 799) {
            s[1]++;
        } else if(800 <= tmp && tmp <= 1199) {
            s[2]++;
        } else if(1200 <= tmp && tmp <= 1599) {
            s[3]++;
        } else if(1200 <= tmp && tmp <= 1599) {
            s[4]++;
        } else if(1600 <= tmp && tmp <= 1999) {
            s[5]++;
        } else if(2000 <= tmp && tmp <= 2399) {
            s[6]++;
        } else if(2400 <= tmp && tmp <= 2799) {
            s[7]++;
        } else if(2800 <= tmp && tmp <= 3199) {
            s[8]++;
        } else {
            s[9]++;
        }
    }
    
    int ans_min = 0;
    int ans_max = 0;
    irep(i, 9) {
        if(s[i]) { ans_min++; ans_max++; }
    }
    
    if(s[9]) {
        ans_max += s[9];
    }

    if(ans_min == 0 && s[9]) {
        ans_min++;
    }

    cout << ans_min << " " << ans_max << endl;

    return 0;
}


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

int main(void)
{
    // input
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    int answer = 0;
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        rep(j, m) cin >> a[i][j];
    }

    // compute
    int total;
    rep(i, n) {
        total = 0;
        rep(j, m) total += b[j] * a[i][j];
        if (total + c > 0) answer++;    
    }

    // output
    cout << answer << endl;
 }


Measured memory_bytes: 256
/*
                       ::
                      :;J7, :,                        ::;7:
                      ,ivYi, ,                       ;LLLFS:
                      :iv7Yi                       :7ri;j5PL
                     ,:ivYLvr                    ,ivrrirrY2X,
                     :;r@Wwz.7r:                :ivu@kexianli.
                    :iL7::,:::iiirii:ii;::::,,irvF7rvvLujL7ur
                   ri::,:,::i:iiiiiii:i:irrv177JX7rYXqZEkvv17
                ;i:, , ::::iirrririi:i:::iiir2XXvii;L8OGJr71i
              :,, ,,:   ,::ir@mingyi.irii:i:::j1jri7ZBOS7ivv,
                 ,::,    ::rv77iiiriii:iii:i::,rvLq@huhao.Li
             ,,      ,, ,:ir7ir::,:::i;ir:::i:i::rSGGYri712:
           :::  ,v7r:: ::rrv77:, ,, ,:i7rrii:::::, ir7ri7Lri
          ,     2OBBOi,iiir;r::        ,irriiii::,, ,iv7Luur:
        ,,     i78MBBi,:,:::,:,  :7FSL: ,iriii:::i::,,:rLqXv::
        :      iuMMP: :,:::,:ii;2GY7OBB0viiii:i:iii:i:::iJqL;::
       ,     ::::i   ,,,,, ::LuBBu BBBBBErii:i:i:i:i:i:i:r77ii
      ,       :       , ,,:::rruBZ1MBBqi, :,,,:::,::::::iiriri:
     ,               ,,,,::::i:  @arqiao.       ,:,, ,:::ii;i7:
    :,       rjujLYLi   ,,:::::,:::::::::,,   ,:i,:,,,,,::i:iii
    ::      BBBBBBBBB0,    ,,::: , ,:::::: ,      ,,,, ,,:::::::
    i,  ,  ,8BMMBBBBBBi     ,,:,,     ,,, , ,   , , , :,::ii::i::
    :      iZMOMOMBBM2::::::::::,,,,     ,,,,,,:,,,::::i:irr:i:::,
    i   ,,:;u0MBMOG1L:::i::::::  ,,,::,   ,,, ::::::i:i:iirii:i:i:
    :    ,iuUuuXUkFu7i:iii:i:::, :,:,: ::::::::i:i:::::iirr7iiri::
    :     :rk@Yizero.i:::::, ,:ii:::::::i:::::i::,::::iirrriiiri::,
     :      5BMBBBBBBSr:,::rv2kuii:::iii::,:i:,, , ,,:,:i@petermu.,
          , :r50EZ8MBBBBGOBBBZP7::::i::,:::::,: :,:,::i;rrririiii::
              :jujYY7LS0ujJL7r::,::i::,::::::::::::::iirirrrrrrr:ii:
           ,:  :@kevensun.:,:,,,::::i:i:::::,,::::::iir;ii;7v77;ii;i,
           ,,,     ,,:,::::::i:iiiii:i::::,, ::::iiiir@xingjief.r;7:i,
        , , ,,,:,,::::::::iiiiiiiiii:,:,:::::::::iiir;ri7vL77rrirri::
         :,, , ::::::::i:::i:::i:i::,,,,,:,::i:i:::iir;@Secbone.ii:::
		 
-->
*/

#include<bits/stdc++.h>

using namespace std;

int main() {
	int n;
	cin>>n;
	if (n<1200) {
		cout<<"ABC"<<endl;
	}
	else if (n<2800) {
		cout<<"ARC"<<endl;
	}
	else {
		cout<<"AGC"<<endl;
	}
//	system("pause");
}

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

int main(){
int W,a,b;
  cin>>W>>a>>b;
  
  if(a+W<b){cout<<b-(a+W);}
  else if(a+W>=b && b>=a){cout<<0;}
  else{cout<<a-(b+W);}
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int r, d, x;cin>>r>>d>>x;
    ll last_x = x;
    for(int i=0;i<10;i++){
        ll ans = r*last_x - d;
        last_x = ans;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

ll compare_ll(const void *a, const void *b){
    return *(ll*)a - *(ll*)b;
}

int main(){
    int n, m;
	ll money=0;
  	typedef struct{
      ll a,b;
    }st;
  	st store[100000]={0};

    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++){
		scanf("%lld%lld", &store[i].a, &store[i].b);
    }
    qsort( store, n, sizeof(store[0]), compare_ll );
	
	for(int i=0; i<n; i++){
		if( m > store[i].b ){ m -= store[i].b;	money += (store[i].a * store[i].b); }
		else				{					money += (store[i].a * m); break;   }
	}
	printf("%lld\n", money);
  	return 0;
}

Measured memory_bytes: 4660
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	int ns = 0;
	for (int i = 0; i < n; i++) {
		long long p; cin >> p;
		while (p % 2 == 0) {
			p /= 2;
			ns++;
		}
	}
	cout << ns << endl;
}

Measured memory_bytes: 512
alp = input()
list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
point_alp = list.index(alp)
print(list[point_alp+1])

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int sum = 0;
    
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                for (int l = 0; l<= 9; l++) {
                    if (i + j + k + l >= A
                        && i + j + k + l <= B
                        && 1000 * i + 100 * j + 10 * k + l <= N){
                            sum += 1000 * i + 100 * j + 10 * k + l;
                        }

                }
            }
        }
    }

    if (N == 10000 && A == 1) { 
        sum += 10000;
    }

    cout << sum << endl;

    
}

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

int main() {
  long long N;
  cin >> N;
  
  long long juu=1;
  long long kyuu=1;
  long long hachi=1;
  
  for(int i=0;i<N;i++){
    kyuu = kyuu * 9; kyuu = kyuu%1000000007;
    hachi = hachi * 8; hachi = hachi%1000000007;
    juu = juu * 10; juu = juu%1000000007;
  }
  
  long long ans = juu + hachi + 1000000007 + 1000000007 - kyuu - kyuu;
  
  cout << ans % 1000000007 << endl;
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b - b);
}


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

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using str = string;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int N;
    cin >> N;
    str S;
    cin >> S;
    int R = 0, B = 0, G = 0 ;

    for(int i = 0; i < N; i++) {
        if(S[i] == 'R') R++;
        if(S[i] == 'B') B++;
        if(S[i] == 'G') G++;
    }
    ll count = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int k = 2*j - i;
            if(k >= N) continue;
            if(S[i] == S[j] || S[j]== S[k] || S[k] == S[i]) continue;
            count++;
        }
    }
    cout << (ll)R*B*G - count << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define int long long

const int mod = (int) 1e9 + 7;
const int N = 1000005;

int fac[N];
int inv[N];

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}

int mul(int a, int b) {
  return (1ll * a * b) % mod;
}

int fp(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = mul(ans, a);
    }
    b >>= 1;
    a = mul(a, a);
  }
  return ans;
}

int inver(int x) {
  return fp(x, mod - 2);
}

int comb(int n, int k) {
  int ans = (1ll * fac[n] * inv[k]) % mod;
  ans = (1ll * ans * inv[n - k]) % mod;
  return ans;
}

int32_t main() {
  int x, y;
  cin >> x >> y;
  fac[0] = 1;
  for (int i = 1; i < N; i++) fac[i] = (1ll * i * fac[i - 1]) % mod;
  for (int i = 0; i < N; i++) inv[i] = inver(fac[i]);
  int ans = 0;
  for (int i = 0; i <= x; i++) {
    if (2 * i > y) break;
    int aa = x - i, bb = y - 2 * i;
    if (bb == 0) {
      if (aa == 0) add(ans, 1);
      continue;
    }
    if (aa % 2 != 0 || aa / bb != 2 || aa % bb != 0) continue;
    add(ans, comb(bb + i, bb));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string A, B, C;
   cin >> A >> B >> C;
   if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) cout << "YES" << endl;
   else cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 256
def resolve():
    N,k = map(int,input().split())
    K = k-1
    H = list(int(input()) for _ in range(N))
    H.sort()
    minh = 10**10
    for i in range(K,N):
        minh = min(minh,abs(H[i-K]-H[i]))
    print(minh)
resolve()


Measured memory_bytes: 7492
<?php
 
function gcd($a,$b){
	return $b==0? $a:gcd($b,$a % $b);
}
while(true){
	$input = fgets(STDIN,255);
	if(! $input)break;
	$input = explode(' ',$input);
	$a = intVal($input[0]);
	$b = intVal($input[1]);
	$c = gcd($a,$b);
	echo sprintf("%d %d\n",$c,$a*$b/$c);
}
flush();

?>

Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define MAX 1000000000
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  int p[N][2];
  rep(i,N)cin>>p[i][0]>>p[i][1];
  int c[M][2];
  rep(i,M)cin>>c[i][0]>>c[i][1];
  int minnum;
  rep(i,N){
    int mn = MAX;
    rep(j,M){
      if(abs(c[j][0] - p[i][0])+abs(c[j][1] - p[i][1]) < mn){
        minnum = j;//あとで+1;
        mn = abs(c[j][0] - p[i][0])+abs(c[j][1] - p[i][1]);
      }
    }
    cout << minnum+1 << endl;
  }
}

Measured memory_bytes: 256
S = input()
HD = int(S[0:2])
TL = int(S[2:])

if HD > 0 and HD <= 12 and TL > 0 and TL <= 12:
    print('AMBIGUOUS')
elif (HD == 0 or HD > 12) and TL > 0 and TL <= 12:
    print('YYMM')
elif HD > 0 and HD <= 12 and (TL == 0 or TL > 12):
    print('MMYY')
else:
    print('NA')


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

using i64 = long long;
using P = pair<i64, i64>;


void solve(long long X){
    vector<bool> dp(X + 1, false);
    dp[0] = true;
    for(int i = 0; i < X + 1; ++i){
        for(int j = 0; j < 6; ++j){
            if(i + 100 + j <= X){
                dp[i + j + 100] = (dp[i] || dp[i + j + 100]);
            }
        }
    }
    if(dp[X]) cout << 1 << endl;
    else cout << 0 << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
/*
std::vector<std::pair<std::set<int>, std::set<int>>> list;

int root_idx;

std::vector<int> FindLongestPathToRoot(int n){
	if(n == root_idx) {
      std::vector<int> v;
      v.push_back(n);
      return v;
    }
  	std::vector<int> max_path;
  	for(int parent : list[n].first){
    	auto tmp = FindLongestPathToRoot(parent);
    	if(tmp.size() > max_path.size()) max_path = tmp;
    }
  max_path.push_back(n);
  return max_path;
}

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++){
    list.push_back(std::make_pair(std::set<int>(), std::set<int>()));
  }
  for(int i = 0; i < N - 1 + M; i++){
  	int from, to;
    scanf(" %d %d", &from, &to);
    list[to - 1].first.insert(from - 1);	// in
    list[from - 1].second.insert(to - 1);	// out
  }
  for(int i = 0; i < N; i++){
  	if(list[i].first.size() == 0){
      root_idx = i;
      break;
    }
  }
  for(int i = 0; i < N; i++){
    if(list[i].first.size() == 0){
    	printf("0\n");
      continue;
    }
    if(list[i].first.size() <= 1){
      printf("%d\n", *list[i].first.begin() + 1);
      continue;
    }
    auto path = FindLongestPathToRoot(i);
    for(int p : path){
    }
    int p = 0;
    while(path.size()){
      p = path.back();
      path.pop_back();
      if(list[i].first.find(p) != list[i].first.end()){
        break;
      }
    }
    for(auto it = list[i].first.begin(); it != list[i].first.end(); )
        if(*it != p){
          list[*it].second.erase(list[*it].second.find(i));
          it = list[i].first.erase(it);
        }
      else ++it;
    printf("%d\n", *list[i].first.begin() + 1);
  }
  return 0;
}
*/

int main(){
  int T, X;
  scanf("%d %d", &T, &X);
  printf("%lf", (double)T / X);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int n;
  double x1,x2,x3,x4,y1,y2,y3,y4,m1,m2;

  scanf("%d",&n);

  while(n-- > 0){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
    m1 = (y2-y1)/(x2-x1);
    m2 = (y4-y3)/(x4-x3);
    m1 == m2?printf("YES\n"):printf("NO\n");
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 1000000000000
int main() {
	long long n,x;
	cin >> n >> x;
	vector<long long> a;
	REP(i, n) {
		long long b;
		cin >> b;
		a.push_back(b);
	}
	long long cost = 0;
	for (int i = 1;i < n;++i) {
		if (a[i] + a[i - 1] > x) {
			long long wow =  (a[i] + a[i - 1])-x;
			cost += wow;
			a[i] -= wow;
			if (a[i] < 0) {
				a[i - 1] += a[i];
				a[i] = 0;
			}
		}
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int l=0,r=0;
    for(int i=1;i<n;i++){
        if(s[i]=='W') r++;
    }
    int ans=n-r-1;
    for(int i=1;i<n;i++){
        if(s[i-1]=='E')  l++;
        if(s[i]=='W') r--;
        ans=min(ans,n-l-r-1);
    }
    cout<<ans<<endl;
}

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

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

    vector<vector<int> > grid(10, vector<int>(10, 0));
    for(int i=1; i<=n; i++) {
        int first = i%10;
        int temp = i;
        while(temp>=10) temp/=10;
        int last = temp;

        grid[first][last]++;
    }

    int res = 0;
    for(int i=0; i<=9; i++) {
        for(int j=0; j<=9; j++) {
            res+=grid[i][j]*grid[j][i];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
/* 17D8104017J 長田ひかり C++ hikadesyon911 */

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){

  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string str,word;
  set<string> dictionary;
  vector<string> ans;

  while(n--){
    cin >> str >> word;
    if(str=="insert"){
      dictionary.insert(word);
    }
    else  cout << (dictionary.find(word)!=dictionary.end()?"yes":"no") << endl;
  }
}


Measured memory_bytes: 29812
#n = int(input())
n,a,b = map(int,input().split())
#lst1 = list(map(int,input().split()))
ans = 0
for i in range(1,n+1):
    lst1 = list(str(i))
    res = 0
    for j in lst1:
        res += int(j)
    if a <= res <= b:
        ans += i
print(ans)

Measured memory_bytes: 40556
#include <stdio.h>
int main(void) {
	int stack[100], value, i, top = -1;
	char in[10];
	
	while (scanf("%s ", in) != EOF) {
		if ('0' <= in[0] && in[0] <= '9') {
			for (value = i = 0; in[i] != '\0'; i++) {
				value *= 10;
				value += in[i] - '0';
			}
			stack[++top] = value;
		} else if (in[0] == '+') {
			stack[top-1] += stack[top];
			top--;
		} else if (in[0] == '-') {
			stack[top-1] -= stack[top];
			top--;
		} else if (in[0] == '*') {
			stack[top-1] *= stack[top];
			top--;
		}
	}
	printf("%d\n", stack[top]);
	return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
int main(void) 
{
    string s, t;
    int a, b;
    string u;
    cin>> s>> t>> a>> b>> u;
    if (u == s) a--;
    if (u == t) b--;
    cout <<a <<" " <<b <<endl;
    
    return 0;
}

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

using namespace std;

int n;
bool visit[560000];
int prime[560000], num = 0;

void init_prim() {
    memset(visit, true, sizeof(visit));
    for (int i = 2; i <= 560000; ++i) {
        if (visit[i]) {
            num++;
            prime[num] = i;
        }
        for (int j = 1; ((j <= num) && (i * prime[j] <= n)); ++j) {
            visit[i * prime[j]] = false;
            if (i % prime[j] == 0) break;
        }
    }
}

const int table[] = {7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297, 1307, 1327, 1367, 1427, 1447, 1487, 1567, 1597, 1607, 1627, 1637, 1657, 1667, 1697, 1747, 1777, 1787, 1847, 1867, 1877, 1907, 1987, 1997};

int main() {
    cin >> n;
    init_prim();
    for (int i = 0; i < n; i++) {
        cout << table[i];
        if (i < n - 1) cout << " ";
    }

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
int a[200010];
int m;
int b[200010];

void solve() {
  cin >> n;
  REP(i, n) cin >> a[i+1];
  m = 0;
  for(int i = n; i >= 1; i--) {
    int ptr = n-n%i;
    int x = 0;
    while(ptr > i) {
      x ^= b[ptr];
      ptr -= i;
    }
    b[i] = x ^ a[i];
    if(b[i] == 1) m++;
  }
  cout << m << endl;
  FOR(i, 1, n+1) if(b[i]) cout << i << " " ;
  if (m > 0) cout << endl;

}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> d(N);
	for(int i=0;i<N;i++){
		cin>>d[i];
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans += d[i]*d[j];
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}

Measured memory_bytes: 256
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y,z;
int main(){
	fastio;
	cin>>n;
	int dp[n+1][3]={0};
	// dp[0][0]=dp[0][1]=dp[0][2]=0;
	forn(i,n){
		cin>>x>>y>>z;
		dp[i+1][0] = max(dp[i][1],dp[i][2])+x;
		dp[i+1][1] = max(dp[i][0],dp[i][2])+y;
		dp[i+1][2] = max(dp[i][1],dp[i][0])+z;
	}
	cout<< max({dp[n][0],dp[n][1],dp[n][2]}) <<ln;
	return 0;
}

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

int main() {
    int x,a;
    cin >> x >> a;
    x<a ? cout << 0 : cout << 10;
    cout << endl;
}


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

using namespace std;
int res;
vector<string> del(vector<string> s){
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i][0] != 'A' && s[i][0] == s[i][1] && s[i][0] == s[i][3] && s[i][0] == s[i][4] && s[i][0] == s[i][2]){
      res+=5*(s[i][0]-'0');s[i][0] = s[i][1] = s[i][2] = s[i][3] = s[i][4] = 'A';
    }
    if(s[i][0] != 'A' && s[i][0] == s[i][1] && s[i][0] == s[i][3] && s[i][0] == s[i][2]){
      res+=4*(s[i][0]-'0');s[i][0] = s[i][1] = s[i][2] = s[i][3] = 'A';
    }
    if(s[i][1] != 'A' && s[i][1] == s[i][3] && s[i][1] == s[i][4] && s[i][1] == s[i][2]){
      res+=4*(s[i][1]-'0');s[i][1] = s[i][2] = s[i][3] = s[i][4] = 'A';
    }
    if(s[i][0] != 'A' && s[i][0] == s[i][1] && s[i][0] == s[i][2]){res+=3*(s[i][0]-'0');s[i][0] = s[i][1] = s[i][2] = 'A';}
    if(s[i][1] != 'A' && s[i][3] == s[i][1] && s[i][3] == s[i][2]){res+=3*(s[i][1]-'0');s[i][3] = s[i][1] = s[i][2] = 'A';}
    if(s[i][2] != 'A' && s[i][4] == s[i][3] && s[i][4] == s[i][2]){res+=3*(s[i][2]-'0');s[i][4] = s[i][3] = s[i][2] = 'A';}
  }
  return s;
}

vector<string> move(vector<string> s){
  for(int i = s.size()-1; i > 0 ; i --){
    for(int j = 0 ; j < 5 ; j ++){
      //cout<<s[i][j];
      if(s[i][j] == 'A'){
	//cout<<"c";
	swap(s[i][j],s[i-1][j]);
      }
    } 
    //cout<<endl;
  }
  return s;
  
}

int main(void){
  int n;
  while(cin>>n,n){

    res = 0;
    vector<string> s(n);
    for(int i = 0 ; i < n ;  i++){
      for(int j = 0 ; j < 5 ; j ++){
	char c;
	cin>>c;
	s[i]+=c;
      }
    }
    vector<string> last;
    while(last!=s){
      last=s;
      s = del(s);
      /*
      cout<<"del "<<res<<endl;
      for(int i= 0 ; i< s.size() ; i ++){
	cout<<s[i]<<endl;;
      }
      cout<<"move"<<endl;
      //*/
      s = move(s);
      s = move(s);
      /*
      for(int i= 0 ; i< s.size() ; i ++){
	cout<<s[i]<<endl;;
      }
      //*/
    }
    /*
    cout<<"hellO"<<endl;
    for(int i = 0 ; i < last.size() ; i ++)cout<<last[i]<<endl;
    //*/
    cout<<res<<endl;
  }  
}

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

ll INF = 1001001001001;

int main() {
    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R){
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());

    ll d[N][N];
    rep(i, N){
        rep(j, N){
            if(i == j){
                d[i][j] = 0;
            } else {
                d[i][j] = INF;
            }
        }
    }

    rep(i, M){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(k, N){
        rep(i, N){
            rep(j, N){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int last = INF;
    do {
        int ans = 0;
        rep(i, R-1){
            ans += d[r[i]][r[i+1]];
        }
        last = min(last, ans);
    } while(next_permutation(r.begin(), r.end()));
    
    cout << last << endl;

    return 0;
}

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

using namespace std;

#define DIM 107
#define DIMM 2007
#define INF 10000000000007.0
#define X 2000000007
#define epc 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;
typedef pair<ll,pllll> pllpllll;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,m,c;
ll x,sum,res;
ll b[DIM];

int main()
{
    //freopen("events.in", "r", stdin);
    //freopen("events.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>m>>c;
    for(int i=1;i<=m;i++)cin>>b[i];
    for(int j=1;j<=n;j++){
     sum=0;
     for(int i=1;i<=m;i++){
      cin>>x;
      sum+=(b[i]*x);
     }
     if((sum+c)>0)res++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
ll inf=1e18;

/*
AC
補グラフを考え，２部グラフになってるかを確認する．２部グラフになってたら，連結成分を交互に２色に塗り分け，高国と橋国のどちらに振り分けるか決める．
作りうる全ての数を作るdpで片方の国の大きさを列挙し，それをc1とすると，答えは(c1,2)+(c2,2)の最小値（(a,b)は二項係数）
*/

bool ok=true;
ll n,m,d[710][710],visit[710]={},color[710]={},dp[710]={},smallest=1e9;
vector<int> c1,c2;

int main(void){
	rep(i,710)rep(j,710)d[i][j]=0;
	cin>>n>>m;
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		d[a-1][b-1]=1;
		d[b-1][a-1]=1;
	}
	rep(i,n)rep(j,n){
		if(i==j)continue;//補グラフでも自己辺は認めない
		d[i][j]=1-d[i][j];
	}
	//孤立点があった時も大丈夫（後述）
	rep(i,n){
		if(visit[i]==0){
			int a[3]={};
			a[1]++;
			visit[i]=1;
			color[i]=1;
			queue<mp> Q;
			Q.push({i,1});
			while(!Q.empty()){
				mp p=Q.front();Q.pop();
				rep(j,n){
					if(d[p.first][j]==1){
						if(visit[j]==0){
							visit[j]=1;
							color[j]=3-p.second;
							a[color[j]]++;
							Q.push({j,color[j]});
						}else{
							if(color[j]!=3-color[p.first]){
								ok=false;
								break;
							}
						}
					}
				}
			}
			//孤立点でも1,0になり，ほかと同様に扱えるので行ける．
			c1.push_back(a[1]);
			c2.push_back(a[2]);
		}
	}
	//作りうる全ての数を作るdp
	dp[0]=1;
	rep(i,c1.size()){
		int dp2[710]={};
		rep(j,710){
			if(dp[j]==1){
				if(j+c1[i]<710)dp2[j+c1[i]]=1;
				if(j+c2[i]<710)dp2[j+c2[i]]=1;
			}
		}
		rep(j,710)dp[j]=dp2[j];
	}
	rep(i,710){
		if(dp[i]==1){
			smallest=min(smallest,i*(i-1)/2+(n-i)*(n-i-1)/2);//ここを最小にする
		}
	}
	cout<<(ok?smallest:-1)<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
using namespace std;
map<int,int>mp;

int main()
{
    int n,m,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>x;
        if(mp[x]==0){
            cout<<"NO"<<endl;
            exit(0);
        }else mp[x]--;
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#define N 30
int main()
{
	char a[N];
	fgets(a,N,stdin);
	int i = 0;
	while (a[i++] != '\0')
	{
		continue;
	}
	for (i = i - 3; i >= 0; i--)
	{
		printf("%c", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1684
#include<cstdio> 
#include<cctype> 
#include<cstring> 
#include<algorithm> 
#define gc getchar() 
#define pc putchar
#define LL long long
inline int read() { 
    int x = 0,f = 1; 
    char c = getchar(); 
    while(c < '0' || c > '9') c = gc; 
    while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar(); 
    return x * f; 
}
void print(LL x) { 
    if(x < 0) { 
        pc('-'); 
        x = -x; 
    } 
    if(x >= 10) print(x / 10); 
    pc(x % 10 + '0'); 
} 
const int maxn = 20007; 
int n; 
int prime[maxn]; 
bool vis[maxn]; 
void pre(int lim = 10000) {  
    for(int cnt = 0,i = 2;i <= lim;++ i) { 
        if(!vis[i]) prime[++ cnt] = i; 
        for(int j = 1;j <= cnt && prime[j] * i <= lim;++ j) { 
            vis[i * prime[j]] = 1; 
            if(i % prime[j] == 0) break; 
        } 
    } 
} 
LL a[507][507]; 
LL gcd(LL x,LL y) { 
    return y == 0 ? x : gcd(y,x % y); 
} 
LL lcm(LL x,LL y) {
    return x / gcd(x,y) * y; 
} 
int main() { 
    n = read(); 
    pre(); 
    if(n == 2) {
        pc('4');pc(' ');pc('7');pc('\n'); 
        print(23);pc(' '); print(10); pc('\n'); 
        return 0;  
    } 
    for(int i = 0;i <= n + 1;++ i) 
        for(int j = 0;j <= n + 1;++ j) 
                a[i][j] = 1; 
    for(int i = 1;i <= n;++ i) 
        for(int j = 1;j <= n;++ j) { 
            if((j & 1) == (i & 1)) { 
                a[i][j] = prime[(i + j) / 2] * prime[(i + n + 1 - j) / 2 + n];  
                a[i + 1][j] = lcm(a[i + 1][j],a[i][j]); 
                a[i - 1][j] = lcm(a[i - 1][j],a[i][j]); 
                a[i][j + 1] = lcm(a[i][j + 1],a[i][j]); 
                a[i][j - 1] = lcm(a[i][j - 1],a[i][j]); 
            } 
        } 
    for(int i = 1;i <= n;++ i) 
        for(int j = 1;j <= n;++ j) 
            if((i & 1) == (j & 1)); 
            else a[i][j] ++; 
    for(int i = 1;i <= n;++ i,pc('\n')) 
        for(int j = 1;j <= n;++ j) 
            print(a[i][j]),pc(' '); 
    return 0; 
} 

Measured memory_bytes: 5120
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;

void cin_row(int* A, int N)
{
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
}

void cout_row(int* A, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N = 0;

    cin >> N;

    int A[100];
    cin_row(A, N);

    int cnt = 0;

    for (int i = 0; i < N; i++)
    {
        int mini = i;
        for (int j = i; j < N; j++)
        {
            if (A[j] < A[mini]) mini = j;
        }
        if (i != mini)
        {
            std::swap(A[i], A[mini]);
            cnt++;
        }
    }



    cout_row(A, N);
    cout << cnt << endl;

    return 0;
}



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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

int h, w, d;
int a[301][301];
int q;
int l[100001], r[100001];
vector<pair<int, int>> cood(90001);
vector<int> cost(900001, 0);


void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(c <= a+b) {
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
template <typename T>
struct Fenwick {
	int n;
	vector<T> bit;
	Fenwick(int _n) : n(_n) {
		bit.resize(n + 1);
	}
	void update(int p, T v) {
		for (; p <= n; p += p & -p) bit[p] += v;
	}
	T query(int p) {
		T ret{};
		for (; p; p -= p & -p) ret += bit[p];
		return ret;
	}
};
int main() {
	int n;
	scanf("%d", &n);
	vector<vector<int>> A(3, vector<int>(n));
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < n; ++j) {
			scanf("%d", &A[i][j]);
			--A[i][j];
		}
	vector<int> flip(2);
	auto no = []() {
		printf("No\n");
		exit(0);
	};
	for (int c = 0; c < n; ++c) {
		if (A[0][c] / 3 != A[1][c] / 3 || A[1][c] / 3 != A[2][c] / 3 || A[1][c] % 3 != 1) {
			no();
		}
		if ((A[0][c] / 3) % 2 != (c % 2)) no();
		flip[c % 2] ^= A[0][c] % 3 == 2;
	}
	for (int p = 0; p < 2; ++p) {
		Fenwick<int> fenw(n);
		for (int c = p; c < n; c += 2) {
			int i = A[0][c] / 3;
			int greater = fenw.query(n) - fenw.query(i + 1);
			flip[1 - p] ^= greater & 1;
			fenw.update(i + 1, 1);
		}
	}
	printf(flip[0] == 0 && flip[1] == 0 ? "Yes\n" : "No\n");
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;
const ll mod=1e9+7;

ll bigmod(ll a, ll b, ll mod){
  a %= mod;
  ll ret = 1;
  while(b){
    if(b&1) ret = ret*a%mod;
    a = a*a%mod;
    b >>= 1;
  }
  return ret;
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  ll n;  cin >> n;
  ll ans = (bigmod(10, n, mod) - 2*bigmod(9, n, mod) + bigmod(8, n, mod))%mod;
  if(ans<0) ans += mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin >> n;
	ll a[n];
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		ans += (a[i] & 1 && i % 2 == 0);
	}
	cout << ans << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;


map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
signed main() {
    int n;
    cin >> n;
    int ans =0;
    FOR(i,2,n+1) {
        if(i%2==0)continue;
        map<ll,ll> a = prime_factors(i);
        int tmp = 1;
        for(auto aa:a) {
            tmp *= (aa.second+1);
        }
        if(tmp==8) ans++; 
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(void)
{
  int n,a,b; cin>>n>>a>>b;
  
  if((n*a)>b){cout<<b<<endl;}
  else if((n*a)<b){cout<<n*a<<endl;}
  else{cout<<b<<endl;}
  
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string L;
    vector<pair<ll, ll>> dp;
    cin >> L;
    dp.resize(L.size() + 1);
    dp[0].second = 1;
    for(ll i = 0;i < L.size();i++) {
        if(L[i] == '1') {
            dp[i + 1].first += (dp[i].first + dp[i].second) % MOD;
            dp[i + 1].first += 2 * dp[i].first % MOD;
            dp[i + 1].second += 2 * dp[i].second % MOD;
        } else {
            dp[i + 1].first += 3 * dp[i].first % MOD;
            dp[i + 1].second += dp[i].second;
        }
        dp[i + 1].first %= MOD;
        dp[i + 1].second %= MOD;
    }
    cout << (dp[L.size()].first + dp[L.size()].second) % MOD << endl;
    return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll a, b;

int main() {
    cin >> a >> b;
    ll c = a + b;
    if (c & 1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << c / 2 << endl;
    return 0;
}


Measured memory_bytes: 3672
using System.Collections.Generic;
using System;

public class Hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		var d = new Dictionary<string, int>();
		for (int i = 0; i < n; i++)
		{
			var s = Console.ReadLine().Trim();
			var sa = s.ToCharArray();
			Array.Sort(sa);
			var sb = new string(sa);
			if (d.ContainsKey(sb)) d[sb]++;
			else d[sb] = 1;
		}
		getAns(d);
	}
	static void getAns(Dictionary<string, int> d)
	{
		var ans = 0L;
		foreach (var x in d)
			ans += ((long)x.Value) * ((long)x.Value - 1) / 2L;
		Console.WriteLine(ans);
	}
}

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

int main() {
	int n, ans = 0;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 1; i <= n; i++) cin >> v[i];
	for (int i = 1; i <= n; i++)cin >> c[i];
	
	for(int i=1;i<=n;i++){
		if (v[i] - c[i] > 0)ans += v[i] - c[i];
	}

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

Measured memory_bytes: 256
def getN():
    return int(input())

def getlist():
    return [int(x) for x in input().split()]

n = getN()
s = input()

cnt = 0
for c in s:
    if c == "R":
        cnt += 1

if cnt * 2 > n:
    print("Yes")

else:
    print("No")

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    int n; cin>>n;
    string s; cin>>s;
    int res = 1;
    FOR(i, 1, s.size()) {
        if(s[i] != s[i-1]) res++;
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N, p;
  int cnt = 1;
  cin >> N;
  cin >> p;
  int min_p = p;

  for (int i=1; i<N; i++){
    cin >> p;
    if (p < min_p) {
      cnt++;
    }
    min_p =min(p, min_p);
  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    char s[4];
    for(int i=0;i<4;i++)cin >> s[i];

    int ans = 0;
    for(int i=0;i<4;i++){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main()
{
	std::string s, t;
	std::getline(std::cin, s);
	std::getline(std::cin, t);

	for (int i = 0; i < s.length() - 1; i++)
	{
		for (int j = s.length() - 1; j > i; j--)
		{
			if (s[j - 1] > s[j])
			{
				char temp = s[j - 1];
				s[j - 1] = s[j];
				s[j] = temp;
			}
		}
	}

	for (int i = 0; i < t.length() - 1; i++)
	{
		for (int j = t.length() - 1; j > i; j--)
		{
			if (t[j - 1] < t[j])
			{
				char temp = t[j - 1];
				t[j - 1] = t[j];
				t[j] = temp;
			}
		}
	}

	for (int i = 0; i < std::min(s.length(), t.length()); i++)
	{
		if (s[i] < t[i])
		{
			std::cout << "Yes";
			return 0;
		}
		else if (s[i] > t[i])
		{
			std::cout << "No";
			return 0;
		}
	}

	//still alive
	if (s.length() < t.length())
	{
		std::cout << "Yes";
	}
	else std::cout << "No";

    return 0;
}



Measured memory_bytes: 256