akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vl as(m);
    cin>>as;
    sort(rrng(as));
    rep(i, m) as[i]--;
    vl nums {2, 5, 5, 4, 5, 6, 3, 7, 6};

    vl dp(n + 1, -LINF);
    dp[0] = 0;
    rrep(i, 1, n + 1) rep(j, m) {
        if (i - nums[as[j]] >= 0) chmax(dp[i], dp[i - nums[as[j]]] + 1);
    }
    ll cur = n;
    string ans = "";
    while (cur > 0) {
        rep(j, m) {
            if (cur - nums[as[j]] >= 0 && dp[cur - nums[as[j]]] + 1 == dp[cur]) {
                ans.push_back(as[j] + 1 + '0');
                cur -= nums[as[j]];
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
from numpy import*
from scipy.sparse import*
(n,m),*p=[map(int,o.split())for o in open(0)]
e=array([(i,j+n-1,1)for i,q in enumerate(p)for j in list(q)[1:]]).T
print("NO"if 1 in csgraph.connected_components(csr_matrix(((e[2],e[:2])),[n+m]*2))[1][:n]else"YES")

Measured memory_bytes: 61156
K, N = map(int, input().split())
D = list(map(int, input().split()))
L = [i for i in range(10) if i not in D]

if int(len(str(K)) * str(L[-1])) < K:
    if L[0] != 0:
        print(str(L[0]) * (len(str(K)) + 1))
    else:
        print(str(L[1]) + len(str(K)) * str(L[0]))
else:
    for i in range(10 ** (len(str(K)) - 1), 10 ** len(str(K))):
        if i >= K:
            k = str(i)
            for j in k:
                if int(j) not in L:
                    break
            else:
                print(i)
                exit()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 20
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );
Search Find(int ,Search);

int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='f'){
      scanf("%d",&numnode);
    
      if(Find(numnode,road)!=Gard){
	printf("yes\n");
      }

      else{
	printf("no\n");
      }
    }
    
    else if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
  }
  
  return 0;
}

void Insert(int numnode){
  Search x,y,z;
  
  x=road;
  y=Gard;
  z=malloc(sizeof(struct Tree));
  z->nodekey=numnode;
  z->leftch=Gard;
  z->rightch=Gard;
  
  while(x!=Gard){
    y=x;
    
    if(z->nodekey<x->nodekey){
      x=x->leftch;
    }
    
    else{
      x=x->rightch;
    }
  }
  
  z->parent=y;
  
  if(y==Gard){
    road=z;
  }
  
  else if(z->nodekey<y->nodekey){
    y->leftch=z;
  }
  
  else{
    y->rightch=z;
  }
  
}

void Pre(Search road){
  
  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
  
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){
  
  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}

Search Find(int numnode, Search road){
  
  if((road==Gard) || (numnode==road->nodekey)){
    return road;
  }
  
  else if(numnode<road->nodekey){
    return Find(numnode,road->leftch);
  }
  
  else{
    return Find(numnode,road->rightch);
  }
}



Measured memory_bytes: 20460
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  int n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  int ans = 0;
  rep(i,n) if(data[i] != i+1) ans++;
  if(ans == 0 || ans == 2) cout << "YES";
  else cout << "NO";
  hinata;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

		int low = (int)(n/1.08);
		if ((int)(low*1.08) == n)
			System.out.println(low);
		else if ((int)((low+1)*1.08) == n)
			System.out.println(low+1);
		else
			System.out.println(":(");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long,pair<long long,long long>>> edges;
