akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n,a,b;
  cin >> n >> a >>b;
  cout << min(n*a,b) << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3628
#include<stdio.h>

#define IMF 1000000000

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

  char s[51][51];
  int count = 0;
  
  for(int i = 0;i < h;i ++){
    scanf("%s",s[i]);
  }
  
  int rute[51][51] = {0};
  for(int i = 0;i < h;i ++){
    for(int j = 0;j < w;j ++){
      if(s[i][j] == '.'){
        rute[i][j] = IMF;
      }
      else{
        rute[i][j] = -1;
        count ++;
      }
    }
  }

  rute[0][0] = 1;
  int flag = 1;
  while(flag == 1){
    flag = 0;
    for(int i = 0;i < h;i ++){
      for(int j = 0;j < w;j ++){
        if(rute[i][j] != -1){
          if(i+1 < h && rute[i][j] + 1 < rute[i+1][j]){
          rute[i+1][j] = rute[i][j] + 1;
          flag = 1;
        }
        if(0 <= i-1 && rute[i][j] + 1 < rute[i-1][j]){
          rute[i-1][j] = rute[i][j] + 1;
          flag = 1;
        }
        if(j+1 < w && rute[i][j] + 1 < rute[i][j+1]){
          rute[i][j+1] = rute[i][j] + 1;
          flag = 1;
        }
        if(0 <= j-1 && rute[i][j] + 1 < rute[i][j-1]){
          rute[i][j-1] = rute[i][j] + 1;
          flag = 1;
        }
        }
      }
    }
  }
  
  int ans = h*w - (count + rute[h-1][w-1]);

  if(rute[h-1][w-1] == -1 || rute[h-1][w-1] == IMF){
    printf("%d\n",-1);
  }
  
  else{
    printf("%d\n",ans);
  }

  return 0;
  
}

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

#define F first
#define S second
using L = long long;
using P = pair<L, L>;
using T = pair<pair<L, L>, L>;

int n, m, k;
vector<T> zx, zy;
vector<P> g[400010];
L dist[400010]; 

int main()
{
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++){
    L x, y;
    cin >> x >> y;
    zx.emplace_back(P(x, y), i + 1);
    zy.emplace_back(P(y, x), i + k + 1);
    g[i + 1].emplace_back(i + k + 1, 1);
    g[i + k + 1].emplace_back(i + 1, 1);
  }
  zx.emplace_back(P(1, 1), 0);
  zx.emplace_back(P(n, m), k * 2 + 1);
  zy.emplace_back(P(m, n), k * 2 + 2);
  auto connect = [&](vector<T> &z){
    sort(begin(z), end(z));
    for (int i = 0; i + 1 < z.size(); i++){
      if (z[i].F.F != z[i + 1].F.F) continue;
      int d = z[i + 1].F.S - z[i].F.S;
      int s = z[i].S, t = z[i + 1].S;
      g[s].emplace_back(t, d);
      g[t].emplace_back(s, d);
    }
  };
  connect(zx);
  connect(zy);
  
  priority_queue<P, vector<P>, greater<P>> pq;
  fill_n(dist, 400010, 1e18);
  dist[0] = 0;
  pq.emplace(0, 0);
  while (pq.size()){
    P c = pq.top(); pq.pop();
    if (dist[c.S] < c.F) continue;
    for (P e : g[c.S]){
      if (dist[e.F] > c.F + e.S){
        dist[e.F] = c.F + e.S;
        pq.emplace(c.F + e.S, e.F);
      }
    }
  }
  
  L res = min(dist[k * 2 + 1], dist[k * 2 + 2]);
  if (res == L(1e18)) res = -1;
  
  cout << res << endl;
}

Measured memory_bytes: 58800
#include <iostream> 

using namespace std;

static const int INF = 1000000000;

int dp[41][401][401];
int a[40];
int b[40];
int c[40];
int N, Ma, Mb;

int main(int argc, char *argv[]) {
	cin >> N >> Ma >> Mb;

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

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				dp[i][j][k] = INF;
			}
		}
	}
	dp[0][0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 390; j++) {
			for (int k = 0; k <= 390; k++) {
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
			}
		}
	}

	int ans = INF;
	for (int i = 1; i <= 390; i++) {
		for (int j = 1; j <= 390; j++) {
			if (i * Mb == j * Ma)
				ans = min(ans, dp[N][i][j]);
		}
	}

	if (ans != INF) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 25984
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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 (b<a) { a = b; return 1; } return 0; }

