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

#define scd second;
#define fst first;
#define mkp make_pair
#define pb push_back
#define pf push_front

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;

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

	int n, k;
	cin>>n>>k;
	vector<bool> have(n,false);
	while(k--){
		int d;
		cin>>d;
		while(d--){
			int ai;
			cin>>ai;
			have[ai-1]=true;
		}
	}

	cout<<n-(accumulate(have.begin(), have.end(),0))<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[100001][13];
int main(){
	string s;
	cin>>s;
	dp[0][0]=1;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<13;j++){
			if(s[i]=='?')
				for(int k=0;k<=9;k++)
					(dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;
			else
				(dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j])%=mod;
		}
	}
	cout<<dp[s.size()][5]<<endl;
}


Measured memory_bytes: 5504
/*

(x + y)%2019 = 0

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 2019

const int ma = 6;

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

    string s;
    cin >> s;
    int n = s.size();

    ll num = 0;
    ll pot = 1;
    ll cnt = 0;
    vector<int> u(mod);
    u[num]++;

    for (int i=n-1;i>=0;i--) {
        num = (num + (((int)(s[i] - '0')) * pot))%mod;
        cnt += u[num];
        u[num]++;
        pot  = (pot*10)%mod;
    }

    cout << cnt << "\n";
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,num = 0;
    string s;
    cin >> s;
    for(i=0; i<4; i++){
        if(s[i] == '+'){
            num += 1;
        }else if(s[i] == '-'){
            num -= 1;
        }
    }
    cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
A = list(input())
L = len(A)

ans = 'WA'
flag = 0
f = 0
j = 0

if A[0] == 'A':
    if A[0].isupper():
        flag = flag + 1
#print(flag)
count = 0
i=2
while(1):
    if A[i] == 'C':
        if A[i].isupper():
            count = count + 1
    i = i + 1
    if (L-2-i < 0):
        break
#print(count)
if count == 1:
    flag = flag + 1
#print(flag)
count = 0
for i in range(1,L):
    #print(A[i].isupper())
    if A[i].isupper():
        count = count + 1
#print(count)
if count == 1:
    flag = flag + 1
#print(flag)
if flag == 3:
    ans = 'AC'

print(ans)

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



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

	int a, b;
	cin >> a >> b;
	if (a <= 5)
		b = 0;
	else if (a <= 12)
		b = b / 2;
	cout << b;

}


Measured memory_bytes: 256
H, N = map(int, input().split())
magics = []
min_cost = (0, 100000)
max_attack = (0, 100000)
for i in range(N):
    attack, cost = map(int, input().split())
    magics.append((attack,cost))
    if cost < min_cost[1]:
        min_cost = (attack, cost)
    if max_attack[0] < attack:
        max_attack = (attack, cost)
    

dp = [0]
dp.extend([min_cost[1]] * min_cost[0])
for i in range(min_cost[0]+1, H + max_attack[0] + 1):
    minc = 100000000000
    for magic in magics:
        cost = magic[1]
        if 0 < i - magic[0]:
            cost += dp[i - magic[0]]
        if cost < minc:
            minc = cost
    dp.append(minc)
print(min(dp[H:]))

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

int main() {
    vector<int> abc(3);cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    cout << (abc[0]==5 && abc[1]==5 && abc[2]==7 ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;

struct Team
{
	int id;
	int crr_num;
	int time_sum;
	int fal[10];

	bool operator < (const Team& oth)const{
		if(crr_num==oth.crr_num) {
			if(time_sum==oth.time_sum) return id>oth.id;
			return time_sum<oth.time_sum;
		}
		return crr_num>oth.crr_num;
	}
};

int main(int argc, char const *argv[])
{
	int m,t,p,r;

	while(1){
		cin>>m>>t>>p>>r;
		if(m+t+p+r==0) break;

		vector<Team> jg(t);

		for(int i1=0;i1<t;i1++){
			jg[i1].id=i1+1;
			jg[i1].crr_num=0;
			jg[i1].time_sum=0;
			for(int i2=0;i2<10;i2++){
				jg[i1].fal[i2]=0;
			}
		}

		int tm,tt,tp,j;
		for(int i1=0;i1<r;i1++){
			cin>>tm>>tt>>tp>>j;

			if(j==0){
				jg[tt-1].crr_num++;
				jg[tt-1].time_sum+=(tm+jg[tt-1].fal[tp-1]*20);
			}
			else jg[tt-1].fal[tp-1]++;
		}

		sort(jg.begin(),jg.end());

		cout<<jg[0].id;
		for(int i1=1;i1<t;i1++){
			if(jg[i1].crr_num==jg[i1-1].crr_num && jg[i1].time_sum==jg[i1-1].time_sum){
				cout<<"="<<jg[i1].id;
			}
			else cout<<","<<jg[i1].id;
		}
		cout<<endl;

	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll dp[100010][2];
int main() {
	string s;
	cin>>s;
	dp[0][0]=1;//0は未満未確定
	for(ll i=0;i<s.size();i++){
		if(s[i]=='0'){
			dp[i+1][0]+=dp[i][0];//0しか選択できない
			dp[i+1][1]+=dp[i][1];//０を選択
			dp[i+1][1]+=(dp[i][1]*2)%inf;//1を選択
		}
		else{//１のとき
			dp[i+1][1]+=dp[i][0];//0を選択
			dp[i+1][0]+=(dp[i][0]*2)%inf;//１を選択
			dp[i+1][1]+=dp[i][1];//0を選択
			dp[i+1][1]+=(dp[i][1]*2)%inf;//１を選択
		}
		dp[i+1][0]%=inf;
		dp[i+1][1]%=inf;
	}
	cout << (dp[s.size()][1]+dp[s.size()][0])%inf;
	// your code goes here
	return 0;
}

Measured memory_bytes: 2048
from collections import deque

def bfs():
    q = deque([0])
    bit = [-1]*N
    bit[0] = 0
    serial = 0
    
    while q:
        v = q.popleft()
        
        for nv in adj_list[v]:
            if bit[nv]!=-1:
                continue
            bit[nv] = bit[v]|(1<<serial)
            serial += 1
            q.append(nv)
    
    return bit

N = int(input())
adj_list = [[] for _ in range(N)]

for _ in range(N-1):
    ai, bi = map(int, input().split())
    adj_list[ai-1].append(bi-1)
    adj_list[bi-1].append(ai-1)

bit = bfs()
M = int(input())
uv = []
path_bit = []

for _ in range(M):
    ui, vi = map(int, input().split())
    uv.append((ui-1, vi-1))
    path_bit.append(bit[ui-1]^bit[vi-1])

houzyo = 0

for i in range(1, 2**M):
    covered = 0
    c = 0
    
    for j in range(M):
        if (i>>j)&1:
            covered |= path_bit[j]
            c += 1
    
    no_covered = 0
    
    for j in range(N-1):
        if not (covered>>j)&1:
            no_covered += 1
    
    if c%2==1:
        houzyo += 2**no_covered
    else:
        houzyo -= 2**no_covered

print(2**(N-1)-houzyo)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

ld area(ld a, ld b, ld c)
{
  ld s = (a + b + c) / 2.0;
  return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main()
{
  int a, l, x;
  while (~scanf("%d %d %d", &a, &l, &x)){
    ld v = (l + x) / 2.0;
    printf("%.10Lf\n", area(a, l, l) + 2 * area(l, v, v));
  }
  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] firstLine = sc.nextLine().split(" ");
        int N = toInt(firstLine[0]);
        int M = toInt(firstLine[1]);
        int studentPoint[][] = new int[N][2];
        int checkPoints[][] = new int[M][2];

        for (int i = 0; i < N; i++) {
            studentPoint[i][0] = sc.nextInt();
            studentPoint[i][1] = sc.nextInt();
        }

        for (int j = 0; j < M; j++) {
            checkPoints[j][0] = sc.nextInt();
            checkPoints[j][1] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int minLength = Integer.MAX_VALUE;
            int answerForStudentI=Integer.MIN_VALUE;
            for (int j = 0; j < M; j++) {



                int distance = manhattanDistance(
                        studentPoint[i][0], studentPoint[i][1],
                        checkPoints[j][0], checkPoints[j][1]);
                if (distance < minLength) {
                    minLength = distance;
                    answerForStudentI = j + 1;
                }

            }
            System.out.println(answerForStudentI);
        }

    }

    private static int manhattanDistance(int x1, int y1, int x2, int y2) {
        return Math.abs(x1 - x2) + Math.abs(y1 - y2);
    }

    private static int toInt(String str) {
        return Integer.parseInt(str);
    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=2e5+5;

int a[N];
int ans[N];
int fr[N];
int vis[N];

pii dfs(int x,int c){
	if(vis[x]){
		return {x,c-fr[x]};
	}
	vis[x]=1;
	fr[x]=c;
	ans[c]=x;
	return dfs(a[x],c+1);
}

void solve(){
	int n,k;
	cin>>n>>k;
	rep(i,1,n+1){
		cin>>a[i];
	}
	
	pii l=dfs(1,0);
	
	if(k < fr[l.fr]){
		cout<<ans[k];
	}
	else{
		int z=k-fr[l.fr];
		z%=l.sc;
		cout<<ans[fr[l.fr]+z];
		
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  llong ans=0;

  int n; cin >> n;
  int x; cin >> x;
  vector<int> a(n); REP(i, n) cin >> a[i];

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

  cout << ans << endl;
}

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


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

using namespace std;

int main() {
   ll a[3],k;
   cin>>a[0]>>a[1]>>a[2]>>k;
   ll sum=0;
   sort(a,a+3);
   while(k--)
   {
       a[2] = 2*a[2];
       sum = a[1]+a[2]+a[0];
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

signed main()
{
    int n, w;
    sll(n, w);
    vl h(n), dp(n);
    sal(h, n);
    dp[n-1] = 0;
    ford(i, n-1) {
        dp[i] = BIG;
        fin2(k, i+1, n) {
            chmin(dp[i], abs(h[i] - h[k]) + dp[k]);
            if ((k-i) == w) break;
        }
    }
    pl(dp[0]);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int N,i,j, A[100000],B[100000];
	scanf("%d", &N);
	for (i = 1; i <= N ; i++) {
		scanf("%d", &A[i]);
		B[A[i]] = i;
	}
	for (j = 1; j <= N ; j++) {
		printf("%d ", B[j]);
	}
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)

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

const long long MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int v[3] = {7, 5, 3};
int solve(int n, ll x) {
    if (n < x) return 0;

    int res = 0;
    rep(i, 3) res += solve(n, x * 10 + v[i]);
    
    vector<bool> done(10);
    while (0 < x) {
        done[x % 10] = true;
        x /= 10;
    }
    if (done[3] && done[5] && done[7]) res++;
    return res;
}

int main() {
    int n;
    cin >> n;
    cout << solve(n, 0) << endl; 
}

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

A.sort()
C.sort()
sum = 0
for i in B:
    a = bisect.bisect_left(A,i)
    c = len(B)-bisect.bisect_right(C,i)
    sum += a*c

print(sum)
    

Measured memory_bytes: 23232
nn = gets.to_i
aa = gets.split.map(&:to_i).sort

max = 0
idx = aa.bsearch_index{|x|x>=0}

if idx.nil?
  # 全部マイナス
  if nn%2==0
    # 全部プラスにできる
    max = -(aa.inject(:+))
  else
    # 1個だけマイナス残る
    b = aa.pop
    max = -(aa.inject(:+)) + b
  end
elsif idx==0
  # マイナスがない
  max = aa.inject(:+)
else
  # マイナスがある
  minus_cnt = idx
  if minus_cnt%2==0
    # 全部プラスにできる
    max = aa.inject{|s,i|s.abs+i.abs}
  else
    # 1こだけマイナス残る
    sorted = aa.sort_by{|a|a.abs}.to_a
    b = sorted.shift
    b=-b if b>0
    max = (sorted.inject{|s,i|s.abs+i.abs}).abs + b
  end
end

puts max


Measured memory_bytes: 13304
fun main(args: Array<String>) {
  val (D, G) = readInts()
  val PC = (1..D).map { readInts() }

  var min = Int.MAX_VALUE
  val b = Array(D) { false }

  fun f(): Int {
    var n = 0
    var g = G
    for (i in 0 until D) {
      if (b[i]) {
        val (p, c) = PC[i]
        val base = (i + 1) * 100
        n += p
        g -= c
        g -= p * base
      }
    }
    if (g <= 0) {
      return n
    }
    for (i in D - 1 downTo 0) {
      if (!b[i]) {
        val (p, c) = PC[i]
        val base = (i + 1) * 100
        val v = Math.min(g / base, p)
        n += v
        g -= v * base
        if (g <= 0) {
          return n
        }
      }
    }
    return n
  }

  fun dfs(i: Int) {
    if (i == D) {
      min = Math.min(f(), min)
    } else {
      b[i] = true
      dfs(i + 1)
      b[i] = false
      dfs(i + 1)
    }
  }
  dfs(0)

  println(min)
}

fun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {
  var ng = begin
  var ok = end

  while (Math.abs(ok - ng) > 1) {
    val mid = (ok + ng) / 2
    if (isOk(mid)) {
      ok = mid
    } else {
      ng = mid
    }
  }

  return ok
}

fun <T> List<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun <T> Array<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int i, j;
	bool flag1 = false;
	for (i = n - m; i >= 0; i--) {
		bool flag2 = true;
		for (j = 0; j < m; j++) {
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				flag2 = false;
				break;
			}
		}
		if (flag2) {
			for (j = 0; j < m; j++) {
				s[i + j] = t[j];
			}
			for (i = 0; i < n; i++) {
				if (s[i] == '?') {
					cout << 'a';
				}
				else {
					cout << s[i];
				}
			}
			cout << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}

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

int main()
{
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t q = n / (a + b);
  int64_t r = n % (a + b);
  int64_t ans = q * a + min(r, a);
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

type dice struct {
	o, tw, th, fo, fi, s int
}

func main() {
	var Dice dice
	fmt.Scan(&Dice.o, &Dice.tw, &Dice.th, &Dice.fo, &Dice.fi, &Dice.s)
	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var t, f int
		fmt.Scan(&t, &f)
		switch t {
		case Dice.tw:
			Dice = rot(Dice, "N")
		case Dice.th:
			Dice = rot(Dice, "W")
		case Dice.fo:
			Dice = rot(Dice, "E")
		case Dice.fi:
			Dice = rot(Dice, "S")
		case Dice.s:
			Dice = rot(rot(Dice, "N"), "N")
		}
		for Dice.tw != f {
			Dice = rot(Dice, "R")
		}
		fmt.Println(Dice.th)
	}
}

func rot(Dice dice, D string) dice {
	for _, d := range D {
		switch d {
		case 'N':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.tw, Dice.s, Dice.o, Dice.fi
		case 'E':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.fo, Dice.o, Dice.s, Dice.th
		case 'W':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.th, Dice.s, Dice.o, Dice.fo
		case 'S':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.fi, Dice.o, Dice.s, Dice.tw
		case 'R':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.th, Dice.fi, Dice.tw, Dice.fo
		case 'L':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.fo, Dice.tw, Dice.fi, Dice.th
		}
	}
	return Dice
}



Measured memory_bytes: 1156
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    string ans = N == M ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n,m,a[55],ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=n-1;i>=n-1-m+1;i--)
	ans+=a[i];
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{ 
  int a,b[20000],c[20000],d[20000];
  while(cin>>a,a!=0){
    for(int i=0;i<a;i++){
      cin>>b[i]>>c[i]>>d[i];
      if(b[i]==100 || c[i]==100 || d[i]==100){
	cout<<"A\n";
      }else if((b[i]+c[i])/2>=90){
	cout<<"A\n";
      }else if((b[i]+c[i]+d[i])/3>=80){
	cout<<"A\n";
      }else if((b[i]+c[i]+d[i])/3>=70){
	cout<<"B\n";
      }else if((b[i]+c[i]+d[i])/3>=50 && b[i]>=80 || c[i]>=80){
	cout<<"B\n";
      }else{
	cout<<"C\n";
      }
    }
  }
}


Measured memory_bytes: 3048
#include <stdio.h>
int main()
{
  int n,x;
  scanf("%d",&n);
  if(n>=1&&n<=9)
  {
   x=n-0;
   printf("%d",x);
  }
  else if(n>=10&&n<=99)
  {
    x=9;
    printf("%d\n",x);
  }
  else if(n>=100&&n<=999)
  {
    x=(n-100)+1+9;
    printf("%d\n",x);
  }
  else if(n>=1000&&n<=9999)
  {
    x=(999-100)+1+9;
    printf("%d\n",x);
  }
  else if(n>=10000&&n<=99999)
  {
    x=(999-100)+1+9+(n-10000)+1;
    printf("%d\n",x);
  }
  else if(n>=100000&&n<=999999)
  {
    x=(999-100)+1+9+(99999-10000)+1;
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n; cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  sort(all(x));
  int ans = INF;
  rep(i,100){
    int tmp = 0;
    rep(j,n){
      tmp += pow(i-x[j],2);
    }
     ans = min(ans,tmp);
  }

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


Measured memory_bytes: 256
N, M = map(int, input().split())
edges = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
for i in range(N):
    print(len(edges[i]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int,int>> tf(N);
  rep(i,N){
    string A;
    cin >> A;
    ll X=0;
    int ten=9;
    bool flag=false;
    rep(j,sz(A)){
      if(A.at(j)=='.'){
        flag=true;
        continue;
      }
      if(flag)  ten--;
      X*=10;
      X+=int(A.at(j)-'0');
    }
    rep(j,ten)  X*=10;
    int two=0;
    int five=0;
    while(X%2==0){
      X/=2;
      two++;
    }
    while(X%5==0){
      X/=5;
      five++;
    }
    chmin(two,18);
    chmin(five,18);
    tf.at(i)=m_p(two,five);
  }

  vector<vector<int>> tf_sum(20,vector<int>(20,0));
  rep(i,N){
    int two=tf.at(i).fi;
    int five=tf.at(i).se;
    tf_sum.at(two).at(five)++;
  }
  for(int i=18;i>=0;i--){
    for(int j=18;j>=0;j--){
      tf_sum.at(i).at(j) = tf_sum.at(i).at(j) + tf_sum.at(i+1).at(j) + tf_sum.at(i).at(j+1) - tf_sum.at(i+1).at(j+1);
    }
  }

  ll ans=0;
  rep(i,N){
    int two=tf.at(i).fi;
    int five=tf.at(i).se;
    ans+=tf_sum.at(18-two).at(18-five);
  }
  rep(i,N){
    int two=tf.at(i).fi;
    int five=tf.at(i).se;
    if(2*two>=18 && 2*five>=18) ans--;
  }
  ans/=2;
  cout << ans << endl;

  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
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()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int X, Y; cin >> X >> Y;
  
  //main
  ll ans = 0;
  
  if(X == 1){ ans += 3e5; }
  else if(X == 2){ ans += 2e5; }
  else if(X == 3){ ans += 1e5; }
  else{ ans += 0; }
  
  if(Y == 1){ ans += 3e5; }
  else if(Y == 2){ ans += 2e5; }
  else if(Y == 3){ ans += 1e5; }
  else{ ans += 0; }
  
  // output
  if(X == 1 && Y == 1){ ans += 4e5;}
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,A=0;
  scanf("%d",&N);
  int k=0,c=0;
  for(int i=1;i<=N;i++){
    k=i;
    c=0;
    while(k>0){
      k/=10;
      c++;
    }
    if(c%2==1) A++;
  }
  printf("%d\n",A);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(5);
  ll x = 1000000000000000;
  rep(i, 5){
    cin >> a[i];
    x = min(x, a[i]);
  }
  ll ans = (n-1) / x + 5;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3612
from sys import stdin

gets = stdin.readline


def main():
    n = int(gets())
    h, w = 0, 0
    flag = False
    for _ in range(3500):
        h += 1
        w = 0
        for _ in range(3500):
            w += 1
            y = (4 * h * w - n * (h + w))
            if y > 0:
                modulo = n % y * h % y * w % y
                if modulo % y == 0:
                    print(h, w, (n*h*w)//y)
                    flag = True
                    break
        if flag:
            break
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  }
}


Measured memory_bytes: 25968
n,l = map(int,input().split())
taste = [0]*n
for i in range(n):
    taste[i] = l+i
api = sum(taste)
eat = 0
sa = 10000
for i in range(n):
    if abs(taste[i]) < abs(sa):
        sa = taste[i]
print(api-sa)

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

int main() {
  int town_n, road_n;
  std::cin >> town_n >> road_n;
  std::vector<int> data(town_n);
  for (int i=0; i<road_n; i++) {
    int temp_t1, temp_t2;
    std::cin >> temp_t1 >> temp_t2;
    data.at(temp_t1-1)++;
    data.at(temp_t2-1)++;
  }
  for (int i=0; i<town_n; i++) {
    std::cout << data.at(i) << std::endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        String s=sc.nextString();
        int r=0;
        for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='R')r++;
		}
        String ans="No";
        if(2*r>n)ans="Yes";

        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23252
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = map(int, input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0 or (x > 2 * y) or (2 * x < y):
    print(0)
else:
    cnt = (x + y) // 3
    print(bigcmb(cnt, x - cnt, mod))


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    
    int f=0;
    while(n)
    {
        if(n%10==7)
        {
            f=-1;
            break;
        }
        n/=10;
    }
    if(f==-1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
	// your code goes here
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
 
        System.out.println(gcd(Math.max(x, y),Math.min(x, y)));
    }
 
    public static int gcd(int a,int b){
 
        if(b == 0){
            return a;
        }else{
            return gcd(b,a%b);
        }
    }
}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

constexpr int GENTEN = 80 * 80 * 80 / 4 + 1;
constexpr int LEN = GENTEN * 2;

using Bitset = std::bitset<LEN>;
template <class T>
using Row = vector<T>;
template <class T>
using Table = vector<Row<T>>;

void solve(void)
{
  int H, W; cin >> H >> W;
  Table<int> A(H + 1, Row<int>(W + 1));
  Table<int> B(H + 1, Row<int>(W + 1));
  for (int row = 0; row < H; ++row) {
    for (int column = 0; column < W; ++column) {
      cin >> A[row][column];
    }
  }
  for (int row = 0; row < H; ++row) {
    for (int column = 0; column < W; ++column) {
      cin >> B[row][column];
    }
  }

  Table<Bitset> dp(H + 1, Row<Bitset>(W + 1));
  dp[0][0] |=  Bitset(1) << (GENTEN + A[0][0] - B[0][0])
            |  Bitset(1) << (GENTEN + B[0][0] - A[0][0]);

  for (int row = 0; row < H; ++row) {
    for (int column = 0; column < W; ++column) {
      dp[row][column + 1] |=
        ((dp[row][column] << A[row][column + 1]) >> B[row][column + 1])
      | ((dp[row][column] << B[row][column + 1]) >> A[row][column + 1]);

      dp[row + 1][column] |=
        ((dp[row][column] << A[row + 1][column]) >> B[row + 1][column])
      | ((dp[row][column] << B[row + 1][column]) >> A[row + 1][column]);

    }
  }

  const Bitset& res = dp[H - 1][W - 1];
  for (int i = 0; i < GENTEN; ++i) {
    if (res[GENTEN + i]) {
      cout << i << CRLF;
      return;
    }
  }
  assert(false);
  return;
}

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

  solve();

  return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  int max_answer=0,x=0;
  for(int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      if(i!=j) {
        x=abs(a[j]-a[i]);
      }
      max_answer=max(max_answer,x);
    }
  }
  cout << max_answer << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)

N = int(input())
S = [input() for n in range(N)]

for s in S[0]:
  d[s] += 1

for index, s in enumerate(S):
  if index == 0:
    continue
  
  k = defaultdict(int)

  for i in s:
    k[i] += 1

  for t in k:
    if d[t] > k[t]:
      d[t] = k[t]

  for t in d:
    if k[t] == 0:
      d[t] = 0

ans = ""
for i in d:
  if d[i] == 0:
    continue

  ans += i * d[i]

ans = sorted(ans)
ans = "".join(ans)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    while(cin>>n>>k)
    {
        ll ans=n;
            ans=min(ans,(n%k));
            ans=min(ans,(k)-(n%k));
            cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
n, T = map(int,input().split())
ans_c = ans_t = 1001

for i in range(n):
	c, t = map(int,input().split())
	if t > T:
		continue
	if ans_c >= c:
		ans_c, ans_t = c, t
	
print(ans_c if ans_t != 1001 else 'TLE')

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=300005,maxm=106;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-6;


int n,x[3];
bool fl=1;
char c[maxn]={0},tp[maxn];
int ii[maxn][2];

void dfs(int aa,int bb,int cc,int dep)
{
    int i,j,k,l;
    int tmp[3]={aa,bb,cc};
    if(dep==n)
    {
        for(i=0;i<n;i++) c[i]=tp[i];
        return;
    }
    if(c[0]!=0) return;
    if(tmp[ii[dep][0]]>tmp[ii[dep][1]])
    {
        tp[dep]=ii[dep][1]+'A';
        --tmp[ii[dep][0]];++tmp[ii[dep][1]];
        dfs(tmp[0],tmp[1],tmp[2],dep+1);
        ++tmp[ii[dep][0]];--tmp[ii[dep][1]];
    }
    if(c[0]!=0) return;
    if(tmp[ii[dep][1]]>tmp[ii[dep][0]])
    {
        tp[dep]=ii[dep][0]+'A';
        --tmp[ii[dep][1]];++tmp[ii[dep][0]];
        dfs(tmp[0],tmp[1],tmp[2],dep+1);
        ++tmp[ii[dep][1]];--tmp[ii[dep][0]];
    }
    if(c[0]!=0) return;
    if(tmp[ii[dep][1]]!=tmp[ii[dep][0]]) return;
    tp[dep]=ii[dep][1]+'A';
    --tmp[ii[dep][0]];++tmp[ii[dep][1]];
    if(tmp[0]>=0&&tmp[1]>=0&&tmp[2]>=0) dfs(tmp[0],tmp[1],tmp[2],dep+1);
    ++tmp[ii[dep][0]];--tmp[ii[dep][1]];
    if(c[0]!=0) return;
    tp[dep]=ii[dep][0]+'A';
    --tmp[ii[dep][1]];++tmp[ii[dep][0]];
    if(tmp[0]>=0&&tmp[1]>=0&&tmp[2]>=0) dfs(tmp[0],tmp[1],tmp[2],dep+1);
    ++tmp[ii[dep][1]];--tmp[ii[dep][0]];
}

int main()
{
	int i,j,k,l;
	scanf("%d",&n);
	for(i=0;i<3;i++) scanf("%d",x+i);
	for(i=0;i<n;i++)
    {
        char s[5];
        scanf("%s",s);
        ii[i][0]=s[0]-'A',ii[i][1]=s[1]-'A';
    }
    dfs(x[0],x[1],x[2],0);
    printf("%s\n",c[0]!=0?"Yes":"No");
    if(c[0]!=0)
    {
        for(i=0;i<n;i++) printf("%c\n",c[i]);
    }
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int a,b; cin >> a >> b;
    cout << max(a*b,max(a-b,a+b));
    return 0;
}



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

int main() {
  int A, B, X, ans;
  cin >> A >> B >> X;
  if ( X % 500 != 0 ) X += 500 - X%500;
  int a = 0;
  int b = 0;

  if ( A < B ) {
    a = X/1000 + ((X%1000>0)?1:0);
  } else if ( A > 2*B ){
    b = X/500;
  } else {
    a = X/1000; X %= 1000;
    b = X/500;
  }

  cout << A*a + B*b << endl;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
int main(){
long long n,a,b;
scanf("%lld%lld%lld",&n,&a,&b);
long long num=a+b;
long long ans=(n/num)*a;
long long now=n%num;
ans+=min(now,a);
printf("%lld\n",ans);
return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				}
			}
			System.out.println(count);

		}

	}
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


string S;
int sz;

ull rec(int idx) {
    if (idx >= sz) return 0;
    ull ans = 0;
    for (int i = idx + 1; i <= sz; i++) {
        ull p = 1 << (max(0,sz - i - 1));
        string s = S.substr(idx, i - idx);
        ull f = stoull(s);
        ans += p * f + rec(i);
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> S;
    sz = SZ(S);
    cout << rec(0) << endl;

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc061/tasks/abc061_b

N, M = map(int, input().split())

# 各都市から、どこの都市に道路が伸びているかという情報
graph_list = [[] for i in range(N)]

for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph_list[a].append(b)
    graph_list[b].append(a)


for i in range(N):
    print(len(graph_list[i]))
    

Measured memory_bytes: 3060
using System;

namespace ABC064C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());

            string[] bufs = Console.ReadLine().Split(' ');

            bool[] exist = new bool[8];
            int master = 0;

            for (int i = 0; i < N; i++)
            {
                int rank = Int32.Parse(bufs[i]) / 400;
                if (rank < 8)
                {
                    exist[rank] = true;
                }
                else
                {
                    master++;
                }
            }

            int res = 0;
            for (int i = 0; i < 8; i++)
            {
                if(exist[i]) { res++; }
            }

            if (res == 0)
            {
                Console.WriteLine("{0} {1}", 1, master);
            }
            else
            {
                Console.WriteLine("{0} {1}", res, res + master);
            }
        }
    }
}


Measured memory_bytes: 13140