akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
#define pll pair<LL,LL>
#define pii pair<int,int>
#define LL long long
#define pb push_back
#define pi acos(-1)
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
int dis[505][505];
int vis[505][505];
int X[4]={0,0,1,-1};
int Y[4]={1,-1,0,0};
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dis[i][j]=min(min(i,j),min(n-i+1,n-j+1));
            vis[i][j]=1;
        }
    }
    int ans=0;
    for(int i = 1;i<=n*n;i++){
        int p;
        scanf("%d",&p);
        p--;
        int x=p/n+1;
        int y=p%n+1;
        ans+=dis[x][y]-1;
     /*   printf("%d\n",dis[x][y]-1);
        for(int i = 1;i<=n;i++){
            for(int j=1;j<=n;j++){
                printf("%d ",dis[i][j]);
            }
            printf("\n");
        }*/
        dis[x][y]--;
        vis[x][y]=0;
        queue<pii> q;
        q.push(mp(x,y));
        while(!q.empty()){
            pii p=q.front();
            q.pop();
            for(int i = 0 ; i<4;i++){
                int xx=X[i]+p.x;
                int yy=Y[i]+p.y;
                if(dis[xx][yy]>dis[p.x][p.y]+vis[xx][yy]){
                    dis[xx][yy]=dis[p.x][p.y]+vis[xx][yy];
                    q.push(mp(xx,yy));
                }
            }
        }
    }
    printf("%d\n",ans);
}
/*
2 11 14
9 3



*/

Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#define NMAX 40
struct node {
  long long int value, weight;
};

int compare(const void *a, const void *b);

int main(void)
{
  int i, j, n, n2, c1 = 0, c2 = 0;
  long long int w, res = 0;
  static struct node vw[NMAX], ps[1<<(NMAX/2)];
  scanf("%d%lld", &n, &w);
  for (i = 0; i < n; i++) scanf("%lld%lld", &vw[i].value, &vw[i].weight);
  n2 = n / 2;
  for (i = 0; i < 1 << n2; i++) {
    long long int sv = 0, sw = 0;
    for (j = 0; j < n2; j++) {
      if (i >> j & 1) {
        sv += vw[j].value;
        sw += vw[j].weight;
      }
    }
    ps[c1].value = sv;
    ps[c1++].weight = sw;
  }
  qsort(ps, c1, sizeof(struct node), compare);
  for (i = 1; i < c1; i++) {
    if (ps[c2].value < ps[i].value) ps[++c2] = ps[i];
  }
  for (i = 0; i < 1 << (n - n2); i++) {
    long long int sv = 0, sw = 0;
    for (j = 0; j < n - n2; j++) {
      if (i >> j & 1) {
        sv += vw[n2+j].value;
        sw += vw[n2+j].weight;
      }
    }
    if (sw <= w) {
      int m, l = 0, r = c2;
      long long int x = w - sw;
      while (l <= r) {
        m = (l + r) / 2;
        if (ps[m].weight > x) r = m - 1;
        else l = m + 1;
      }
      if (sv + ps[r].value > res) res = sv + ps[r].value;
    }
  }
  printf("%lld\n", res);
}

int compare(const void *a, const void *b)
{
  struct node ta = *(struct node*)a, tb = *(struct node*)b;
  if (ta.weight > tb.weight) return 1;
  else if (ta.weight < tb.weight) return -1;
  else if (ta.value > tb.value) return 1;
  else if (ta.value < tb.value) return -1;
  return 0;
}


Measured memory_bytes: 34480
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  std::io::stdin().read_line(&mut s).unwrap();
  let mut s = s.split_whitespace();
  let n: usize = s.next().unwrap().trim().parse().unwrap();
  let s: Vec<char> = s.next().unwrap().trim().chars().collect();
  let mut chars: Vec<char> = Vec::new();
  chars.push(s[0]);
  for i in 1..n {
    if s[i] != s[i-1] {
      chars.push(s[i]);
    } else {
      continue;
    }
  }
  println!("{}", chars.len());
}

Measured memory_bytes: 2876
import collections
def main():
    N = int(input())
    S = list(input())
    if len(set(S))==1:
        print(0)
        return
    cnt = 0
    left = 0
    right = len(S)-1
    while left<right:
        while left<len(S) and S[left]=='R':
            left += 1
        while right>=0 and S[right] == 'W':
            right -=1
        if left<right and S[left] == 'W':
            cnt +=1
            left += 1
            right -=1
    print(cnt)
    return 0
