akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

bool compare(pair<int, int> &x, pair<int, int> &y) {
    if (x.first != y.first) {
        return x.first < y.first;
    } else {
        return x.second > y.second;
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> data(N);
    REP(i, N) cin >> data[i].first >> data[i].second;

    sort(data.begin(), data.end(), compare);

    ll ans = 0;
    int cnt = 0;
    int ai= 0;
    int bi = 0;
    while (cnt < M) {
        if (bi == data[ai].second) {
            ai++;
            bi = 0;
        }
        ans += data[ai].first;
        cnt++;
        bi++;
    }

    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 1024
n=int(input())
alist=[list(map(int, input().split())) for i in range(n)]
alist.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    h=abs(alist[0][0]-i)+abs(alist[0][1]-j)+alist[0][2]
    ans=True
    for k in range(n):
      if max((h-abs(alist[k][0]-i)-abs(alist[k][1]-j)),0)!=alist[k][2]:
        ans=False 
    if ans:
      ansx=i
      ansy=j
      ansh=h
print(ansx,ansy,ansh)

Measured memory_bytes: 9220
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] str1=Console.ReadLine().Split(' ');
	  string[] str2=Console.ReadLine().Split(' ');
      string S=str1[0];
      string T=str1[1];
      int A=int.Parse(str2[0]);
      int B=int.Parse(str2[1]);
      string U=Console.ReadLine();
      if(S==U){
        Console.WriteLine(A-1 + " "+B);

  }else{
        Console.WriteLine(A +" "+(B-1));
}
}
  }
}

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

int main() {
    int N;
    cin >> N;
    int suma = 0;
    int sumb = 0;
    vector<int> card(N);
    for(int i = 0; i < N; i++){
        cin >> card.at(i);
    }
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    for(int i = 0; i < N; i++){
      
        if(i%2==0){
            suma+=card.at(i);
        }else{
        sumb+=card.at(i);
        }
        }
        int MIN = min(suma,sumb);
        int MAX = max(suma,sumb);
    
    
cout << MAX - MIN << endl;

}

Measured memory_bytes: 256
import sys
import numpy as np

from numba import njit


@njit
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))


Measured memory_bytes: 118048
#include<stdio.h>

int main(void)
{
int w1,w2,c,count1,count2;

count1=0;
count2=0;

while(scanf("%d,%d,%d",&w1,&w2,&c)!=EOF){


if(w1==w2&&w1*w1+w2*w2!=c*c){
count2++;
}
if(w1*w1+w2*w2==c*c&&w1!=w2){
count1++;
}
}
printf("%d\n%d\n",count1,count2);
return 0;
}

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

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

// コピペごめんなさい！
struct UnionFind {
    int N;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : N(N), par(N + 1, -1) { //最初は全てが根であるとして初期化
        // for(int i = 1; i <= N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[ry] += par[rx];
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];
    }

    int groupNum() {
        set<int> ap;
        for (int i = 1; i <= N; ++i) {
            ap.insert(root(i));
        }
        return ap.size();
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int> > brigdes(M);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        brigdes[i] = pair<int, int>(a, b);
    }

    vector<ll> ans(M);
    UnionFind uf(N);
    ans[M - 1] = 0;
    for (int i = M - 1; i >= 1; --i) {
        if (!uf.same(brigdes[i].first, brigdes[i].second)) {
            ans[i - 1] = -((ll)uf.size(brigdes[i].first) * (ll)uf.size(brigdes[i].second));
        }

        ans[i - 1] += ans[i];
        uf.unite(brigdes[i].first, brigdes[i].second);
    }

    uf.unite(brigdes[0].first, brigdes[0].second);

    set<int> vs;
    for (int i = 1; i <= N; ++i) {
        vs.insert(uf.root(i));
    }

    ll c = 0LL;
    for (int v : vs) {
        ll t = uf.size(v);
        c += t * (t - 1LL) / 2LL;
    }

    for (int i = 0; i < M; ++i) {
        cout << (ans[i] + c) << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll x,g = 100,ans = 0;
	cin >> x;
	while(g < x) {
		g += g/100;
		ans++;
	}
	cout << ans;
} 