const long long MAXN = 2e5+5;
long long par[MAXN];
long long sz[MAXN];
pair<pair<long long,long long>,long long> arr[MAXN];
pair<pair<long long,long long>,long long> arr2[MAXN];
long long getpar(long long a){
    if(par[a] == a){
        return a;
    }
    return par[a] = getpar(par[a]);
}
void merge(long long a,long long b){
    a = getpar(a);
    b = getpar(b);
    if(a==b){
        return;
    }
    if(sz[b]>sz[a]){
        swap(a,b);
    }
    sz[a]+=sz[b];
    par[b] = a;
}
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i].first.first>>arr[i].first.second;
        arr2[i].first.first = arr[i].first.second;
        arr2[i].first.second = arr[i].first.first;
        arr[i].second = i;
        arr2[i].second = i;
    }
    sort(arr+1,arr+n+1);
    sort(arr2+1,arr2+n+1);
    for(long long i=1;i<n;i++){
        edges.push_back(make_pair(arr[i+1].first.first-arr[i].first.first,make_pair(arr[i].second,arr[i+1].second)));
        edges.push_back(make_pair(arr2[i+1].first.first-arr2[i].first.first,make_pair(arr2[i].second,arr2[i+1].second)));
    }
    sort(edges.begin(),edges.end());
    for(long long i=1;i<=n;i++){
        par[i] = i;
        sz[i] = 1;
    }
    long long ans = 0;
    for(auto x:edges){
        long long w = x.first;
        long long from = x.second.first;
        long long to = x.second.second;
        if(getpar(from)== getpar(to)){
            continue;
        }
        merge(from,to);
        ans+=w;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 18796
# s = gets
# ans = 0
# for i in 0..s.length do
#   ans += 1 if s[i] != s[s.length - 1 - i]
# end
# puts(ans / 2)

s = gets.chomp
len = s.size
ans = 0
(len/2).times do |i|
 ans += 1 if s[i] != s[-i-1]
end

puts ans


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#define LEN 12
 
int
main(void)
{
    int M;
    char buff[LEN+1];
    if( fgets(buff, LEN, stdin) != NULL ) {
        M = atoi(buff);
        printf("%d\n", 48-M);
    }
}

Measured memory_bytes: 128
n = gets.to_i
s = Array.new(n){ gets.chomp.chars.sort }.sort

ans = 0
cnt = 0
n.times do |i|
    
    if i == n - 1 or s[i] != s[i+1]
        ans += (cnt+1)*cnt/2
        cnt = 0
    else
        cnt += 1
    end
end

puts ans

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

int main() {
	int i,j,n,m,p,x=0,y=0;
	cin>>n>>m;
	string s;
	int a[n]={0},b[n]={0};
	for(i=0;i<m;i++)
	{
		cin>>p>>s;
		if(s=="AC") a[p-1]=1;
		else if(s=="WA" && a[p-1]!=1) b[p-1]++;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==1)
		{
			x++;
			y+=b[i];
		}
	}
	cout<<x<<" "<<y;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,x;

	cin >> a >> b >>x;
	if (a <= x && x <= a + b) {
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}
	
	


}
	

Measured memory_bytes: 256
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for i in range(m):
        a,b=map(int,readline().split())
        G[a].append(b)
        G[b].append(a)

    ans=[0]*(n+1)
    flags=[False]*(n+1)
    flags[1]=True
    d=deque([1])
    while len(d)>0:
        now=d.popleft()
        v=now
        for u in G[v]:
            if flags[u]==False:
                flags[u]=True
                ans[u]=v
                d.append(u)

    print("Yes")
    for i in range(2,n+1):
        print(ans[i])
        
