akhauriyash/Code-Regression huggingface dataset:
// 下記を, 一部修正.
// 解き直し.
// ABC #036 解説.
// http://abc036.contest.atcoder.jp/data/abc/036/editorial.pdf
#include <bits/stdc++.h>

using namespace std;

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

typedef long long LL;
const int LIMIT = 100000;
const LL MOD = 1e9 + 7;

struct edge {
    int to;    // 次の頂点.
    int cost;  // コスト.
};

struct vertex {
    int id;        // 頂点番号.
    int distance;  // 指定された頂点(根)からの距離.
};

int depth[LIMIT];
vector<edge> tree[LIMIT];

// AtCoder Beginner Contest 070 (問題D Transit Tree Path) を参照.
// https://img.atcoder.jp/abc070/editorial.pdf
// 深さ優先探索(depth-first search).
// @param c: 探索地点となる頂点.
// @param b: 探索地点から見て, 前回探索済の頂点.
// @param d: 探索開始地点からの距離.
// @return : 特に無し.
void dfs(int c, int b, int d) {
    depth[c] = d;
    for (auto &e : tree[c]) {
        if (e.to == b) continue;
        dfs(e.to, c, d + e.cost);
    }
}

int main() {
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    map<int, int> m; // 開始頂点取得用.
    FOR(i, 0, N - 1) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        tree[a].push_back({b, 1});
        tree[b].push_back({a, 1});
        m[a]++;
        m[b]++;
    }
    
    // 2. N = 1 の 場合は, 終了(※本問用で追加).
    if(N == 1){
        cout << 2 << endl;
        return 0;
    }
    
    // 3. 探索開始の頂点(根)を取得し, 各頂点までの最短距離を保存.
    int root = -1;
    for(auto &p : m) {
        if(p.second == 1) {
            root = p.first;
            break;
        }
    }
    dfs(root, -1, 0);
    // cout << "root=" << root << endl;
    // FOR(i, 0, N) for(auto &p : tree[i]) cout << "i=" << i << " to=" << p.to << endl;
    // FOR(i, 0, N) cout << depth[i] << " ";
    
    // 4. 解説通り(色の塗り方の数をカウント).
    // -> tree DP を 使って解くとのこと.
    // 探索開始の頂点(根) から遠い順に, f, g の 値を計算していく.
    
    // 4-1. 頂点と距離のセットで保管.
    vector<vertex> vertexes;
    FOR(i, 0, N) {
        vertex v;
        v.id = i;
        v.distance = depth[i];
        vertexes.push_back(v);
    }
    
    // 4-2. 距離で, 降順sort.
    sort(vertexes.begin(), vertexes.end(), [](const vertex& x, const vertex& y) {return x.distance > y.distance;});
    
    // 4-3. f, g を 帰納的に計算.
    LL f[N] = {};
    LL g[N] = {};
    for(auto &x : vertexes) {
        // 頂点 x を 親とする部分木で, x と 隣り合っている頂点(xの子)を探索.
        int p = x.id;  // 親の頂点番号.
        LL lf = 1LL;
        LL lg = 1LL;
        // 隣接している, かつ, 探索開始の頂点(根) からより遠い場合は, xの子 と識別.
        for(auto &v : tree[p]) {
            int c = v.to;  // 子の候補となる頂点番号.
            if(depth[p] < depth[c]) {
                lg *= f[c];
                lf *= g[c];
                lg %= MOD;
                lf %= MOD;
            }
        }
        // f, g を 更新.
        lf += lg;
        lf %= MOD;
        f[p] = lf;
        g[p] = lg;
    }
    // FOR(i, 0, N) cout << f[i] << " ";
    // cout << endl;
    // FOR(i, 0, N) cout << g[i] << " ";
    
    // 5. 出力 ～ 後処理.
    LL ans = f[root];
    printf("%lld\n", ans);
    return 0;

}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, m;
    cin >> n >> m;
    vll a(n, 0);
    vll b(n + 1, 0);
    rep(i, n) cin >> a[i];
    sort(all(a));
    rep(i, n) b[i + 1] = b[i] + a[i];

    ll hi = 2e9+1, lo = 0;
    while(hi - lo > 1) {
        ll mid = lo + (hi - lo) / 2;

        ll cnt = 0;
        rep(i, n) {
            // int j = n - i;
            ll xx = (a.end() - lower_bound(all(a), mid - a[i]));
            cnt += xx;
            // cout << xx << endl;
        }
        // cout << mid << " " << cnt << endl;

        if (cnt < m) hi = mid;
        else lo = mid;
    }

    ll ans = 0, cnt = 0;
    rep(i, n) {
        ll xx = a.end() - lower_bound(all(a), lo - a[i]);
        cnt += xx;
        ans += b.back() - b[n - xx] + xx * a[i];
    }

    // cout << cnt << " " << lo << " " << ans << " " << ans + (m - cnt) * lo << endl;
    cout << ans  + (m - cnt) * lo << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	bool a = false, b = false;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'C') a = true;
		if(s[i] == 'F' && a) b = true;
	}
	if(a && b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;                                              
}
	


Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
      static List<int> a = new List<int>();
      static List<int> b = new List<int>();
      static List<int> c = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read1();
      Read5();
