akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math

def fast_comb(a,b,mod):
    up = reduce(lambda x,y: x*y%mod, range(a,a-b,-1))
    down = reduce(lambda x,y: x*y%mod, range(1,b+1))
    return (up * pow(down, mod-2, mod)) % mod

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def readlines(n):
    for _ in range(n):
        map(int, input().split())
        yield

def main():
    a,b = map(int, input().split())

    for i in range(20000):
        a_ = int(i * 0.08)
        b_ = int(i * 0.1)

        if (a, b) == (a_, b_):
            print(i)
            return

    print(-1)





main()

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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int mm1 = h1 * 60 + m1, mm2 = h2 * 60 + m2;
    int mms = mm2 - mm1;
    cout << mms - k << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
const int MAX = 1e5+10;
const int  MAX1 = 1e5+10;
const int INF = 1e9+10;
double eps = 1e-6;
ll x1[20];
int main(){
    IOS
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

}


/*


*/


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

class Test
{
    static void Main()
    {
        string[] r = Console.ReadLine().Split();
        int n = int.Parse(r[0]);
        int q = int.Parse(r[1]);

        Queue<int>[] A = new Queue<int>[n];
        for (int i = 0; i < n; i++)
        {
            A[i] = new Queue<int>();;
        }

        for (int i = 0; i < q; i++)
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            switch (array[0])
            {
                case 0:
                    A[array[1]].Enqueue(array[2]);
                    break;
                case 1:
                    if (A[array[1]].Count != 0) Console.WriteLine(A[array[1]].Peek());
                    break;
                case 2:
                    if (A[array[1]].Count != 0) A[array[1]].Dequeue();
                    break;
            }
        }
    }
}



Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 200000 + 10;
const int maxm = 100;
ll ans;
int C[maxm][maxm];
inline int lowbit(const int & x) { return x & (-x);}
int sum(int x, int y)
{
	int ret = 0;
	x += 50;
	y += 50;
	for(int i = x; i < maxm; i += lowbit(i))
		for(int j = y; j < maxm; j += lowbit(j))
			ret += C[i][j];
	return ret;
}
void add(int x, int y)
{
	x += 50;
	y += 50;
	for(int i = x; i; i -= lowbit(i))
		for(int j = y; j; j -= lowbit(j))
			++C[i][j];
}
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		double q;
		scanf("%lf", &q);
		ll x = q * 1e9 + 0.5;
		int cnt2 = 0, cnt5 = 0;
		while(x % 2 == 0) x /= 2, ++cnt2;
		while(x % 5 == 0) x /= 5, ++cnt5;
		cnt2 -= 9;
		cnt5 -= 9;
		ans += sum(-cnt2, -cnt5);
		add(cnt2, cnt5);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3808