bool f_x(int x){
    int cp=x, s=0;
    while(x){
        s += x%10;
        x /= 10;
    }
    if(cp%s)return 0;
    return 1;
}

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

    lint n;
    cin>>n;
    Yes(f_x(n));
}

Measured memory_bytes: 256
N = int(input())
S = input()

col_lis = [0 if c == "R" else 1 if c == "G" else 2 for c in S]

ans = 0

r_count = 0
g_count = 0
b_count = 0

color_table = []

for color in col_lis:
    if color == 0:
        r_count += 1
    elif color == 1:
        g_count += 1
    else:
        b_count += 1
    color_table.append([r_count, g_count, b_count])

ans = 0

for center in range(1, N - 1):
    for right in range(center + 1, N):
        if col_lis[right] == col_lis[center]:
            continue
        left = 3 - col_lis[right] - col_lis[center]
        ans += color_table[center - 1][left]
        if center * 2 - right >= 0 and col_lis[center * 2 - right] == left:
            ans -= 1


print(ans)


Measured memory_bytes: 68924
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop


N = int(input())

if N % 2 == 0:
  ans = 0.5
else:
  ans = (N + 1) / 2.0 / N
  
print(ans)

Measured memory_bytes: 15272
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int main() {
    int n,i,x;
    int a,b,c;
    a = b = c = 0;
    scanf("%d",&n);
    for(i = 0;i < n; i++) {
        scanf("%d",&x);
        if(x % 4 == 0) a++;
        else if(x % 2 == 0) b++;
        else c++;
    }
    if(a >= n / 2 || a >= c) puts("Yes\n");
    else puts("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

const int INF = 123;
int d[100][100][4][11];

struct State{
    int y,x,dir,p;
};

int main(){
    int h,w,a;
    cin >>h >>w >>a;
    vector<string> s(h);
    rep(i,h) cin >>s[i];

    pair<int,int> start,goal;
    rep(i,h)rep(j,w){
        if(s[i][j] == 'S') start = {i,j};
        if(s[i][j] == 'G') goal = {i,j};
    }

    auto ok = [&](int y, int x){
        return (0<=y && y<h && 0<=x && x<w && s[y][x]!='#');
    };

    rep(i,100)rep(j,100)rep(k,4)rep(l,11) d[i][j][k][l] = INF;

    queue<State> que;
    if(ok(start.fi+1, start.se)){
        d[start.fi+1][start.se][3][0] = 0;
        que.push({start.fi+1, start.se, 3, 0});
    }

    while(!que.empty()){
        State c = que.front();
        que.pop();

        // printf("( %d %d %d %d)\n", c.y,c.x,c.dir,c.p);

        int D = d[c.y][c.x][c.dir][c.p];
        State t;

        // 鏡を使わず直進
        t = c;
        t.y += dy[t.dir];
        t.x += dx[t.dir];
        if(ok(t.y,t.x) && d[t.y][t.x][t.dir][t.p] > D){
            if(!(t.y==start.fi && t.x==start.se && t.dir==1)){
                d[t.y][t.x][t.dir][t.p] = D;
                que.push(t);
            }
        }

        // type-P mirror
        if(t.p<a && s[c.y][c.x]=='.'){
            t = c;
            t.dir = 3-t.dir;
            t.y += dy[t.dir];
            t.x += dx[t.dir];
            ++t.p;
            if(ok(t.y,t.x) && d[t.y][t.x][t.dir][t.p] > D){
                if(!(t.y==start.fi && t.x==start.se && t.dir==1)){
                    d[t.y][t.x][t.dir][t.p] = D;
                    que.push(t);
                }
            }
        }

        // type-Q mirror
        if(D<a && s[c.y][c.x]=='.'){
            t = c;
            t.dir ^= 1;
            t.y += dy[t.dir];
            t.x += dx[t.dir];
            if(ok(t.y,t.x) && d[t.y][t.x][t.dir][t.p] > D+1){
                if(!(t.y==start.fi && t.x==start.se && t.dir==1)){
                    d[t.y][t.x][t.dir][t.p] = D+1;
                    que.push(t);
                }
            }
        }
    }

    int ans = INF;
    rep(i,4)rep(j,a+1) ans = min(ans, d[goal.fi][goal.se][i][j]+j);
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4976
object Main extends App {
	val N = scala.io.StdIn.readInt

	if(N == 0){
		println(2)
	}else if(N == 1){
		println(1)
	}else{
		val a = new Array[Long](N+1)
		a(0) = 2L
		a(1) = 1L

		for(i<-2 to N){
			a(i) = a(i-1) + a(i-2)
		}
		println(a(N))
	}

}


Measured memory_bytes: 25408
#include <iostream>
using namespace std;
#define ABS(X) ((X)<0?-(X):(X))

int main(void){
  int n,ans;
  int t1=0,x1=0,y1=0;
  int t2,x2,y2,d;
  
  cin >> n; ans=1;
  for (int i=0; i<n; i++){
    cin >> t2 >> x2 >> y2;
    d = ABS(x2-x1) + ABS(y2-y1);
    //cout << t2-t1 << " " << d << endl;
    if (d>t2-t1 || (t2-t1-d)%2==1) ans=0;
    t1=t2; x1=x2; y1=y2;
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define endl "\n"
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow...question galat mat padhna */
{
    fast;   
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}      

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:30:06 2020

@author: divyarth
"""

import sys
import heapq
import math

#sys.setrecursionlimit(100000)
#input=sys.stdin.readline
#print=sys.stdout.write

from collections import deque
from collections import defaultdict
from collections import Counter

modH=int(10**9)+7
I=lambda : list(map(int,input().split(' ')))
def PRINT(lst,sep=' '): print(sep.join(map(str,lst)))


'''
s=input()
stack=[]
mm=0
for i in range(len(s)):
    if s[i]=='R':
        stack.append('R')
    else:
        cnt=0
        while len(stack):
            stack.pop()
            cnt+=1
        mm=max(mm,cnt)        
cnt=0
while len(stack):
    stack.pop()
    cnt+=1
mm=max(mm,cnt)
print(mm)

    
'''
n=int(input())
lst=I()

if len(lst)<=2:
    print(0)
else:
    ans=0
    for i in range(len(lst)-2):
        for j in range(i+1,len(lst)-1):
            for k in range(j+1,len(lst)):
                a,b,c=sorted([lst[i],lst[j],lst[k]])
                if c<b+a and a!=b and b!=c and c!=a:
                    ans+=1
    print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), xx(n);
  rep(i, n) cin >> x[i];
  xx = x;
  sort(xx.begin(), xx.end());
  rep(i, n) {
    if (x[i] <= xx[n / 2 - 1]) {
      cout << xx[n / 2] << endl;
    } else {
      cout << xx[n / 2 - 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
import math
a = int(input())
x = []
y = []
temp = 0

for i in range(a):
	e = list(map(int, input().split(" ")))
	x.append(e[0])
	y.append(e[1])

# print(x, y)
for i in range(len(x)):
	tempx = x[i]
	tempy = y[i]
	xm = x
	ym = y
	del xm[i]
	del ym[i]
	# print(xm, ym)

	for j in range(len(xm)):
		temp += math.sqrt((xm[j] - tempx) ** 2 + (ym[j] - tempy) ** 2)

	x.insert(i, tempx)
	y.insert(i, tempy)
	# print(x, y)
print(temp/a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N   = reader.nextInt();
        int[] H = new int[N];

        for (int i=0; i<N; i++) {
            H[i] = reader.nextInt();
        }

        int max = 0;
        int tmp = 0;
        for (int i=0; i<N-1; i++) {
            if (H[i] < H[i+1]) {
                max = Math.max(max, tmp);
                tmp = 0;
            } else {
                tmp++;
            }
        }
        max = Math.max(max, tmp);
        
        System.out.println(max);
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 23704
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) - 1 for _ in range(D)]

S = 0
last = [-1] * 26
score = 0
for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    score += max(10 ** 6 + S, 0)
    print(S)


Measured memory_bytes: 9332
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, K, Q int

func main() {
	sc.Split(bufio.ScanWords)

	N, K, Q = nextInt(), nextInt(), nextInt()

	P := make([]int, N+1)

	var A int
	for i := 0; i < Q; i++ {
		A = nextInt()
		P[A]++
	}

	//fmt.Println(P)

	for i := 1; i <= N; i++ {

		if K-Q+P[i] > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 3968
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n;
    static int new_ok[100010];
    static int a[100010], b[100010];
    scanf("%d", &n);
    rep (i, n)
	scanf("%d%d", a + i, b + i);
    rep (i, n)
    {
	++new_ok[min(b[i], n + 1)];
	--new_ok[min(a[i] - 1, n + 1)];
    }
    ++new_ok[n + 1];

    int res = -3, ok = 0;
    for (int i = n + 1; i > 0; --i)
    {
	if (new_ok[i])
	    ok += new_ok[i];
	if (ok >= i)
	{
	    res = i - 1;
	    break;
	}
    }
    printf("%d\n", res);
}

Measured memory_bytes: 0
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>
#include<math.h>

using namespace std;
#define rep(i, n) for ( int i = 0; i < ( int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < ( int)(n); i++)

int main() {
	string s;
	int w;
	cin >> s >> w;
	int n = s.size();
	rep(i, n) {
		if (i % w == 0) cout << s[i];
	}
	cout << endl;
	return 0;

}//mita

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 sum=0LL,a;
    for(i64 i=0LL;i<5LL;++i){
        scanf("%lli",&a);
        sum+=a<40LL?40LL:a;
    }
    printf("%lli\n",sum/5);
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> tonari[100010];
void solve(int ca){
    ll X; cin>>X;
    for (ll i = 0; i < 300; ++i) {
        for (ll j = i; j < 300; ++j) {
            if(pow(i,5ll)-pow(j,5ll)==X){
                cout<<i<<" "<<j<<endl;
                return;
            }
            if(pow(-i,5ll)-pow(j,5ll)==X){
                cout<<-i<<" "<<j<<endl;
                return;
            }
            if(pow(i,5ll)-pow(-j,5ll)==X){
                cout<<i<<" "<<-j<<endl;
                return;
            }
            if(pow(-i,5ll)-pow(-j,5ll)==X){
                cout<<-i<<" "<<-j<<endl;
                return;
            }
        }
    }
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   int n;cin>>n;
   vector<int> v;
   rep(i,n){
      int a;cin>>a;
      v.push_back(a);
   }
   ll ans=INF;
   FOR(i,-100,100){
      ll t=0;
      rep(j,n){
         t+=(v[j]-i)*(v[j]-i);
      }
      ans=min(ans,t);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3604
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);

  auto g = GraphM!int(n).init;
  foreach (_; 0..m) {
    int a, b, c; readV(a, b, c); --a; --b;
    g[a][b] = g[b][a] = c;
  }

  auto d = g.floydWarshal, ans = 0;

  foreach (i; 0..n)
    foreach (j; i+1..n)
      if (g[i][j] < g.inf && g[i][j] > d[i][j]) ++ans;

  writeln(ans);
}

struct GraphM(W = int, W i = 10^^9)
{
  alias Wt = W, inf = i;
  int n;
  Wt[][] g;
  alias g this;
  this(int n) { this.n = n; g = new Wt[][](n, n); }
  ref auto init() { foreach (i; 0..n) { g[i][] = inf; g[i][i] = 0; } return this; }
}

template FloydWarshal(Graph)
{
  import std.algorithm, std.array, std.traits;
  alias Wt = TemplateArgsOf!Graph[0];

  Wt[][] floydWarshal(ref Graph g)
  {
    Wt[][] dist;
    int[][] inter;
    floydWarshal(g, dist, inter);
    return dist;
  }

  void floydWarshal(ref Graph g, out Wt[][] dist, out int[][] inter)
  {
    auto n = g.n, sent = n;
    dist = g.g.map!(i => i.dup).array;

    inter = new int[][](n, n);
    foreach (i; 0..n) inter[i][] = sent;

    foreach (k; 0..n)
      foreach (i; 0..n)
        foreach (j; 0..n)
          if (dist[i][j] > dist[i][k] + dist[k][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
            inter[i][j] = k;
          }
  }
}
auto floydWarshal(G)(G g) { return FloydWarshal!(typeof(g)).floydWarshal(g); }


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

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
def hoge(n):
    nx = max(0, x-n)
    ny = max(0, y-n)
    return 2*n*c + nx*a+ny*b

ans = 10**10

for i in range(3*10**5):
    ans = min(ans, hoge(i))

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int N,X,Y,cnt[2222]={};

int main() {
	cin>>N>>X>>Y;
	for(int i=1;i<N;i++)for(int j=i+1;j<=N;j++){
		if(j<=X||Y<=i)cnt[j-i]++;
		else cnt[min(abs(X-i)+abs(Y-j)+1,j-i)]++;
	}
	for(int i=1;i<N;i++)cout<<cnt[i]<<endl;
	return 0;
}



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

int a[4];
int c[8];
int k;

int calc(){
	int op = c[k++];
	int ret = 0;
	if(op >= 0){
		ret = op;
	}
	else if(op >= -3){
		int x = calc();
		int y = calc();
		if(op == -1){
			ret = x + y;
		}
		else if(op == -2){
			ret = x - y;
		}
		else{
			ret = x * y;
		}
	}
	else{
		throw 0;
	}
	return ret;
}

void print(){
	int op = c[k++];
	if(op >= 0){
		printf("%d", op);
	}
	else{
		char ch;
		if(op == -1){ ch = '+'; }
		else if(op == -2){ ch = '-'; }
		else{ ch = '*'; }

		putchar('(');
		print();
		printf(" %c ", ch);
		print();
		putchar(')');
	}
}

void solve(int i, int S, int oprem){
	if(i == 7){
		try{
			if(S == 0){
				k = 0;
				if(calc() == 10 && k == 7){
					k = 0;
					print();
					puts("");
					throw "";
				}
			}
		}catch(int){}
		return;
	}

	if(oprem > 0){
		for(int op = -1; op >= -3; --op){
			c[i] = op;
			solve(i + 1, S, oprem - 1);
		}
	}
	for(int j = 0; j < 4; ++j){
		if(S >> j & 1){
			c[i] = a[j];
			solve(i + 1, S ^ 1 << j, oprem);
		}
	}
}

int main(){
	while(1){
		for(int i = 0; i < 8; ++i){
			c[i] = -9;
		}
		for(int i = 0; i < 4; ++i){
			scanf("%d", &a[i]);
		}
		if(a[0] == 0){ break; }
		try{
			solve(0, 15, 3);
			puts("0");
		}catch(...){}
	}
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> arr(n);
    for (auto &x : arr) cin >> x;
    int dp[n][n];
    for (int i = 0; i < n; ++i) dp[i][i] = arr[i];
    for (int d = 1; d < n; ++d)
        for (int i = 0, j = d; j < n; ++i, ++j)
            dp[i][j] = max(arr[i] - dp[i+1][j], arr[j] - dp[i][j-1]);
    cout << dp[0][n-1] << '\n';
    return 0;
}

Measured memory_bytes: 70400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ll x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    rep(i,0, a) cin>>p[i];
    rep(i,0, b) cin>>q[i];
    rep(i,0,c) cin>>r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    priority_queue <ll, vector<ll>, greater<ll> > que;
    ll ans=0;
    rep(i, 0,x) {
        que.push(p[i]);
        ans+=p[i];
    }
 
    rep(i, 0,y) {
        que.push(q[i]);
        ans+=q[i];
    }
    rep(i, 0,c){
        ll s=que.top();
        if(r[i]>=s){
            que.pop();
            que.push(r[i]);
            ans=max(ans, ans+r[i]-s);
        }
        else break;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    int o = n - m;
    int p = o * 100;
    int q = 1900 * m;
    int r = pow(2, m);

    cout << (r * (p + q)) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout <<"ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

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

using namespace std;

int main() {
	const ll MOD = 1e9 + 7;
	ll N;
	cin >> N;

	int n = 0;
	while (pow(2, n) <= N) { ++n; }
	vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));
	dp[0][0] = 1;

	for (int i = 1; i <= n; ++i) {
		if ((N>>(n - i)) & 1) {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][2] = 2*dp[i - 1][1] + 3*dp[i - 1][2];
		} else {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][1] + 3*dp[i - 1][2];
		}
		for (int j = 0; j < 3; ++j) {
			dp[i][j] %= MOD;
		}
	}

	ll res = (dp[n][0] + dp[n][1] + dp[n][2]) % MOD;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define G_SIZE 100

int main(int argc, char* argv[])
{
	int u, k, n, v, i, j;
	int G[G_SIZE+1][G_SIZE+1];

	for(i = 1; i <= G_SIZE; i++){
		for(j = 1; j <= G_SIZE; j++){
			G[i][j] = 0;
		}
	}

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &u);
		scanf("%d", &k);
		for(j = 0; j < k; j++){
			scanf("%d", &v);
			G[u][v] = 1;
		}
	}

	for(i = 1; i <= n; i++){
		for(j = 1; j < n; j++){
			printf("%d ", G[i][j]);
		}
		printf("%d\n", G[i][j]);
	}

	return(0);
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	final static long r = 1000000000 + 7;
	final static int MAX = 60;

	public static long solve(long a[]) {
		long ans = 0, tmp = 0, tmp2 = 0, current = 1;
		int n = a.length;
		int bit[] = new int[MAX];
		for (int i = 0; i < MAX; ++i) {
			int cnt = 0;
			for (int j = 0; j < n; ++j) {
				long target = a[j];
				tmp = current & target;
				if (tmp == 0)
					++cnt;
			}
			bit[i] = cnt;
			current <<= 1;
		}
		current = 1;
		for (int i = 0; i < MAX; ++i) {
			tmp = bit[i];
			tmp = (n - tmp) * tmp;
			tmp %= r;
			tmp2 = current % r;
			current <<= 1;
			tmp = tmp * tmp2;
			tmp %= r;
			ans += tmp;
			ans %= r;
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a[] = new long[n];
		for (int i = 0; i < n; ++i)
			a[i] = sc.nextLong();
		sc.close();
		long ans = solve(a);
		System.out.println(ans);
	}
}


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

int main(){
    long long n,k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    bool ok=false;
    long long res=0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合
        if (d != -1 && !(k & (1LL<<d))) continue;
        long long tmp=0;
    for(int i=60;i>=0;--i){
        long long num=0;
        long long mask=1LL<<i;
        for(int j=0;j<n;++j){
            if(a[j]&mask)num++;
        }
        
        if(i>d){
            if(k&mask)tmp+=mask*(n-num);
            else tmp+=mask*num;
        }else if(i==d){
            tmp+=mask*num;
        }else{
            tmp+=mask*max(num,n-num);
        }
    }
    res=max(tmp,res);
    }
    cout << res;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
template <class T>
using vec = vector<T>;
template <class T>
using mat = vector<vector<T>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    int res = 0;

    for (int i = 9; i <= n; i+=2) {
        int m = i;

        map<int, int> p;

        int j = 2;
        while (j * j <= m) {
            if (m % j == 0) {
                p[j]++;
                m /= j;
            }
            else {
                j++;
            }
        }
        if (m > 1) p[m]++;

        int d = 1;
        for (auto&& e : p) {
            d *= e.second + 1;
        }

        if (d == 8) res++;
    }
    cout << res << endl;
    return 0;
}

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

const int N=1e5+100;
int mod=1e9+7;
typedef long long ll;
int a[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    char s[500];
    int k=0;
    //if(n%27==0) n+=n/27;
    while(n){
        int kk=n%26;
        n/=26;
       // if(n==0) break;
        if(kk==0){
            kk=26;
            n-=1;
        }
        s[++k]=kk-1+'a';
    }
    for(int i=k;i>=1;i--)
        cout<<s[i];
    return 0;
}
/*
1e15
*/


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int N, MONEY = 1000;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
	cin >> A.at(i);
  }
  
  for (int i = 0; i < N - 1; i++){
    
    if (A.at(i) < A.at(i + 1)){
      long long int KAB = MONEY / A.at(i);
      MONEY += (A.at(i + 1) - A.at(i)) * KAB;
    }
    
  }
  
  cout << MONEY << endl;
}

Measured memory_bytes: 3496
// AOJ 0212 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0212)
#include<cstdio>
#include<algorithm>
#include<limits>
#include<queue>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)

typedef std::pair<int, int> P;

const int MAX_N = 100, MAX_C = 10, INF = std::numeric_limits<int>::max()>>2;

struct St
{
	int v, dist, tick;

	St( int v, int dist, int tick )
	:	v(v), dist(dist), tick(tick)
	{}

	bool operator< ( const St &s ) const
	{ return dist > s.dist; }
};

int c, n, m, s, d;
std::vector<P> G[MAX_N];
int dp[MAX_N][MAX_C];

int main()
{
	while( scanf( "%d%d%d%d%d", &c, &n, &m, &s, &d ), c|n|m|s|d )
	{
		rep( i, n )
			G[i].clear();

		--s; --d;

		rep( i, m )
		{
			int a, b, f;
			scanf( "%d%d%d", &a, &b, &f );
			--a; --b;
			G[a].push_back( P( b, f ) );
			G[b].push_back( P( a, f ) );
		}

		std::priority_queue<St> pque;
		pque.push( St( s, 0, c ) );
		
		rep( i, n ) rep( j, c+1 )
			dp[i][j] = INF;
		dp[s][c] = 0;
		
		while( !pque.empty() )
		{
			St st = pque.top(); pque.pop();
			int v = st.v, dist = st.dist, t = st.tick;

			if( dp[v][t] < dist )
				continue;

			rep( i, G[v].size() )
			{
				P &e = G[v][i];

				if( dp[e.first][t] > dp[v][t]+e.second )
				{
					dp[e.first][t] = dp[v][t]+e.second;
					pque.push( St( e.first, dp[v][t]+e.second, t ) );
				}

				if( t && dp[e.first][t-1] > dp[v][t]+e.second/2 )
				{
					dp[e.first][t-1] = dp[v][t]+e.second/2;
					pque.push( St( e.first, dp[v][t]+e.second/2, t-1 ) );
				}
			}
		}

		printf( "%d\n", *std::min_element( dp[d], dp[d]+c+1 ) );
	}

	return 0;
}

Measured memory_bytes: 1076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt(),c=s.nextInt();
        if(b-a==c-b) System.out.println("YES");
        else System.out.println("NO");
    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25364
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  string S;
  int s=0,n=0,e=0,w=0,cnt=0;
  cin>>S;
  for(int i=0;i<S.size();i++){
    if(S[i]=='N') n++;
    else if(S[i]=='W') w++;
    else if(S[i]=='S') s++;
    else if(S[i]=='E') e++;
  }
  if((n==0&&s==0)||(n!=0&&s!=0)) cnt++;
  if((w==0&&e==0)||(e!=0&&w!=0)) cnt++;
  if(cnt==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
}

Measured memory_bytes: 21972
// AIZU ONLINE JUDGE http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10006
//*
#include <stdio.h>

int main(){
    int x;
    int i=0;
    while(1){
        scanf("%d", &x);
        if(x==0)break;
        printf("Case %d: %d\n", ++i, x);
    }
    return 0;
}
//*/

Measured memory_bytes: 2724
n = int(input())

p = []

for i in range(n):
    a = int(input())
    b = [input().split() for j in range(a)]
    p.append(b)

ans = 0
bit = 2**n

for i in range(bit):
    # 正直状態
    a = format(i,'0{}b'.format(n))

    flag = 1
    for j in range(len(p)):
        if a[j]=='1':
            for k in range(len(p[j])):
                if a[int(p[j][k][0])-1]!=p[j][k][1]:
                    flag = 0
                    break

    if flag:
        ans = max(ans,a.count('1'))
print(ans)






Measured memory_bytes: 44636
#include <stdio.h>
#include <math.h>
 
int main(void) {
    int n, i, t, sc[1000];
    double a, v;
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        t = 0;
        for (i = 0; i < n; i++) {
            scanf("%d", sc + i);
            t += sc[i];
        }
        a = (double)t / (double)n;
        v = 0;
        for (i = 0; i < n; i++) {
            v += ((double)sc[i] - a) * ((double)sc[i] - a);
        }
        printf("%lf\n", sqrt(v / (double)n));
    }
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

void chmin(int &a,int b){
  if(a>b) a=b;
}

int main(){
  int M,N;
  cin>>M>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  if(M==2){
    vector<vector<int>> dp(N+1,vector<int> (2,0));
    for(int i=0;i<=N;i++) rep(j,2) dp[i][j]=N+1;
    dp[1][0]=0;
    dp[1][1]=1;
    for(int i=1;i<N;i++){
      if(A[i]==A[i-1]){
        chmin(dp[i+1][0],dp[i][1]);
        chmin(dp[i+1][1],dp[i][0]+1);
      }else{
        chmin(dp[i+1][0],dp[i][0]);
        chmin(dp[i+1][1],dp[i][1]+1);
      }
    }
    int ans=min(dp[N][0],dp[N][1]);
    cout<<ans<<endl;
  }else{
    int ans=0;
    bool ch=false;
    for(int i=1;i<N;i++){
      if(ch){
        ch=false;
      }else{
        if(A[i]==A[i-1]){
          ch=true;
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        char[] str = new char[n];
        process(str, 0, 'a');
    }

    private static void process(char[] str, int pos, char maxChar){
        if(str.length == pos){
            System.out.println(new String(str));
        }else{
            for (char c = 'a'; c<=maxChar; c++){
                str[pos]=c;
                process(str, pos+1, c==maxChar ? (char)(maxChar+1) : maxChar);
            }
        }
    }
}

Measured memory_bytes: 41248