akhauriyash/Code-Regression huggingface dataset:
/*input
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................


*/
#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;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll h,w;char g[1001][1001];
ll dpt[1001][1001];
ll mod=1000000007;
ll dp(ll i,ll j){
	if(g[i][j]=='#')
		return 0;
	// cout<<i<<' '<<j<<endl;
	if(i==h && j==w){
		dpt[i][j]=1;
	}
	else if(i==h){
		dpt[i][j]=dp(i,j+1)%mod;
	}
	else if(j==w){
		dpt[i][j]=dp(i+1,j)%mod;
	}
	if(dpt[i][j]!=-1){
		return dpt[i][j];
	}
	
	dpt[i][j]=(dp(i+1,j)%mod+dp(i,j+1)%mod)%mod;
	return dpt[i][j]%mod;
}
int main(){
	IOS
	cin>>h>>w;
	string s;
	memset(dpt,-1,sizeof(dpt));
	for(int i=1;i<=h;++i){
		cin>>s;
		for(int j=1;j<=w;++j){
			g[i][j]=s[j-1];
			if(g[i][j]=='#'){
				dpt[i][j]=0;
			}
		}
	}

	cout<<dp(1,1)<<endl;

	return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
int main(){
int i, j, n, r, p, c, A[52], B[52];
	while(1){
		scanf("%d %d",&n ,&r);
		if( n == 0 && r == 0 ){ break; }
		for(i=n ; i>0 ; i--){
		A[n-i]=i;
		B[n-i]=i;
		}
		for( i=0 ; i < r ; i++ ){
			scanf("%d %d",&p,&c);
			for( j = 0 ; j < p-1 ; j++) B[j+c]=A[j];
			for( j = p-1 ; j < p-1+c ; j++) B[j-(p-1)]=A[j];
			for( j = 0 ; j < n ; j++ ) A[j]=B[j];
		}
		printf("%d\n",B[0]);
	}
return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) return a.first > b.first;
    return a.second < b.second;
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> p(n);
        for (int &pi: p) cin >> pi;
        vector<pair<int, int>> cur(50001, {-INF, INF}), nxt(cur);
        cur[0] = {0, 0};
        int rest_ma = 0;
        for (int pi: p) {
            int mod = pi % 1000;
            if (1 <= mod && mod <= 500) {
                int rev = 1000 - mod - 500;
                rest_ma += rev;
                for (int rest = rest_ma; rest >= rev; rest--) {
                    nxt[rest] = min(nxt[rest], {
                        cur[rest - rev].first + 1, cur[rest - rev].second + pi
                    }, cmp);
                }
            } else {
                int rev = (1000 - mod) % 1000;
                int need = (mod + 500) % 1000;
                rest_ma += max(rev, need);
                for (int rest = 0; rest <= rest_ma; rest++) {
                    nxt[rest] = cur[rest];
                }
                for (int rest = rest_ma; rest >= rev; rest--) {
                    nxt[rest] = min(nxt[rest], {
                        cur[rest - rev].first, cur[rest - rev].second + pi
                    }, cmp);
                }
                for (int rest = need; rest <= rest_ma; rest++) {
                    nxt[rest - need] = min(nxt[rest - need], {
                        cur[rest].first + 1, cur[rest].second + pi
                    }, cmp);
                }
            }
            swap(cur, nxt);
        }
        auto res_p = *min_element(cur.begin(), cur.end(), cmp);
        cout << res_p.first << " " << res_p.second << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    ll arr[n],aux[n+5];
    aux[0]=1;
    for(int i=1;i<n+5;i++) aux[i]=(aux[i-1]*2)%mod;
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x=n-i-1;
        x=((x+2)*aux[x])%mod;
        x=(x*aux[i])%mod;
        x=(x*arr[i])%mod;
        ans=(ans+x)%mod;
    }
    cout<<(aux[n-1]*ans)%mod<<endl;
}

Measured memory_bytes: 3328
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B = map(int, readline().split())

    if A * N < B:
        print(A * N)
    else:
        print(B)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