decimal[] checkA,checkB,checkC;
      checkA=new decimal[N];
           checkB=new decimal[N]; 
            checkC=new decimal[N];
      checkA[0]=a[0];
      checkB[0]=b[0];
      checkC[0]=c[0];
      for(int i=1;i<N;i++){
        if(checkA[i-1]>=checkB[i-1] && checkA[i-1]>=checkC[i-1]){
      if(checkB[i-1]>=checkC[i-1]){checkA[i]=checkB[i-1]+a[i];}else{checkA[i]=checkC[i-1]+a[i];}
          checkB[i]=checkA[i-1]+b[i];
          checkC[i]=checkA[i-1]+c[i];
        }
           else if(checkA[i-1]<=checkB[i-1] && checkB[i-1]>=checkC[i-1]){
      if(checkA[i-1]>=checkC[i-1]){checkB[i]=checkA[i-1]+b[i];}else{checkB[i]=checkC[i-1]+b[i];}
          checkA[i]=checkB[i-1]+a[i];
          checkC[i]=checkB[i-1]+c[i];
        }     
                else if(checkC[i-1]>=checkB[i-1] && checkA[i-1]<=checkC[i-1]){
            if(checkA[i-1]>=checkB[i-1]){checkC[i]=checkA[i-1]+c[i];}else{checkC[i]=checkB[i-1]+c[i];}
          checkB[i]=checkC[i-1]+b[i];
          checkA[i]=checkC[i-1]+a[i];
        }
      }
      
                    Console.WriteLine(Math.Max(Math.Max(checkA[N-1],checkB[N-1]),checkC[N-1]).ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
for(int i=0;i<N;i++){
       string[] tmp = Console.ReadLine().Split(' ');
       a.Add(int.Parse(tmp[0]));
       b.Add(int.Parse(tmp[1]));
       c.Add(int.Parse(tmp[2]));
}
 
    }


}

Measured memory_bytes: 22976
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

string S;

