akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

string s;

void solve(){
    cin >> s;
    for(char& c : s){
        if(c == '?'){
            c = 'D';
        }
    }
    cout << s << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
#define N 100000

int group[N];
vector<int> vec[N];
int n,m;

int dfs_visit(int x,int k){
  stack<int> S;
  S.push(x);
  while(!S.empty()){
    int u=S.top();S.pop();
    for(int i=0;i<vec[u].size();i++){
      int v=vec[u][i];
      if(group[v]==0){
        group[v]=k;
        S.push(v);
      }
    }
  }
}
void dfs(){
  int id=1;
  for(int i=0;i<n;i++){
    if(group[i]==0) dfs_visit(i,id++);
  }
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    vec[s].push_back(t);
    vec[t].push_back(s);
  }
  dfs();
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    if((group[a]!=0&&group[b]!=0)&&group[a]==group[b]){
      cout<<"yes"<<"\n";
    }else{
      cout<<"no"<<"\n";
    }
  }
}



Measured memory_bytes: 8900
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,a[60][60];
char c;

int main()
{ 
    int le=-10;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            cin>>c;
            if(c=='#')
            {
                a[i][j]=le;
                a[i-1][j-1]++;
                a[i-1][j]++;
                a[i-1][j+1]++;
                a[i][j-1]++;
                a[i][j+1]++;
                a[i+1][j-1]++;
                a[i+1][j]++;
                a[i+1][j+1]++;
            }
        }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++){
        	if(a[i][j]<0)cout<<"#";
            else cout<<a[i][j];
        }   
        cout<<endl;
    } 
	return 0;  
}

Measured memory_bytes: 256
loop do
  count = gets.to_i
  break if count == 0

  pa = 0
  pb = 0
  
  count.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
  
    if a > b
      pa += a + b
    elsif a < b
      pb += a + b
    else
      pa += a
      pb += b
    end
  end
  
  puts "#{pa} #{pb}"
end

Measured memory_bytes: 8772
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 int n;
 scanf("%d",&n);
 long  int sum1=0,a_count[100001] = {0},t;
 for(int i=0;i<n;i++){
  scanf("%ld",&t);
  //aの和と数値ごとの出現回数を格納する。
  a_count[t]++;//数値ごとの出現回数
  sum1+=t;//aの和
 }
 int q;
 scanf("%d",&q);
 int b[q],c[q];
 for(int i=0;i<q;i++){
  scanf("%d%d",&b[i],&c[i]);
  sum1+=(c[i]-b[i])*a_count[b[i]];
  a_count[c[i]] += a_count[b[i]];
  a_count[b[i]] = 0;
  printf("%ld\n",sum1);
 }
 
}

Measured memory_bytes: 3696
#include<stdio.h>
int main(){
  int n, m, k;
  int i, j;
  int flag = 0;
  int gokei = 0;
  scanf("%d %d %d", &n, &m, &k);
  for(i = 0; i < n; i++){
    gokei = m * i;
    if(gokei == k){
      flag = 1;
      break;
    }
    for(j = 0; j < m; j++){
      gokei = gokei + n - i - i;
      if(gokei == k){
        flag = 1;
        break;
      }
    }
    gokei = 0;
  }
  if(flag == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<cmath>
#include<algorithm>

int main() {
	int n, temp, count=0, p;
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &temp);
		p = sqrt(temp);
		for(int j=2; j<=p; j++) {
			if (temp%j == 0) {
				count++;
				break;
			}
		}
	}
	printf("%d\n", n-count);
	return 0;
}


Measured memory_bytes: 2684
import math
a, b, h, m = list(map(int, input().split()))

ji = (h * 60 + m) * 0.5
fun = m * 6
ka = abs(ji - fun)
if ka > 180:
    ka = 360 - ka

if ka == 90:
    cc = a ** 2 + b ** 2
else:
    cc = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ka))

c = math.sqrt(cc)

print(c)

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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << #x " = " << (x) << '\n'
#define DBG         cerr << "Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction
#define MAX     8001
vector<int>X,Y;
int dp[8010][16010];