bool is(string s) {
	string ss=s;
	reverse(s.begin(),s.end());
	if(ss==s) return 1;
	else return 0;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	if(is(s)&&is(s.substr(0,(n-1)/2))&&is(s.substr((n+3)/2-1))) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,d;
  int ans;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  if(a>=b){
    if(c>=d)
      ans=b+d;
    else if(d>c)
      ans=b+c;
  }
  else if(b>a){
    if(c>=d)
      ans=a+d;
    else if(d>c)
      ans=a+c;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 1e3 + 5;
const int mod = 1e9 + 7;
int n, m, k;
int a[N];
ll ans, sum[N], s[N * N];
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			s[++m] = sum[j] - sum[i - 1];
		}
	}
	sort(s + 1, s + 1 + m);
	reverse(s + 1, s + 1 + m);
	vector<ll> v;
	for (int i = 1; i <= m; ++i) v.push_back(s[i]);
	for (int i = 60; i >= 0; --i) {
		int cnt = 0;
		for (ll j: v) {
			if (j >> i & 1) 
				++cnt;
		}
		if (cnt >= k) {
			ans += 1ll << i;
			vector<ll> tmp;
			for (ll j: v) {
				if (j >> i & 1) 
					tmp.push_back(j);
			}
			v = tmp;
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 10608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

struct Data {
	string str;
	int w;
	Data() {}
	Data(string str, int w) : str(str), w(w) {}
};

bool done[30][600000];

int main() {
	int W;
	cin >> W;
	
	vector<int> table;
	int tmp = 1;
	table.push_back(tmp);
	while (tmp <= W) {
		tmp *= 3;
		table.push_back(tmp);
	}
	
	queue<Data> que;
	que.push(Data("", 0));
	
	while (!que.empty()) {
		Data now = que.front(); que.pop();
		
		string str = now.str;
		int w = now.w;
		int len = str.size();
		
		if (w == W) {
			reverse(str.begin(), str.end());
			cout << str << endl;
			break;
		}
		
		if (w + 300000 >= 600000 || w + 300000 < 0) continue;
		if (done[len][w + 300000]) continue;
		done[len][w + 300000] = true;
		
		if (len >= table.size()) continue;
		que.push(Data(str + "+", w + table[len]));
		que.push(Data(str + "-", w - table[len]));
		que.push(Data(str + "0", w));
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a,b,c,d;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    if (a + b + c + d == 7){
        cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
    }else if (a + b + c - d == 7){
        cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
    }else if (a + b - c + d == 7){
        cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
    }else if (a + b - c - d == 7){
        cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
    }else if (a - b + c + d == 7){
        cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
    }else if (a - b + c - d == 7){
        cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
    }else if (a - b - c + d == 7){
        cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
    }else if (a - b - c - d == 7){
        cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
    }
    return 0;
}

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

int main()
{
    ll r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;

    rep(i, n+1){
        rep(j, n+1){
            ll r_num = i;
            ll g_num = j;
            ll b_num = (n - r_num*r - g_num*g) / b;
            ll b_mod = (n - r_num*r - g_num*g) % b;
            if (b_mod == 0 && b_num >= 0 && b_num <= 3000){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n;
map<int, int> h;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        h[x]++;
    }

    LL res = 0;
    for(auto it = h.begin(); it != h.end(); it++)
        if(it->second >= it->first) res += it->second - it->first;
        else res += it->second;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	double A, B;
	cin >> A >> B;
	cout <<fixed<<setprecision(20)<< A * B / (A + B) << endl;
}

Measured memory_bytes: 256
// AOJ ALDS1_11_B Depth First Search
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_V 102
int  d[MAX_V], f[MAX_V];
int  hi[MAX_V], *to[MAX_V];
char mk[MAX_V];
int  tm;

void dfs(int u)
{
	int i, v;

	d[u] = tm++;
	mk[u] = 1;
	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (!mk[v]) dfs(v);
	}
	f[u] = tm++;
}

int main()
{
	int n, i, j, k, u;

	n = in();
	for (i = 0; i < n; i++) {
		u = in()-1;
		hi[u] = k = in();
		to[u] = malloc(k<<2);
		for (j = 0; j < k; j++) to[u][j] = in()-1;
	}

	tm = 1;
	for (i = 0; i < n; i++) if (mk[i] == 0) dfs(i);
	for (i = 0; i < n; i++) printf("%d %d %d\n", i+1, d[i], f[i]);
	return 0;
}


Measured memory_bytes: 2072
p = 998244353
N = (10 ** 5)*2 +10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def chng2(n): #10進数nを2進数に変換(配列)
    ans = list(bin(n))
    return ans

def pwr(n,k): #nのk乗高速版 n^k
    memo = chng2(k)
    lng = len(memo)

    li = [0 for i in range(lng-1)]
    li[0] = 1
    
    a = n
    ans = 1
    for i in range(1,lng-1):
        li[i] = a%p
        a *= a
        a %= p
 
    for i in range(1,lng-1):
        if memo[-i]=='1':
            ans *= li[i]
            ans %= p

    return ans



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

ans = 0
for k in range(K+1):
    memo1 = cmb(N-1,k,p)
    memo2 = pwr(M-1,N-k-1)*M
    ans += memo1*memo2
    ans %= p
    # print(k,memo1,memo2)
# print((100*(99**99))%p)
print(ans)


Measured memory_bytes: 32836
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 5e5+5;
const int mod = 1e9+7;
using namespace std;

int block, curl, curr, res;
struct qry {
	int id, l, r;
} q[maxn];
int ans[maxn], a[maxn], mp[maxn];

void add(int pos) {
	if (mp[a[pos]]==0) {
		res++;
		mp[a[pos]]=1;
	} else {
		mp[a[pos]]++;
	}
}

void del(int pos) {
	if (mp[a[pos]]-1==0) {
		mp[a[pos]]=0;
		res--;
	} else {
		mp[a[pos]]--;
	}
}

void solve() {
	ll n,m; cin >> n >> m;
	block = sqrt(n);
	rep(i,1,n+1) cin >> a[i];
	rep(i,1,m+1) cin >> q[i].l >> q[i].r, q[i].id=i;
	sort(q+1, q+m+1, [](qry x, qry y) {
		if (x.l/block == y.l/block)
			return x.r < y.r;
		return x.l/block < y.l/block;
	});
	curl = curr = res = 0;
	for (int i=1; i<=m; i++) {
		while(curr > q[i].r)
			del(curr--);
		while(curr < q[i].r)
			add(++curr);
		while(curl > q[i].l)
			add(--curl);
		while(curl < q[i].l)
			del(curl++);
		ans[q[i].id]=res;
	}
	for(int i=1; i<=m; i++) 
		cout << ans[i] << '\n';
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

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

    return 0;
}

Measured memory_bytes: 15460
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

// #include "competitive_helper.cpp"

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

vector<int> edges[100010];
int dep[100010], fa[100010], link[100010];
int n, posT, posA;
int x, y;

void dfs(int u, int _f, int _d) {
    fa[u] = _f;
    dep[u] = _d;
    link[u] = 0;
    for (int v: edges[u]) {
        if (!dep[v]) {
            dfs(v, u, _d + 1);
            link[u] = max(link[u], link[v] + 1);
        }
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    cin >> n >> posT >> posA;
    for (int i = 0; i < n - 1; ++i) {
        cin >> x >> y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    dfs(posA, -1, 1);
    int ans = 0;
    int curT = posT;
    int step = -1;
    while (curT != posA) {
        ++step;
        if (dep[curT] - dep[posA] <= step) {
            break;
        }
        // int finalT = dep[curT] + link[curT];
        // int finalA = dep[posA] + step + link[curT];
        ans = max(ans, link[curT] + dep[curT] - dep[posA] - 1);
        curT = fa[curT];
    }
    cout << ans << endl;
    return 0;
}


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

r = n % 27
if r == 13 or r == 26:
    print(':(')
elif r ==0:
    x = int(100*n/108)
    print(x)
else:
    for i in range(1, 25):
        if 1.08*(i-1) < r <= 1.08*i:
            break
    x = int(100*(n - i)/108) + i
    print(x)

Measured memory_bytes: 9120
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if(a<b && b<c) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

void solve(){
	int k,a,b;
	cin>>k>>a>>b;
	int low=a/k;
	for(int i=low*k;true;i+=k){
		if(i>=a and i<=b){
			cout<<"OK\n";
			return;
		}
		if(i>b){
			cout<<"NG\n";
			return ;
		}
	}
	return;
}

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

    #ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t=1;
	//cin>>t;

	while(t--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 3652
def II(): return int(input())
def MI(): return map(int,input().split())
def LMI(): return list(map(int,input().split()))
def LIIN(n): return list(int(input()) for _ in range(n))
def LMIN(n): return [list(map(int, input().split())) for _ in range(n)]
def IS(): return input()
def MS(): return map(str,input().split())
def LMS(): return list(map(str,input().split()))
def LISN(n): return list(input() for _ in range(n))
def LMSN(n): return [input().split() for _ in range(n)]
MOD = 10**9+7
INF = 10**18

def main():
    a,b = MI()
    print(1+(b-a+(a-1)-1)//(a-1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
a,b,c = map(int,input().split())
sum = 0

for x in range(a+1):
    keta = 0
    x_str = str(x)
    
    for y in range(len(x_str)):
        keta += int(x_str[y:y+1])
    
    if keta >= b and keta <= c:
        sum += x

print(sum)


Measured memory_bytes: 2940
from collections import defaultdict

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

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        x -= 1
        L[i].append((x, y))

ans = 0
for s in range(1 << N):
    honest = 0
    D = defaultdict(list)
    for i in range(N):
        if s >> i & 1:
            honest += 1
            D[i].append(1)
            for x, y in L[i]:
                D[x].append(y)

    mujun = False
    for k, v in D.items():
        if len(set(v)) != 1:
            mujun = True
        if s >> k & 1:
            if v[0] == 0:
                mujun = True
        else:
            if v[0] == 1:
                mujun = True

    if not mujun:
        ans = max(ans, honest)

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
    int a , b, c;
    cin >> a >> b >> c;
    int mp[3][3];
    mp[0][0] = a;
    mp[0][1] = b;
    mp[1][1] = c;
    mp[0][2] = c*3 - a - b;
    mp[2][2] = c*3 - a - c;
    mp[2][1] = c*3 - b - c;
    mp[2][0] = c*3 - mp[0][2] - c;
    mp[1][2] = c*3 - mp[0][2] - mp[2][2];
    mp[1][0] = c*3 - c - mp[1][2];
    rep(i, 3){
        rep(j, 3){
            cout << mp[i][j];
            if(j != 2)cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
 
using namespace std;
constexpr int64_t INF = 1000000000000010;
 
int64_t Func(int64_t n){
    int64_t sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
 
int main(){
    int64_t K;
    cin >> K;
 
    for(int i = 1; i <= min(9, int(K)); ++i){
        cout << i << endl;
    }
    K -= 9;
    int64_t num = 10;
    int64_t plus = 1;
    while(K > 0){
        int64_t ans = num + plus;
        for(int64_t i = 2; i <= 1000; ++i){
            int64_t po = num + i * plus;
            if(po * Func(ans) <= ans * Func(po)){
                ans = po;
            }
        }
        cout << ans << endl;
        while(plus <= ans / 10000){
            plus *= 10;
        }
        num = ans;
        --K;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vector<vector<pair<int,double>>> g;
	public:
	vd DIJ(int s){
		priority_queue<pair<double,int>> q;
		vd d(n,inf);
		d[s]=0;
		q.push(make_pair(0,s));
		while(!q.empty()){
			auto p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first;
				double D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vector<vector<pair<int,double>>>(v);
	}
	void add_edge(int s,int t,double c){
//		cout<<s<<' '<<t<<' '<<syosu(9)<<c<<endl;
		g[s].push_back(make_pair(t,c));
	}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		string a,b,c;
		cin>>a;
		if(a=="0") break;
		cin>>b>>c;
		int n=a.size();
		vi dp(3);
		dp[0]++;
		for(int i=0;i<n;i++){
			vi DP(3);
			for(int j=0;j<10;j++) for(int k=0;k<10;k++) for(int l=0;l<10;l++){
				if(a[i]!='?'&&a[i]-'0'!=j) continue;
				if(b[i]!='?'&&b[i]-'0'!=k) continue;
				if(c[i]!='?'&&c[i]-'0'!=l) continue;
				if(i==0&&j==0) continue;
				if(i==0&&k==0) continue;
				if(i==0&&l==0) continue;
				for(int I=0;I<3;I++){
					int t=10*I+l-j-k;
					if(0<=t&&t<3) (DP[t]+=dp[I])%=mod;
				}
			}
			dp=DP;
		}
		cout<<dp[0]<<endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, k, x, y;

int main(){
	cin >> n >> k >> x >> y;
	if (n <= k){
		cout << x*n << endl;
	}
	else{
		cout << x*k + y*(n - k) << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    ans=sum(B)
    for i in range(N-1):
        if A[i+1]==A[i]+1: ans+=C[A[i]-1]
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,flag=0,cnt=0; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    while(1){
        rep(i,n){
            if(a[i]%2!=0) flag++;
            a[i]=a[i]/2;
        }
        if(flag!=0) break;
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3624
import heapq;

n, u, v = [int(v) for v in input().split()]

vert = []

for i in range(n):
    vert.append([])

for i in range(n - 1):
    a, b = [int(v) - 1 for v in input().split()]
    vert[a].append(b)
    vert[b].append(a)

taka = u-1
aoki = v-1

if taka == aoki:
    print(0)
    exit()

q = [(0, aoki)]
aoki_dist = [-1] * n
aoki_dist[aoki] = 0

index = 0
while index < len(q):
    c0, i = q[index]
    c = c0 + 1
    for l in vert[i]:
        if aoki_dist[l] >= 0:
            continue
        aoki_dist[l] = c
        q.append((c, l))
    index += 1

q = [(0, taka)]
max_dist = aoki_dist[taka]
aoki_dist[taka] = -1

index = 0
while index < len(q):
    c0, i = q[index]
    c = c0 + 1
    for l in vert[i]:
        if aoki_dist[l] < 0:
            continue
        if c >= aoki_dist[l]:
            continue
        if max_dist < aoki_dist[l]:
            max_dist = aoki_dist[l]
        aoki_dist[l] = -1
        q.append((c, l))
    index += 1

print(max_dist - 1)



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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    int g = r - l + 1;
    sum += g;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<time.h>
using namespace std;

struct Dice{
    int s[6];
    void move(char c){
        int tmp;
        if(c=='N'){
            tmp=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=tmp;
        }
        else if(c=='S'){
            tmp=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=tmp;
        }
        else if(c=='E'){
            tmp=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=tmp;
        }
        else if(c=='W'){
            tmp=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=tmp;
        }
        else if(c=='R'){
            tmp=s[1];
            s[1]=s[2];
            s[2]=s[4];
            s[4]=s[3];
            s[3]=tmp;
        }
    }
    int get_top(){
        return s[0];
    }
    int get_right(){
        return s[2];
    }
};

bool same(Dice a,Dice b){
    for(int i=0;i<6;i++){
        if(a.s[i]!=b.s[i])return false;
    }
    return true;
}

int main(){
    Dice d1,d2;
    for(int i=0;i<6;i++)cin>>d1.s[i];
    for(int j=0;j<6;j++)cin>>d2.s[j];
    bool flag=false;
    
    for(int i=0;i<4;i++){
        d2.move('R');
        for(int j=0;j<4;j++){
            d2.move('N');
            if(same(d1,d2))flag=true;
        }
    }
    d2.move('E');
    for(int i=0;i<4;i++){
        d2.move('N');
        if(same(d1,d2))flag=true;
    }
    d2.move('W');
    d2.move('W');
    for(int i=0;i<4;i++){
        d2.move('N');
        if(same(d1,d2))flag=true;
    }
    cout<<(flag?"Yes":"No")<<endl;

    return 0;
}


Measured memory_bytes: 3116
// Last Change: 04/14/2019 00:35:49.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

class Movement {
public:
  int xn, yn, xp, yp;
  Movement(int a, int b, int c, int d) {
    xp = a;
    yp = b;
    xn = c;
    yn = d;
  }
};

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<ll>> a(H, vector<ll>(W));
  for (int x = 0; x < H; ++x) {
    for (int y = 0; y < W; ++y) {
      cin >> a[x][y];
    }
  }

  vector<Movement> ans;
  queue<pair<int, int>> route;
  for (int x = 0; x < H; ++x) {
    if (x % 2 == 0) {
      for (int y = 0; y < W; ++y) {
        route.push(make_pair(x, y));
      }
    } else {
      for (int y = W - 1; y >= 0; --y) {
        route.push(make_pair(x, y));
      }
    }
  }

  int cal = 0;
  while (route.size() > 1) {
    pair<int, int> cur = route.front();
    route.pop();
    if ((a[cur.first][cur.second] + cal) % 2 == 1) {
      ans.push_back(Movement(cur.first, cur.second, route.front().first,
                             route.front().second));
      cal = 1;
    } else {
      cal = 0;
    }
  }

  cout << ans.size() << endl;
  for (auto &&e : ans) {
    cout << e.xp + 1 << ' ' << e.yp + 1 << ' ' << e.xn + 1 << ' ' << e.yn + 1
         << endl;
  }

  //NS::LoopUntilZeroInpput();
}


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

ll nC2(ll n){
    return n*(n-1)/2;
}

int main(void){
    int n, m;
    cin >> n >> m;
    cout << (nC2(n) + nC2(m)) << endl;
    return 0;
}


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

using namespace std;

int N;
vector<vector<pair<int, int>>> Edge;

int dp1[100000 + 10], dp2[100000 + 10];
int parent[100000 + 10];

void dfs1(int pos, int bef) {
	parent[pos] = bef;
	for (int i = 0; i < Edge[pos].size(); i++) {
		int nxt = Edge[pos][i].first;
		if (nxt == bef)continue;
		dfs1(nxt, pos);
		dp1[pos] = max(dp1[pos], dp1[nxt] + Edge[pos][i].second);
	}
}

void dfs2(int pos, int bef, int bef_val) {
	if (bef == -1) {
		vector<pair<int, int>> tmp;
		for (int i = 0; i < Edge[pos].size(); i++) {
			tmp.push_back(make_pair(dp1[Edge[pos][i].first] + Edge[pos][i].second, Edge[pos][i].first));
		}
		sort(tmp.rbegin(), tmp.rend());
		dp2[pos] = tmp.size() >= 2 ? tmp[0].first + tmp[1].first : tmp[0].first;

		for (int i = 0; i < Edge[pos].size(); i++) {
			int nxt = Edge[pos][i].first;
			if (nxt == bef)continue;
			if (tmp.size() == 1) {
				dfs2(nxt, pos, 0);
			}
			else {
				dfs2(nxt, pos, tmp[(nxt == tmp.front().second)].first);
			}
		}

	}
	else {
		vector<int> tmp;
		int c = 0;
		for (int i = 0; i < Edge[bef].size(); i++) {
			if (Edge[bef][i].first == pos) {
				c = Edge[bef][i].second;
				continue;
			}
			else if (Edge[bef][i].first == parent[bef])tmp.push_back(bef_val + Edge[bef][i].second);
			else tmp.push_back(dp1[Edge[bef][i].first] + Edge[bef][i].second);
		}
		sort(tmp.rbegin(), tmp.rend());

		dp2[pos] = dp1[pos] + c + (tmp.size() ? tmp.front() : 0);

		for (int i = 0; i < Edge[pos].size(); i++) {
			int nxt = Edge[pos][i].first;
			if (nxt == bef)continue;
			dfs2(nxt, pos, (tmp.size() ? tmp.front() : 0));
		}
	}
}

int main() {
	cin >> N;
	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}
	Edge.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int s, t;
		int cost;
		cin >> s >> t >> cost;
		Edge[s].push_back(make_pair(t, cost));
		Edge[t].push_back(make_pair(s, cost));
	}

	dfs1(0, -1);
	dfs2(0, -1, 0);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, dp2[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 26748
"use strict";
const combi = function(n){
    return n*(n-1)/2
}

const main = arg => {
    const input = arg.trim().split("\n");

    const N = parseInt(input[0].split(" ")[0]);
    const A = input[1].split(" ").map(n => parseInt(n));

    let m = {}
    for(let i = 0; i<A.length; i++){
        if(!m[A[i]]) m[A[i]] = 1
        else m[A[i]]++
    }
    let orgCnt = 0
    let keys = Object.keys(m)
    for(let i = 0; i<keys.length; i++){
        let tmp = m[keys[i]]
        orgCnt = orgCnt + tmp * (tmp-1)/2
    }

    for(let i = 0; i<A.length; i++){
        let num = m[A[i]]
        const diff = num*(num-1)/2 - (num-1)*(num-2)/2
        console.log(orgCnt-diff)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 52348
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    right = 0
    cur_bin = 0
    for left in range(N):
        while right < N and (cur_bin & A[right] == 0):
            cur_bin += A[right]
            right += 1
        ans += right-left
        if left == right:
            right += 1
        else:
            cur_bin ^= A[left]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

bool isprime[100000001]={};

int main()
{
	int n;
	cin >> n;
	int ans = 0;

	for(int i = 0;i<n;i++)
	{
		int x ;
		cin >> x;
		for(int j = 2;j*j<=x;j++)
		{
			if(x%j==0)
			{
				ans++;
				break;
			}
		}
	}
	cout<<n-ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3104
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, M = map(lambda x: int(x), line.split(" ", 2))

        services_1 = {}
        services_n = []
        for i in xrange(M):
            a, b = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
            if a == 1:
                services_1[b] = True
            if b == N:
                services_n.append(a)

        if 1 in services_n:
            print("POSSIBLE")

        result = "IMPOSSIBLE"
        for service in services_n:
            if service == 1 or service in services_1:
                result = "POSSIBLE"
                break
        print result                

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 16700
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 20000 + 5;

int n;
int a[N], b[N], p[N];

int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(p[i]);
	for (int i = 1; i <= n; i++) a[i] = (i - 1) * (n + 1);
	for (int i = n; i >= 1; i--) b[i] = (n - i) * (n + 1);
	for (int i = 1; i <= n; i++) a[p[i]] += i, b[p[i]] += i;
	//for (int i = 1; i < n; i++) if (a[p[i]] + b[p[i]] >= a[p[i + 1]] + b[p[i + 1]]) printf("FUCK\n");
	for (int i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n");
	for (int i = 1; i <= n; i++) printf("%d ", b[i]); printf("\n");
	return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35720
#include <iostream>

using namespace std;

int main(void) {
    int N, max_height=0, result=0;
    cin >> N;
    
    int H[N];
    for (int i=0; i<N; i++) { cin >> H[i]; }

    for (auto x: H) { 
        if (x >= max_height) {
            result += 1;
            max_height = x;
        }
    }

    cout << result << flush;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

l=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])

print(l[n])


Measured memory_bytes: 14252
import itertools

N = int(input())

Flist = []
for i in range(N):
    f = [int(x) for x in input().split()]
    Flist.append(f)

Plist = []
for i in range(N):
    p = [int(x) for x in input().split()]
    Plist.append(p)

cases = []
for i in range(1,11):
    cases.extend(list(itertools.combinations([0,1,2,3,4,5,6,7,8,9], i)))

result = -10**9
for case in cases:
    counter = [0]*N
    cache = 0
    for x in case:
        for i,f in enumerate(Flist):
            if f[x] == 1:
                counter[i] += 1
    for i,count in enumerate(counter):
        cache += Plist[i][count]
    if cache > result:
        result = cache

print(result)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int arr[5];
int main()
{
    long long int k,a,b,ans=1;
    cin >> k >> a >> b;
    long long int temp;
    if(b-a <= 2)
    {
        cout << k + 1 << endl;
    }
    else
    {
        temp = min(k,a-1);
        k -= temp;
        ans += temp;
        if(k%2 == 1)
            ans++;
        temp = k/2;
        ans += (b-a)*(k/2);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w = readInts()
A = [input() for _ in range(h)]
cnt = 0
for y in range(h):
    for x in range(w):
        if A[y][x] == '#':
            cnt += 1
if h + w - 1 == cnt:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

bool check(int n, string s){
    rep(i, s.size()){
        if (s[i] == 'X') s[i] = n + '0';
    }
    auto iplus = s.find('+');
    auto ieq = s.find('=');
    vs ss(3);
    ss[0] = s.substr(0, iplus);
    ss[1] = s.substr(iplus + 1, ieq - iplus - 1);
    ss[2] = s.substr(ieq + 1);
    rep(i, 3){
        if (ss[i].size() != 1 && ss[i][0] == '0') return false;
    }

    rep(i, 3){
        reverse(all(ss[i]));
        ss[i].resize(ss[2].size(),'0');
    }
    int carry = 0;
    rep(i, ss[2].size()){
        if ((ss[0][i] + ss[1][i] - 2 * '0' + carry)%10 == ss[2][i] - '0'){
            carry = ss[0][i] + ss[1][i] - 2 * '0' + carry >= 10;
        }
        else {
            return false;
        }
    }
    return true;
}

int main(){
    string s;
    while (cin >> s){
        int ans = -1;
        rep(i, 10){
            if (check(i, s)){
                ans = i;
                break;
            }
        }
        if (ans == -1) cout << "NA";
        else cout << ans;
        cout << endl;
    }
}

Measured memory_bytes: 1200
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll arr[50];
ll maxv = 0, max_index = -1;

bool array_check() {
	bool flag = true;
	maxv = 0;
	rep(i, N) {
		flag &= (arr[i] < N);
		if (maxv < arr[i]) {
			maxv = arr[i];
			max_index = i;
		}
	}
	return flag;
}

int main() {
	cin >> N;
	ll sum = 0;
	rep(i, N) {
		cin >> arr[i];
        sum += arr[i]/N;
	}
    ll cnt = 0;
	while (!array_check()) {
        rep(i, N){
            ll tmp = arr[i];
            arr[i] -= (tmp/N)*N;
            arr[i] += (sum - tmp/N);
            cnt += tmp/N;
        }
        sum = 0;
        rep(i, N){
            sum += arr[i]/N;
        }
	}
    cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==0||n==2) cout<<1<<endl;
	else if(n==1) cout<<2<<endl;
	else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if (C - (A - B) < 0) {
      System.out.println(0);
    } else { 
    System.out.println(C - (A - B));
    }
  }
}

Measured memory_bytes: 22484
while true do
    m,f,r=gets.chomp.split(" ").map(&:to_i)
    break if m == -1 && f == -1 && r == -1
    if m == -1 || f == -1
        puts "F"
        next
    end
    if m+f >= 80
        puts "A"
    elsif m+f >= 65
        puts "B"
    elsif m+f >= 50
        puts "C"
    elsif m+f >= 30
        if r >= 50
            puts "C"
        else
            puts "D"
        end
    else
        puts "F"
    end
end


Measured memory_bytes: 6872
parseInt(x) = parse(Int, x)

function main()
	n = readline() |> parseInt
	a = map(parseInt, split(readline()))

	b = Array{Int}(n)
	b[1] = a[1]
	k = 0
	for i in 2:n
		b[i] = a[i]+b[i-1]
		if b[i]*b[i-1] >= 0
			if b[i-1] < 0
				k += abs(b[i]-1)
       			b[i] = 1
			else
				k += abs(b[i]+1)
				b[i] = -1
			end
		end
	end

	c = Array{Int}(n)
	l = 0
	if a[1] > 0
		c[1] = -1
		l += abs(a[1]+1)
	else
		c[1] = 1
		l += abs(a[1]-1)
	end
	for i in 2:n
		c[i] = a[i]+c[i-1]
		if c[i]*c[i-1] >= 0
			if c[i-1] < 0
				l += abs(c[i]-1)
       			c[i] = 1
			else
				l += abs(c[i]+1)
				c[i] = -1
			end
		end
	end

	d = Array{Int}(n)
	m = 0
	if a[1] > 0
		d[1] = 1
		m += abs(a[1]-1)
	else
		d[1] = -1
		m += abs(a[1]+1)
	end
	for i in 2:n
		d[i] = a[i]+d[i-1]
		if d[i]*d[i-1] >= 0
			if d[i-1] < 0
				m += abs(d[i]-1)
       			d[i] = 1
			else
				m += abs(d[i]+1)
				d[i] = -1
			end
		end
	end
	if a[1] == 0
		print(min(l,m))
	else
		print(min(k,l,m))
	end
end

main()

Measured memory_bytes: 145664
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int flag = 0;
	for(int i=0;i<3;i++)
	{
		if(s[i] == s[i+1])
		{
			flag = 1;
			break;
		}
	}
	if(flag == 1)
	cout<<"Bad";
	else
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))  
b=list(map(int, input().split()))
c=list(map(int, input().split()))   
ans=0

for i in range(n):
    ans+=b[a[i]-1]
    if i>=1 and  a[i]-a[i-1]==1:
        ans+=c[a[i-1]-1]
    
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//????????¢??°????????????MAX???
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//?????\??¢??°
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//??????????????¢??°
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int ub(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<d[m]?ub(l,m,n,d):ub(m+1,r,n,d);
}
int d[1000010];
int main(){
  int n,m,max=0,i,j;
  while(scanf("%d %d",&n,&m),n){
    R=C=1;
    for(i=max=0;i<n;i++){
      scanf("%d",&d[i]);
      hin(d[i]);
      for(j=0;j<=i;j++)hin(d[i]+d[j]);
    }
    for(i=0;C-1;i++)d[i]=N[hout()];
    //for(j=0;j<i;j++)printf("%d\n",d[j]);printf("\n");
    for(j=0;j<i;j++){
      if(d[j]>m)continue;
      n=ub(0,i,m-d[j],d);
      if(n==0)continue;
      if(max<d[j]+d[n-1])max=d[j]+d[n-1];
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 12796
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                long n=long_v(read()),n1=n;
                int res=0;
                for(int i=2;(long)i*i<=n;i++){
                    if(n%i!=0) continue;
                    int c=0;
                    while(n1%i==0){c++;n1/=i;}
                    double k=(double)Math.sqrt(1+8*c);k-=1d;
                    k/=2d;k=(int)Math.floor(k);
                    res+=k;
                }
                if(n1>1) res++;
                out.write(res+"");
                out.flush();

    }
}


Measured memory_bytes: 36732
def get
  gets.chomp.split(" ").map(&:to_i)
end

n,m = get
input = m.times.map{get.sort}.flatten!

task = Hash.new 0

input.each do |t|
  task[t] += 1
end

puts task.all?{|k,v| v.even?} ? :YES : :NO

Measured memory_bytes: 15980
n = int(input())
a = list(map(int, input().split()))
count_baff = 0
count = float("inf")
for i in a:
    p = i
    while(p % 2 == 0 ):
        p /= 2
        count_baff += 1
    if count > count_baff:
        count = count_baff
    count_baff = 0
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> pi;
int n;
pi arr[205];
ll mod = 998244353;
ll answer = 0;
ll factorial[205];
ll ifactorial[205];
vector<ll> v;
bool collinear[205][205];

ll power(ll a, ll b){
	a %= mod;
	if (b == 0) return 1;
	if (b == 1) return a;
	ll half = power(a, b/2);
	half*=half;
	half%=mod;
	if (b % 2 == 1){
		half *= a;
		half %= mod;
	}
	return half;
}

void init(){
	factorial[0] = 1;
	for (int i = 1; i < 205; i++){
		factorial[i] = factorial[i - 1]*i;
		factorial[i] %= mod;
	}
	for (int i = 1; i < 205; i++){
		ifactorial[i] = power(factorial[i], mod - 2);
	}
	
}

ll choose(ll n, ll k){
	if (n == k) return (long long)1;
	return (((factorial[n]*ifactorial[k])%mod)*ifactorial[n - k])%mod;
}

ll adjust(ll x){
	x %= mod;
	if (x < 0){
		x += mod;
	}
	return x;
}

int main(){
	init();
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld%lld", &arr[i].first, &arr[i].second);
	}
	sort(arr, arr + n);
	ll answer = 0;
	for (int i = 3; i <= n; i++){
		answer += choose(n, i);
		answer = adjust(answer);
		//cout << "choose (" << n << ", " << i << ") = " << choose(n, i) << endl;
	}
	answer = adjust(answer);
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			if (collinear[i][j]) continue;
			v.clear();
			v.push_back(i);
			v.push_back(j);
			for (int k = j + 1; k < n; k++){
				if ((arr[i].second - arr[j].second)*(arr[i].first - arr[k].first) == (arr[i].second - arr[k].second)*(arr[i].first - arr[j].first)){
					v.push_back(k);
				}
			}
			for (int k = 0; k < (int)v.size(); k++){
				for (int l = 0; l < (int)v.size(); l++){
					collinear[v[k]][v[l]] = true;
				}
			}
			for (int k = 3; k <= (int)v.size(); k++){
				answer -= choose((long long)v.size(), (long long)k);
				answer = adjust(answer);
			}
		}
	}
	answer = adjust(answer);
	printf("%lld\n", answer);
	
}

Measured memory_bytes: 256