h,w=map(int,input().split())
s=list(input()for _ in range(h))
dx=[0,1,0,-1,1,1,-1,-1]
dy=[1,0,-1,0,1,-1,1,-1]
for i in range(h):
	for j in range(w):
		if s[i][j]=='.':
			c=0
			for r in range(8):
				x=i+dx[r]
				y=j+dy[r]
				c+=0<=x<h and 0<=y<w and s[x][y]=='#'
			print(c,end='')
		else:print('#',end='')
	print()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a,b;
    cin>>a>>b;

    int n = a.size();
    int m = b.size();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i-1]==b[j-1])
            {
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i=n;
    int j=m;
    int ln = dp[n][m];
    string ans = "";
    while(i>0 && j>0)
    {
        if(a[i-1]== b[j-1])
        {
            ans+= a[i-1];
            i--;
            j--;
            ln--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 38516
#include <bits/stdc++.h> 
 
using namespace std;
 
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);
 
 
#define index_of(as, x) distance(as.begin(), lower_bound(as.begin(), as.end(), x))
LL lis_fast(const vector<LL>& a) {
  const int n = a.size();
  vector<LL> A(n, INF);
  vector<LL> id(n);
  for (int i = 0; i < n; ++i) {
    id[i] = index_of(A, a[i]);
    A[ id[i] ] = a[i];
  }
  LL m = *max_element(id.begin(), id.end());
  /*vector<LL> b(m+1);
  for (int i = n-1; i >= 0; --i)
    if (id[i] == m) b[m--] = a[i];*/
  return m+1LL;
}
 
int main(){
    ios::sync_with_stdio(false);
    LL x[2],y[2];
    cin>>x[0]>>y[0]>>x[1]>>y[1];
 
    if(x[0]>x[1]){
        swap(x[0],x[1]);swap(y[0],y[1]);
    }
    LL c=1;
    if(y[0]>y[1]){
        c=-1;
    }
    int N;
    cin>>N;
    vector<PLL>XY,YX;
    long double qt=5.0L*PI;
 
    REP(i,N){
        LL X,Y;
        cin>>X>>Y;
        if(X>=x[0]&&X<=x[1]&&Y>=min(y[0],y[1])&&Y<=max(y[0],y[1])){
            XY.PB(MP(X,c*Y));
            //YX.PB(MP(c*Y,c*X));
        }
    }
    long double sum=abs(y[1]-y[0])+abs(x[1]-x[0]);
    if(x[0]==x[1]||y[0]==y[1]){
        cout<<fixed<<setprecision(20)<<sum*100.0L+(long double)SZ(XY)*(qt*2.0L-20.0L)<<endl;
        return 0;
    }
    SORT(XY);
    vector<LL>a;
    long double res1=0;
    if(SZ(XY)){
        REP(i,SZ(XY))a.PB(XY[i].second);
        res1=lis_fast(a);
    }
    //cout<<res1<<" "<<res2<<endl;
    if(res1==(abs(x[1]-x[0])+1)||res1==(abs(y[1]-y[0])+1)){
        cout<<fixed<<setprecision(20)<<sum*100.0L+(res1-1.0L)*(qt-20.0L)+(qt*2.0L-20.0L)<<endl;
    }else{
        cout<<fixed<<setprecision(20)<<sum*100.0L+res1*(qt-20.0L)<<endl;
    }
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    map<i64, i64> factor;
    for (i64 i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            factor[i]++;
            n /= i;
        }
    }
    if (n != 1) factor[n] = 1;

    i64 ans = 0;
    for (auto& e : factor) {
        i64 num, cnt;
        tie(num, cnt) = e;
        for (i64 i = 1; cnt - i >= 0; i++) {
            cnt -= i;
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static final void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                int nb = m * i + n * j - i * j * 2;
                if (nb == k)
                    YES();
            }
        }
        NO();
    }

    static void YES() {
        System.out.println("Yes");
        System.exit(0);
    }

    static void NO() {
        System.out.println("No");
        System.exit(0);
    }
}

Measured memory_bytes: 23124
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N;
    cin >>N;

    //-----------------------------------
    ll ans=0;
    repd(A,1,N){
        ans+=(N+A)/(A+1);
    }


    cout << ans <<'\n';

    return (0);
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
ll mod = 998244353;
ll modpow(ll a, ll n = mod-2) {
    ll r=1;
    while(n) r=r*((n%2)?a:1)%mod,a=a*a%mod,n>>=1;
    return r;
}
ll dp[301][300*305+1];
ll dp2[301][300*305+1];
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll sum = accumulate(a.begin(),a.end(),0LL);
    ll ans = modpow(3,n);
    ll inv = modpow(2);
    ll inv3 = modpow(3);
    ll po = modpow(2,n);
    show(ans,inv,po);
    dp[0][0] = 1;
    dp2[0][0] = 1;
    rep(i,n){
        rep(j,300*300+1){
            if(dp[i][j]){
                dp[i+1][j] += dp[i][j];
                if(dp[i+1][j] >= mod)dp[i+1][j] -= mod;
                dp[i+1][j+a[i]] += dp[i][j] * inv % mod;
                if(dp[i+1][j+a[i]] >= mod)dp[i+1][j+a[i]] -= mod;
                
                dp2[i+1][j] += dp2[i][j];
                if(dp2[i+1][j] >= mod)dp2[i+1][j] -= mod;
                dp2[i+1][j+a[i]] += dp2[i][j]% mod;
                if(dp2[i+1][j+a[i]] >= mod)dp2[i+1][j+a[i]] -= mod;
            }
        }
    }
    ll fuga = 0;
    ll hoge = 0;
    rep(j,300*300+1){
        if(dp[n][j] and sum-j<= j){
//            show(j);
//            show(dp[n][j]);
//            show(po*dp[n][j]%mod);
            fuga +=po * 3 % mod * dp[n][j] % mod;
            fuga %= mod;
            ans = (ans - po * 3 % mod * dp[n][j] % mod + mod ) % mod;
        }
        if(dp[n][j] and sum-j ==  j){
            show(j);
            show(dp2[n][j]);
            hoge += 3 *  dp2[n][j] % mod;
            hoge %= mod;
//            ans = (ans - 3*modpow(2, dp2[n][j]1) % mod + mod ) % mod;
        }
    }
    cout << (ans + hoge) % mod << endl;
}