if __name__=="__main__":
    main()

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if( s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if( s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if( s == "Rainy"){
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char T[1000001],P[10001];

int main(){
  int i,tlen,plen;
  scanf("%s",T);
  scanf("%s",P);
  
  tlen = strlen(T);
  plen = strlen(P);
  
  for(i=0;i<tlen;i++)if(strncmp(&T[i],P,plen)==0)printf("%d\n",i);
 
  return 0;
}

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

int main() {
  int r,g,b,n;
  ll ans=0;
  cin >> r >> g >> b >> n;
  for(int i=0; i<=n/r; i++){
    for(int j=0; j<=n/g; j++){
      int sum=r*i+g*j;
      int rem=n-sum;
      if(rem>=0&&rem%b==0) ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> proof(n, vector<int>(n, -1));
    // -1 無情報
    // 1 正直
    // 0 不親切
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for(int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            proof[i][x] = y;
        }
    }
    // cout << proof[2][0] << endl;
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        int bc = bit;
        vector<int> tmp(n, 0);
        int c = 0;
        int m = 0;
        while(bc) {
            tmp[c] = (bc & 1);
            m += tmp[c];
            c++;
            bc = (bc >> 1);
        }
        for(int i = 0; i < n; i++) {
            if(tmp[i] == 0) {
                continue; //不親切は無視
            }
            for(int j = 0; j < n; j++) {
                if(proof[i][j] != -1) {
                    if(proof[i][j] != tmp[j]) {
                        m = -1;
                    }
                }
            }
        }
        if(m == 1 && ans != 1) {
            // cout << tmp[0] << tmp[1] << tmp[2] << endl;
            // cout << proof[2][0] << endl;
        }
        ans = max(ans, m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
#m1,d1=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import math
flag=':('
for x in range(1,n+1):
    price=math.floor(x*1.08)
    if math.floor(x*1.08) == n:
        flag=x
        break
print(flag)

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N, M;
    string S;
    cin >> N >> M >> S;

    reverse(S.begin(), S.end());
    ll tmp = 0;
    vec ans;
    bool progress = true;
    while (tmp < N) {
        progress = false;
        for (ll i = M; i >= 1; i--) {
            if (tmp+i <= N && S[tmp+i] == '0') {
                ans.push_back(i);
                tmp += i;
                progress = true;
                break;
            }
        }
        if (!progress) {
            cout << "-1\n";
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());
    Rep (i, ans.size()) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 1480
#include<bits/stdc++.h>
#define ll long long 
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll n;
ll dp[1+100000][3];
ll a[1+100000][3];
ll f(ll l,ll i)
{
   if(dp[l][i]!=-1)
   return dp[l][i];
   
   dp[l][i]=a[l][i]+max(f(l-1,(i+1)%3),f(l-1,(i+2)%3));
   return dp[l][i];
}
int main()
{
   speed
   cin>>n;
   for(ll i=1;i<=n;i++)
   {
       cin>>a[i][0]>>a[i][1]>>a[i][2];
       dp[i][0]=-1;
       dp[i][1]=-1;
       dp[i][2]=-1;
   }
   
   dp[1][0]=a[1][0];
   dp[1][1]=a[1][1];
   dp[1][2]=a[1][2];
   
   cout<<max(f(n,0),max(f(n,1),f(n,2)))<<endl;
}

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


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

	double D, N, M;
	cin >> N >> M >> D;
	CST(15);
	if(D!=0)cout << 2.0*(N - D)*(M - 1.0) / (N*N) << endl;
	else cout << (N - D)*(M - 1.0) / (N*N) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	
	bool isYes = false;
	
	for (int i = 0; i < S.size(); i++)
	{
		// SとTが一致した場合
		if (S == T)
		{
			isYes = true;
			break;
		}
		
		string last = S.substr(S.size() - 1, 1);
		string notLast = S.substr(0, S.size() - 1);
		S = last + notLast;
	}
	
	// 出力
	if (isYes == true)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool ans = false;
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 14; j++){
      if(i*4 + j*7 == N) ans = true;
    }
  }
  cout << (ans? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

vector<double> vec;
int main() {
    double t;
    while(cin>>t) {
        vec.pb(t);
    }
    sort(all(vec));
    cout<<vec[vec.size()-1]-vec[0]<<endl;
    return 0;
}

Measured memory_bytes: 1304
n, q = map(int, input().split())
S = input()
flag = False
L = [0 for _ in range(n)]
cnt = 0
for i, s in enumerate(S):
    if flag:
        if s == "C":
            cnt += 1
        flag = False
    if s == "A":
        flag = True
    L[i] = cnt

for _ in range(q):
    l, r = map(lambda x: int(x) - 1, input().split())
    print(L[r] - L[l])

Measured memory_bytes: 11632
def m():
    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if len(A) == 1:
        return 0
    l2r = 0
    for i in range(N):
        prev = A[i]
        for j in range(i, N):
            if prev > A[j]:
                l2r += 1
    r2l = 0
    for i in range(N - 1, -1, -1):
        prev = A[i]
        for j in range(i, -1, -1):
            if prev > A[j]:
                r2l += 1

    ans1 = K * (K + 1) // 2 * l2r % MOD
    ans2 = (K - 1) * K // 2 * r2l % MOD
    return (ans1 + ans2) % MOD


print(m())


Measured memory_bytes: 73976
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli dp[2*MX1+5];

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i;
    cin>>N;

    lli Min=Inf;

    rep(i,1,N+1)
    {
        cin>>dp[i];
    }

    rep(i,1,N+1)
    {
        dp[i]+=dp[i-1];
    }

    rep(i,1,N)
    {
        lli x=dp[i],y=dp[N]-dp[i];

        Min=min(Min,abs(x-y));
    }

    cout<<Min;




 return 0;
}


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

int main(){

   int N;
   cin>> N;
   int a[N];
   for(int i=0; i<N; i++) cin>> a[i];

   int r=0;
   for(int i=0; i<N; i++){
      r+=(a[i]%2);
   }

   if(r%2==0){
      cout<< "YES"<< endl;
   }else{
      cout<< "NO"<< endl;
   }

   return 0;
}


Measured memory_bytes: 640
var
	n,i,mx,mn,imx,imn,a:Longint;
begin
	read(n);
	imx:=1;
    imn:=1;
	for i:=1 to n do begin
		read(a);
		if mx<a then begin
			mx:=a;
			imx:=i;
		end;
		if mn>a then begin
			mn:=a;
			imn:=i;
		end;
	end;
	writeln(2*n-1);
	if mx>-mn then begin
		for i:=1 to n do writeln(imx,' ',i);
		a:=1;
	end else begin
		for i:=1 to n do writeln(imn,' ',i);
		a:=-1;
	end;
	if a>0 then begin
		for i:=1 to n-1 do writeln(i,' ',i+1);
	end else begin
		for i:=n downto 2 do writeln(i,' ',i-1);
	end;
end.


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

int K, X;

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

    int s, f;
    s = X-K+1;
    f = X+K-1;
    if (s<(-MAX)) s = -MAX;
    if (f>MAX) f = MAX;
    for (int i=s; i<=f; i++) printf("%d ", i);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN], b[MAXN];
void answer(int x, int y) {
	if (x & 1 && y & 1) printf("Second\n");
	else printf("First\n");
}
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	sort(a + 1, a + n + 1);
	if (a[1] >= n) {
		answer(1, a[1] - n + 1);
		return 0;
	}
	for (int i = 1; i <= n; i++)
		if (a[i] == a[i - 1]) b[i] = b[i - 1] + 1;
		else b[i] = 1;
	for (int i = 2; i <= n; i++) {
		int tmp = a[i - 1] - n + i;
		if (a[i] > n - i && tmp <= 1) {
			if (tmp == 1) answer(1 + b[i - 1], a[i] - n + i);
			else answer(1, a[i] - n + i);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
using namespace std;

int main()
{
    int N, K;
    cin.sync_with_stdio(false);
    cin >> N >> K;
    int a;
    int r;
    int max_v = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        r = __gcd(a, r);
        max_v = max(a, max_v);
    }

    if (max_v >= K && K % r == 0) {
        cout << "POSSIBLE";
    } else {
        cout << "IMPOSSIBLE";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{
    int n;
    cin >> n;
    map<int, int>a;
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
        ans += x;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        a[c] += a[b];
        ans += a[b] * (c - b);
        a[b] = 0;
        cout << ans << endl;
    }

    return 0;

}

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int n, m, q, a[57][4], ans;

void solve(int cur, int d, string s){
	if(d<=n){
		if(d==n){
			int sum=0;
			for(int i=0;i<q;i++)
				if((int)(s[a[i][1]]-'0')-(int)(s[a[i][0]]-'0')==a[i][2])
					sum+=a[i][3];
			ans=max(ans,sum);
		}
		for(int i=cur;i<m;i++)
			solve(i, d+1, s+(char)(i+'0'));
	}
}

int main(){
	setIO();
	cin>>n>>m>>q;
	for(int i=0;i<q;i++)
		for(int j=0;j<4;j++){
			cin>>a[i][j];
			if(j<2) a[i][j]--;
		}
	solve(0, 0, "");
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 

int main() 
{ 

 	ios::sync_with_stdio(0);
    cin.tie(0);
   lli n;
    cin>>n;
    vp temp;
    for(lli i=0;i<n;i++){
    	lli x,y;
    	cin>>x>>y;
    	temp.pb(mp(y,x));
    }
    sort(temp.begin(),temp.end());
    lli ani=0;
    bool ans=true;
    //ani+=temp[0].se;
    for(lli i=0;i<n;i++){
    	ani+=temp[i].se;
    	if(temp[i].fi<ani)ans=false;
    	

    //	cout<<ani<<endl;
    }


    if(ans)cout<<"Yes";
    else cout<<"No";



	return 0; 
} 


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     1000000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     10005

using namespace std;

string A;

int d;
ll dp[MAX][2][101][2];

ll solve(int idx,string A,int lim,int sum,int zero)
{
    if(idx==A.size())
    {
        if(sum%d==0 && zero==0)return 1;
//        cerr<<">> "<<sum<<endl;
        return 0;
    }
    if(dp[idx][lim][sum][zero]!=-1)return dp[idx][lim][sum][zero];
    int ans=0,num=9;
    if(lim)
    {
        num=A[idx]-'0';
    }
    for(int i=0;i<=num;i++)
    {
        int z=0;
        if(zero==1 && i==0)z=1;
        ans+=solve(idx+1,A,lim&&(i==num),(sum+i)%d,z);
        if(ans>=MOD)ans%=MOD;
    }
    return dp[idx][lim][sum][zero]=ans%MOD;
}

int main()
{
//    READ;
//    WRITE;
        cin>>A>>d;
        ms(dp,-1);
        ll ans=solve(0,A,1,0,1);
        printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 131712
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    map<ll,ll> mp;
    rep(i,N){
        ll A;
        cin >> A;
        if(!mp.count(A)){
            mp.emplace(A,1);
        }else mp.erase(A);
    }
    ll out = mp.size();
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi X(61);
  rep(i,0,N){
    int A; cin>>A;
    bitset<61> B(A);
    rep(j,0,61){
      if(B.test(j))
        X[j]++;
    }
  }
  int ans=0;
  int K=1;
  rep(i,0,61){
    ans+=((K*(X[i]%MOD))%MOD*((N-X[i])%MOD))%MOD;
    ans%=MOD;
    K*=2;
    K%=MOD;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args){

		Scanner scan01 = new Scanner(System.in);
		String str = scan01.next();

		String abc = "ABC";
		String arc = "ARC";

		if(str.equals(abc)){
			System.out.println("ARC");
		}else if(str.equals(arc)){
			System.out.println("ABC");
		}
			scan01.close();
	}
}

Measured memory_bytes: 26944
from itertools import accumulate


def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    ac = list(accumulate(a))
    ans = 0
    for i in range(n):
        ans += a[i] * (ac[-1] - ac[i])
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>
#include <iomanip>
#include <bitset>


using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	cout<<setprecision(12) <<(n%2==0?(double)(n/2)/n:(double)(n/2+1)/n)<<endl;
	return 0;
}

Measured memory_bytes: 256
# Nの入力
N = int(input())

N = N % 10

if(N == 2 or N == 4 or N == 5 or N == 7 or N == 9):
  print('hon')
elif(N == 0 or N == 1 or N == 6 or N == 8):
  print('pon')
else:
  print('bon')

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

using namespace std;

int main(void){
  int n;
  long long k;
  vector<pair<int, int> > v;
  
  cin >> n >> k;
  for (int i=0; i<n; i++){
    int a,b;
    cin >> a >> b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(), v.end());
  for (int i=0; i<n; i++){
    if (k<=v[i].second){
      cout << v[i].first << endl;
      break;
    }
    k -= v[i].second;
  }
  return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <queue>
using namespace std;

int dy[] = {0,0,1,-1}, dx[] = {1,-1,0,0};

inline int enc(int y,int x){
    return 52*y+x;
}

inline int enc2(int ty, int tx, int ky, int kx){
    return enc(ty,tx)*52*52 + enc(ky,kx);
}

int main(){
    int w,h,tx,ty,kx,ky;
    static int board[52][52];
    static int dist[52*52*52*52];
    while(scanf("%d%d",&w,&h),w){
        int ans = 1<<20;
        queue< pair<int,int> > Q;
        scanf("%d%d%d%d",&tx,&ty,&kx,&ky);
        for(int i=0; i<52; i++)
            for(int j=0; j<52; j++)
                board[i][j] = 1;
        for(int i=1; i<=h; i++)
            for(int j=1; j<=w;j++)
                scanf("%d",board[i]+j);
        for(int i=0; i<52*52*52*52; i++)
            dist[i] = 1<<10;
        if(enc(ty,tx)==enc(ky,kx)){
            printf("%d\n",0);
            goto end;
        }

        dist[enc2(ty,tx,ky,kx)] = 0;
        for(int k=0; k<4; k++){
            int nty = ty + dy[k],
                ntx = tx + dx[k],
                nky = ky - dy[k],
                nkx = kx - dx[k];
            if(board[nty][ntx]) nty = ty, ntx = tx;
            if(board[nky][nkx]) nky = ky, nkx = kx;
            if(enc(nty,ntx)==enc(nky,nkx)){
                printf("%d\n",1);
                goto end;
            }
            int p = enc2(nty,ntx,nky,nkx);
            if(1 < dist[p]){
                dist[p] = 1;
                Q.push( make_pair(p,2) );
            }
        }
        while(!Q.empty()){
            ty = (Q.front().first/(52*52))/52;
            tx = (Q.front().first/(52*52))%52;
            ky = (Q.front().first%(52*52))/52;
            kx = (Q.front().first%(52*52))%52;
            int d = Q.front().second;
            if(d > 100) break;
            Q.pop();
            for(int k=0; k<4; k++){
               int nty = ty + dy[k],
                   ntx = tx + dx[k],
                   nky = ky - dy[k],
                   nkx = kx - dx[k];
               if(board[nty][ntx]) nty = ty, ntx = tx;
               if(board[nky][nkx]) nky = ky, nkx = kx;
               if(enc(nty,ntx)==enc(nky,nkx)){
                    printf("%d\n",d);
                    goto end;
               }
               int p = enc2(nty,ntx,nky,nkx);
               if(d < dist[p]){
                   dist[p] = d;
                   Q.push( make_pair(p,d+1) );
               }
           }
        }
        printf("NA\n");
end:;
    }
}

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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define fore(it, v) for(auto it=v.begin(); it!=v.end(); it++)

struct city {
    int i, p, y, x;
    bool cmpi = false;
    city(int i, int p, int y): i(i), p(p), y(y) {}
    bool operator<(city& c) { return cmpi? i<c.i : y<c.y; }
    void show() { printf("%06d%06d\n", p, x); }
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<city> v;
	rep(i, m) {
	    int p, y;
	    cin >> p >> y;
	    v.push_back(city(i, p, y));
	}
	sort(v.begin(), v.end());
	map<int, int> cnt;
	fore(it, v) it->x = ++cnt[it->p], it->cmpi = true;
	sort(v.begin(), v.end());
	for(city c: v) c.show();
}


Measured memory_bytes: 8176
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;


int main() {
	int n, r;
	while(cin >> n >> r) {
		if(n == 0 && r == 0) break;
		int a[50], b[50];
		for(int i = 0; i < n; i++) {
			a[i] = n - i;
		}
		for(int i = 0; i < n; i++) {
			b[i] = n - i;
		}
		for (int i = 0; i < r; i++) {
			int p, c;
			cin >> p >> c;
			for(int j = 0; j < c; j++) {
				b[j] = a[p + j - 1];
			}
			for(int j = 0; j < p-1; j++) {
				b[c + j] = a[j];
			}
			for(int j = 0; j < n; j++) {
				a[j] = b[j];
			}
		}
		cout << b[0] <<endl;
	}


	return 0;
}

Measured memory_bytes: 1160
if __name__ == "__main__":
    N = int(input())
    S = input()

    count = 0
    max_count = 0
    for i in range(N - 1):
        if S[i] not in S[:i]:
            if S[i] in S[i + 1:]:
                count += 1
        elif S[i] not in S[i + 1:]:
            count -= 1
        max_count = max(count, max_count)

    print(max_count)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define MAX 100
  
int main(){
    int n;
    int t_point=0, h_point=0;
    char tarou[MAX], hanako[MAX];
  
    scanf("%d", &n);
    for(;n>0;n--){
        scanf(" %s %s", tarou, hanako);
        if(strcmp(tarou, hanako)>0){
            t_point+=3;
        }else if(strcmp(tarou, hanako)==0){
            t_point+=1;
            h_point+=1;
        }else if(strcmp(tarou, hanako)<0){
            h_point+=3;
        }
    }
    printf("%d %d\n", t_point, h_point);
  
    return 0;
} 

Measured memory_bytes: 604
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

//		int N = Integer.parseInt(sc.next());
		String S = sc.next();

		Map<String,Integer> map = new HashMap();

		for(int i=0;i < 4;i++) {
			String a = S.substring(i,i+1);
			if(map.containsKey(a)){
				map.put(a, map.get(a)+1);
			} else {
				map.put(a,1);
			}
		}
		for(Integer aa : map.values()) {
			if(aa != 2) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 20948
pre = 4280
v = [0,125,140,160]
while True:
    w = int(input())
    if w == -1:break

    s= 1150

    
    amari = w

    for i in reversed(range(1,4)):
        if amari > i*10:
            spam = amari - i*10
            s += spam * v[i]
            amari = i*10

    print (pre - s)

Measured memory_bytes: 6724
package main

import (
	"fmt"
)

func main() {
	var n, ans int64
	fmt.Scan(&n)
	F := make([]int64, n+1)
	for i := int64(1); i < n+1; i++ {
		for j := i; j < n+1; j += i {
			F[j] += j
		}
	}
	for _, f := range F {
		ans += f
	}
	fmt.Println(ans)
}


Measured memory_bytes: 82560
#include<iostream>
#include<string>
using namespace std;
int main(){
int N;
cin>>N;
int N2;
N2=N;
int Sn=0;

while(N2){
  Sn += N2 % 10;
  N2 = N2/ 10;


}
if(N%Sn==0){
  cout<<"Yes"<<endl;
}else if(N%Sn!=0){
  cout<<"No"<<endl;
}












}


Measured memory_bytes: 256
use std::io::stdin;

fn read_line() -> Vec<i32> {
    let mut a_str = String::new();
    stdin().read_line(&mut a_str).expect("read error");
    a_str.split_whitespace()
        .map(|x| x.parse::<i32>().expect("parse error"))
        .collect::<Vec<i32>>()
}

fn main() {
    let v = read_line();
    let h = v[0];
    let _n = v[1];
    let a = read_line();

    let sum = a.iter().fold(0, |sum, x| sum + x);

    if sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int x;
        cin >> x;
        int t = 0;
        int amt = 100;
        double p = 1.01;
        while(amt < x){
            amt *= p;
            t++;
        }
        cout << t << '\n';
    }
}

Measured memory_bytes: 34196
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);


int main()
{
	fast
		string s;  cin >> s;
	if (s[5] == s[4] && s[3] == s[2])
		cout << "Yes";
	else
		cout << "No";

	return 0;

}

Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, X, Y, Z;

i64 dp[41][1 << 17];
const int mask = (1 << 17) - 1;

int trans[1 << 17][11];
i64 powten[41];

int main()
{
	scanf("%d%d%d%d", &N, &X, &Y, &Z);

	dp[0][1] = 1;

	powten[0] = 1;
	for (int i = 0; i < N; ++i) powten[i + 1] = powten[i] * 10 % MOD;

	for (int i = 0; i < (1 << 17); ++i) {
		for (int j = 1; j <= 10; ++j) {
			int i2 = i;
			for (int k = 0; k < 17; ++k) {
				if (k < X && k + j > X) i2 &= ~(1 << k);
				if (k < X + Y && k + j > X + Y) i2 &= ~(1 << k);
				if (k < X + Y + Z && k + j > X + Y + Z) i2 &= ~(1 << k);
			}
			i2 <<= j;
			i2 |= 1;
			i2 &= (1 << 18) - 1;

			trans[i][j] = i2;
		}
	}

	i64 ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < (1 << 17); ++j) {
			for (int k = 1; k <= 10; ++k) {
				int j2 = trans[j][k];

				if (j2 & (1 << (X + Y + Z))) {
					ADD(ans, dp[i][j] * powten[N - i - 1] % MOD);
					continue;
				}
				j2 &= mask;
				ADD(dp[i + 1][j2], dp[i][j]);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 46848
#include <bits/stdc++.h>
#define FOR(i,a,b,m) for(int i = a; i <= b; i+=m)
using namespace std;

int main()
{
        string s; cin >> s;
        int l = s.size();
        if(s[0] == s[l-1])
        {
            if(l%2==0) cout << "First"; else cout << "Second";
        }
        else {
            if(l%2==0) cout << "Second"; else cout << "First";
        }
}

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

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

#define MOD 1000000007

int main(void) {
    ll N, M;
    vector<pair<ll, ll>> students, points;
    cin >> N >> M;
    for(ll i = 0;i < N;i++) {
        ll a, b;
        cin >> a >> b;
        students.emplace_back(a, b);
    }
    for(ll i = 0;i < M;i++) {
        ll a, b;
        cin >> a >> b;
        points.emplace_back(a, b);
    }
    for(ll i = 0;i < N;i++) {
        ll mini = LONG_LONG_MAX;
        ll index = 0;
        for(ll j = 0;j < M;j++) {
            ll dis = abs(points[j].first - students[i].first) + abs(points[j].second - students[i].second);
            if(dis < mini) {
                mini = dis;
                index = j;
            }
        }
        cout << index + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){   
    int h,n;
    cin>>h>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int sum = 0;
    rep(i,n)sum += a[i];
    if(sum >= h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

const long long MOD = 1e9 + 7;
long long n, fac[2005];

long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

long long ncr(long long a, long long b){
    long long ans = (fac[a] * binpow(fac[b], MOD - 2)) % MOD;
    ans = (ans * binpow(fac[a - b], MOD - 2)) % MOD;
    return ans;
}

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

    fac[0] = 1;
    for(long long i = 1; i <= 2000; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
    }

    cin >> n;
    if(n  < 3){
        cout << 0 << '\n';
    } else {
        long long max_term = n / 3;
        long long ans = 1;
        for(int i = 2; i <= max_term; i++){
            ans = (ans + ncr((long long) n - 2 * i - 1, (long long) i - 1)) % MOD;
        }
        cout << ans << '\n';
    }
    return 0;
}

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

int	main()
{
	int	N;
	cin >> N;
	vector<int64_t>	a(3 * N);
	for (int i = 0; i < 3 * N; ++i)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	int64_t	sum = 0;
	for (int i = N; i < 3 * N; i+= 2)
		sum += a.at(i);
	cout << sum << endl;
}


Measured memory_bytes: 2560
#include <cstdio>

int main(){
    int a, b, t;
    scanf("%d %d %d", &a, &b, &t);
    int ans = 0;
    for(int i = a; i <= t; i += a){
        ans += b;
    }
    printf("%d\n", ans);

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int K, S;
    cin >> K >> S;

    int ans = 0;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            if(x+y+0<=S && x+y+K>=S) ans++;
        }
    }

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

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

typedef long long ll;

using namespace std;

int main() {
	char c;
	cin >> c;
	int a = 1;
	a *= (c-'a');
	a *= (c-'e');
	a *= (c-'i');
	a *= (c-'o');
	a *= (c-'u');
	cout << ((a==0)?"vowel":"consonant") << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n = int(input())
p = list(map(int, input().split()))
p = [-1] + [q-1 for q in p]
c = [[] for _ in range(n)]
for i in range(1, n):
	c[p[i]].append(i)
x = list(map(int, input().split()))

def dfs(cur):
	dp = [10**10 for _ in range(x[cur]+1)]
	dp[0] = 0
	for v in c[cur]:
		z, w = dfs(v)
		#print(cur, z, w)
		for i in range(x[cur], -1, -1):
			if dp[i] < 10**10:
				tmp = dp[i]
				dp[i] = 10**10
				if i+z <= x[cur]:
					dp[i+z] = min(dp[i+z], tmp+w)
				if i+w <= x[cur]:
					dp[i+w] = min(dp[i+w], tmp+z)
	#print(cur, dp)
	if min(dp) == 10**10:
		print("IMPOSSIBLE")
		sys.exit()
	return min(dp), x[cur]

dfs(0)
print("POSSIBLE")

Measured memory_bytes: 15048