if __name__ == "__main__":
    main()

Measured memory_bytes: 11068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int count = 0;
  for(int i = a; i <= b; i++){
    int r;
    r = i%10*10000 + i/10%10*1000 + i/100%10*100 + i/1000%10*10 + i/10000%10*1;
    if(r == i){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long N, A, B;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A >> B;
  if (N == 1) {
    if (A==B) cout << 1 << "\n";
    else cout << 0 << "\n";
  }
  else {
    long long lo = A*(N-1)+B, hi = B*(N-1)+A;
    cout << max(0LL, hi-lo+1) << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001];
	unsigned int i;
	int j;
	
	fgets(str, 1001, stdin);
	
	for(i = 0;i <= strlen(str) - 5;i++){
		if(strncmp(&str[i],"peach",5) == 0){
			strncpy(&str[i],"apple",5);
			i += 5;
		}
		if(strncmp(&str[i],"apple",5) == 0){
			strncpy(&str[i],"peach",5);
			i += 5;
		}
	}
	printf("%s", str);
	
	return (0);
}

Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n/2){
        if(s[i] != s[n-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=25555555;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,ga,gb,sa,sb,ba,bb;
ll f[maxn],g[maxn];
int main(){
	n=read();ga=read();sa=read();ba=read();gb=read();sb=read();bb=read();
	FOR(i,0,25000000){
		if(i>=gb) f[i]=max(f[i],f[i-gb]+ga-gb);
		if(i>=sb) f[i]=max(f[i],f[i-sb]+sa-sb);
		if(i>=bb) f[i]=max(f[i],f[i-bb]+ba-bb);
	}
	FOR(i,0,25000000) f[i]=i+f[i];
	FOR(i,0,25000000){
		if(i>=ga) g[i]=max(g[i],g[i-ga]+gb-ga);
		if(i>=sa) g[i]=max(g[i],g[i-sa]+sb-sa);
		if(i>=ba) g[i]=max(g[i],g[i-ba]+bb-ba);
	}
	printf("%lld\n",f[n+g[n]]);
}

Measured memory_bytes: 393472
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

int N;
long long int K, A[100005];
int V[45];

long long int CALC(long long int tmp) {

	long long int ret = 0;
	for (int i = 1; i <= N; i++) {
		ret += tmp^A[i];
	}
	return ret;
}

int main(void) {

	cin >> N >> K;

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

	for (int i = 0; i<=44; i++) {
		int num = 0;
		for (int j = 1; j <= N; j++) {
			if (A[j] & ((long long int) 1 << i)) {}
			else { num++; }
		}
		if (num > N - num) { V[i] = 1; }
		else { V[i] = 0; }
	}

	

	long long int X = 0;
	for (int i = 44; i >= 0; i--) {
		X *= 2;
		X += V[i];
	}

	//cout << "X=" << bitset<12>(X) << endl;

	long long int ans = 0;

	long long int tmp = K;
	ans = CALC(tmp);
	while (tmp) {
		long long int h = tmp&(-tmp);
		tmp -= h;
		long long int G;
		G = tmp | (X&(h - 1));// cout << "G= " << G << endl;
		ans = max(ans, CALC(G));
	}
	tmp = 0;

	/*cout << "K= " << bitset<12>(K) << endl;

	for (int i = 44; i >= 0; i--) {
		if (K&((long long int) 1 << i)) {
			cout << "i=  " << i << endl;
			long long int H;
			H = ((K >> i) << i);
			H += (X&((1 << i) - 1));
			cout << "H= " << bitset<12>(H) << endl;
			ans = max(ans, CALC(H));
		}
	}*/

	ans = max(ans, CALC(0));

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

using namespace std;

const int N = 1234567;

int n;
int a[N];

bool win() {
  vector <int> pref(n + 1), suf(n + 1);
  pref[0] = 0;
  for (int i = 0; i < n; i++) {
    pref[i + 1] = __gcd(pref[i], a[i]);
  }
  suf[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    suf[i] = __gcd(suf[i + 1], a[i]);
  }
  int safe = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      continue;
    }
    int g = __gcd(pref[i], suf[i + 1]);
    if (g > 1 && (a[i] - 1) % g == 0) {
      a[i]--;
      for (int j = 0; j < n; j++) {
        a[j] /= g;
      }
      if (!win()) {
        return true;
      }
      for (int j = 0; j < n; j++) {
        a[j] *= g;
      }
      a[i]++;
    } else {
      safe++;
    }
  }
  if (safe > 0) {
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i] - 1;
    }
    if (sum % 2 == 1) {
      return true;
    }
  }
  return false;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  puts(win() ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 19456
#include<iostream>

using namespace std;

long long int a,b;

int main(void)
{
	while(cin>>a>>b){
		long long int x,y;
		x=1;
		for(int i=2;i<=a&&i<=b;){
			if(a%i==0&&b%i==0){
				x=x*i;
				a=a/i;
				b=b/i;
				i=2;
			}else{ i++; }
		}
		y=x*a*b;
		cout<<x<<" "<<y<<endl;
	}
}

Measured memory_bytes: 1156
from collections import deque
H,W=map(int,input().split())
wnum=0
field=[input() for _ in range(H)]
for i in range(H):
    for j in range(W):
        if field[i][j]=='.':
            wnum+=1
# スタートからゴールまでの最短経路をBFSで求め、wnumからその分を引けば、最大スコアが得られる。
dist=[[-1]*W for _ in range(H)]
dist[0][0]=0
que=deque()
que.append([0,0])
while (len(que)!=0):
    s_h,s_w=que.popleft()
    for dh,dw in [[-1,0],[1,0],[0,-1],[0,1]]:
        nh=s_h+dh
        nw=s_w+dw
        if nh<0 or nh>=H or nw<0 or nw>=W:continue
        if field[nh][nw]=='#':continue
        if dist[nh][nw]!=-1:continue
        dist[nh][nw]=dist[s_h][s_w]+1
        que.append([nh,nw])
if dist[H-1][W-1]==-1:
    print(-1)
else:
    print(wnum-(dist[H-1][W-1]+1))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << 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...); }