Measured memory_bytes: 428544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a;
	set<int>s;
	for(int i=0;i<3;i++)
	{
		cin>>a;
		s.insert(a);
	}
	if(s.size()==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
    int N,A,B,S;
    cin >> N >> A >> B;
    S = 0;

    for(int i = 1;i < N + 1;i++){
        int X = i;
        int Y = 0;
        while(X > 0){
            Y += (X % 10);
            X /= 10;
        }
        if((Y > (A - 1)) && (Y < (B + 1))) S += i;
    }
    cout << S << endl;
    }

Measured memory_bytes: 256
n=int(input())
t_won=0
h_won=0
for _ in range(n):
    t_wd,h_wd = input().split()
    if   t_wd > h_wd: t_won += 1
    elif t_wd < h_wd: h_won += 1
print(t_won*3 + (n-t_won-h_won), h_won*3 + (n-t_won-h_won))


Measured memory_bytes: 5596
import math

def cin(): # To take limited number of inputs
	return map(int,input().split())

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # to print space seperated array
    for i in l:
        print(i,end=" ")

def calangle(h,m):
    hour_angle = 0.5 * (h * 60 + m) 
    minute_angle = 6 * m 
          
    # Find the difference between two angles 
    angle = abs(hour_angle - minute_angle) 
        
    # Return the smaller angle of two  
    # possible angles 
    angle = min(360 - angle, angle) 
        
    return angle 

def main():
    a,b,c,d = cin()
    ans = math.sqrt(a**2 + b**2  - 2*a*b*math.cos(calangle(c,d)*(math.pi/180)))
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9444
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn=200050;
int sum_x[maxn],sum_y[maxn];
int n,m;