Measured memory_bytes: 3652
#include <stdio.h>
int n, p, i, a[50];
int main() {
	while(~scanf("%d", &n), n) {
		for(i=0;i<n;i++)scanf("%d",&a[i]);p=0;
		for(i=1;i<n;i++){
			if(a[i-1]+1!=a[i]) {
				if(i-p-1)printf("%d-%d ",a[p],a[i-1]);
				else printf("%d ",a[p]);
				p=i;
			}
		}
		if(n-p-1)printf("%d-%d\n",a[p],a[n-1]);
		else printf("%d\n",a[p]);
	}
	return 0;
}

Measured memory_bytes: 2572
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	vector<int> n1(n + 1);
	vector<int> n2(n + 1);

	for (int i = 1; i < n; i++)
	{
		if (s[i - 1] == 'W') n1[i] = n1[i - 1] + 1;
		else n1[i] = n1[i - 1];
	}
	
	for (int i = n - 1; i > 0; i--)
	{
		if (s[i] == 'E') n2[i - 1] = n2[i] + 1;
		else n2[i - 1] = n2[i];
	}

	int min_ = inf;

	for (int i = 0; i < n; i++)
	{
		min_ = min(min_, n1[i] + n2[i]);
	}
	cout << min_ << endl;

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int dp[11][100010];
signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, d, x;
  cin>>N>>d>>x;
  vector<vector<Int> > p(d, vector<Int>(N));
  cin>>p;

  for(Int i=0;i<=d;i++)
    for(Int j=0;j<100010;j++) dp[i][j] = -INF;

  dp[0][x] = 0;
  dp[0][0] = x;

  for(Int i=0;i<d-1;i++)
    for(Int j=100000; j>=0;j--){
      if(dp[i][j] >= 0) Max(dp[i+1][ dp[i][j] + j ], 0LL);
      if(dp[i][j] >= 0) Max(dp[i+1][0], dp[i][j] + j);
      for(Int k=0;k<N;k++)
        if(j - p[i][k] >= 0) Max(dp[i][j - p[i][k]], dp[i][j] + p[i+1][k]);

    }

  Int ans = dp[d-1][0];
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 11756
def main():
	n,m,c = map(int,input().split())
	# n,k = map(int,input().split())
	# n = str(input())
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(5)]
	# s = list(s)
	b = list(map(int,input().split()))
	a = [list(map(int, input().split())) for _ in range(n)]

	# print(a)
	ans = 0
	ans_sum = 0
	for n_i in range(n):
		# print(n_i)
		for m_i in range(m):
			ans_sum += a[n_i][m_i] * b[m_i]
		if ans_sum > -1*c:
			ans += 1
		ans_sum = 0
	print(ans)



 
if __name__ == '__main__':
	main()

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

using namespace std;

vector<int> prime;


