akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    int S,W;
    cin >> S >> W;
    if (S>W) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
    
}

Measured memory_bytes: 3612
K,T=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
a.sort(reverse=True)
if T==1:
    print(a[0]-1)
else:
    if a[0]-(b-a[0])>=2:
        print(a[0]-(sum(a)-a[0])-1)
    else:
        print(0)

Measured memory_bytes: 61912
def countingSort(A,B):
    k = max(A)
    C = [0]*(k+1)
    
    for j in range(len(A)):
        C[A[j]] += 1
    
    for i in range(1,k+1):
        C[i] += C[i-1]   
    for j in range(len(A)):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -=1

n = int(input())
A = list(map(int,input().split()))
B = [0]* len(A)
countingSort(A,B)
print(*B)

Measured memory_bytes: 233752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N

int main(){
	FIO;
	int n; cin >> n;
    n %= 10;
    if(n==3) cout << "bon" << endl;
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
    else cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;



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

	map<ll, ll> mp;
	rep(i,0,n) {
		ll x;
		cin >> x;
		mp[x]++;
	}

	vector<ll> rec;
	vector<ll> sq;
	for (auto x : mp) {
		if (x.second >= 2) {
			rec.push_back(x.first);
			if (x.second >= 4) {
				sq.push_back(x.first);
			}
		}
	}

	sort(rec.begin(),rec.end());
	reverse(rec.begin(), rec.end());
	sort(sq.begin(), sq.end());
	reverse(sq.begin(), sq.end());



	if (rec.size() >= 2 && sq.size() >= 1) {
		cout << max(rec[0]*rec[1],sq[0]*sq[0]) << endl;
	}
	else if (rec.size() >= 2 && sq.size() < 1) {
		cout << rec[0] * rec[1] << endl;
	}
	else if (rec.size() < 2 && sq.size() >= 1) {
		cout << sq[0] * sq[0] << endl;
	}
	else {
		cout << "0" << endl;
	}


	
	
	return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 3e2 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int dp[maxN][maxN][maxN];

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(dp, 0, sizeof dp);
	string s; cin >> s;
	int n = s.size();
	int X; cin >> X;
	for (int len = 0; len < n; len++)
		for (int l = 0; l + len < n; l++){
			for (int i = 0; i <= X; i++){
				int r = l + len;
				if (l == r){
					dp[i][l][r] = 1;
					continue;
				}
				if (l + 1 < n)
					dp[i][l][r] = max(dp[i][l][r], dp[i][l + 1][r]);
				if (r > 0)
					dp[i][l][r] = max(dp[i][l][r], dp[i][l][r - 1]);
				if (s[l] == s[r])
					dp[i][l][r] = max(dp[i][l][r], dp[i][l + 1][r - 1] + 2);
				if (i > 0)
					dp[i][l][r] = max(dp[i][l][r], dp[i - 1][l + 1][r - 1] + 2);
			}
		}
	printf("%d\n", dp[X][0][n - 1]);
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 



Measured memory_bytes: 111104
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(data) {
  	var result = [];
  	var index = 0;
    while (data[index] !== 0) {
    	result.push('Case ' + (index + 1) + ': ' + data[index++]);
    }
    return result.join('\n');
  }(lines.map(Number)
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 10884
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}

void solve(){
    string s, t;
    cin >> s >> t;
    long mn = 1e9;
    for (int i = 0; i <= s.size() - t.size(); ++i){
        long res = 0, k = i;
        for (int j = 0; j < t.size(); ++j){
            if( s[k] != t[j] ) res ++;
            k ++;
        }
        mn = min(mn, res);
    }
    cout << mn;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 3856
#include <iostream>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    while (x != 0 || y != 0)
    {
        if (x > y)
        {
            cout << y << ' ' << x << endl;
        }
        else
        {
            cout << x << ' ' << y << endl;
        }
        cin >> x >> y;
    }
    return 0;
}


Measured memory_bytes: 3052
from sys import stdin

n = int(stdin.readline())
p = [int(x) for x in stdin.readline().rstrip().split()]
count = 0

for i, pi in enumerate(p):
    if i == 0:
        continue
    elif i == n-1:
        break
    tmplist = sorted([pi, p[i-1], p[i+1]])
    if pi == tmplist[1]:
        count = count + 1

print(count)


Measured memory_bytes: 2940
import sys

input = sys.stdin.readline

N = int(input())
W = []
for _ in range(N):
    W.append(input().strip())

check = set([W[0]])
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
        break
    else:
        before = W[i][-1]
        check.add(W[i])

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	ans = 0
	for i,val in enumerate(A):
		ii = i+1
		if ii % 2 == 1:
			if val % 2 == 1:
				ans += 1

	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76824
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;

    for(int i=1;i<=3;i++){
        if((a*b*i)%2!=0){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";


    return 0;


}


Measured memory_bytes: 256
import itertools
n,k = map(int,input().split())
x = []
a = []
b = []
for i in range(n):
    x1,y1=[int(i) for i in input().split()]
    x.append([x1,y1])
    a.append(x1)
    b.append(y1)
ue = list(itertools.combinations(a,2))
mi = list(itertools.combinations(b,2))
e = len(ue)
ue.extend(mi)
ans = float("inf")
for i in range(e):
  u = ue[i]
  if u[0] > u[1]:
    UP = u[0]
    DO = u[1]
  else:
    UP = u[1]
    DO = u[0]
  for j in range(e):
    kazu = 0
    m = ue[j+e]
    if m[0] > m[1]:
      RI = m[0]
      LE = m[1]
    else:
      RI = m[1]
      LE = m[0]
    for i in  x:
      c = i[0]
      d = i[1]
      if (UP >= c and c>= DO and RI >= d and d >= LE):
        kazu += 1
    if kazu >= k:
      ans = min(ans,(UP-DO)*(RI-LE))
print(ans)

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

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n,m;
	cin>>n>>m;
  double k,sum=0;
	vector<int>v(n);
	for(int i=0;i<n;i++){
	cin>>v[i];
	sum+=v[i];
	}
	
	k=sum/(m*4);
	bool ok=true;
	sort(v.begin(),v.end());
	for(int i=0;i<m;i++){
		if(v[n-1-i]<k){
		ok=false;
		break;
		}
	}
	if(ok)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}
/*
3 2
380 19 1
No

12 3
4 56 78 901 2 345 67 890 123 45 6 789  
Yes
*/
int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


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

int main(){
  int n,l;
  cin >> n >> l;
  int total = 0;
  int tmp = 0;
  for(int i = 1; i < n+1; i++) {
    total += l + i - 1;
  }
  int minNum = 1000;
  int ans = 0;
  for (int i = 1; i < n+1; i++) {
    if (abs((total - (l + i-1)) - total) < minNum) {
      minNum = abs((total - (l+i-1)) - total);
      ans = total - (l+i-1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
x=int(input())
value=0
index=0
hashmap=dict()
while value<int(1e18)+1:
    value=index**5
    hashmap[value]=index
    index+=1
#print(hashmap)    
 
for i in range(1,1000):
    b1=x+ i**5
    b2=x+(-i)**5
    if hashmap.get(b1)!=None:
        print(hashmap[b1],i)
        break
    if hashmap.get(abs(b2))!=None:
        print(hashmap[abs(b2)],-i)
        break     


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

using namespace std;

int main() {
    long long a;
    string b;
    cin >> a >> b;

    long long result = 0;
    int mul = 100;
    for(long unsigned int i = 0; i < b.length(); i++) {
        if(b[i] == '.') continue;
        result += a * (b[i] - '0') * mul;
        mul /= 10;
    }

    cout << (result / 100) << endl;
}

Measured memory_bytes: 3628
n = int(input())
def gcd(a, b):
    if a < b:
        t = a
        a = b
        b = t
    if b == 0: 
        return a
    else:
        return gcd(b, a%b)
ans = 1
for i in range(n):
    t = int(input())
    ans = ans * t // gcd(ans, t)
print(ans)

Measured memory_bytes: 3060
n=int(input()) 
s, t = input().split()

l = [[] for _ in range(2*n)]
for i in range(2*n):
    if i % 2==0:
        l[i]=s[i//2]
    else:
        l[i]=t[i//2]
answer = ''.join(l)
print("{}".format(answer))

Measured memory_bytes: 3060
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005

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

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

    int r, c; 
    cin>>r>>c;
    string s[r];
    REP(i, r) cin>>s[i];
    REP(i, r){
        REP(j, c){
            if(s[i][j] == '#'){
                cout<<'#';
                continue;
            }
            int cnt = 0;
            for(int d = 0; d < 8; d++){
                int x = i + dx[d];
                int y = j + dy[d];
                if(s[x][y] == '#' && x >= 0 && x < r && y >= 0 && y < c){
                    cnt++;
                }
            }
            cout<<cnt;
        }
        cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 256
import math 

nk = input().split()
hl = input().split()


n = int(nk[0])
k = int(nk[1])

if(n<k):
	print(0)
else:

	h = sorted([int(i) for i in hl])
	hp = 0

	for i in hl:
		hp = hp + int(i)



	for i in range(k):
		hp = hp - int(h[-1-i])

	print(hp)


Measured memory_bytes: 29364
#include <iostream>

using namespace std;

int main() {
    int cnt[4];
    fill(cnt, cnt + 4, 0);
    for (int i = 0; i < 6; ++i) {
        int a;
        cin >> a;
        ++cnt[--a];
    }

    int p = 0;
    for (int i = 0; i < 4; ++i) p += cnt[i] % 2;
    cout << (p <= 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct node{
    int x,y,z;
    bool operator<( const node& right ) const {
        if(x == right.x){
            if(y == right.y) return z < right.z;
            else return y < right.y;
        }else return x < right.x;
    }
};

vector<int> v;
int N;
inline void init(int m) {N = m; v.resize(m + 1, 0);}
inline void add(int a, int x){a++; for(int i=a;i<=N;i+=i&-i) v[i] += x;}
inline int sum(int a){
    a++; int ret = 0;
    for(int i=a;i>0;i-=i&-i) ret += v[i];
    return ret;
}
inline int sum(int a, int b){return sum(b) - sum(a - 1);}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, q, l, r;
    cin >> n >> q;
    int c[n], num[n];
    memset(num, -1, sizeof(num));
    init(n);
    for(int i=0;i<n;i++){
        cin >> c[i];
        c[i]--;
    }
    vector<node> qu;
    for(int i=0;i<q;i++){
        cin >> l >> r;
        l--; r--;
        qu.push_back({r, l, i});
    }
    int ans[q];
    sort(be(qu));
    int idx = 0;
    for(int i=0;i<n;i++){
        if(num[c[i]] != -1) add(num[c[i]], -1);
        num[c[i]] = i;
        add(num[c[i]], 1);
        while(idx != q && qu[idx].x == i){
            ans[qu[idx].z] = sum(qu[idx].y, qu[idx].x);
            idx++;
        }
    }
    for(int i=0;i<q;i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 17592
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[50][50];
int dp[50][50][50][50];
int sum[50][50];
int rect(int a,int b,int c,int d){
	return sum[c][d]-sum[a][d]-sum[c][b]+sum[a][b];
}
int H,W;
int calc(int a,int b,int c,int d){
	if(~dp[a][b][c][d])return dp[a][b][c][d];
	if(a==0&&b==H&&c==0&&d==W)return dp[a][b][c][d]=0;
	int ret=mod;
	for(int i=0;i<H;i++){
		if(a<i&&i+1<b)continue;
		for(int j=0;j<W;j++){
			if(c<j&&j+1<d)continue;
			if((a==i||i+1==b)&&(c==j||j+1==d))continue;
			int tmp=calc(min(i,a),max(i+1,b),min(j,c),max(j+1,d));
			tmp+=rect(a,min(j,c),b,max(j+1,d))+rect(min(i,a),c,max(i+1,b),d)-rect(a,c,b,d)*2;
			ret=min(ret,tmp);
		}
	}
//	printf("%d %d %d %d: %d\n",a,b,c,d,ret);
	return dp[a][b][c][d]=ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	H=a;W=b;
	int pi,pj;
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='P'){
			pi=i;pj=j;
		}
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)
		for(int k=0;k<=b;k++)for(int l=0;l<=b;l++){
			dp[i][j][k][l]=-1;
		}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='#')sum[i+1][j+1]++;
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=b;j++){
		sum[i][j+1]+=sum[i][j];
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=b;j++){
		sum[i+1][j]+=sum[i][j];
	}
	int ret=mod;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<=a;j++){
			for(int k=0;k<b;k++){
				for(int l=k+1;l<=b;l++){
					if(i>pi||j<=pi||k>pj||l<=pj)continue;
					int tmp=calc(i,j,k,l);
					int A=min(min(rect(i,k,pi+1,pj+1),rect(i,pj,pi+1,l)),min(rect(pi,k,j,pj+1),rect(pi,pj,j,l)));
					ret=min(ret,tmp+A);
				}
			}
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 20480
#include<stdio.h>

#define MAX 100000
#define NIL -1

struct node{
  int parent;
  int left;
  int right;
};

struct node T[MAX];
int n;
int D[MAX];

int rec(int ,int );

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);

      if(j==0)T[v].left=c;
      else T[l].right=c;

      l=c;
      T[c].parent=v;
    }

  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++){

    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,D[i]);

    if(T[i].parent==NIL)printf("root, ");
    else if(T[i].left==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0,c=T[i].left;c!=NIL;j++,c=T[c].right){
      if(j)printf(", ");
      printf("%d",c);
  }
    printf("]\n");
  }
  return 0;
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)rec(T[u].right,p);
  if(T[u].left!=NIL)rec(T[u].left,p+1);
  return 0;
}

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

bool vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A;
  int ain;
  int aMax = 0;

  for(int i=0;i < N; i++){
    cin >> ain;
    A.push_back(ain);
    if(aMax < ain)
      aMax = ain;
  }
  vector<int> mapA(aMax+1, 0);
  int aLen = A.size();
  
  for(int i=0; i < aLen; i++ ){
    int multiVal = A[i];
    if(mapA[multiVal] >=1){
      mapA[multiVal] += 1;
      continue;
    }
    while(multiVal <= aMax){
      mapA[multiVal] += 1;
      multiVal += A[i];
    }
  }

  int passed = 0; 
  for(int i=0; i < aLen; i++){
    if(mapA[A[i]] <=1)
      passed++;  
  }   
  cout << passed << endl;
}


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

int main() {
  int n,a,b;string s;cin>>n>>a>>b>>s;
  int cnt=0,B=0;
  rep(i,n){
    if(s[i]=='c')cout<<"No"<<endl;
    else {
      if(s[i]=='a'){
        if(cnt<a+b){
          cout<<"Yes"<<endl;
          cnt++;
        }
        else cout<<"No"<<endl;
      }
      else {
        if(B<b&&cnt<a+b){
          cout<<"Yes"<<endl;
          cnt++;
        }
        else cout<<"No"<<endl;
        B++;
      }
    }
  }
}

Measured memory_bytes: 3760
#include<stdio.h>

int main(void){
  
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(a==b){
    if(b!=c){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }
  else if(b==c){
    if(a!=b){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }
  else if(a==c){
    if(a!=b)
      printf("Yes");
    else
      printf("No");
  }
  else
    printf("No");
    
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	c = max(0, (c-(a-b)));
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
const int LMAX=2010;
class SCC{//cmp(0 - kk-1) is scc's return. Same number is group. The number is no relatoin.
	public:
	int n;
	vvi G,rG;
	vector<bool>used;
	vi vs,cmp;
	SCC(int size){
		n=size;
		G=rG=vvi(n);
		used=vector<bool>(n);
		cmp=vi(n);
		vs=vi(0);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
		rG[t].pb(s);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		rep(i,rG[v].size())if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
	void dfs(int v){
		used[v]=true;
		rep(i,G[v].size())if(!used[G[v][i]])dfs(G[v][i]);
		vs.pb(v);
	}
	int scc(){
		rep(i,n)used[i]=false;
		rep(v,n)if(!used[v])dfs(v);
		rep(i,n)used[i]=false;
		int kk=0;
		for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],kk++);
		return kk;  
	}
};
vp in;
vvi G,rG;
vi visit;
int out=0;
void dfs(int a){
	out+=in[a].second;
	visit[a]=true;
	rep(i,G[a].size())if(visit[G[a][i]]==0)
		dfs(G[a][i]);
}
int main(){
	int n;
	while(cin>>n,n){
		map<string,int>m;
		vector<string>a(n),c(n);
		vi b(n),d(n);
		rep(i,n)cin>>a[i]>>b[i]>>c[i]>>d[i];
		rep(i,n)m[a[i]]=i;		
		SCC scc(n);
		rep(i,n){
			if(a[i]!=c[i])scc.add_edge(m[c[i]],m[a[i]]);
		}
		int N=scc.scc();
		in=vp(N);
		G=rG=vvi(N);
		rep(i,N){
			vi t;
			rep(j,n)if(scc.cmp[j]==i)t.pb(j);
			if(t.size()==1){
				if(i!=scc.cmp[m[c[t[0]]]]){
					rG[i].pb(scc.cmp[m[c[t[0]]]]);
					G[scc.cmp[m[c[t[0]]]]].pb(i);
				}
				in[i]=pii(b[t[0]],d[t[0]]);
			}else{
				int mi=inf,sum=0;
				rep(j,t.size())sum+=d[t[j]];
				rep(j,t.size())mi=min(mi,b[t[j]]-d[t[j]]);
				in[i]=pii(mi+sum,inf);
			}
		}
		visit=vi(N);
		out=0;
		rep(i,N)if(visit[i]==0&&rG[i].size()==0){
			out+=in[i].first-in[i].second;
			dfs(i);
		}
		cout<<out<<endl;
		
	}
}

Measured memory_bytes: 1712
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
string s;
signed main() {
	cin >> n >> s;
	int black = 0, white = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.') white++;
	}
	int ans = white;
	for (int i = 0; i < n; i++) {
		if (s[i] == '#') {
			black++;
		}
		else {
			white--;
		}
		ans = min(ans, white + black);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
long []a=Console.ReadLine().Split().Select(long.Parse).ToArray();
      if(lcm(a[0],a[1])==a[0]){Console.WriteLine(-1);}
      else{Console.WriteLine(a[0]);}
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static string Reverse(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
import fractions

n = int(input())
aList = list(map(int, input().split()))

def gcd3(nums):
    ans1 = fractions.gcd(nums[0], nums[1])
    ans2 = fractions.gcd(nums[0], nums[2])
    ans3 = fractions.gcd(nums[1], nums[2])

    if ans1 >= ans2 and ans1 >= ans3:
        return ans1, nums[2]
    if ans2 >= ans1 and ans2 >= ans3:
        return ans2, nums[1]
    if ans3 >= ans1 and ans3 >= ans2:
        return ans3, nums[0]

ans = 0
if n == 2:
    ans = max(aList)
else:
    sList = []
    sList.append(aList.pop(0))
    sList.append(aList.pop(0))
    sList.append(aList.pop(0))
    ans, v = gcd3(sList)

    for i in range(len(aList)):
        tmp = aList.pop(0)
        tmp1 = fractions.gcd(ans, v)
        tmp2 = fractions.gcd(ans, tmp)
        if tmp1 >= tmp2:
            ans = tmp1
            v = tmp
        else:
            ans = tmp2

print(ans)

Measured memory_bytes: 16156
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define N 501
using namespace std;
typedef long long ll;
vector<ll>gx;
vector<ll>gy;
map<ll,int> mpx;
map<ll,int> mpy;
ll c[N],d[N];
int main(){
    int n,z;
    cin>>n>>z;
    for(int i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        c[i]=x;d[i]=y;

        if(!mpx[x])
            gx.push_back(x);
        if(!mpy[y])
            gy.push_back(y);
        mpx[x]=1;
        mpy[y]=1;
    }
    ll ans=5e18;
    sort(gx.begin(),gx.end());
    sort(gy.begin(),gy.end());
//    for(int i=0;i<gy.size();i++)
//        cout<<gy[i]<<-1<<endl;
  //  cout<<-1<<endl;
    for(int i=0;i<gx.size();i++)
        for(int j=gx.size()-1;j>=i;j--)
            for(int p=0;p<gy.size();p++)
              for(int q=gy.size()-1;q>=p;q--){
                int sum=0;
                for(int k=1;k<=n;k++)
                 {
                         //cout<<c[k]<<d[k]<<endl;
                      if(c[k]<=gx[j]&&c[k]>=gx[i]&&d[k]<=gy[q]&&d[k]>=gy[p])
                        sum++;
                      if(sum>=z){
                        if(ans>(gx[j]-gx[i])*(gy[q]-gy[p]))
                        ans=(gx[j]-gx[i])*(gy[q]-gy[p]);
                        break;
                      }
                }
//               if(sum<z){
//                cout<<ans<<endl;
//                return 0;
//               }
              }
              cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	
	typedef long long ll;
	#define pi 3.14159265 
	#define EPS 1e-8
	
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"
 
	const ll INF=(ll)2e18;
	

	
	int main()
	{
		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
			
		 ll n;
		 cin>>n;
		 map<string,ll> m;
		 for(int i=0;i<n;i++)
		 {
			 string s;
			 cin>>s;
			 m[s]++;
		 }
		 cout<<m.size();
		 
	}


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    double a,b,h,m,angle,ans;
    cin>>a>>b>>h>>m;
    angle=abs(((11*m)-(60*h))/2);
    if(angle>180)
        angle=360-angle;
    angle=(PI*angle)/180;
    //cout<<angle<<nl;
    ans=sq(a)+sq(b)-(2*a*b*cos(angle));
    cout<<fixed<<setprecision(20)<<sqrt(ans)<<nl;
    return 0;
}


Measured memory_bytes: 4168
from collections import defaultdict

class LCM_mod:
    """
    最小公倍数の計算を行う
    オーバーフローが発生しないように素因数分解し,
    因数の積を逐次余りに置き換えて最小公倍数を導出する.
    """
    def __init__(self, max_num, p=10**9+7):
        self.max_num = max_num + 1
        self.p = p
        self.prime = [0 for _ in range(self.max_num)]
        self.max_map = defaultdict(int)
        self.sieve()

    def rep_sqr(self, base, k):
        # 繰り返し二乗法
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k / 2) ** 2) % self.p
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.p

    def sieve(self):
        """
        エラトステネスの篩　O(n)
        nまでに含まれる素数を導出
        """
        self.prime[0], self.prime[1] = 1, 1
        for i in range(2, self.max_num):
            if self.prime[i]:
                continue
            for j in range(i * 2, self.max_num, i):
                if self.prime[j]:
                    continue
                self.prime[j] = i
            self.prime[i] = i

    def lcm_list_mod(self, arr):
        """
        listのそれぞれの要素について、素因数分解する
        それぞれの因数について最大であれば更新する
        """
        for i in range(len(arr)):
            num = arr[i]
            d = defaultdict(int)

            while num > 1:
                fact = self.prime[num]
                d[fact] += 1
                num //= fact

            for i in d.keys():
                self.max_map[i] = max(self.max_map[i], d[i])

        ans = 1
        for i in self.max_map.keys():
            ans = (ans * self.rep_sqr(i, self.max_map[i])) % self.p
        return ans


def rep_sqr(base, k, mod):
    if k == 0:
        return 1
    elif k % 2 == 0:
        return (rep_sqr(base, k / 2, mod) ** 2) % mod
    else:
        return (rep_sqr(base, k - 1, mod) * base) % mod

# a^(-1) == a^(m-2)

def flt(a, mod):
    return rep_sqr(a, mod-2, mod)

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

lcm_mod = LCM_mod(max(a), MOD)

lcm_all = lcm_mod.lcm_list_mod(a)

b = list(map(lambda x: lcm_all * flt(x, MOD), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 115952
package main

import (
	"fmt"
)

const mod = int(1e9 + 7)

var ifac, fac []int

var pows map[int]map[int]int

func main() {
	const cmax = int(2e6 + 1)
	fac = make([]int, cmax)
	ifac = make([]int, cmax)
	inv := make([]int, cmax)
	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i < cmax; i++ {
		fac[i] = (fac[i-1] * i) % mod
		inv[i] = (mod - inv[mod%i]*(mod/i)) % mod
		if inv[i] < 0 {
			inv[i] += mod
		}
		ifac[i] = (ifac[i-1] * inv[i]) % mod
	}

	var k int
	fmt.Scan(&k)
	var s string
	fmt.Scan(&s)
	n := len(s)
	var sum int
	for i := n; i <= k+n; i++ {
		a := comb(k+n, i) * modpow(25, k+n-i)
		sum += a
		sum %= mod
	}
	fmt.Println(sum)
}

func comb(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 || r == n {
		return 1
	}
	t := (ifac[n-r] * ifac[r]) % mod
	return (t * fac[n]) % mod
}

func modpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 > 0 {
			res *= a
			res %= mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 53484
h,w,a,b = map(int,input().split())
for _ in range(b):
  l = []
  for _ in range(a):
    l.append("0")
  for _ in range(w-a):
    l.append("1")
  jo = "".join(l)
  print(jo)
for _ in range(h-b):
  l = []
  for _ in range(a):
    l.append("1")
  for _ in range(w-a):
    l.append("0")
  jo = "".join(l)
  print(jo)

  
    
  

Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int n = vals[0];
        int a = vals[1];
        int b = vals[2];

        int diff = Math.Abs(a - b);
        if (diff % 2 == 0)
        {
            Console.WriteLine("Alice");
        }
        else
        {
            Console.WriteLine("Borys");
        }
    }
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    int ans = 0;
    ans += max(400000 - 100000 * x, 0);
    ans += max(400000 - 100000 * y, 0);
    if (x == y && x == 1) ans += 400000;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc046/virtual

#include <iostream>
#define _ std::ios::sync_with_stdio(false); std::cin.tie(0);

int lcm(int m, int n){
  int a;
  a = (m > n) ? m : n;
  while (true) {
    if (a % m == 0 && a % n == 0)
      return a;
    ++a;
  }
}

int main() { _
  int x;
  std::cin >> x;
  std::cout << lcm(360, x)/x << '\n';
  
  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    int sum=0;
    rep(i,n-1)sum+=a[i];
    if(sum>a[n-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}

/*ライブラリゾーン！！！！！！！！！！！！！！！*/
int n, m, a,ans;
signed main(){
	cin >> n >> m >> ans;
	ans = abs(m - ans);
	for (int i = 1; i < n; i++) {
		cin >> a;
		ans = gcd(ans, abs(a - m));
	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>

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

using namespace std;
int mod = 1000000007;

int D;
ll G;

int main() {
  cin >> D >> G;
  vector<P> v;
  for (int i=1; i<=D; i++) {
    int p, c;
    cin >> p >> c;
    v.emplace_back(p, c);
  }

  int ans = INT_MAX;
  for (int i=0; i<(1<<D); i++) {
    ll sum = 0;
    int sumq = 0;
    for(int k=0; k<D; k++) {
      if (i>>k & 1) {
        sum += v.at(k).first*(k+1)*100 + v.at(k).second;
        sumq += v.at(k).first;
      }
    }
    if (sum >= G) {
      ans = min(sumq, ans);
    } else {
      int k=D-1;
      while (k>0 && (i>>k & 1)) {
        k--;
      }
      ll rem = G-sum;
      ll remi = rem/((k+1)*100);
      if (rem%(ll)((k+1)*100) != 0) {
        remi++;
      }
      if (remi < v.at(k).first) {
        ans = min(sumq+(int)remi, ans);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
C = {}

def firstd(num):
    if num < 10:
        return num
    prev = 0
    while num > 0:
        num = num // 10
        if num == 0:
            return prev
        prev = num
    return prev

assert firstd(123) == 1
assert firstd(321) == 3

for x in range(1, N + 1):
    first = firstd(x)
    last = x % 10
    C[(first,last)] = C.get((first,last), 0) + 1

ans = 0
for x in range(1, N + 1):
    first = firstd(x)
    last = x % 10

    ans += C.get((last,first), 0)
print(ans)

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

int main(){
    int n, d;
    cin >> n >> d;
    int ans;
    if (n % (2 * d + 1) != 0) {
        ans = n / (2 * d + 1);
        cout << ans + 1 << endl;
    }
    else cout  << n / (2 * d + 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

void preparse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preparse(T[u].l);
  preparse(T[u].r);
}

void inparse(int u){
  if(u==NIL)return;
  inparse(T[u].l);
  printf(" %d",u);
  inparse(T[u].r);
}

void postparse(int u){
  if(u==NIL)return;
  postparse(T[u].l);
  postparse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;

  printf("Preorder\n");
  preparse(root);
  printf("\n");
  printf("Inorder\n");
  inparse(root);
  printf("\n");
  printf("Postorder\n");
  postparse(root);
  printf("\n");

  return 0;
}


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

constexpr int64_t mod = 1000000007;
vector<int64_t> fact, inv;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t res = power(n * n % mod, k / 2);
  if (k % 2) {
    res = res * n % mod;
  }
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 1; i <= n; i++) {
    fact.push_back(i * fact.back() % mod);
    inv.push_back(power(fact.back(), mod - 2));
  }
}

int64_t ncr(int64_t n, int64_t r) {
  if (r < 0 or n - r < 0) return 0;
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

int main() {
  int64_t n, k, ans = 0;
  cin >> k;
  string s;
  cin >> s;
  n = s.size();
  init(n + k);
  for (int64_t i = 0; i <= k; i++) {
    ans += power(25, i) * ncr(n + k, i) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 36932
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    vector<vector<int>> c(3, vector<int>(3));
    REP(i, 3){
        readvec(c[i]);
    }
    int a[3], b[3];
    a[0] = 0;
    REP(j, 3){
        b[j] = c[0][j];
    }
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    string ans = "Yes";

    REP(i, 3){
        REP(j, 3){
            if(a[i] + b[j] != c[i][j]) ans = "No";
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
N = int(input())
A = sorted((map(int,input().split())))
a_Max = A[-1]
B = [0]*a_Max

for a in A:
    if B[a-1] == 0:
        B[a-1] = 1
        for j in range(2,a_Max+1):
            if a*j > a_Max:
                break
            B[a*j-1] = 2
    elif B[a-1] == 1:
        B[a-1] = 2
            
ans = 0
for b in B:
    if b == 1:
        ans += 1

print(ans)



Measured memory_bytes: 32232
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll a,b; cin >> a >> b;
    if(a + b == 15) puts("+");
    else if(a * b == 15) puts("*");
    else puts("x");
}

Measured memory_bytes: 256