const int N = 1001;

vector<int> gr[N];
int p[N], sn, en;
bool o[N], c[N], v[N];

void dfs(int node)
{
	o[node] = true;
	for(int it : gr[node])
	{
		if(!o[it])
			dfs(it);
		else if(!c[it])
		{
			sn = it;
			en = node;
		}
	}
	c[node] = true;
}

int main()
{
	fio;
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++)
	{
		int u, v;
		cin >> u >> v;
		gr[u].pb(v);
	}
	for(int i=1; i<=n; i++)
		if(!o[i])
			dfs(i);
	if(sn == 0)
	{
		cout << -1 << endl;
		return 0;
	}
	queue<int> q;
	q.push(sn);
	while(!q.empty())
	{
		int t = q.front();
		q.pop();
		if(t == en)
			break;
		for(int it : gr[t])
		{
			if(!v[it])
			{
				p[it] = t;
				v[it] = true;
				q.push(it);
			}
		}
	}
	vector<int> v;
	v.pb(en);
	while(en != sn)
		v.pb(en = p[en]);
	reverse(v.begin(), v.end());
	cout << v.size() << endl;
	for(int it : v)
		cout << it << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

			int n = sc.nextInt();

			int border = sc.nextInt();
			
			int ok = 0;
			for(int i = 0 ; i < n ; i++) {
				int val = sc.nextInt();
				if (val >= border ) {
					ok++;
				}
			}
			
			System.out.println(ok);
		}
	}
}


Measured memory_bytes: 45684
#include <stdio.h>

#define INF 2000000000

int L[250002],R[250002];
int cnt=0;