bool isPrime(int x){
	if(x<2)return false;
	if(x==2)return true;
	if(x==3)return true;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
void init(){
	for(int i=2;i<=55555;i++){
		if(isPrime(i))prime.push_back(i);
	}
}
int main(void){
	int N;
	cin >> N;
	init();
	int cnt = 0;
	for(auto x:prime){
		if(x%5==1){
			cnt ++;
			cout << x;
			if(cnt!=N)cout << " ";
		}
		if(cnt==N)break;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define z 100
using namespace std;
int n,a,b,la,be,an,ct[z],c[z][z];bool v[z],s[z];void d(int x,int len){if(len>be){la=x;be=len;}v[x]=1,s[x]=1;for(int i=0;i<ct[x];i++)if(!v[c[x][i]]){d(c[x][i],len+1);v[c[x][i]]=0;}}int main(){while(1){cin>>n;if(!n)break;r(i,z)ct[i]=0;r(i,n){cin>>a>>b;a--,b--;c[a][ct[a]]=b,c[b][ct[b]]=a;ct[a]++,ct[b]++;}r(i,z)s[i]=0;an=0;for(int i=0;i<z;i++)if(!s[i]){r(i,z)v[i]=0;be=0;d(i,1);r(i,z)v[i]=0;be=0;d(la,1);an=max(an,be);}cout<<an<<endl;}return 0;}

Measured memory_bytes: 3032
#include <stdio.h>
int main()
{
    float a,b,c,d,e,f;
    int ret;
    while((ret=scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f))!=EOF)
    {
        float y=(c*d-f*a)/(b*d-e*a),x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n,m,k,a;
  int  mp[31]={0};
   cin>>n>>m;
  

   for(int i=0;i<n;i++)
   {
       cin>>k;
       for(int j=0;j<k;j++)
       {
           cin>>a;
           mp[a]++;

       }
   }
   int count=0;
   for(int i=0;i<=31;i++)
   {
       if(mp[i]==n)
       {
           count++;
       }
   }
   cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {

	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method sub
		new Main().run();

	}

	void run() {
		sc.useDelimiter("\n|\r\n");
		while (true) {
			String s = sc.next();
			if (s.equals("."))
				break;
			Stack<Character> stack = new Stack<Character>();
			boolean yes = true;
			for (int i = 0; i < s.length(); i++) {
				if (!yes)
					break;
				char c;
				switch (c = s.charAt(i)) {
				case '[':
					stack.push(c);
					break;
				case ']':
					if (stack.isEmpty()) {
						yes = false;
					} else {
						c = stack.pop();
						if (c != '[') {
							yes = false;
						}
					}
					break;
				case '(':
					stack.push(c);
					break;
				case ')':
					if (stack.isEmpty()) {
						yes = false;
					} else {
						c = stack.pop();
						if (c != '(') {
							yes = false;
						}
					}
					break;
				}
			}
			if (!stack.isEmpty())
				yes = false;
			System.out.println(yes ? "yes" : "no");
		}
	}
}

Measured memory_bytes: 27884
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
	int n;
	double ave=0;
	double kiroku;
	double min=100000000;
	cin>>n;
	double a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		ave+=a[i];
	}
	ave/=n;
	for(int i=0;i<n;i++){
		if(abs(ave-a[i])<min){
			min=abs(ave-a[i]);
			kiroku=i;
		}
	}
	cout<<kiroku<<endl;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
//aea ctmr https://codeforces.com/contest/1271/submission/66946806
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
    
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 105000;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#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...);}
#else
#define trace(...)
#endif
 
vector <pair <int, int>> xd;

int main(){

    int a, b;
    cin >> a >> b;

    cout << 6 - a - b << endl;


    return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}

bool isP(string s){
    for(int i = 0 ; i < sz(s) / 2; ++i){
        if(s[i] != s[sz(s) - 1 - i]){
            return false;
        }
    }
    return true;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector <int> v;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        v.pb(x);
    }
    int sum = 0;
    sort(all(v));
    reverse(all(v));
    for(int i = 0; i < n ; ++i){
        if((i % 2) == 0){
            sum = sum + v[i];
        }else{
            sum = sum - v[i];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int n = b - a;

    int sum = 0;
    for (int i = 1; i < n; i++) {
        sum += i;
    }

    cout << sum - a << endl;

    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;

		int nums[] = new int[3];
		nums[0] = A;
		nums[1] = B;
		nums[2] = C;
		Arrays.sort(nums);
		int tmp = (nums[2] - nums[1]) + (nums[2] - nums[0]);
		if (tmp % 2 == 0) {
			ans = tmp / 2;
		} else {
			ans = (tmp + 3) / 2;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#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 <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll K, X;
	cin >> K >> X;

	cout << (X <= K * 500 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
use input::{Input, ReadMode};

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let s = input.parse::<String>().chars().collect::<Vec<_>>();
    if s[1] == 'B' {
        println!("ARC");
    } else {
        println!("ABC");
    }
}

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = match iter.next() {
                        Some(x) => x,
                        None => {
                            self.iter = self.naive_read();
                            self.iter.as_mut().unwrap().next().expect("reached EOF")
                        }
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<vector<ll>> G(N);
	vector<ll> deg(N, 0);
	REP(i, N-1+M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		++deg[b];
	}

	queue<ll> que;
	REP(i, N) if (!deg[i]) que.push(i);

	vector<ll> par(N, 0);
	while (que.size())
	{
		ll v = que.front();
		que.pop();
		for (auto &nv : G[v])
		{
			--deg[nv];
			if (!deg[nv])
			{
				par[nv] = v + 1;
				que.push(nv);
			}
		}
	}

	for (ll i = 0; i < N; ++i)
		std::cout << par[i] << std::endl;
}


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

int main() {
    string t;
    cin >> t;
    for(int i = 0; i < t.size(); ++i) {
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << '\n';

    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
long long int S[200010];


int fib(int n){
    if (n==0 || n==1){
        return 1;
    }
    
    else if(S[n]!=-1) {
        return S[n];
    }
    else{
        S[n]=fib(n-1)+fib(n-2);
        return S[n];
        
    }
    
    
}


int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=0;
    flag=false;
    cin >>N;
    S[0]=1;
    S[1]=1;
    
    for (i=2;i<1000;i++){
        S[i]=-1;
    } 
    
    ans = fib(N);

    cout<< ans <<endl;
    

    return 0;
    
}




Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int n,m;
    while(1){
        cin>>n>>m;
        if(n+m==0)return 0;
        vector<int>V1,V2;
        int h[n+1],w[m+1];
        h[0]=w[0]=0;
        for(int i=0;i<n;i++)cin>>h[i+1];
        for(int i=0;i<m;i++)cin>>w[i+1];
        for(int i=1;i<=n;i++)h[i]+=h[i-1];
        for(int i=1;i<=m;i++)w[i]+=w[i-1];
        for(int i=0;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                V1.push_back(h[j]-h[i]);
            }
        }
        for(int i=0;i<=m;i++){
            for(int j=i+1;j<=m;j++){
                V2.push_back(w[j]-w[i]);
            }
        }
        sort(V1.begin(),V1.end());
        sort(V2.begin(),V2.end());
        int cnt=0,f=-1;
        map<int,int>VV1,VV2;
        for(int i=0;i<V1.size();i++){
            if(f==V1[i])cnt++;
            else{
                if(f==-1){
                    f=V1[i];
                    cnt=1;
                }else{
                    VV1[f]=cnt;
                    f=V1[i];cnt=1;
                }
            }
        }
        VV1[f]=cnt;
        cnt=0;f=-1;
        for(int i=0;i<V2.size();i++){
            if(f==V2[i])cnt++;
            else{
                if(f==-1){
                    f=V2[i];
                    cnt=1;
                }else{
                    VV2[f]=cnt;
                    f=V2[i];cnt=1;
                }
            }
        }
        VV2[f]=cnt;
        int ans=0;
        map<int,int>::iterator it;
        for(it=VV1.begin();it!=VV1.end();it++){
            ans+=(it->second)*VV2[(it->first)];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 38068
import java.util.*;
import java.lang.*;


public class Main {
    static int countChar(String S, char c){
        int ans = 0;
        for(int i=0; i<S.length(); i++) if(S.charAt(i)==c) ans++;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        System.out.println(countChar(S,'x')<8 ? "YES" : "NO");
    }
}

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

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

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;


int main(){
	ll n,a=1,b=1;
	cin>>n;

	long double x,y,z;
	for (int i = 0; i < n; ++i){
		cin>>x>>y;
		z=max(ceil(a/x),ceil(b/y));
		a=x*z;
		b=y*z;
	}

	cout<<a+b<<endl;

}

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

typedef long long ll;
const int maxn = 1e3 + 10;
const ll mod = 1e9 + 7;


string s;

int main()
{
    cin >> s;
    int len = s.size();
    string ss = s;
    reverse(ss.begin(), ss.end());
    string s1 = s.substr(0, (len - 1) / 2);
    string ss1 = s1;
    string s2 = s.substr((len + 3) / 2 - 1);
    string ss2 = s2;
    reverse(ss1.begin(), ss1.end());
    reverse(ss2.begin(), ss2.end());
    if(s == ss && s1 == ss1 && s2 == ss2)  puts("Yes");
    else puts("No");
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
typedef long long ll;

#define N 100005
vector<int> adj[N];
int vis[N];

void bfs(int n) {
    queue<int> q;
    q.push(n);
    int u, v;

    while (!q.empty()) {
        u = q.front(); q.pop();

        for (int v : adj[u]) {
            if (!vis[v]) {
                vis[v] = u;
                q.push(v);
            }
        }
    }
}

int main() {
    FAST;

    int n, m, i, u, v;
    cin >> n >> m;

    for (i = 0; i < m; ++i) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vis[1] = 1;
    bfs(1);

    bool f = 1;
    for (i = 1; i <= n; ++i) {
        if (!vis[i]) {
            f = 0;
            break;
        }
    }

    if (f) {
        cout << "Yes\n";
        for (i = 2; i <= n; ++i) cout << vis[i] << "\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 10476
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    cout<<((n/500)*1000 + (n%500)/5*5);
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ARegistration {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s,t;
        in >>s >> t;
        if(s==t.substr(0,s.size())){
            out << "Yes" << endl;
        }else{
            out << "No" << endl;
        }
	}
};


int main() {
	ARegistration solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3556
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if i<N-1 and n>1 :
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

Measured memory_bytes: 27252
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
	int n;
  scanf("%d", &n);

	int fe[10][10] = {0};
	rep(i, 1, n + 1) {
		int num = i;
		int end = num % 10;
		while ( num / 10 ) num /= 10;
		int first = num;
		fe[first][end]++;
	}
	int ans = 0;
	rep(f, 1, 10) {
		rep(e, 1, 10) {
			ans += fe[f][e] * fe[e][f];
		}
	}
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
using namespace std;
int main(){
  int a,b,c; cin >> a >> b >> c;
  set<int> st;
  for (int i = 0; i <= b; i++)
    st.insert((a*i)%b);
  printf("%s\n",(st.find(c)!=st.end()) ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(){
	int N, D[111][2];
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d%d", &D[i][0], &D[i][1]);
		if(i > 1){
			if(D[i][0] == D[i][1] && D[i-1][0] == D[i-1][1] && D[i-2][0] == D[i-2][1]){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

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


/*int cnt,head[N];
struct edge{int next,to;}e[N<<1];
inline add(int u,int v)
{
	cnt++;
	e[cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}   */
	
int len1,len2,ans,sum;
char a[1005],b[1005];
int main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	len1=strlen(a+1);
	len2=strlen(b+1);
	ans=len2;
	for (register int i=1; i<=len1-len2+1; ++i)
	{
		sum=0;
		for (register int j=1; j<=len2; ++j)
		if (b[j]!=a[i+j-1]) sum++;
		ans=min(ans,sum); 
	}
	printf("%d\n",ans);
	
return 0;	
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>

int main() {
    int n, as, bs, ag, bg;
    std::string s;
    std::cin >> n >> as >> bs >> ag >> bg >> s;

    --as, --bs, --ag, --bg;
    if (as > bs) {
        std::swap(as, bs);
        std::swap(ag, bg);
    }

    int i = as;
    while (i < std::max(ag, bg)) {
        if (s[i + 1] == '.') {
            i += 1;
        } else if (i + 2 < n && s[i + 2] == '.') {
            i += 2;
        } else {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    if (bg < ag) {
        bool ok = false;
        for (int i = bs; i <= bg; ++i) {
            if (0 < i && i < n - 1 &&
                s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                ok = true;
            }
        }

        if (!ok) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

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


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int N, x;
  scanf("%d %d", &N, &x);

  int array[100000];
  for(int i=0; i<N; i++){
    scanf("%d", &array[i]);
  }

  int start = 0;
  int end = N-1;
  long long count = 0ll;
  int d = 0;

  for(int i=1; i<N; i++){
    d = array[i-1]+array[i]-x;
    if(d>0){
      count += d;
      array[i] -= d;
      if(array[i]<0){
        array[i] = 0;
      }
    }
  }

  printf("%lld\n", count);

  return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  cout << ans << endl;
}

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

struct Move{
  int bx, by, ax, ay;
  Move(int x, int y, int x1, int y1){ bx = x; by = y; ax = x1; ay = y1;}
};

int main(){
  int W, H, a, oddNum=0, preLastOddIndex = -1, oddIndex[500];
  std::vector<Move> moves;

  std::cin >> H >> W;
  for(int i=0; i<H; i++, oddNum = 0){
    for(int j=0; j<W; j++){
      std::cin >> a;
      if(j == preLastOddIndex){
        a++;
        preLastOddIndex = -1;
      }
      if(a%2){//odd
        oddIndex[oddNum] = j;
        oddNum++;
      }
    }

    if(oddNum % 2 && i != H-1){//sum is odd
      preLastOddIndex = oddIndex[-1 + oddNum--];
      //oddNum--;
      moves.push_back( Move(preLastOddIndex, i, preLastOddIndex, i+1) );
    }
    for(int j=0; j < oddNum; j+=2)
      for(int k = oddIndex[j]; k < oddIndex[j+1]; k++)
        moves.push_back(Move(k,i,k+1,i));
  }

  std::cout << moves.size() << std::endl;
  for(int i = 0; i < (int)moves.size(); i++)//YとX逆
    std::cout << moves[i].by+1 <<" "<< moves[i].bx+1 <<" "<< moves[i].ay+1 <<" "<< moves[i].ax+1 << std::endl;

  return 0;
}









Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 20000000;
using namespace std;


const int MAX_V = 201;

class Edge{
    public:
        int to, cap, rev;
};

typedef vector<vector<Edge>> AdjList;
AdjList G(MAX_V);
bool used[MAX_V];

void addEdge(int from, int to, int cap){
    G[from].emplace_back(Edge{to, cap, static_cast<int>(G[to].size())});
    G[to].emplace_back(Edge{from, 0, static_cast<int>(G[from].size() - 1)});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    rep(i,G[v].size()){
        Edge &e = G[v][i];
        if(not used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int maxFlow(int s, int t){
    int flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){
    int v, e;
    cin >> v >> e;
    rep(i,e){
        int a, b, c;
        cin >> a >> b >> c;
        addEdge(a,b,c);
    }
    cout << maxFlow(0,v - 1) << endl;
}

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

int a[20][20];

int root(int x, int y){
	if (x == 0) { 
		if(a[0][y - 1] == -1)return a[0][y-1] = root(0, y - 1);
		else return a[0][y - 1];
	}
	if (y == 0) {
		if (a[x - 1][0] == -1)return a[x-1][0] = root(x - 1, 0);
		else return a[x - 1][0];
	}
	if (a[x - 1][y] == -1) a[x - 1][y] = root(x - 1, y);
	if (a[x][y - 1] == -1) a[x][y - 1] = root(x, y - 1);
	return a[x - 1][y] + a[x][y - 1];
}

int main(){
	int ax, by, n, x, y;
	while(cin >> ax >> by >> n){
		if (!ax && !by) break;
		for (int i = 0; i < 20; i++) {
			for(int j = 0;j<20;j++){
				a[i][j] = -1;
			}
		}
		a[0][0] = 1;
		for(int i = 0;i<n;i++){
			cin >> x >> y;
			a[x-1][y-1] = 0;
		}
		int temp = root(ax-1, by-1);
		cout << root(ax-1, by-1) << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

inline int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

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

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

int mexp(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)
            res = mul(res, x);
        y >>= 1;
        x = mul(x, x);
    }
    return res;
}

int inv(int x) {
    return mexp(x, MOD - 2);
}

int f[N];
void pre() {
    f[0] = 1;
    for (int i = 1; i < N; i++)
        f[i] = mul(i, f[i - 1]);
}

int calc(int p, int q, int m, int n) {
    return mul(f[m - p + n - q], mul(inv(f[m - p]), inv(f[n - q])));
}

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

    pre();

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    int ans = 0;
    for (int i = b + 1, cur, prev = 0; i <= w; i++) {
        cur = calc(1, 1, h - a, i);
        ans = add(ans, mul(sub(cur, prev), calc(h - a, i, h, w)));
        prev = cur;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1

int main() {
    int n;
    LL t;
    LL ans=0;
    cin >> n >> t;
    vector<LL> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=1; i<n; i++){
        if(a[i]-a[i-1]>=t){
            ans+=t;
        }else{
            ans+=a[i]-a[i-1];
        }
    }
    ans+=t;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
from math import gcd
from functools import reduce


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[int(x)] += 1

    # エラトステネスの篩
    primes = []
    not_primes = set()
    for a in range(2, MAX_A):
        if a in not_primes:
            continue
        primes.append(a)
        for b in range(a * 2, MAX_A, a):
            not_primes.add(b)

    for divider in primes:
        count = sum(histogram[divider::divider])
        if count > 1:
            break
    else:
        return 'pairwise coprime'

    gcd_total = reduce(gcd, array)
    if gcd_total == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


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

int MAX = 1000000007;
int MOD = 1000000007;
const int MAX_R = 510000;
long long DCom[MAX_R];

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long modpow(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  long long res = modpow(a, b / 2, mod);
  if (b % 2 == 0) res = (res * res) % mod;
  else res = (((res * res) % mod) * a) % mod;
  return res;
}

inline long long inv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    return mod(u, m);
}

void calc_Dcom(long long n, long long p) {
    long long t = 1; DCom[0] = t;
    for (int i = 1; i < MAX_R; ++i) {
        t = mod(t * (n-i+1), p);
        t = mod(t * inv(i, p), p);
        DCom[i] = t;
    }
}

int main() {
  long long n, a, b; cin >> n >> a >> b;
  long long ans = mod(modpow(2, n, MOD) - 1, MOD);
  calc_Dcom(n, MOD);
  long long tmp1 = DCom[a];
  long long tmp2 = DCom[b];
  ans = mod(ans - tmp1 - tmp2, MOD);
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
inline int get(){
	int n;char c;while((c=getchar())||23333)if(c>='0'&&c<='9')break;
	n=c-'0';while((c=getchar())||23333){
		if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
	}
}
typedef struct _b{
	int dest;int nxt;
}bian;bian memchi[1000001];int gn=1;int heads[100001];
int que[100001];int col[100001];
inline int erfen(){
	memset(col,-1,sizeof(col));col[1]=1;register int head=0,tail=1;que[0]=1;do{
		int me=que[head];head++;for(register int i=heads[me];i;i=memchi[i].nxt){
			if(col[memchi[i].dest]!=-1){
				if(col[memchi[i].dest]==col[me])return(0);
			}else{
				col[memchi[i].dest]=col[me]^1;que[tail]=memchi[i].dest;tail++;
			}
		}
	}while(head<tail);return(1);
}
inline void add(int s,int t){
	memchi[gn].dest=t;memchi[gn].nxt=heads[s];heads[s]=gn;gn++;
}
signed main(){
	int n=get(),m=get();for(register int i=1;i<=m;i++){
		int s=get(),t=get();add(s,t);add(t,s);
	}if(erfen()){
		int bai=0;for(register int i=1;i<=n;i++)bai+=col[i];
		cout<<(ll)bai*((ll)n-(ll)bai)-(ll)m<<endl;
	}else{
		cout<<(((ll)n*((ll)n-1))>>1)-m<<endl;
	}
	return(0);
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

// keyが降順ソートされるmap
// map<int, int, std::greater<int>> edges;

signed main() {
  int n;
  cin >> n;
  
  int a;
  int count1 = 0;
  int count2 = 0;
  int count4 = 0;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%4==0){
      count4++;
    }
    else if(a%2==0){
      count2++;
    }
    else{
      count1++;
    }
  }
  if( (count4>=count1) 
     || (count2==0 && count4==count1-1 && count4>=1) ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
  string s;
  cin >> s;
  string a = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i, 16) {
    if (a[i] != s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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


using namespace std;

int main(int argc, char const *argv[])
{

    long long  A, B;

    cin>>A>>B;
    if (A>=10)
    {
        cout << B << endl;
    }else
    {
        cout << B + (10-A) * 100 << endl;
    }
    
    
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll mo=998244353;
int N;
int B[1303030];
int A[1303030];

vector<int> P[303030];
int L[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		A[i]--;
	}
	
	if(count(A,A+N,0)==0) return _P("0\n");
	if(count(A,A+N,0)==N) {
		ll ret=1;
		FOR(i,N) ret=ret*(i+1)%mo;
		cout<<ret<<endl;
		return;
	}
	
	FOR(i,N) if(A[i]==0 && A[(i+N-1)%N]>0) {
		FOR(j,2*N) B[j]=A[(i+j)%N];
		FOR(j,2*N) A[j]=B[j];
		FOR(j,N) P[A[j]].push_back(j);
		break;
	}
	
	ll ret=1;
	set<int> empty,unused;
	int numfree=0;
	
	empty.insert(4*N);
	FOR(i,N) empty.insert(i), empty.insert(i+N);
	
	FOR(i,N) {
		//cout<<"!"<<i<<" "<<numfree<<endl;
		L[i]=P[i].size();
		if(L[i]>L[0]) return _P("0\n");
		if(L[i]==0) {
			//cout<<i<<" "<<numfree<<endl;
			ret=ret*numfree%mo;
			numfree--;
		}
		else {
			if(P[i][0]+L[i]-1!=P[i].back()) return _P("0\n");
			FORR(p,P[i]) {
				empty.erase(p);
				empty.erase(N+p);
				unused.insert(p);
			}
			
			x=P[i][0];
			if(A[x+N-1]>i && A[x+L[i]]>i && L[i]!=L[0]) return _P("0\n");
			if(A[x+N-1]<i && A[x+L[i]]<i) ret=ret*(L[0]-L[i]+1)%mo;
			auto it=unused.lower_bound(P[i][0]-(L[0]-1));
			while(it!=unused.end() && *it<=P[i].back()) {
				auto it2=empty.lower_bound(*it);
				if(*it2-*it<L[0]) {
					it=unused.lower_bound(*it2);
				}
				else {
					numfree++;
					it=unused.erase(it);
				}
			}
			numfree--;
		}
	}
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 54144
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    for(int i=0;i<n;i++){
        ans=min(2*ans,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N = int(input())
XY = [list(map(int, input().split())) + [i + 1] for i in range(N)]

dist = []

XY.sort()
for i in range(N - 1):
  dist.append((abs(XY[i][0] - XY[i + 1][0]), (XY[i][2], XY[i + 1][2])))
XY.sort(key = lambda x: x[1])
for i in range(N - 1):
  dist.append((abs(XY[i][1] - XY[i + 1][1]), (XY[i][2], XY[i + 1][2])))
dist.sort()

root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx != ry:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
      
answer = 0
for d, (a, b) in dist:
  if root_find(a) != root_find(b):
    merge(a, b)
    answer += d

print(answer)

Measured memory_bytes: 109864