int main() {
    cin >> S;
    int ans = 7;

    if (S == "SAT") {
        ans = 1;
    } else if (S == "FRI") {
        ans = 2;
    } else if (S == "THU") {
        ans = 3;
    } else if (S == "WED") {
        ans = 4;
    } else if (S == "TUE") {
        ans = 5;
    } else if (S == "MON") {
        ans = 6;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef pair <int,pair <int,int>> piii;
const int N = 5e3 + 1;
int n,m,d1,d2,c1,c2;
bool avail[N][N] , check = true;
priority_queue <piii,vector<piii>,greater<piii>> heap , loop;
int Dijkstra(int val,int x,int y)
{
    avail[x][y] = true;
    heap.push({val,{x,y}});
    loop.push({val,{x,y}});
    while (!heap.empty())
    {
        while (!heap.empty())
        {
            piii temp = heap.top(); heap.pop();
            int u = temp.se.fi , v = temp.se.se;
            loop.push({temp.fi,{u,v}});
            if (u == d1 && v == d2) return temp.fi;
            if (!avail[u - 1][v])
            {
                avail[u - 1][v] = true;
                heap.push({temp.fi,{u - 1,v}});
                loop.push({temp.fi,{u - 1,v}});
            }
            if (!avail[u + 1][v])
            {
                avail[u + 1][v] = true;
                heap.push({temp.fi,{u + 1,v}});
                loop.push({temp.fi,{u + 1,v}});
            }
            if (!avail[u][v - 1])
            {
                avail[u][v - 1] = true;
                heap.push({temp.fi,{u,v - 1}});
                loop.push({temp.fi,{u,v - 1}});
            }
            if (!avail[u][v + 1])
            {
                avail[u][v + 1] = true;
                heap.push({temp.fi,{u,v + 1}});
                loop.push({temp.fi,{u,v + 1}});
            }
        }
        while (!loop.empty())
        {
            piii temp = loop.top(); loop.pop();
            int x = temp.se.fi , y = temp.se.se;
            for (int i = max(x - 2,1); i <= min(x + 2,n); i++)
            for (int j = max(y - 2,1); j <= min(y + 2,m); j++)
                if (!avail[i][j])
                {
                    avail[i][j] = true;
                    heap.push({temp.fi + 1,{i,j}});
                }
        }
        /*cout << "==================================\n";
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++)
                if (avail[i][j] == true) cout << "#"; else cout << ".";
                cout << "\n";
            }*/
    }
    return -1;
}
int main()
{
    cin >> n >> m;
    cin >> c1 >> c2;
    cin >> d1 >> d2;
    for (int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++)
            if (s[j - 1] == '#') avail[i][j] = true;
    }
    for (int i = 0; i <= n + 1; i++) avail[i][0] = avail[i][m + 1] = true;
    for (int j = 0; j <= m + 1; j++) avail[0][j] = avail[n + 1][j] = true;
    /*for (int i = 0; i <= n + 1; i++)
    {
        for (int j = 0; j <= m + 1; j++)
            if (avail[i][j] == true) cout << "#"; else cout << ".";
        cout << "\n";
    }*/
    cout << Dijkstra(0,c1,c2);
    return 0;
}

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

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

int main() {
    string s;
    cin >> s;

    int n = s.size();

    int res = 0;
    int ct = 0;

    rep(i, n) {
        char c = s[i];
        if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
            ct++;
        }
        else {
            res = max(res, ct);
            ct = 0;
        }
    }
    if (ct > 0) res = max(res, ct);

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

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

int n;
string s;

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

	cin >> n >> s;

	for (int i = 0; i < _sz(s); i++)
	{
		int x = s[i] - 'A';
		x = (x + n) % 26;
		s[i] = char(x + 'A');
	}

	cout << s << '\n';
}


Measured memory_bytes: 256
# 13
import sys
import numpy as np


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = np.array(LI())
b = np.array(LI())
diff = a - b
pos = [diff[i] for i in range(len(diff)) if diff[i] > 0]
neg = [diff[i] for i in range(len(diff)) if diff[i] < 0]
if sum(pos) + sum(neg) < 0:
    print(-1)
    exit()

if len(neg) == 0:
    print(0)
    exit()

ans = len(neg)
s_neg = sum(neg)
sort_pos = sorted(pos)[::-1]
for elem in sort_pos:
    if s_neg < 0:
        ans += 1
        s_neg += elem
    else:
        break
print(ans)


Measured memory_bytes: 39776
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

LL xs[100*1000];
LL as[100*1000];
LL bs[100*1000];
LL vs[100*1000];
int main() {
	LL N,C;
	cin >> N >> C;
	LL ret=0;
	LL s=0;
	LL pre=0;
	LL m=0;
	for(int i=0;i<N;i++){
		cin >> vs[i];
		cin >> xs[i];
		s+=xs[i];
		s-=abs(vs[i]-pre);
		pre=vs[i];
		ret=max(ret,s);
		m=max(m,s-vs[i]);
		as[i]=m;
	}
	s=0;
	pre=C;
	m=0;
	for(int i=N-1;i>=0;i--){
		s+=xs[i];
		s-=abs(vs[i]-pre);
		pre=vs[i];
		ret=max(ret,s);
		m=max(m,s-(C-vs[i]));
		bs[i]=m;
		if(i>0){
			ret=max(ret,as[i-1]+s);
		}
	}
	pre=0;
	s=0;
	for(int i=0;i<N-1;i++){
		s+=xs[i];
		s-=abs(vs[i]-pre);
		pre=vs[i];
		ret=max(ret,bs[i+1]+s);
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
long long mod=1000000007;
int f[1001][1001];
int main()
{
	int n,m,i,j;
	char c;
	long long ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=m;j++)
		{
			scanf("%c",&c);
			if(c=='.')
			{
				if(i==1&&j==1)
					f[i][j]=1;
				else
					f[i][j]=(f[i-1][j]+f[i][j-1])%mod;
			}
		}
	}
	printf("%d",f[n][m]);
	return 0;
} 

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
const int MAX_H =100,MAX_W =100;
const int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