void solve(){
	scanf("%d %d",&n,&m);
	ll res=(ll)(n-2)*(n-2);
	int cur_x=n-1,cur_y=n-1;
	for(int i=1;i<=n;i++)	sum_x[i]=n-2;
	for(int j=1;j<=n;j++)	sum_y[j]=n-2;
	for(int i=1;i<=m;i++){
		int op;
		scanf("%d",&op);
		if(op==1){
			int x;
			scanf("%d",&x);
			if(cur_x>=x){
				for(int i=cur_x;i>=x;i--){
					sum_x[i]=cur_y-1;
				}
				cur_x=x-1;
			}
			res-=sum_x[x];
			sum_x[x]=0;
		}
		else if(op==2){
			int y;
			scanf("%d",&y);
			if(cur_y>=y){
				for(int j=cur_y;j>=y;j--){
					sum_y[j]=cur_x-1;
				}
				cur_y=y-1;
			}
			res-=sum_y[y];
			sum_y[y]=0;
		}
	}
	printf("%lld\n",res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 5348
#include <iostream>

int main(){
   int M, D;
   std::cin >> M >> D;

   int ans = 0;
   for(int m=1; m<=M; ++m){
      for(int d=1; d<=D; ++d){
	 int d1 = d%10;
	 int d2 = d/10;
	 if(d1<2 || d2<2) continue;
	 if(d1*d2==m) ans++;
      }
   }
   std::cout << ans << std::endl;
   return 0;

}


Measured memory_bytes: 256
#include<vector>
#include<cstdio>
class Tree{
private:
    int numVertex;
    int *parent, *depth;
    std::vector<int> *child;
public:
    Tree(int v);
    ~Tree();
    void addEdge(int p,int c);
    void printData();
    void printData(int v);
    bool isRoot(int v);
    void computeDepth(int v);
    void computeDepth();
};
Tree::Tree(int v){
    numVertex=v;
    parent=new int[v];
    for(int i=0;i<v;i++)parent[i]=-1;
    depth=new int[v];
    for(int i=0;i<v;i++)depth[i]=-1;
    child=new std::vector<int>[v];
}
Tree::~Tree(){
    delete[] parent;
    delete[] child;
}
void Tree::addEdge(int p,int c){
    parent[c]=p;
    child[p].push_back(c);
}
bool Tree::isRoot(int v){
    return parent[v]==-1;
}
void Tree::computeDepth(){
    for(int i=0;i<numVertex;i++){
        if(isRoot(i))computeDepth(i);
    }
}
void Tree::computeDepth(int v){
    if(isRoot(v))depth[v]=0;
    for(auto itr=child[v].begin();itr!=child[v].end();itr++){
        depth[*itr]=depth[v]+1;
        computeDepth(*itr);
    }
}
void Tree::printData(int v){
    printf("node %d: ",v);
    printf("parent = %d, ",parent[v]);
    printf("depth = %d, ",depth[v]);
    if(parent[v]==-1)printf("root, ");
    else if(child[v].empty())printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(auto itr=child[v].begin(); itr!=child[v].end(); itr++){
        printf("%s%d",(itr==child[v].begin())?"":", ",*itr);
    }
    printf("]\n");
}
void Tree::printData(){
    for(int i=0;i<numVertex;i++)printData(i);
}
int main(){
    int n;
    scanf("%d",&n);
    Tree t(n);
    for(int i=0;i<n;i++){
        int id,k;
        scanf("%d%d",&id,&k);
        for(int j=0;j<k;j++){
            int c;
            scanf("%d",&c);
            t.addEdge(id,c);
        }
    }
    t.computeDepth();
    t.printData();
    return 0;
}


Measured memory_bytes: 6332
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
#define pb push_back
#define pii pair<int,int>
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
void solve() {
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int div=x/d;
    if(k<=div) {
        cout<<x-(k*d);
    }
    else {
        x-=(div*d);
        k-=div;
        x=x%d;
        if(k%2==0) cout<<x;
        else cout<<abs(x-d);
    }

}
int32_t main()
{
    fastio
    solve();   
    

    return 0;


}

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
using namespace std;
long long n,a,s;
int main()
{
	cin>>n;
	for(int i=sqrt(n);i>0;i--)
	{
		if(n%i==0)
		{
			a=n/i;
			break;
		}
	}
		while(a>0)
		{
			s++;
			a/=10;
		}
	cout<<s<<endl;;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
  int main(){
    int a,b,x,y,z;
    cin>>a>>b>>x>>y>>z;
    if(x-z >= 0 && x+z <= a && y-z >= 0 && y+z <= b)
cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3120
import sys,math
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False

def ddprint(x):
  if DBG:
    print(x)

def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

def divisorlist(z):
    if len(z)==1:
        return [z[0][0]**i for i in range(z[0][1]+1)]
    y = divisorlist(z[1:])
    s = []
    for i in range(z[0][1]+1):
        for j in y:
            s.append((z[0][0]**i)*j)
    return s

n,k = inm()
a = inl()
sm = sum(a)
zz = prime_division(sm)
z = divisorlist(zz)
z.sort(reverse=True)
ddprint(z)
for p in z:
    if p>sm+k:
        continue
    b = [ai%p for ai in a]
    b.sort()
    s = sum(b)
    m = s//p
    t = sum(b[:n-m])
    ddprint("p {} b {} s {} m {} t {}".format(p,b,s,m,t))
    if t<=k:
        print(p)
        exit()


Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

string s;
string t;

int main()
{
    cin>>s;
    cin>>t;
    int ans=0;
    for(int i=0; i<s.length(); i++){
        if (s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdio>
#define mst(a,b) memset(a,b,sizeof(a))
#define rev(x) reverse(x,x+strlen(x))
using namespace std;
const int inf=1<<29;
typedef long long ll;
int main()
{
    double r,g;
    scanf("%lf %lf",&r,&g);
    cout<<2*g-r<<endl;
    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int mojisu(char s[])
{
    int i = 0;
    while (s[i]){
        i++;
    }
    return i;
}
int main()
{
    char s[10000];
    int n;
    
    cin >> n;
    cin >> s;
    
    for (int i = 0;i < mojisu(s);i++){
        if (s[i]+n <= 'Z'){
            s[i] = s[i]+n;
        }
        else {
            s[i] = s[i]+n-'Z'+'A'-1;
        }
    }
    cout << s << endl;
}
        



Measured memory_bytes: 256
#include<stdio.h>
#define swap(a,b) a^b,b^a,a^b
typedef struct{int Parent,Rank;}UnionFind;
UnionFind uft[100000];
int Root(int x){return(uft[x].Parent!=x)?uft[x].Parent=Root(uft[x].Parent):x;}
int Unite(int x,int y)
{
  x=Root(x),y=Root(y);
  if(x!=y)
  {
    if(uft[x].Rank!=uft[y].Rank)swap(x,y);
    uft[y].Parent=x;
    uft[x].Rank+=uft[y].Rank;
  }
  return x!=y;
}
int Size(int x){return uft[Root(x)].Rank;}
int Belong(int x,int y){return Root(x)==Root(y);}
int main(void)
{
  int A,B,C,D,N,M,K,i,j,known[100000]={0};
  j=scanf("%d %d %d",&N,&M,&K);
  for(i=0;i<N;i++){uft[i].Parent=i;uft[i].Rank=1;}
  while(M--)
  {
    j=scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B);
  }
  while(K--)
  {
    j=scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D))known[C]++,known[D]++;
  }
  for(i=0;i<N;i++){printf("%d ",Size(i)-known[i]-1);}
  return printf("\n"),0;
}

Measured memory_bytes: 2560
while 1:
    n, x = map(int, raw_input().split())
    if n == 0: break
    count = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if i+1 + j+1 + k+1 == x:
                    count += 1
    print count

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

int main(){
	int N;
	cin >> N;
	string S[N+1];
	int P[N+1];
	set<string> city;
	set<int> b;
	rep(i,N) {
		cin >> S[i+1] >> P[i+1];
		city.insert(S[i+1]);
		b.insert(100-P[i+1]);
	}

	for (string s: city) {
		for (int bp: b) {
			for (int i = 1; i <= N; i++) {
				if (s==S[i]  && bp==100-P[i]) cout << i << endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main()
{
   int a , b ,c ,i ,ans;
   cin >> a >> b >> c;
   ans = 0;
   for ( i = a ; i <= b ; i ++ )
   {
        if (c % i == 0)
        ans ++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  int cnt = 0;
  while(true)
  {
    int s = 0;
    for (int i = 0; i < N; i++)
    {
      if(vec[i] > 0)
      {
        s=1;
        vec[i]--;
      }
      else if(s == 1 && vec[i] == 0)break;
    }
    if(s == 0)break;
    
    cnt++;
  }
  cout<<cnt<<endl;
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

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

			for (int lp = 0; lp < dataCount; lp++)
			{
				int[] ballNumber = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

				int cylinderA = 0;
				int cylinderB = 0;

				bool isAccept = true;

				for (int index = 0; index < ballNumber.Length; index++)
				{
					int item = ballNumber[index];

					//A < B
					if (cylinderA < cylinderB)
					{
						//B???A???not
						//B
						if (cylinderB < item)
						{
							cylinderB = item;
						}
						//A
						else if (cylinderA < item)
						{
							cylinderA = item;
						}
						//can not
						else
						{
							isAccept = false;
							break;
						}
					}
					//A > B
					else
					{
						//A???B???not
						//A
						if (cylinderA < item)
						{
							cylinderA = item;
						}
						//B
						else if (cylinderB < item)
						{
							cylinderB = item;
						}
						//can not
						else
						{
							isAccept = false;
							break;
						}
					}
				}

				if (isAccept)
					Console.WriteLine ("YES");
				else
					Console.WriteLine ("NO");
			}
		}
	}
}

Measured memory_bytes: 9256
#B
n, m = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
total = sum(a)
th = 1 / (4 * m) * total
import numpy as np
A = np.array(a)
A_sorted = A.argsort()[::-1]
# 上からM個選ぶ
if A[A_sorted[m - 1]] < th:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 27144
def main():
    n = int(input())
    b = list(map(int, input().split()))
    a = []

    for i in range(n):
        if i == 0:
            a.append(b[0])
        elif i == n-1:
            a.append(b[n-2])
        else:
            a.append(min(b[i-1], b[i]))

    print(sum(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ulli;
typedef long long int lli;
#define pb(a) push_back(a)
#define pbb(a) pop_back(a)  
#define ph(a) push_heap(a.begin(), a.end())
#define pph(a) pop_heap(a.begin(), a.end())
#define si set<int>
#define sl set<long>
#define sc set<char>
#define pii pair<int, int>
#define pll pair<long, long>
#define pdd pair<double, double>
#define TC(t) while(t--)
#define FORA(a,b,c) for ((a) == (b); (a) < (c); (a) ++)
#define FORB(a,b,c) for ((a) == (b); (a) <= (c); (a) ++)
#define FORC(a,b) for ((a) == (b); (a) > 0; (a)--)
#define FORD(a,b) for ((a) == (b); (a) >= 0; (a)--)                         
#define WM(a) while(a--)
#define WP(a) while(a++)
#define print(data) cout << data << endl
#define tin(a) cin >> a
#define ttin(a,b) cin >> a >> b
#define tttin(a,b,c) cin >> a >> b >> c
#define maxheap(a) make_heap(a.begin(),a.end())
#define fixp(a)  cout << fixed << setprecision(a);
#define RM(a,n) a.erase(remopricee(a.begin(), a.end(), n),a.end())
#define MOD 1000000007
ll prime[] = {2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47};
inline int gmx (int a, int b){
	return a > b ? a : b;
}
inline int gmm (int a, int b){
	return a < b ? a : b;
}
inline ll get_gcd(ll a, ll b){
    ll rem = 0;
    while( b != 0){
        rem = a % b;
        a = b; 
        b = rem;
    }
    return a;   
}
ll fastexp (ll base, ll exp){
	ll res = 1;
	if (exp == 0) return 1LL;
	while(exp){
		if(exp&1) res = (res*base)%MOD;
		res = (res+MOD)%MOD;
		base = (base*base)%MOD;
		base = (base+MOD)%MOD;
		exp >>= 1;
	}
	return (ll)res;
}
struct compare {
    bool operator()(const std::string& first, const std::string& second) {
        return first.size() < second.size();
    }
};
void Verdict_Check(){
	ifstream A("my_output.txt");
	ifstream B("code_output.txt");
	
	int c1=0,c2=0;
	bool WA = false;
	string str;
	while(getline(A,str)){
		c1++;
	}
	while(getline(B,str)){
		c2++;
	}
	A.close();
	B.close();
	ifstream AA("my_output.txt");
	ifstream BB("code_output.txt");
	if (c1 != c2){
		WA = true;
	}else{
		string s,ss;
		while(getline(AA,s) && getline(BB,ss)){
			if(s != ss){
				WA = true;
			}
		}
	}
	if (WA){
		cout << "Wrong answer!!!" << endl;
	}else{
		cout << "All test cases are passed!!!" << endl;
	}
	AA.close();
	BB.close();
}
int main(){
	
	//freopen("a.in","r",stdin);
	//freopen("my_output.txt","a", stdout);
	clock_t tStart = clock();
	char s[5];
	scanf("%s",s);
	if(s[0] == s[1] && s[1] == s[2]) puts("Yes");
	else if (s[1] == s[2] && s[2] == s[3]) puts("Yes");
	else puts("No");
	//freopen("CON", "w", stdout);
	//Verdict_Check();
	// printf("Time taken: %.7fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w,a,b;
    cin>>w>>a>>b;
    if((b>=a&&b<=a+w)||(a>=b&&a<=b+w))
        cout<<0;
    else if(a>b+w)
        cout<<a-(b+w);
    else
        cout<<b-(a+w);
    return 0;
}


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

int ans = 0;
int n, m, q;
vector<int> a, b, c, d;
void test(vector<int> x){
  if(x.size() == n){
  	int pts = 0;
    for(int i = 0; i < q; ++i){
      if(x[b[i]]-x[a[i]] == c[i]) pts += d[i]; 
    }
    ans = max(ans, pts);
    return;
  }
  int ans = 0;
  for(int i = x.back(); i <= m; ++i){
    vector<int> y(x);
    y.emplace_back(i);
  	test(y);
  }
  
}


int main(){
  
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  
  for(int i = 0; i < q; ++i){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --b[i]; 
  }
  test(vector<int>{1});
  cout << ans << '\n';
  
  
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long   int n,a,arr[1000],ans,d;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(i==0){ans=a;}
     else   {

d=__gcd(a,ans);
ans=ans*(a/d);
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;

int main()
{
  std::cin >> N;

  printf( "%.12f\n", double(N-N/2)/N );

  return 0;
}

Measured memory_bytes: 888
n,m = map(int,input().split())
prefs= [[]for _ in range(n)]

for i in range(m):
    p,y = map(int,input().split())
    prefs[p-1].append((y,i))
for pref in prefs:
    pref.sort()

answers = []
for pn,pref in enumerate(prefs):
    for cn,city in enumerate(pref):
        L = str(pn+1).zfill(6)
        R = str(cn+1).zfill(6)
        i = city[1]
        id_number = L+ R
        answers.append((i,id_number))
answers.sort()
for i,id_number in answers:
    print(id_number)

Measured memory_bytes: 42324
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;


vi last_used;

void update_add(int x, int ind) {
  rep (i, 20) {
    if (((x >> i) & 1) == 1) {
      last_used[i] = ind;
    }
  }
}

void update_remove(int ind) {
  rep (i, 20) {
    if (last_used[i] < ind) {
      last_used[i] = -1;
    }
  }
}

int last_used_index(int x) {
  int ret = -1;
  rep (i, 20) {
    if (((x >> i) & 1) == 1) {
      ret = max(ret, last_used[i]);
    }
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  last_used.assign(20, -1);
  int start = 0;
  update_add(a[0], 0);
  ll cnt = 1;
  FOR (finish, 1, n) {
    int lui = last_used_index(a[finish]);
    if (lui >= 0) {
      start = lui + 1;
      update_remove(start);
    }
    cnt += (finish - start + 1);
    update_add(a[finish], finish);
  }
  printf("%lld\n", cnt);
    
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

void solve(){
	string s;
	while(getline(cin,s)&&s!="."){
		stack<char> sk;
		bool ok=true;
		for(int i=0;i<s.size();i++){
			if(s[i]=='(')sk.push('(');
			else if(s[i]=='[')sk.push('[');
			else if(s[i]==')'){
				if(sk.size()&&sk.top()=='('){
					sk.pop();
				}
				else{
					ok=false;
					break;
				}
			}
			else if(s[i]==']'){
				if(sk.size()&&sk.top()=='['){
					sk.pop();
				}
				else{
					ok=false;
					break;
				}
			}
		}
		if(ok&&sk.size()==0)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}

int main(){

	solve();

	return 0;
}

Measured memory_bytes: 904
import sys
from math import gcd
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
    nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
    print('not coprime')
    exit()

# osa_k法で前処理
MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
while p * p <= MAXN:
    # まだチェックされていないなら
    if sieve[p] == p:
        # 次のqの倍数からp刻みでチェック入れていく
        for q in range(2 * p, MAXN + 1, p):
            if sieve[q] == q:
                sieve[q] = p
    p += 1

check = set()
for a in A:
    tmp = set()
    while (a > 1):
        tmp.add(sieve[a])
        a //= sieve[a]
    for p in tmp:
        if p in check:
            print('setwise coprime')
            exit()
        check.add(p)
print('pairwise coprime')


Measured memory_bytes: 134420
// C. Synthetic Kadomatsu - C++.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>



using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

template <class T>
void chmin(T& ans, const T& b)
{
	if (ans > b) {
		ans = b;
	}
}

constexpr int BIG = std::numeric_limits<int>::max();

int dfs(const int N, const vec& L, int nowIdx, const int A, const int B, const int C, int a, int b, int c, int nowcost)
{
	if (N == nowIdx) {
		if (min({ a,b,c }) == 0) return BIG;
		else return abs(A - a) + abs(B - b) + abs(C - c) + nowcost - 30;
	}

	int ans = BIG;
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b, c, nowcost));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a+L[nowIdx], b, c, nowcost+10));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b+L[nowIdx], c, nowcost+10));
	chmin(ans, dfs(N, L, nowIdx + 1, A, B, C, a, b, c+L[nowIdx], nowcost+10));
	return ans;
}

int main()
{
	lolo N, A, B, C;
	cin >> N >> A >> B >> C;
	vec L(N);
	FOR(i, N) cin >> L[i];
	cout << dfs(N, L, 0, A, B, C, 0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue
import itertools

n,k = map(int, input().split())
p = 1
for i in range(0, 114514):
	if p <= n:
		p *= k
	else:
		print(i)
		break


Measured memory_bytes: 13664
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	N := readInt64()

	for h := int64(1); h <= 3500; h++ {
		for n := int64(1); n <= 3500; n++ {
			v := N * h * n
			u := 4*h*n - N*n - N*h
			if u <= 0 {
				continue
			}
			if v%u == 0 {
				w := v / u
				if w > 3500 {
					continue
				}
				println(h, n, w)
				return
			}
		}
	}

}

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


Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong();
        long k=sc.nextLong();
        long d=sc.nextLong();
        
        x=Math.abs(x);
        long q=k-(x/d);
        long p=x%d;
        if(q<0)
        {
        	System.out.println((x-(k*d)));
        	System.exit(0);
        }
        else
        {
        	if(q%2==1)
        		System.out.println(Math.min(Math.abs(p-d),Math.abs(p+d)));
        	else
        		System.out.println(p);
        }
        
	}

}


Measured memory_bytes: 35588
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
        int n;
        cin >> n;
        int count[n][26] = {{0}};
        for(int i = 0; i < n; i++){
                string s;
                cin >> s;
                for(int j = 0; j < s.length(); j++){
                        count[i][s[j]-(int)'a']++;
                }
        }
        for(int i = 1; i < n; ++i){
                for(int j = 0; j < 26; ++j){
                        if(count[i][j] < count[0][j]){
                                count[0][j] = count[i][j];
                        }
                }
        }
        for(int i = 0; i < 26; i++){
                for(int j = 0; j < count[0][i]; j++){
                        cout<<(char)((int)'a'+i);
                }
        }
        cout<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int gusu = 0, kisu = 0;
	int i;
	int kotae = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		if (A % 2 == 0) gusu++; else kisu++;
	}
	if (kisu == 0 || gusu == 0) {
		puts("0");
	} else {
		kotae += (kisu - 1) / 2;
		gusu += (kisu - 1) / 2;
		kotae += gusu;
		printf("%d\n", kotae);
	}
	return 0;
}



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

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define si(c) ((int)(c).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()

typedef vector<int> vi;

const int 
    MAXN = 25,
    MAXM = MAXN*(MAXN-1)/2; 

int n,m,d[MAXM], cnt[500];

vi pos;

bool viable(int p) {
    for (int pi : pos) {
        int d = abs(pi-p);
        if (!cnt[d]) return false;
    }
    return true;
}

void put(int p) {
    for (int pi : pos) {
        int d = abs(pi-p);
        cnt[d]--;
    }
    pos.pb(p);
}

void take() {
    int p = pos.back(); pos.pop_back();
    for (int pi : pos) {
        int d = abs(pi-p);
        cnt[d]++;
    }
}

set<vi> res;
void go(int from) {
    //cerr << from << endl;
    if (from == m) {
        vi cand = pos;
        sort(all(cand));
        vi d; forn(i,n-1) d.pb(cand[i+1] - cand[i]);
        res.insert(d);

        reverse(all(cand));
        d.clear(); forn(i,n-1) d.pb(cand[i] - cand[i+1]);
        res.insert(d);
        return;
    }

    if(cnt[d[from]] == 0) go(from+1);

    int p = pos[0] + d[from];
    if (viable(p)) { put(p); go(from+1); take(); }
    if (si(pos) > 1) {
        p = pos[1] - d[from];
        if (viable(p)) { put(p); go(from+1); take(); }
    }
}

void init() {
    fill_n(cnt,500,0);
    res.clear();
    pos.clear();
}

int main(int argc, const char *argv[])
{
    ios_base::sync_with_stdio(false);
    while (cin >> n && n) {
        init();
        m = n*(n-1)/2;
        forn(i,m) {
            cin >> d[i];
            cnt[d[i]]++;
        }
        
        pos.pb(0);
        go(0);
        for (auto &row : res) {
            forn(i,si(row)) {
                if (i) cout << ' ';
                cout << row[i];
            }
            cout << endl;
        }
        cout << "-----" << endl;
    }
    return 0;
}

Measured memory_bytes: 1252