int call(int pos, int need, vector<int>&X)
{
    if(pos == X.size())
    {
        if(need == 0)
            return true;
        else
            return false;
    }
    int &ret = dp[pos][need+MAX];
    if(ret != -1)
        return ret;
    return ret = max(call(pos+1, need-X[pos], X), call(pos+1, need+X[pos], X));
}

bool solve(int st)
{
    int x, y;
    sff(x,y);
    x -= st;
    mem(dp,-1);
    if(call(0,x,X))
    {
        mem(dp,-1);
        if(call(0,y,Y))
            return true;
    }
    return false;
}

int main()
{
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s;
    cin >> s;
    bool xDir = false;
    int cur = 0;
    int st;
    for(st = 0; st < s.size(); st++)
    {
        if(s[st] == 'T')
            break;
    }
    for(int i = st+1; i<s.size(); i++)
    {
        if(s[i] == 'T')
        {
            if(xDir == 0)
            {
                Y.pb(cur);
                xDir = 1;
                cur = 0;
            }
            else
            {
                X.pb(cur);
                xDir = 0;
                cur = 0;
            }
        }
        else
            cur++;
    }
    if(cur)
    {
        if(xDir)
            X.pb(cur);
        else
            Y.pb(cur);
    }
    if(solve(st))
        puts("Yes");
    else
        puts("No");
    return 0;
}




Measured memory_bytes: 501504
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1010
#define MAX_P 12
typedef vector<char> Vec;
typedef vector<Vec> Mat;
 
int dp[MAX][1<<MAX_P];
 
int get_dir(char ch)
{
    if (ch == 'L') return 0;
    if (ch == 'U') return 1;
    if (ch == 'R') return 2;
    return 3;
}
 
int main()
{
    int HPi, HPm;
    while (cin >> HPi >> HPm, HPi) {
        int H, W;
        cin >> H >> W;
        Mat a(H, Vec(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int T, d, dmg[26] = {}, S;
        char ch;
        cin >> T;        
        for (int i = 0; i < T; i++) {
            cin >> ch >> d;
            dmg[ch-'A'] = d;
        }
        cin >> S;
         
        char dir;
        int dist, x = 0, y = 0;
        vector<int> vec;
        const int dx[] = {-1, 0, 1, 0};
        const int dy[] = {0, -1, 0, 1};
         
        for (int i = 0; i < S; i++) {
            cin >> dir >> dist;
            int d = get_dir(dir);
            for (int j = 0; j < dist; j++) {
                x += dx[d]; y += dy[d];
                vec.push_back(dmg[a[y][x]-'A']);
            }
        }
 
        int P;
        cin >> P;
        vector<int> p(P);
        for (int i = 0; i < P; i++) {
            cin >> p[i];
        }
         
        memset(dp, -1, sizeof(dp));
        dp[0][0] = HPi;
         
        int N = vec.size();
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < (1<<P); j++) {
                if (dp[i][j] <= 0) continue;
                if (dp[i][j] - vec[i] > 0) {
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j] - vec[i]);
                }
                for (int k = 0; k < P; k++) {
                    if (j >> k & 1) continue;
                    dp[i][j|(1<<k)] = max(dp[i][j|(1<<k)], min(dp[i][j] + p[k], HPm));
                }
            }
        }
        bool reachable = 0;
        for (int i = 0; i < (1<<P); i++) {
            if (dp[N][i] > 0) {
                reachable = 1;
                break;
            }
        }
        cout << (reachable ? "YES" : "NO") << endl;
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >>C >>D;
  
  if (A+B>C+D){
    cout <<"Left";
  }
  else if (A+B==C+D){
    cout <<"Balanced";
  }
  else {
    cout <<"Right";
  }
}


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