char field[MAX_H][MAX_W];
int h,w;
int ans;

void dfs(int x, int y, char k)
{
	field[y][x] = '.';
	for(int i = 0; i < 4; ++i){
		int nx = x + dx[i], ny = y + dy[i];
		if(0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] == k){
			dfs(nx,ny,k);
		}
	}
}


int main()
{
	while(1){
		ans = 0;
		cin >> h >> w;
		if(h == 0 && w == 0)break;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cin >> field[i][j];
			}
		}
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(field[i][j] != '.'){
					++ans;
					dfs(j,i,field[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1632
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  /// freopen("input.txt","r",stdin);
  /// freopen("output.txt","w",stdout);
	lli t=1;
    //cin>>t;
	while(t--)
	{
        lli a,b,T;
        cin>>a>>b>>T;
        lli n=(T+0.5)/a;
        cout<<b*n<<endl;
    }
}
/*
1
8 2
1 0 1 0 0 1 0 0
*/


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
L = LIST()

L.sort()

print(sum(L[::2]))


Measured memory_bytes: 5144
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
    ll n;
    ll a[200000];
    ll a_min=1e10;
    // ll a;
    ll sum=0;
    int i;

  scanf("%lld", &n);

  for (i = 0; i < n; i++)
  {
      scanf("%lld", a + i);
    //   a_min = (a < a_min) ? a : a_min;
  }
  sortdown(a, n);

  sum = a[0];
  for (i = 1; i < n-1; i++)
  {
      sum += a[(i+1)/2];
  }
  
  printf("%lld\n", sum);

  return 0;
}

Measured memory_bytes: 4684
S = gets.chomp.chars
N = S.size
ans = 0
(0...N).each do |i|
  (i...N).each do |j|
    if S[i..j].all? { |ch| ['A', 'C', 'G', 'T'].include?(ch) }
      size = j - i + 1
      ans = size if size > ans
    end
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#define ll long long
#define ull unsigned long long
#define mod 1000000007

using namespace std;

int n;
map<int, set<string>>mp;
map<string, int>mapi;
string s;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		mapi[s]++;
		mp[mapi[s]].insert(s);
	}
	map<int, set<string>>::iterator it = mp.end();
	it--;
	for (auto i : it->second)
		cout << i << '\n';
	return 0;
}

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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