void merge(int A[],int n,int l, int m, int r){
  int i,j,k,n1,n2;
  n1 = m - l;
  n2 = r - m;
  for (i = 0; i < n1; i++) {
    L[i] = A[l + i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[m + i];
  }
  L[n1] = INF;
  R[n2] = INF;
  i = 0, j = 0;
  for (k = l; k < r; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergesort(int A[],int n,int l,int r){
  int m;
  if (l+1 < r) {
    m = (l + r)/2;
    mergesort(A,n,l,m);
    mergesort(A,n,m,r);
    merge(A,n,l,m,r);
  }
}

int main() {
  int i,n,A[500000];

  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }

  mergesort(A,n,0,n);

  for (i = 0; i < n; i++) {
    if (i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 5668
#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 <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(string S){
    string a,b;
    REP(i,S.length()){
        a.push_back('0' + i % 2);
        b.push_back('1' - i % 2);
    }
    int ans[2] = {};
    for(int i = 0;i < S.length();++i){
        if(a[i] != S[i]) ans[0]++;
        if(b[i] != S[i]) ans[1]++;
    }
    cout << min(ans[0],ans[1]) << endl;

}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 768
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
using namespace std;
const LL Max=1e5+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
LL N,M,Loc,Ans,Num[Max];
int main(){
	LL I,J,K;
	scanf("%lld%lld",&N,&M);
	for(I=1;I<=M;I++){
		scanf("%lld",&Num[I]);
	}
	
	if(N<=M){
		printf("1");
	} else {
		Ans=1;N-=M;
		Ans+=N/(M-1);
		if(N%(M-1)){
			Ans++;
		}
		printf("%lld",Ans);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10, mod = 998244353;
int const nax = 1e6;

void plusle(int &a, int b){if((a += b) >= mod) a -= mod;}
void minun(int &a, int b) {if( (a -= b) < 0) a += mod ;}
int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
int sub(int a,int b) {a -= b; return a < 0 ? a + mod : a;}
int mul(int a,int b) {return (int)((1LL * a * b) % mod);}
int power(int a,int b){int res = 1; while(b > 0){if(b & 1) res = mul(res, a); a = mul(a,a); b >>= 1;} return res;}

int go[nax + 5], n, x, f[nax + 5];

int main(){
    int ans = 0;
    for(scanf("%d", &n); n -- ; ){
        scanf("%d", &x);
        plusle(go[x], x);
        minun(ans, x);
    }
    for(int i = nax ; i >= 1 ; i --){
        int res = 0, t = 0;
        for(int j = i ; j <= nax ;j += i){
            if(go[j])
                plusle(res, go[j]);
            if(j != i)
                plusle(t, f[j]);
        }
        res = mul(res, res);
        minun(res, t);
        f[i] = res;
        if(f[i])
            plusle(ans, mul(f[i], power(i, mod - 2)));
    }
    printf("%d\n", mul(ans, power(2, mod - 2)));
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pi acos(-1)
#define pii pair<int,int>
#define pb push_back
#define lowbit(x) ((x)&(-x))
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const ll mod =  998244353;

int n,num[maxn],len = 0,dig[55];
ll k;

void F(ll a) {
    int tot = 0;
    while(a) {
        if(a & 1) num[tot]++;
        tot++;
        a >>= 1;
    }
}
ll two[55],dp[55];
ll ans = 0;

void dfs(int pos,ll now,bool limit) {
    if(pos < 0) {
        ans = max(ans, now);
        return ;
    }
    if(!limit) {
        ans = max(ans, now + dp[pos]);
        return ;
    }
    int one = num[pos], zero = n - num[pos];
    if(one >= zero) {
        dfs(pos - 1, now + two[pos] * one, dig[pos] == 0);
    } else {
        if(dig[pos] == 0) dfs(pos - 1, now + two[pos] * one, limit);
        else {
            dfs(pos - 1, now + two[pos] * zero, true);
            dfs(pos - 1, now + two[pos] * one, false);
        }
    }

}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    mst(dig, 0);
    mst(num, 0);
    two[0] = 1;
    for(int i = 1; i < 55; i++) two[i] = two[i - 1] * 2;
    scanf("%d%lld",&n,&k);
    for(int i = 0; i < n; i++) {
        ll a;
        scanf("%lld",&a);
        F(a);
    }
    while(k) dig[len++] = k & 1,k >>= 1;
//    for(int i = 0; i < len / 2; i++) swap(dig[i], dig[len - 1 - i]);
//    for(int i = 0; i < len; i++) printf("%d",dig[i]);
//    printf("\n");
    for(int i = 0; i < 50; i++) {
        ll add = two[i] * max(num[i], n - num[i]);
        dp[i] = add;
        if(i) dp[i] += dp[i - 1];
    }
    dfs(40,0,true);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#![allow(unused)]

use std::{cell, cmp, collections, fmt, ops};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[cfg(feature = "debug")]
macro_rules! dbg {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! dbgln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! dbg {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! dbgln {
    ($($args:tt)*) => {};
}

mod num {
    //
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

mod bits {
    pub fn is_high(bits: u64, pos: u64) -> bool {
        bits & (1 << pos) != 0
    }
}

fn main() {
    const CAKE: i32 = 4;
    const DONUT: i32 = 7;

    input!(sum: i32);

    let mut rem = sum;
    while rem >= 0 {
        if rem % CAKE == 0 {
            println!("Yes");
            return;
        }

        rem -= DONUT;
    }

    println!("No");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };


int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  REP(i, n+1) cin >> a[i];
  REP(i, n) cin >> b[i];
  ll ans = sum(all(a));
  REP(i, n) {
    ll tmp = min(b[i], a[i]);
    a[i] -= tmp;
    b[i] -= tmp;
    tmp = min(b[i], a[i+1]);
    a[i+1] -= tmp;
    b[i] -= tmp;
  }
  cout << ans - sum(all(a)) << endl;
  return 0; 
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define ld long double
#define hell 1000000007
#define dd double
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define sep(i,n,b) for(ll i=n-1;i>=b;i--)
#define pb push_back
#define mp make_pair
#define Mll map<ll,ll>
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
vector<ll> adj[100005];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin >> n >> m;
	rep(i,0,m){
		ll u,v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	pair<ll,ll> que[500005];
	que[0]={1,0};
	ll st=0;
	ll en=1;
	map<ll,ll> ans;
	while(st<en){
		pair<ll,ll> top=que[st];
		st++;
		for(auto u:adj[top.F]){
			if(ans[u]==0){
				ans[u]=top.F;
				que[en++]={u,top.S+1};
			}
		}
	}
	int f=0;
	rep(i,2,n+1){
		if(ans[i]==0){
			f=1;
			break;
		}
	}
	if(f==1){
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	rep(i,2,n+1){
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 25884
a=input()
N=int(a)
b=input()
first_input=[i for i in b]
c=input()
second_input=[i for i in c]
d=input()
third_input=[i for i in d]        
count=0
count2=0
while count2<N:
    if first_input[count2]==second_input[count2] and second_input[count2]==third_input[count2]:
        pass
    
    elif first_input[count2]==second_input[count2] or second_input[count2]==third_input[count2] or first_input[count2]==third_input[count2]:
        count+=1
    else:
        count+=2
    count2+=1
print(count)



Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
typedef double db;
typedef long long ll;
const db pi = acos(-1.0);
const int N = 1 << 21 | 5; // 2n^2
const int M = 1 << 22 | 5;
struct comp_t {
	db x, y;
	comp_t(db a = 0, db b = 0) : x(a), y(b) {}
	comp_t operator + (const comp_t &b) const { return (comp_t) {x + b.x, y + b.y}; }
	comp_t operator - (const comp_t &b) const { return (comp_t) {x - b.x, y - b.y}; }
	comp_t operator * (const comp_t &b) const { return (comp_t) {x * b.x - y * b.y, b.x * y + x * b.y}; }
	inline void rev() { y = -y; }
} wnk[M];
int lim, r[M], A[M], B[M], n;
ll ans[N];
void init(int len) {
	int l = 0;
	for(lim = 1; lim <= len; lim <<= 1) l ++;
	for(int i = 1; i < lim; i ++) {
		r[i] = (r[i >> 1] >> 1) | ((i & 1) << (l - 1));
	}
	wnk[0] = comp_t(1, 0);
	wnk[1] = comp_t(cos(2 * pi / lim), sin(2 * pi / lim));
	for(int i = 2; i < lim; i ++) wnk[i] = wnk[i - 1] * wnk[1];
}
void fft(comp_t *a, int t) {
	for(int i = 1; i < lim; i ++)
		if(i < r[i]) swap(a[i], a[r[i]]);
	for(int i = 1; i < lim; i <<= 1) {
		for(int j = 0; j < lim; j += i << 1) {
			for(int k = 0; k < i; k ++) {
				comp_t y = wnk[lim / (i << 1) * k];
				if(t == -1) y.rev();
				comp_t p = a[j + k], q = y * a[j + k + i];
				a[j + k] = p + q; a[j + k + i] = p - q;
			}
		}
	}
}
ll *const_mul(int *a, int *b, int n, int m) {
	static ll ans[M];
	static comp_t A[M], B[M];
	init(n + m);
	for(int i = 0; i < lim; i ++) A[i] = comp_t(i <= n ? a[i] : 0);
	for(int i = 0; i < lim; i ++) B[i] = comp_t(i <= m ? b[i] : 0);
	fft(A, 1); fft(B, 1);
	for(int i = 0; i < lim; i ++) A[i] = A[i] * B[i];
	fft(A, -1);
	for(int i = 0; i <= n + m; i ++) ans[i] = (ll) (A[i].x / lim + 0.5);
	return ans;
}
int main() {
	scanf("%d", &n);
	int ma = n * (2 * n - 1) - 1, s = 0;
	for(int x, i = 0; i < n; i ++) {
		for(int j = 0; j < n; j ++) {
			scanf("%d", &x); s += x;
			A[2 * n * i + j] += x;
		}
	}
	copy(A, A + ma + 1, B); reverse(B, B + ma + 1);
	ll *t = const_mul(A, B, ma, ma);
	for(int i = 0; i <= (ma << 1); i ++) if(t[i]) {
		ll val = i - ma, dy = (val % (n * 2) + (n * 2)) % (n * 2);
		if(dy > n) dy -= n * 2;
		ll dx = (val - dy) / (n * 2);
		ans[dx * dx + dy * dy] += t[i];
	}
	ll tot = 0; db sum = 0;
	for(int i = 0; i < 2 * n * n; i ++) if(ans[i]) {
		if(!i) ans[i] -= s;
		ans[i] /= 2;
		sum += sqrt(i) * ans[i]; tot += ans[i];
	}
	printf("%.10f\n", (double) (sum / tot));
	int pr_lim = 10000;
	for(int i = 0; i < 2 * n * n; i ++) if(ans[i]) {
		printf("%d %lld\n", i, ans[i]);
		if(-- pr_lim == 0) break ;
	}
	return 0;
}


Measured memory_bytes: 281024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n],b[n];
	forn(i,0,n) cin>>a[i];
	forn(i,0,n) cin>>b[i];
	
	ll ans=INF;
	forn(mask,0,(1<<n))
	{
		bool fail=0;
		ll cnt=0;
		
		ii c[n],s[n];
		
		forn(i,0,n){
			if(mask & (1<<i)){
				s[i].F=c[i].F=a[i];
				s[i].S=c[i].S=0;
			}
			else{
				s[i].F=c[i].F=b[i];
				s[i].S=c[i].S=1;
			}
		}
		
		sort(s,s+n);
		
		forn(i,0,n)
		{
			bool found=0;
			for(int j=i;j<n;j++){
				if(s[i].F==c[j].F && abs(i-j)%2==c[j].S){
					cnt+=abs(i-j);
					for(int k=j;k>=i+1;k--){
						c[k]={c[k-1].F, c[k-1].S^1};
					}
					c[i]=s[i];
					found=1;
					break;
				}
			}
			if(!found){
				fail=1; //cout<<"FAIL: mask="<<mask<<", i="<<i<<"\n";
				break;
			}
		}
		
		if(!fail) ans=min(ans,cnt);
	}
	
	if(ans==INF) cout<<-1<<'\n';
	else cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int f(ll n) {  //nの桁数を求める関数
    int x = 0;

    while(n != 0) {
        x++;
        n /= 10;
    }

    return x;
}

int g(ll n) {  //nの先頭の数を求める関数
    int m = f(n);

    rep(i, m-1) {
        n /= 10;
    }
    int x = (int)n;

    return x;
}

int main() {
    ll n;
    cin >> n;
    int m = f(n);
    int a = g(n);

    if(m == 1) {
        cout << n << endl;
        return 0;
    }
    
    int ans = 9*(m-1) + (a-1);

    ll p = 1;
    rep(i, m-1) {
        p *= 10;
    }

    if( (n+1)%p == 0 ) {
        ans += 1;
    } 

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

Measured memory_bytes: 256
// Getting Started - Prime Numbers
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C
using System;
using System.Linq;

namespace ALDS1_1_C {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var N = int.Parse(Input);	// Number of elements
			int count = 0;
			for(int i = 0; i < N; i ++)
				if(isPrime(int.Parse(Input))) count++;
			
			Output(count.ToString());
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
		
		bool isPrime(int p) {
			if(p == 2) return true;
			if(p < 2 || p % 2 == 0) return false;
			
			for(int i = 3; i * i <= p; i += 2)
				if(p % i == 0) return false;
			return true;
		}
	}
}

Measured memory_bytes: 9160
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N, A, B = getNM()
X = getList()
ans = 0
for i in range(N - 1):
    walk = X[i + 1] - X[i]
    ans += min(walk * A, B)
print(ans)

Measured memory_bytes: 63596
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, A, x, c = 0;

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    if (A == 1)
      x = i;
  }

  for (int i = 0; i < N; c ++)
    if (i == 0) {
      i += K;
    }
    else {
      i += K - 1;
    }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>

using namespace std;

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

    vector<int> dp(3, 0);

    for(int i = 0; i < N; ++i)
    {
        vector<int> new_dp(3);
        for(int i = 0; i < 3; ++i)
        {
            int val;
            cin >> val;

            for(int j = 0; j < 3; ++j)
            {
                if(i != j){
                    new_dp[i] = max(new_dp[i], dp[j] + val);
                }
            }
        }

        dp = new_dp;
    }

    cout << max(dp[0], max(dp[1], dp[2])) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n, q, k;
    cin >> n;
    vector<P> G[100010];
    for(int i = 0; i < n-1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    cin >> q >> k;
    ll d[100010];
    for(int i = 0; i < 100010; i++) d[i] = 1LL << 50;
    d[k] = 0;
    priority_queue<P, vector<P> ,greater<P>> que;
    que.push({0,k});
    while(!que.empty()){
        P p = que.top();
        que.pop();
        ll cost = p.first, v = p.second;
        if(d[v] < cost) continue;
        for (auto x: G[v]){
            ll to = x.first, co = x.second;
            if(d[to] <= d[v] + co) continue;
            d[to] = d[v] + co;
            que.push({d[to], to});
        }
    }
    for(int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 11120
class Stack:
    def __init__(self,arg_size):
        self.size = arg_size
        self.stack = [None]*arg_size
        self.head = 0
        self.tail = 0
    def is_empty(self):
        return self.tail == self.head
    def isFull(self):
        return self.tail == len(self.stack) - 1
    def push(self,arg_object):
        self.stack[self.tail] = arg_object
        self.tail += 1
    def pop(self):
        self.tail -= 1
        return self.stack[self.tail]
    def top(self):
        return self.stack[self.head]

size = 105
NUM = Stack(size)

input_str = list(map(str,input().split()))

for i in range(len(input_str)):
    T = input_str[i]
    if T in ['+','-','*']:
        num2 = NUM.pop()
        num1 = NUM.pop()
        num = 0
        if T == '+':
            num = num1 + num2
        elif T == '-':
            num = num1 - num2
        elif T == '*':
            num = num1 * num2
        NUM.push(num)
    else:
        NUM.push(int(T))

print(NUM.pop())


Measured memory_bytes: 5604
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		vec.at(i)=0;
	}
	int d;
	for (int i = 0; i < K; i++) {
		cin >> d;
		rep(j, d) {
			int p;
			cin >> p;
			vec.at(p - 1)++;
		}

	}

	int an = 0;
	rep(i, N) {
		if (vec.at(i) == 0) {
			an++;
		}
	}

	cout<< an<<endl;
}


Measured memory_bytes: 3600
N = int(input())
d = {}
for i in range(N):
    s = input()[0]
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
march = ["M","A","R","C","H"]
lis = []
for a in d.keys():
    if a in march:
        lis.append(a)
import itertools
ans = 0
for l in list(itertools.combinations(lis,3)):
    ans += d[l[0]]*d[l[1]]*d[l[2]]
print(ans)


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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXM 110000

int main(){
  int n,m;cin>>n>>m;
  vector<int> x(n);
  rep(i, n)cin>>x[i];
  map<int, int>mp, mm;
  rep(i, n){
    mm[x[i]]++;
    mp[x[i]%m]++;
  }

  int result = 0;
  int tr = 0;
  rep(i, m){
    if(i==0 || m%2==0 && i==m/2){
      tr += mp[i]/2;
    }else{
      int j = m-i;
      int s=mp[i],t=mp[j];
      mp[i]=0,mp[j]=0;
      if(s>t){
        swap(s,t);
        j=i;
      }
      //if(s==0)continue;
      result += s;
      t-=s;s=0;

      for(int k=j; k<=MAXM; k+=m){
        if(t>=2 && mm[k]>=2){
          int x = min(mm[k]/2, t/2);
          result += x;
          t -= 2*x;
        }
      }
    }
  }

  cout<<result+tr<<endl;
//  cout<<result<<' '<<tr<<endl;

  return 0;
}


Measured memory_bytes: 12772
n = int(input())
judges = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(n):
    s = input()
    for k in judges:
        if k == s:
            judges[k] += 1

for k in judges:
    print(k + ' x ' + str(judges[k]))


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    vector<bool> good(N, true);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        if (H[A] <= H[B]) good[A] = false;
        if (H[B] <= H[A]) good[B] = false;
    }

    // print(good);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (good[i]) ans += 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
import math
k = int(input())
count=0
for p in range(1,k+1):
    for q in range(p,k+1):
        for r in range(q,k+1):
            if p == q == r:
                count+=math.gcd(math.gcd(p,q), r)
            elif p == q:
                count+=math.gcd(math.gcd(p,q), r)*3
            elif q == r:
                count+=math.gcd(math.gcd(p,q), r)*3
            elif p == r:
                count+=math.gcd(math.gcd(p,q), r)*3
            else:
                count+=math.gcd(math.gcd(p,q), r)*6
print(count)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int n, m;
vector<vector<int>> graph;
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    int a, b;
    cin >> a >> b;
    cout << a* b << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K,C; cin>>N>>K>>C;
	string S; cin>>S; S='@'+S;
	vector<int> L(N,INT_MAX), R(N,INT_MAX);
	int cur=0;
	for (int i=1; i<=N; i++) {
		if(S[i]=='o') {
			L[++cur]=i;
			if(cur>=K) break;
			i+=C;
		}
	}
	cur=K;
	for (int i=N; i>=1; i--) {
		if(S[i]=='o') {
			R[cur--]=i;
			if(cur<=0) break;
			i-=C;
		}
	}
	ll ret=0;
	for (int i=1; i<=K; i++)
		if(L[i]==R[i])
			cout<<L[i]<<"\n";
	return 0;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
typedef pair<int,int>P;

int main(){
  int n,k;
  cin>>n>>k;
  int mx=(n-1)*(n-2)/2;
  if(k>mx){
    cout<<-1<<endl;
    return(0);
  }
  vector<P>ans;
  int now=mx;
  for(int i=2;i<=n;i++){
    ans.push_back(P(1,i));
  }
  if(now==k){
    cout<<ans.size()<<endl;
    rep(k,ans.size()){
      cout<<ans[k].fi<<' '<<ans[k].se<<endl;
    }
    return(0);
  }
  for(int i=2;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      ans.push_back(P(i,j));
      now--;
      if(now==k){
        cout<<ans.size()<<endl;
        rep(k,ans.size()){
          cout<<ans[k].fi<<' '<<ans[k].se<<endl;
        }
        return(0);
      }
    }
  }
  return(0);
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main() {
    int N, A, B;

    cin >> N >> A >> B;

    cout << min(A, B) << " ";

    if((A+B) < N){
        cout << 0;
    }
    else{
        cout << ((A+B) - N);
    }

    return 0;
}

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

using namespace std;

int main(){
  for(int a;cin>>a,a!=-1;){
    vector<int> in(10);
    in[0]=a;
    vector<int> v(10);
    v[0]=1;
    for(int i=0;i<9;i++){
      cin>>in[i+1];
      v[i+1]=i+2;
    }
    int ans=0;
    do{
      bool f=false;
      for(int i=0;i<10;i++){
	f|=in[i]!=0&&in[i]!=v[i];
      }
      if(f)continue;
      set<int> st;
      int s=0,bs=0;
      for(int i=0;i<3;i++){
	bs+=v[i*3+i];
	s+=v[2*i+2];
	int vt=0,h=0;
	for(int j=0;j<3;j++){
	  vt+=v[j*3+i];
	  h+=v[i*3+j];
	}
	st.insert({vt%v[9],h%v[9]});
      }
      st.insert({s%v[9],bs%v[9]});
      ans+=st.size()==1;
    }while(next_permutation(begin(v),end(v)));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, x; 
    cin >> a >> b >> x;
    double ta;
    if (x >= a*a*b/2) {
        ta = 2*(double)b/a-2*(double)x/(a*a*a);
        double ans = atan(ta)*180/3.1415926535;
        printf("%.8f\n", ans);
    } else {
        ta = (double)a*b*b/(2*(double)x);
        double ans = atan(ta)*(double)180/3.1415926535;
        printf("%.8f\n", ans);
    }
    

    

}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int mapping1[26] = {};
int mapping2[26] = {};

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

  string S1, S2;
  cin >> S1 >> S2;

  REP(i, S1.length()) {
    if (mapping1[S1[i] - 'a'] == 0) {
      mapping1[S1[i] - 'a'] = S2[i];
    } else if (mapping1[S1[i] - 'a'] != S2[i]) {
      cout << "No" << endl;
      return 0;
    }

    if (mapping2[S2[i] - 'a'] == 0) {
      mapping2[S2[i] - 'a'] = S1[i];
    } else if (mapping2[S2[i] - 'a'] != S1[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 916