int func(string s) {
	int sum = 0;
	for (auto u : s) sum += u - '0';
	return sum;
}

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

	int ans = 1e9;

	reps(i, 1, n) {
		string s1 = to_string(i);
		string s2 = to_string(n - i);
		// cout << s1 << " " << s2 << endl;
		int sum = func(s1) + func(s2);
		// printf("sum %d %d %d\n", sum, func(s1), func(s2));
		if (sum < ans) {
			ans = sum;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

std::map<ll,ll> prime(ll n)
{
    std::map<ll,ll> cnt;
    while(n%2==0)
    {
        cnt[2]++;
        n/=2;
    }
    for(ll i=3; i*i<=n; i++)
    {
        while(n%i==0)
        {
            cnt[i]++;
            n/=i;
        }
    }
    if(n>2) cnt[n]++;
    return cnt;
}

int main()
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0); std::cout.tie(0);
    //freopen("input.txt", "r", stdin);
    ll n;
    std::cin >> n;
    std::map<ll,ll> cnt = prime(n);
    ll ans = 0;
    for(auto p: cnt)
    {
        if(p.first==1) continue;
        ll c=0,pres=0,i=1;
        while(pres<p.second)
        {
            pres += i;
            i++;
            c++;
        }
        if(pres>p.second) ans--;
        ans += c;
    }
    std::cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3676
#!/usr/bin/env python3
#AGC18 B

import sys
import math
import copy
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(flag):
    global ans
    cnt = [0]*m
    for i in range(n):
        for j in range(m):
            if flag[a[i][j]-1]:
                cnt[a[i][j]-1] += 1
                break
        else:
            return
    flag[cnt.index(max(cnt))] = False
    ans = min(ans,max(cnt))
    f(flag)
n,m = LI()
a = [LI() for _ in range(n)]
flag = [True]*m
ans = inf
f(flag)
print(ans)

Measured memory_bytes: 43228
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    vector<int> a, b;
    int x = 1;
    while(1){
        ll y = (x * (x + 1) * (x + 2)) / 6;
        if(y > 1000000){
            break;
        }
        a.push_back(y);
        if(y % 2 == 1) b.push_back(y);
        x++;
    }
    vector<int> dp1(1000001, INF), dp2(1000001, INF);
    dp1[0] = 0;
    dp2[0] = 0;
    for(auto&& i : a){
        for(int j = 0; j <= 1000000 - i; j++){
            dp1[j + i] = min(dp1[j + i], dp1[j] + 1); 
        }
    }
    for(auto&& i : b){
        for(int j = 0; j <= 1000000 - i; j++){
            dp2[j + i] = min(dp2[j + i], dp2[j] + 1); 
        }
    }
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BTripleDots {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int K;
        cin >> K;
        string s;
        cin >> s;

        if (s.size() <= K) {
            cout << s << endl;
        } else {
            string sub = s.substr(0, K);
            sub += "...";
            cout << sub << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BTripleDots solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3644
'use strict'
const inArray = (needle, haystack) => haystack.some(item => item === needle)
const main = (input) => {
    const str = input.split('\n')[0].split('')
    if(inArray('a', str) && inArray('b', str) && inArray('c', str)){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
typedef pair<int,long long> pii; 
int main(){
    int n;
    cin >> n;
    map<int,vector<pii>> edge;
    int a,b;
    long long c;
    rep(i,n-1){
        cin >> a >> b >> c;
        edge[a].push_back(make_pair(b,c));
        edge[b].push_back(make_pair(a,c));
    }
    long long distance[n+1];
    int qq,k;
    cin >> qq >> k;
    distance[k]=0;
    queue<int> q;
    q.push(k);
    bool check[n+1];
    rep(i,n+1){
        check[i]=false;
    }
    check[k] = true;
    while(!q.empty()){
        int t = q.front();
        q.pop();
        for(int i = 0;i<edge[t].size();i++){
            if(!check[edge[t][i].first]){
                distance[edge[t][i].first] = distance[t]+edge[t][i].second;
                q.push(edge[t][i].first);
            } 
        }
        check[t]=true;
    }
    vector<long long> ans;
    int x,y;
    rep(i,qq){
        cin >> x >> y;
        ans.push_back(distance[x]+distance[y]);
    }
    rep(i,qq){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 16624
X,K,D=map(int,input().split())
if abs(X+D)>abs(X-D):
    if K<=abs(int(X/D)):
        print(abs(X-D*K))
    else:
        K-=abs(int(X/D))
        if K%2==0:
            print(abs(X-D*abs(int(X/D))))
        else:
            print(abs(X-D*(abs(int(X/D))+1)))
else:
    if K<=abs(int(X/D)):
        print(abs(X+D*K))
    else:
        K-=abs(int(X/D))
        if K%2==0:
            print(abs(X+D*abs(int(X/D))))
        else:
            print(abs(X+D*(abs(int(X/D))+1)))

Measured memory_bytes: 9196
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(len(A)):
    ans += B[A[i] - 1]
    if (i >= 1) & (A[i] == (A[i - 1] + 1)):
        ans += C[A[i - 1] - 1]
    else:
        ans = ans
print(ans)

Measured memory_bytes: 3064
n,m=[int(i) for i in input().split()]
li=[]
if n>=m:
    for i in range(n):
        li.append(m)
    for i in range(n):
        print(li[i],end="")
    print()

else:
    for i in range(m):
        li.append(n)
    for i in range(m):
        print(li[i],end="")
    print()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  string S; cin >> S;
  vector<int> cnt(26, 0);
  for(int i = 0; i < S.size(); i++){
    int tmp = S[i] - 'a';
    if(cnt[tmp] > 0){
      cout << "no" << endl;
      return 0;
    }
    cnt[tmp]++;
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
//#define M 1000000007
#define M 998244353
using namespace std;
const int inf=4e18;
const double pi=3.14159265358979;
int power(int x,int y)
{
	int res=1;
	x=x%M;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%M;
		y=y>>1;
		x=(x*x)%M;
	}
	return res;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,i;cin>>n;
	map<int,int> mp;set<int> s;
	for(i=0;i<n;i++)
	{
		int d;cin>>d;
		if(i==0&&d!=0)
		{
			cout<<0<<endl;
			return 0;
		}
		s.insert(d);
		mp[d]++;
	}
	if(mp[0]>1)
	{
		cout<<0<<endl;
		return 0;
	}
	i=0;
	int o=1,prev=1;
	for(auto it=s.begin();it!=s.end();it++)
	{
		if(*it!=i)
		{
			cout<<0<<endl;
			return 0;
		}
		o=(o*power(prev,mp[i]))%M;prev=mp[i];i++;
	}
	cout<<o<<endl;
}

Measured memory_bytes: 11264
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define MOD 10000000009

int main() {
ll i,j,n,m,b=0,c=0;
cin>>n;
vector <int> a;
for(i=0;i<n;i++){
    cin>>m;
    a.push_back(m);
}
sort(a.rbegin(),a.rend());
for(i=0;i<n;i+=2){
        b+=a[i];
}
for(i=1;i<n;i+=2){
        c+=a[i];
}
cout<<b-c;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
vector< ll > adj[N];
ll n,k,ans[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)ans[i]=-N;
    for(ll i=1,u,v;i<=n-1;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);
    priority_queue< pair<ll,ll> >pq;
    cin>>k;
    for(ll i=0,u,w;i<k;i++)cin>>u>>w,ans[u]=w,pq.push({w,u});
    while(!pq.empty()){
        ll w=pq.top().first,u=pq.top().second;
        pq.pop();
        for(auto &v:adj[u]){
            if(ans[v]==ans[u]+1 || ans[v]==ans[u]-1)continue;
            if(ans[v]!=-N)return cout<<"No" , 0;
            ans[v]=ans[u]-1;
            pq.push({ans[v],v});
        }
    }
    cout<<"Yes\n";
    for(ll i=1;i<=n;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 9460
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int R;
	cin>>R;

	cout<<(double)R*2* 3.141592653589793<<endl;
}

Measured memory_bytes: 3780
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
string S, T;
  int ans=0;
cin >> S >> T;
for(int i = 0; i < S.size(); i++){
  
if (S.at(i) == T.at(i)){
  ans += 1;
}
}
  if (ans == S.size()){
    cout << "Yes" << endl;
  }else {
  cout << "No" << endl;
  }
  

}


Measured memory_bytes: 3632
#include <unistd.h>
#include <stdio.h>

int main()
{
        char buf[4] = {0};
        int N = 0;

        int len = 0;
        int rank = 1;

        read(0, buf, 4);

        for (int i = 1; i < 4; i++) {
                if (buf[i] != 0) {
                        len++;
                }
        }

        for (int i = len; i > 0; i--) {
                N += (int)((buf[i-1] - 0x30) * rank);
                rank = rank * 10;
        }

        for (int i = 1; i < 10; i++) {
                for (int j = 1; j < 10; j++) {
                        if (N == (i * j)) {
                                write(1, "Yes\n", 4);
                                return 0;
                        }
                }
        }

        write(1, "No\n", 3);

        return 0;
}

Measured memory_bytes: 128
<?php
  fscanf(STDIN, "%d", $d);

  for($i = 0; $i < $d; $i++) {
$aa = fgets(STDIN);
$a = explode(' ', $aa);

foreach ($a as &$value) {
    $value = (int) $value;
}
unset($value);
    
    //echo max($a);
    $key =  array_keys($a, max($a));
    echo (1 + (int) $key[0]).PHP_EOL;
    unset($a);
    unset($aa);
  }

Measured memory_bytes: 16260
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl b(n);
    rep(i, n) {
        cin >> b[i];
    }

    vl ans;
    rep(loop, n) {
        ll cnt = 1;
        ll pos = -1;
        rep(i, b.size()) {
            if(cnt == b[i]) {
                pos = i;
            }
            cnt++;
        }
        if(pos == -1) {
            out(-1);
            re0;
        }
        ans.pb(b[pos]);
        b.erase(b.begin() + pos);
    }

    reverse(all(ans));

    for(auto p : ans) {
        out(p);
    }
    
    re0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
d = {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1, 4:2, 6:2, 9:2, 11:2, 2:3}
print("Yes" if d[x] == d[y] else "No")  

Measured memory_bytes: 3060
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x: x[0])
k_ = 0
for a_, b_ in ab:
    k_ += b_
    if k_ >= k:
        print(a_)
        exit()

Measured memory_bytes: 29912
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] == 0:
                for j in range(i * 2, self.max_num, i):
                    if self.prime[j] == 0:
                        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: 16196
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        
        Arrays.sort(s);
        Arrays.sort(t);
        
        
        for(int i=0; i<Math.min(s.length,t.length); i++){
            if(s[i]<t[t.length-i-1]){
                System.out.println("Yes");
                return;
            }else if(s[i]==t[t.length-i-1]){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        
        if(s.length<t.length){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        
        
        
        
          
        }
    }

Measured memory_bytes: 35648
#include <iostream>
using namespace std;
#define N_MAX 200000 
int A[N_MAX]={0}, Rmax[N_MAX+1]={0},Lmax[N_MAX+2]={0};
int main(){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++)cin>>A[i];
  
  //Rmax[n]:max in A[1]~A[n] 
  for(int i=1;i<=N;i++)Rmax[i]=max(Rmax[i-1],A[i]);
  //Lmax[n]:max in A[n]~A[N]
  for(int i=N;i>0;i--)Lmax[i]=max(Lmax[i+1],A[i]);
  
  for(int i=1;i<=N;i++)cout << max(Rmax[i-1],Lmax[i+1]) << endl;
  return 0;
}

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

int main(){
    int N,X;
    cin>>N>>X;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin>>L.at(i);
    }

    int count=1,D=0;
    for(int i=0;i<N;i++){
        D+=L.at(i);
        if(D<=X) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 384
R, C, K = map(int,input().split())
V = [[]for i in range(R)]
for i in range(K):
    r,c,v = map(int,input().split())
    V[r-1].append([c,v])
cost = [0]*(C+1)
for r in range(R):
    V[r].sort()
    hoge = [0,0,0,0]
    for c,v in V[r]:
        for i in range(3,0,-1):
            hoge[i] = max(cost[c]+v,hoge[i-1]+v,hoge[i])
        hoge[0] = cost[c]
        cost[c] = max(hoge)
    for i in range(1,C+1):
        cost[i] = max(cost[i],cost[i-1])

print(cost[-1]) 

Measured memory_bytes: 100392
list :: [Int]
list =
  [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

main = do
  k <- readLn :: IO Int
  print $ list !! (k - 1)


Measured memory_bytes: 508
k = int(input())
if k < 10:
    print(k)
    exit()
l = list(range(1, 10))
for i in l:
    for j in range(max(i % 10 - 1, 0), min(i % 10 + 2, 10)):
        l += [i * 10 + j]
    if len(l) > k:
        break
print(l[k - 1])

Measured memory_bytes: 7320
import queue
N,M=map(int,input().split())
s=[[]for i in range(N)]
for i in range(M):
    L,R,D=map(int,input().split())
    s[L-1].append((R-1,D))
    s[R-1].append((L-1,-D))

q=queue.Queue()
dist=[None]*N

for i in range(N):
    if dist[i]==None:
        dist[i]=0
        q.put(i)
    while not q.empty():
        From=q.get()
        for l in s[From]:
            To,w=l
            if dist[To]==None:
                dist[To]=dist[From]+w
                q.put(To)
            else:
                if dist[To]!=dist[From]+w:
                    print("No")
                    exit()
print("Yes")

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> s >> k;
    set<string> set;
    REP(len, 1, min((ll) s.size(), 5ll) + 1) {
        REP(idx, 0, s.size() - len + 1) {
            string substr = s.substr(idx, len);
            set.insert(s.substr(idx, len));
        }
    }

    for (auto itr = set.begin(); itr != set.end(); ++itr) {
        auto dist = distance(set.begin(), itr);
        if (dist == k - 1) {
            END(*itr)
        }
    }
}


Measured memory_bytes: 1664
program main
  implicit none
  integer*8 N,D
  integer*8,allocatable::P(:,:)
  integer i,ans
  
  read(*,*)N,D
  allocate(P(2,N))
  read(*,*)P
  
  ans = 0
  do i=1,N
    if(P(1,i)*P(1,i)+P(2,i)*P(2,i) <= D*D) then
      ans = ans+1
    end if
  end do
  
  write(*,*) ans
end program main

Measured memory_bytes: 6208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ld a, b, x; cin >> a >> b >> x;
    if(2 * x >= a * a * b){
        ld ans = (ld)atan(2.0L*(a*a*b - x) / (a*a*a));
        ans *= 180.0L / PI;
        cout << fixed << setprecision(15) << ans << endl;
    }
    else {
        ld ans = (ld)atan(a*b*b/(2.0L*x));
        ans *= 180.0L / PI;
        cout << fixed << setprecision(15) << ans << endl;
    }


}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"text/scanner"
	"unicode/utf8"
)

var sin scanner.Scanner
var ans int

func scan() string {
	tok := sin.Scan()
	if tok == scanner.EOF {
		return ""
	}
	return sin.TokenText()
}

func main() {
	sin.Init(os.Stdin)
	s := scan()

	a := 0
	b := 0

	//fmt.Printf(s)

	for i := 0; i < utf8.RuneCountInString(s); i++ {

		switch s[i : i+1] {
		case "A":
			b++
		case "T":
			b++
		case "C":
			b++
		case "G":
			b++
		default:
			if a < b {
				a = b
				b = 0
			}
		}
		//fmt.Printf("%d\n", b)

	}

	if a < b {
		a = b
	}

	fmt.Printf("%d\n", a)

}


Measured memory_bytes: 640
import sys
nmlist = list(map(int,input().split(" ")))
N = nmlist[0]
M = nmlist[1]

moves = []
for i in range(M):
    moves.append(list(map(int,input().split(" "))))

box = [[1,0] for i in range(N)]
box[0][1] = 1

for i in range(M):
    before = moves[i][0] - 1
    after = moves[i][1] - 1
    if box[before][0] != 0:
        box[before][0] -= 1
        if box[before][1] == 1:
            box[after][1] = 1
        if box[before][0] == 0:
            box[before][1] = 0
        box[after][0] += 1

output = 0
for i in range(N):
    output += box[i][1]

print(output)

Measured memory_bytes: 34632
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<double > x(N);
  std::vector<std::string > u(N);
  double ans = 0.0;
  for (int i=0; i<N; i++) {
    std::cin >> x[i] >> u[i];
    if (u[i]=="JPY") {
      ans += x[i];
    } else {
      ans += x[i]*380000.0;
    }
    //printf("%.12lf\n", ans);
  }
  printf("%.12lf\n", ans);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(2, -1));

  dp[0][0] = 0;
  dp[0][1] = -1e18;
  rep(i, n) {
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
  }
  cout << dp[n][0] << endl;
  // rep(i, n) cerr << dp[i][0] << " " << dp[i][1] << endl;
  return 0;
}


Measured memory_bytes: 8996
#include <iostream>

using namespace std;
 
#define MAX 10
 
void res(int);
 
int main()
{
    int n, num;
 
    while (cin >> n, n) {
	int ice[MAX] = {0};
	for (int i = 0; i < n; i++) {
	    cin >> num;
	    ice[num]++;
	}
	for (int i = 0; i < MAX; i++) {
            res(ice[i]);
        }
    }
    return 0;
}
 
void res(int n)
{
    if (n == 0) {
        cout << '-' << endl;
    } else {
	while (n > 0) {
	    cout << '*';
	    n--;
	}
	cout << endl;
    }
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll N, A, B;
  cin >> N;
  cin >> A;
  cin >> B;

  ll ans;

  if ( ((B-A) % 2) == 0 ) {
    ans = (B-A)/2;
  }
  else {
    ll a_to_1, a_to_n, b_to_1, b_to_n;
    a_to_1 = A - 1;
    a_to_n = N - A;

    b_to_1 = B - 1;
    b_to_n = N - B;

    ll min_ = min(min(min(a_to_1, a_to_n), b_to_1), b_to_n);

    if (min_ == a_to_1) {
      ans = 0;
      ans += a_to_1;
      ans += 1; // now, b is (B - (a_to_1 + 1))
      ans += ((B - A - 1) / 2);
    }
    else if (min_ == b_to_n) {
      ans = 0;
      ans += b_to_n;
      ans += 1; // now, b is (B - (a_to_1 + 1))
      ans += (B - A - 1) / 2;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int N, ans = 0, i, j;
  cin >> N;
  int a[N];
  for(i=0; i<N; i++){
    cin >> a[i];
  }
  
  for(i=0; i<N; i++){
    for(j=i; j<N; j++){
      if (j != i) ans += a[i] * a[j];
    }
  }
  
  cout << ans << endl;
  
 return 0; 
}

Measured memory_bytes: 384
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    if it
        .next()
        .unwrap()
        .chars()
        .any(|c| c.to_digit(10).unwrap() == 7)
    {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2080
#include <iostream>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,y;
  cin >> n >> y;
  int s = n*1000;
  rep(i,n+1){
    rep(j,n+1-i){
      if(s + i*4000 + j*9000 == y){
        cout << j << " " << i << " " << n-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 256
int main(void)
{
	int mountain[10];
	int tmp = 0;
	int i,j;
	
	for(i = 0;i < 10;i++){
		scanf("%d",&mountain[i]);
	}
	
	for(i = 0;i < 9;i++){
		for(j = 0;j < 9;j++){
			if(mountain[j] < mountain[j+1]){
				tmp = mountain[j];
				mountain[j] = mountain[j+1];
				mountain[j+1] = tmp;
			}
		}
	}
	
	for(i = 0;i < 3;i++){
		printf("%d\n",mountain[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    string s;
    cin>>s;
    cout<<s.at(0)<<s.at(1)<<s.at(2)<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(void) {
	int a, b, i, j, c[5], temp, cnt = 0;
	
	scanf("%d %d", &a, &b);
	
	for (i = a; i <= b; i++) {
		temp = i;
		for (j = 4; j >= 0; j--) {
			c[j] = temp / (int)pow(10, j);
			temp = temp % (int)pow(10, j);
		}
		if (c[0] == c[4] && c[1] == c[3])
			cnt++;
	}
	
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>

using namespace std;

int main() {
    map<int, long long> m;

    for(int i = 1; i <= 100000; i++) {
        m.insert(make_pair(i, 0));
    }

    int N;
    cin >> N;

    long long ans = 0;

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

    int Q;
    cin >> Q;

    for(int i = 0; i < Q; i++) {
        int B, C;
        cin >> B >> C;
        if(m[B] > 0) {
            ans += (C - B) * m[B];
            m[C] += m[B];
            m[B] = 0;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;main(){int N;cin>>N;int A[N],B[N],c[N+1]={};rep(i,N)cin>>A[i];rep(i,N)cin>>B[i];rep(i,N)c[A[i]]++,c[B[i]]++;if(*max_element(c,c+N+1)>N)printf("No");else{printf("Yes\n");queue<int> s;rep(i,N)if(A[i]==B[i])s.push(i);while(!s.empty()){int n=s.front(),t=rand()%N;s.pop();if(A[n]!=B[t]&&A[t]!=B[n])swap(B[n],B[t]);else s.push(n);}rep(i,N)cout<<B[i]<<" ";}}

Measured memory_bytes: 6756
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();

        int result = 10;
        if (x < a) result = 0;
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#include <stack>
#include <bitset>
#include <map>

using namespace std;

int solve();

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

int solve() {

	const int arsize = 100000 + 1;
	long long N, K;
	vector<long long> arr(arsize, 0);

	cin >> N >> K;
	K--;

	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		arr[a] += b;
	}

	long long cnt = 0;

	for (int i = 0; i < arsize;i++) {
		if (cnt <= K && K < cnt + arr[i]) {
			cout << i << endl;
			break;
		}
		cnt += arr[i];
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//



//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n ;
  ll ans = 0 ;
  ll mans ;
  vector<int> a(n) ;
  vector<int> b(n) ;
  REP(i,n){
    cin >> a.at(i) >>b.at(i) ;
  }
  reverse(ALL(a)) ;
  reverse(ALL(b)) ;
  
  REP(i,n){
    mans = ans%b.at(i) ;
    a.at(i) = (a.at(i)+mans)%b.at(i) ;
    if(a.at(i)%b.at(i)!=0){
      ans += b.at(i)-a.at(i)%b.at(i) ;
    }
  }
  
  cout <<ans <<endl ;
    
  
  
  
  return 0 ;
}

Measured memory_bytes: 1152
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

#N,T = list(map(int, input().split()))
N = int(input())

def nrof_divided_by(n, d):
    return n//d

def ndiv_list(n, d):
    l = []
    for i in range(n):
        _d = d**(i+1)
        if _d > n:
            break
        l.append(n//_d)
    return l
    
nrof_factor10 = ndiv_list(N//2,10)
nrof_factor5 = ndiv_list(N//2,5)
nrof_factor2 = ndiv_list(N//2,2)

if N % 2 == 1:
    print(0)
else:
    print(sum(nrof_factor5))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<62;
const ll MOD=1000000007;

vector<vector<ll>> G(100007, vector<ll>(0));

void dfs(ll x,vl &d){
    for(auto p: G[x]){
        if(d[p]==-1){
            d[p]=d[x]+1;
            dfs(p,d);
        }
    }
}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N-1,0);
    vector<ll> B(N-1,0);
    for(ll i=0;i<N-1;++i){cin>>A[i]>>B[i];A[i]--;B[i]--;}
    for(ll i=0;i<N-1;++i){
        G[A[i]].emplace_back(B[i]);
        G[B[i]].emplace_back(A[i]);
    }
    vector<ll> d1(N,-1);
    vector<ll> dN(N,-1);
    d1[0]=0;dN[N-1]=0;
    dfs(0,d1);dfs(N-1,dN);
    ll F=0,S=0;
    for(ll i=0;i<N;++i){
        if(d1[i]<=dN[i])F++;
        else S++;
    }
    if(F>S)prt("Fennec")
    else prt("Snuke")

    return 0;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int H, W, A, B;

  void init() {
    cin >> H >> W >> A >> B;
  }

  void solve() {
    rep(i, H-B) {
      rep(j, W-A) cout << 1;
      rep(j, A) cout << 0;
      cout << "\n";
    }
    rep(i, B) {
      rep(j, W-A) cout << 0;
      rep(j, A) cout << 1;
      cout << "\n";
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1280