int main()
{
    string s;
    cin >> s;
    vector<char> a;
    for (auto c : s) {
        if (c == 'B') {
            if (!a.empty()) {
                a.pop_back();
            }
        } else {
            a.push_back(c);
        }
    }
    for (auto c : a) {
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
include Math
 
ans = 0
num, *ary = $<.map &:to_i
 
ary.each do|i|
 
  for j in 2..sqrt(i).floor
 
   if i % j == 0
 
    ans -= 1
    break
 
   end
  end
   
  ans += 1

end
 
puts ans


Measured memory_bytes: 7028
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
const ll MOD = 1000000007;
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    int vsum = 0;
    rep(i, n) vsum += a[i];
    rep(i, n - 1) {
        vsum -= a[i];
        sum += (a[i] * (vsum % MOD)) % MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 4764
#include<stdio.h>
int main()
{
	int n,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	{
		n=a;
		a=b;
		b=n;
	}
	if(a>c)
	{
		n=a;
		a=c;
		c=n;
	}
	if(b>c)
	{
		n=b;
		b=c;
		c=n;
	}
	printf("%d\n",c-b+b-a);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

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

	vector<int> p;

	for (size_t i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		p.push_back(tmp);
	}
	
	int count = 0;
	for (size_t i = 1; i < n - 1; ++i) {
		int first = p.at(i-1);
		int second = p.at(i);
		int third = p.at(i+1);

		if ((first <= second && second < third) || (third <= second && second < first)) {
			count += 1;
		} else if (first == third && second > first) {
			count += 1;
		}
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long n, a, b;
	cin >> n >> a >> b;

	long long t = n / (a + b);
	long long s = n % (a + b);
	
	if (s < a) {
		cout << a * t + s << endl;
	}
	else {
		cout << a * t + a << endl;
	}

	return 0;
}

Measured memory_bytes: 256
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 K = sc.nextInt();

		for(int i=0; i<K; i++){
			if(i%2==0){
				if(A%2==1){
					A--;
                }
				B += A/2;
				A /= 2;
			}else{
				if(B%2==1){
					B--;
                }
				A += B/2;
				B /= 2;
			}
        }
		System.out.println(A + " " + B);
	}
}


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

char ary[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

int calc(int a, int b) {
    return((a + b) % 10);
}
int convert(string a) {
    while(a.size() > 1) {
        string b = "";
        for(int r = 0; r < a.size() - 1; r++) {
            b += ary[calc(a[r] - '0', a[r + 1] - '0')];
        }
        a = b;
    }
    return(a[0] - '0');
}

int main(void) {
    string input;
    while(cin >> input) {
        cout << convert(input) << endl;
    }
    return(0);
}

Measured memory_bytes: 1196
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> sum(n+1);
    for (int i=1;i<n+1;i++){
        if(s.at(i-1)=='E')
            sum.at(i) = sum.at(i-1)+1;
        else
            sum.at(i) = sum.at(i-1);
    }
    int ans = INF;
    // (0)W(0)E(1)E(2)W(2)W(2)
    for (int i=0;i<n+1;i++){
        //左のWの数
        // cout << i-sum.at(i) << endl;
        // cout << sum.at(n)-sum.at(i);
        ans = min (ans,i+sum.at(n)-2*sum.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1812
// Problem Code: abc172_b

#include <iostream>
#include <string>

using namespace std;

int minor_change(string& S, string& T) {
	int cnt = 0;
	for (int i = 0; i < S.length(); i++)
		cnt += S[i] != T[i];
	return cnt;
}

int main() {
	string S, T;
	cin >> S >> T;
	cout << minor_change(S, T);
	return 0;
}

Measured memory_bytes: 3736
#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(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;
    vector<ll> w(100005,mod);
    w[0]=0; w[1]=1;

    for(int i=2; i<=n; i++){
        w[i]=min(w[i],w[i-1]+1);
        for(int j=6; j<=i; j*=6){
            w[i]=min(w[i],w[i-j]+1);
        }
        for(int j=9; j<=i; j*=9){
            w[i]=min(w[i],w[i-j]+1);
        }
    }
    cout << w[n] << endl;
    
    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)

void solve()
{
   ll x,k,d;
   cin>>x>>k>>d;
   x=abs(x);
//    if(x<0){
//        ll req=abs(x)/d;
//        if(k<=req)
//        {
//            cout<<abs(x)-k*d<<"\n";
//            return ;
//        }
//    }
   ll req=x/d;
   if(k<=req){
       cout<<x-k*d<<"\n";
       return ;
   }
   ll cr=x-req*d;
   ll rem=k-req;
   if(cr==0){
       if(rem%2){
           cout<<d<<"\n";
           return ;
       }
       else
       {
           cout<<0<<"\n";
           return ;
       }
   }
   else if(cr>0){
       if(rem%2){
           ll v1=abs(cr-d),v2=abs(cr+d);
           cout<<min(v1,v2)<<'\n';
       }
       else
       {
           if(rem==0)cout<<cr<<"\n";
           else cout<<min(abs(cr-2*d),cr)<<"\n";
       }
   }
   else
   {
       if(rem%2){
           ll v1=abs(cr-d),v2=abs(cr+d);
           cout<<min(v1,v2)<<'\n';
       }
       else
       {
           if(rem==0)cout<<abs(cr)<<"\n";
           else cout<<min(abs(cr+2*d),cr)<<"\n";
       }
   }
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
	char txt[100];
	int flg=0;
	scanf("%s",txt);
    for(int i=0;i<3;i++){
    	if(txt[i]==txt[i+1]){
        	flg=1;
        	break;
        }
    }
    if(flg==0){
    	printf("Good");
    }
    else if(flg==1){
    	printf("Bad");
    }
    
}

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

vector <int> val,rval;
string s;
int n,k;

int main(){
	cin>>n>>k>>s;
	if(s[0]=='0') val.push_back(0);
	int len=0;
	for(int i=0;i<s.size();i++){
		if(i>0&&s[i]!=s[i-1]){
			val.push_back(len);
			len=1;
		}
		else len++;
	}
	val.push_back(len);
	rval.resize(val.size()+1);
	for(int i=0;i<val.size();i++) rval[i+1]=rval[i]+val[i];
	int score=0;
	int Max=val.size();
	for(int i=0;i<rval.size();i+=2){
		int now=rval[min(Max,i+k*2+1)]-rval[i];
		score=max(now,score);
	}
	cout<<score<<endl;
	return 0;
}

Measured memory_bytes: 1272
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        int XOR = 0;
        for (int i=0; i<N; i++) {
            XOR ^= Integer.parseInt(sc.next());
        }
        sc.close();

        if (XOR==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 46452
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;++i)
    {
        int a;
        scanf("%d", &a);
        ans += i & a &1;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    vector<int> money;
    int nums[] = {6, 9};
    rep(i, 2){
        rep(j, INF){
            if(pow(nums[i], j) <= n) money.emplace_back(pow(nums[i], j));
            else break;
        }
    }
    sort(all(money));

    vector<int> dp(n+1, -1);
    dp[0] = 0;
    repi(i, 1, n+1){
        vector<int> cnt = {dp[i-1] + 1};
        rep(j, money.size()){
            if(i >= money[j]){
                cnt.emplace_back(dp[i - money[j]] + 1);
            }
        }

        dp[i] = *min_element(all(cnt));
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 768
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K = ir()
que = deque(range(1, 10))
count = 0
while count < K-1:
    count += 1
    x = que.popleft()
    remain = x % 10
    if remain > 0:
        que.append(10*x + remain - 1)
    que.append(10*x + remain)
    if remain < 9:
        que.append((10*x + remain + 1))

answer = que.popleft()
print(answer)


Measured memory_bytes: 18708
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
i = 0
while i < N-1:
  if A[i]+A[i+1] > x:
    d = A[i]+A[i+1]-x
    ans += d
    A[i+1] = 0 if A[i+1] < d else A[i+1]-d
  i += 1
print(ans)

Measured memory_bytes: 63856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

ll a; cin>>a;
cout<<a+a*a+a*a*a<<endl;

}


Measured memory_bytes: 3168
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	var sum int
	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		var size int
		for _, r := range s {
			size += int(r - '0')
		}
		if size >= a && size <= b {
			sum += i
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

int main()
{
    ll n ,a ,b ;
    cin>>n>>a>>b ;
    if(a > b)
    {
        cout<<0<<"\n"; 
        return  0;
    }
    if(n==1 && a!=b)
    {
        cout<<0<<"\n";
        return 0 ;
    }
    ll min1 = a * (n-1) + b ;
    ll min2 = b *(n-1)+ a ;
     cout<<min2 - min1+1 <<"\n" ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
ll A[200009], a;
ll d(int l, int r, int m){
  return abs((A[r] - A[m]) - (A[m] - A[l]));
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll s = 0;
  FOR(i, 1, n+1){
    cin >> a;
    s += a;
    A[i] = s;
  }
  ll ans = linf, mi;
  int i1, i2;
  FOR(i, 2, n-1){
    int l, r, m1, m2;
    l = 1, r = i-1;
    while(r - l > 2){
      m1 = (l + l + r) / 3;
      m2 = (l + r + r) / 3;
      if(d(0, i, m1) < d(0, i, m2)){
        r = m2;
      }else{
        l = m1;
      }
    }
    mi = linf;
    FOR(j, l, r+1) if(d(0, i, j) < mi){
      mi = d(0, i, j);
      i1 = j;
    }

    l = i+1, r = n-1;
    while(r - l > 2){
      m1 = (l + l + r) / 3;
      m2 = (l + r + r) / 3;
      if(d(i, n, m1) < d(i, n, m2)){
        r = m2;
      }else{
        l = m1;
      }
    }
    mi = linf;
    FOR(j, l, r+1) if(d(i, n, j) < mi){
      mi = d(i, n, j);
      i2 = j;
    }
    vl v;
    v.pb(A[i1] - A[0]);
    v.pb(A[i] - A[i1]);
    v.pb(A[i2] - A[i]);
    v.pb(A[n] - A[i2]);
    sort(rng(v));
    mins(ans, v[3] - v[0]);
  }

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

Measured memory_bytes: 1792
import std.stdio;
import std.algorithm;
import std.conv;
import std.math;
import std.string;

void main()
{
    uint ans = 0 - 1;
    int[] a = readln.split.to!(int[]);


    foreach (i; 0..3){
        foreach (j; 0..3) {
            foreach (k; 0..3) {
                int t_ans = 0;
                if (i == j || j == k || k == i)
                    continue;
                t_ans += abs(a[j]-a[i]);
                t_ans += abs(a[j]-a[k]);
                ans = min(ans, t_ans);
            }
        }
    }
    writeln(ans);
}


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

vector<int> data[3];
int main(){
  int n, m;
  cin >> n >> m;

  int a,b,c;
  while(cin >> a >> b >> c, a != 0){
    data[0].push_back(a);
    data[1].push_back(b);
    data[2].push_back(c);
  }

  int l;
  cin >> l;
  for(int i = 0;i < l;i++){
    int memo[10010] = {};
    int money[10010];

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

    for(int i = 0;i < data[0].size();i++){
      memo[data[0][i]-1] += money[data[1][i]-1] * data[2][i];
    }

    for(int i = 0;i < n;i++){
      cout << memo[i];
      if(i < n-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}




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

int main(){
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int a_buf, c_buf;
    a_buf = a;
    c_buf = c;

    int w_flg, l_flg;
    w_flg = 0;
    l_flg = 0;

    while((a_buf>0) && (c_buf>0)){
        c_buf -= b;
        if (c_buf<=0){
            w_flg = 1;
            break;
        }
        a_buf -= d;
        if (a_buf <= 0){
            l_flg = 1;
            break;
        }
    }

    if (w_flg == 1){
        cout << "Yes" << endl;
        return 0;
    }
    if (l_flg == 1){
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3596
iN,iX = [int(x) for x in input().split()]
aL = [int(x) for x in input().split()]
aL.sort()
iNec = sum(aL)

#余ってるとき
if iNec < iX :
    print( iN - 1 )

#余ってないとき
else:
    iCounter = 0
    for iE in aL:
        if iX >= iE:
            iX -= iE
            iCounter += 1
        else:
            break
    print(iCounter)


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
using namespace std;

int a,b,d,r;
double f;

int main(){
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;

    printf("%d %d %.8lf\n",d,r, f);
    return 0;
}


Measured memory_bytes: 3232
s = int(input())

snooker =[0]*1000

for p in range (1, 100):
	for q in range (2, 10):
		if p**q<=10000:
			snooker[10*(p-1)+q-1]=p**q

snooker = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1024, 1089, 1156, 1225, 1296, 1331, 1369, 1444, 1521, 1600, 1681, 1728, 1764, 1849, 1936, 2025, 2116, 2187, 2197, 2209, 2304, 2401, 2500, 2601, 2704, 2744, 2809, 2916, 3025, 3125, 3136, 3249, 3364, 3375, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 4913, 5041, 5184, 5329, 5476, 5625, 5776, 5832, 5929, 6084, 6241, 6400, 6561, 6724, 6859, 6889, 7056, 7225, 7396, 7569, 7744, 7776, 7921, 8000, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9261, 9409, 9604, 9801, 10000]

slist = [0]*123

for i in range (0, 123):
	if snooker[i]<=s:
		slist[i]=snooker[i]
      
print(max(slist))

Measured memory_bytes: 3064
#include<cstdio>
int main(){
	int n,d1,x;
	scanf("%d%d%d",&n,&d1,&x);
	double a=d1*2+x,d=x*4,s=a/2+d*(n-1)/4;
	for(int i=n;--i;){
		a+=a/(i+1)+d-d/(2*i+2);
		s+=a/2+d*(i-1)/4;
	}
	printf("%.15lf\n",s);
}

Measured memory_bytes: 128
package main

import "fmt"

func PrintWall() {
	fmt.Print("#")
}

func PrintWallN(n int) {
	for i := 0; i < n; i++ {
		PrintWall()
	}
}

func PrintInner() {
	fmt.Print(".")
}

func PrintInnerN(n int) {
	for i := 0; i < n; i++ {
		PrintInner()
	}
}

func Println() {
	fmt.Println("")
}

func main() {
	var h, w int
	for {
		fmt.Scanln(&h, &w)
		if h == 0 && w == 0 {
			break
		}
		PrintWallN(w)
		Println()
		for i := 0; i < h-2; i++ {
			PrintWall()
			PrintInnerN(w - 2)
			PrintWall()
			Println()
		}
		PrintWallN(w)
		Println()
		Println()
	}
}


Measured memory_bytes: 1124
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);

    if (a * b > c * d || a * b == c * d) printf("%d\n", a * b);
    else if (a * b < c * d) printf("%d\n", c * d);

    return (0);
}


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

int main(int argc, char const *argv[])
{
	int n,m, sum=0;
	cin>>n>>m;
	int a[n];

	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a, a+n);
	for(int j=0; j<m; j++){
		sum+=a[j];
	}

cout<<sum;
	return 0;
}


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

int main(){
    int n;
    long min, min_tmp;
    min = 0;
    min_tmp = 0;
    cin >> n;
    int x[n];
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    for(int i=0; i<n; i++){
       min += (long)(x[i] - 1)*(long)(x[i] - 1);
    }
    for(int i=2; i<101; i++){
        for(int j=0; j<n; j++){
            min_tmp += (long)(x[j]-i)*(long)(x[j]-i);
        }
        if(min_tmp < min) min=min_tmp;
        min_tmp = 0;
    }
    cout << min;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, D[202020]; i64 C[202020];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d%lld", D + i, C + i);

	i64 ret = 0, digs = 0;
	for (int i = 0; i < N; ++i) {
		ret += C[i];
		digs += D[i] * C[i];
	}

	ret += (digs - 1) / 9;
	--ret;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 2560
// Last Change: 05/26/2019 21:34:53.
#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

int main() {
  ll N;
  cin >> N;

  vector<pair<string, pair<int, int>>> ipt(N);
  ll cnt = 1;
  for (auto &&e : ipt) {
    cin >> e.first >> e.second.first;
    e.second.first = 100 - e.second.first;
    e.second.second = cnt;
    ++cnt;
  }

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

  for (auto &&e : ipt) {
    cout << e.second.second << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  int l[N+10];
  for(int i=0; i<N; i++){
    cin >> l[i];
  }sort(l,l+N,greater<int>());
  for(int i=0; i<K; i++){
    sum += l[i];
  }cout << sum << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }

  vector<int> num(N+1);
  int over = 0;
  rep(i, 0, N) {
    if (a[i] > N) {
      over++;
    } else {
      num[a[i]]++;
    }
  }

  int ans = over;
  rep(i, 0, N+1) {
    if (num[i] < i) {
      ans += num[i];
    } else if (num[i] > i) {
      ans += (num[i] - i);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INF = (1LL<<60);

int main(){
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> shrine(A+2), temple(B+2);

    shrine[0] = -INF;
    for(int i=1; i<=A; i++) cin >> shrine[i];
    shrine[A+1] = INF;

    temple[0] = -INF;
    for(int i=1; i<=B; i++) cin >> temple[i];
    temple[B+1] = INF;

    for(int i=0; i<Q; i++){
        ll x; cin >> x;
        auto itr1 = upper_bound(shrine.begin(), shrine.end(), x);
        ll s1 = *itr1; itr1--;
        ll s2 = *itr1;

        auto itr2 = upper_bound(temple.begin(), temple.end(), x);
        ll t1 = *itr2; itr2--;
        ll t2 = *itr2;

        // max(s1, t1) - x, x - min(s2, t2), 2*min(s1-x, x-t2)+max(s1-x, x-t2), 2*min(t1-x, x-s2)+max(t1-x, x-s2)
        cout << min(min(max(s1, t1) - x, x - min(s2, t2)), min(2*min(s1-x, x-t2)+max(s1-x, x-t2), 2*min(t1-x, x-s2)+max(t1-x, x-s2))) << endl;
    }
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int Ceil(int a,int b){return ((a%b==0)?a/b:a/b+1);}

int main(){
	int n,a[100010];
	cin>>n;
	REP(i,n){
	    cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int ans = 0;
                String an = new Integer(N).toString();
                char t = an.charAt(an.length()-1);
                int a = Character.getNumericValue(t);
                
                if( a == 2 || a == 4 ||a == 5 ||a ==7 ||a == 9 ){
                    System.out.println("hon");
                }else if(a == 3){
                    System.out.println("bon");
                }else{
                    System.out.println("pon");
                }

        }
}

Measured memory_bytes: 35752