akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

using llu = unsigned int;

llu power( llu b, llu i ){
    llu r = 1;
    while( i ){
        if( i&1 ) r *= b;
        i >>= 1;
        b *= b;
    }
    return r;
}

int main() {

    int N;
    Scd(N);

    char s[312][312];

    Rep(i,N) Scs(s[i]);

    llu hash = 0;
    llu roll = 1000000007;
    llu roll2 = 998244353;
    llu rollN = power(roll,N);
    llu roll2N = power(roll2,N);
    vector<vector<llu>> vh(N,vector<llu>(N,0)); // vertical hash
    vector<vector<llu>> hh(N,vector<llu>(N,0)); // horizontal hash
    vector<vector<llu>>vhh(N,vector<llu>(N,0)); // vertical hash hash
    vector<vector<llu>>hhh(N,vector<llu>(N,0)); // horizontal hash hash

    Rep(i,N){
        hash = 0;
        Rep(j,N) hash = hash*roll + s[i][j];
        Rep(j,N){
            hh[i][j] = hash;
            hash = hash*roll - s[i][j]*rollN + s[i][j];
        }
    }
    Rep(j,N){
        hash = 0;
        Rep(i,N) hash = hash*roll2 + hh[i][j];
        Rep(i,N){
            hhh[i][j] = hash;
            hash = hash*roll2 - hh[i][j]*roll2N + hh[i][j];
        }
    }
    Rep(j,N){
        hash = 0;
        Rep(i,N) hash = hash*roll + s[i][j];
        Rep(i,N){
            vh[i][j] = hash;
            hash = hash*roll - s[i][j]*rollN + s[i][j];
        }
    }
    Rep(i,N){
        hash = 0;
        Rep(j,N) hash = hash*roll2 + vh[i][j];
        Rep(j,N){
            vhh[i][j] = hash;
            hash = hash*roll2 - vh[i][j]*roll2N + vh[i][j];
        }
    }

    int ans = 0;
    Rep(i,N) Rep(j,N){
        // printf ("%020llu %020llu\n", vhh[i][j], hhh[i][j] );
        if( vhh[i][j] == hhh[i][j] ) ans++;
    }
    printf ("%d\n", ans );

    return 0;
}





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

int main()
{
	int a, b, c, count=0;
	cin >> a >> b >> c;

	for(int i=a;i<=b;++i){
		if(c%i==0){
			count++;
		}
	}

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

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

const int N=1e9+7;
int n;

inline int read()
{
	int Num=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {Num=(Num<<1)+(Num<<3)+ch-'0'; ch=getchar();}
	return Num*f;
}
inline int abs(int x) {return x>0?x:-x;}
inline void write(int x)
{
	char F[200];
	int tep=abs(x),cn=0;
	if(x<0) putchar('-');
	while(tep) 
	{
		F[cn++]=(char)tep%10;
		tep/=10;		
	}
	while(cn) putchar(F[--cn]);
}
long long ksm(int x,int y)
{
	long long ans1=x;
	long long ans2=1;
	while(y)
	{
		if(y&1) ans2=ans1*ans2%N;
		ans1=ans1*ans1%N;
		y>>=1;
	} 
	return ans2;
}
int main()
{
	cin>>n;
	if(n==1) {
		puts("0"); return 0;
	}
	if(n==2) 
	{
		puts("2") ; return 0;
	}
	long long ans=ksm(10,n)%N;
	ans=(ans-2*ksm(9,n)%N)%N;
	ans=(ans+ksm(8,n)%N)%N;
	printf("%lld",(ans+N)%N);
	return 0;
}

Measured memory_bytes: 3744
#include <vector>
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int inf = 1e9;
const int N = 800010;

int mn[N], b[N];
int n, m, l, r, ans;
vector <int> p[N];

void build(int h, int l, int r)
{
    if (l == r)
    {
        if (!l) mn[h] = 0; else mn[h] = inf;
        return;
    }
    int mid = (l + r) >> 1;
    build(h << 1, l, mid); build(h << 1 | 1, mid + 1, r);
    mn[h] = min(mn[h << 1], mn[h << 1 | 1]);
}

int find(int h, int l, int r, int ll, int rr)
{
    if (l == ll && r == rr) return mn[h];
    int mid = (l + r) >> 1;
    if (rr <= mid) return find(h << 1, l, mid, ll, rr); else
    if (ll > mid) return find(h << 1 | 1, mid + 1, r, ll, rr); else
        return min(find(h << 1, l, mid, ll, mid), find(h << 1 | 1, mid + 1, r, mid + 1, rr));
}

void change(int h, int l, int r, int x, int y)
{
    if (l == r) {mn[h] = min(mn[h], y); return;}
    int mid = (l + r) >> 1;
    if (x <= mid) change(h << 1, l, mid, x, y);
        else change(h << 1 | 1, mid + 1, r, x, y);
    mn[h] = min(mn[h << 1], mn[h << 1 | 1]);
}

int main()
{
    scanf("%d", &n);
    FOR(i, 0, n - 1)
    {
        scanf("%d", &b[i]);
        if (!b[i]) ++ans;
    }
    scanf("%d", &m);
    FOR(i, 1, m)
    {
        scanf("%d%d", &l, &r);
        p[l - 1].push_back(r);
    }
    build(1, 0, n);
    FOR(i, 0, n - 1)
    {
        for(int j = 0; j < p[i].size(); ++j)
            change(1, 0, n, p[i][j], find(1, 0, n, i, p[i][j]));
        change(1, 0, n, i + 1, find(1, 0, n, i, i) + (b[i] ? 1 : -1));
    }
    printf("%d\n", find(1, 0, n, n, n) + ans);
    return 0;
}


Measured memory_bytes: 28800
#include <iostream>
#include <stack>

using namespace std;

void Solution()
{

    int ink[][2] = {{0,0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}, {-2, 0}, {2, 0}, {0, 2}, {0, -2}}; // range from small size to big size
    
    int x;
    int y;
    int size;
    char comma;
    
    int a[10][10] = {0}; // the boundary, +1 for judging the spread of ink
    
    int count = 0;
    int density = 0;
    
    while (cin>>x>>comma>>y>>comma>>size)
    {
        for (int i = 0; i <= size * 4; i++)
        {
            if (x + ink[i][0] < 10 && x + ink[i][0] >= 0 && y + ink[i][1] < 10 && y + ink[i][1] >= 0)
            {
                a[x + ink[i][0]][y + ink[i][1]]++;
            }
        
        }
        
    }
    
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if(a[i][j] > 0)
            {
                count = count+1;
            }
            
            if (a[i][j] > density)
            {
                density = a[i][j];
            }
        }
    }

    
    cout<<100 - count<<endl;
    cout<<density<<endl;

}

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

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
using namespace std;

const int N_MAX = 1e+5;
int N;
int h[N_MAX];
int dp[N_MAX];

int solve (int i){
	if (i == N-1) return 0;
	if (dp[i] != -1) return dp[i];

	int min_cost = abs(h[i] - h[i+1]) + solve(i+1);

	if (i + 2 <= N-1)
	{
		min_cost = min(
			min_cost,
			abs(h[i] - h[i+2]) + solve(i+2)
		);
	}
	return dp[i] = min_cost;
}

int main ()
{
	cin >> N;

	for (int i=0; i<N; ++i)
	{
		cin >> h[i];
		dp[i] = -1;
	}

	cout << solve(0) << endl;

	return 0;
}


Measured memory_bytes: 5760
n = int(input())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

if len(l) == 1:
    print(1)
    exit()


from collections import defaultdict
d = defaultdict(int)

for i in range(len(l)):
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx!=0 or dify!=0:
            dif = str(difx) + "_" + str(dify)
            d[dif] += 1

p_q = max((v,k) for (k,v) in d.items())[1]
p,q = p_q.split("_")

ans=0
for i in range(len(l)):
    found=False
    for j in range(len(l)):
        difx = l[i][0] - l[j][0]
        dify = l[i][1] - l[j][1]
        if difx==int(p) and dify==int(q):
            found=True
            break
    if not found:
        ans+=1
print(ans)

Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    int n = s.size();
    bool ok = true;
    for (int i = 0; i < n && ok; i += 2) {
        if (s[i] == 'L') ok = false;
    }
    for (int i = 1; i < n && ok; i += 2) {
        if (s[i] == 'R') ok = false;
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
import static java.lang.Integer.parseInt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * A Thief (0-1 Knapsack problem)
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int c = 0;
		while (!(line = br.readLine()).equals("0")) {
			c++;
			int w = parseInt(line);
			int n = parseInt(br.readLine());

			int[][] dp = new int[n + 1][w + 1];
			int[] vs = new int[n + 1];
			int[] ws = new int[n + 1];

			for (int i = 1; i < n + 1; i++) {
				line = br.readLine();
				vs[i] = parseInt(line.substring(0, line.indexOf(',')));
				ws[i] = parseInt(line.substring(line.indexOf(',') + 1));
			}

			int maxv = 0;
			int minw = w;
			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < w + 1; j++) {
					if (j >= ws[i]) {
						dp[i][j] = Math.max(dp[i - 1][j - ws[i]] + vs[i],
								dp[i - 1][j]);
					} else {
						dp[i][j] = dp[i - 1][j];
					}
					//
					if (dp[i][j] > maxv) {
						maxv = dp[i][j];
						minw = j;
					} else if (dp[i][j] == maxv) {
						minw = j < minw ? j : minw;
					}
				}
			}
			System.out
					.print(String.format("Case %d:\n%d\n%d\n", c, maxv, minw));

		}

	}

}

Measured memory_bytes: 26408
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll k;
void dfs(Graph& g, Array& used, ll v) {
	ll con = k - 2;
	for (auto e : g[v]) {
		if (used[e.to] == -1) {
			used[e.to] = con;
			dfs(g, used, e.to);
			con--;
			if (con < 0) con = 0;
		}
	}
}


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

	ll n;
	cin >> n >> k;

	Graph g(n);
	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 1, true, 1);
	}

	if (n == 1) {
		cout << k << endl;
		return 0;
	}
	if (n == 2) {
		cout << k * (k - 1) % MOD << endl;
		return 0;
	}

	Array used(n, -1);
	used[0] = k;
	used[g[0][0].to] = k - 1;
	dfs(g, used, 0);
	dfs(g, used, g[0][0].to);
	
	ll ans = 1;
	for (auto i : used) (ans *= i) %= MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14720
#Nは食材の数を示す変数
#vは食材ごとの価値を表す
N = int(input())
v = list(map(float, input().split()))
#vを昇順に並び替える
v.sort()
#現在の価値を保管しておく変数を定義
now_value = 0.0
#価値を最大にする方法は価値の小さいものから順に入れていくのがベストと考えられる。
now_value = v.pop(0)
for i in range(N-1):
    #新たな食材を鍋の中に入れる
    now_value +=v[i]
   
    #合計値の半分(平均)を求める
    now_value = now_value /2.0

print('{:.5f}'.format(now_value))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define mod 1000000007



int main()
{
	
	FAST;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	int n; cin>>n;
    	
    	int a[n+1] , dp[n+1];
    	
    	for(int i=1; i<=n; i++) cin>>a[i];
    	
    	memset(dp, 0, sizeof(dp)); 
    	
        dp[1] = 0 , dp[2] = abs(a[2]-a[1]); 
    	
    	for(int i=3; i<=n; i++)
    	{
    		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));
    		
		}
		
		cout<<dp[n]<<endl;
	}
		
    return 0;
}

Measured memory_bytes: 4396
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



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

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


	int r = 0;

	ll ans = 0;

	ll sum = 0;
	ll xo = 0;

	for (int l = 0; l < N; ++l)
	{
		while (r < N)
		{
			if ((sum + a[r]) == (xo ^ a[r]))
			{
				sum += a[r];
				xo ^= a[r];
				r++;
			}
			else
			{
				break;
			}
		}
		ans += (r - l);
		sum -= a[l];
		xo ^= a[l];
	}

	cout << ans << endl;

	return 0;
}


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

int n;

int main(){
    cin>>n;
    
    int a[n];
    int time=0;
    bool b=false;
    
    for(int i=0;i<n;i=i+1){
        cin>>a[i];
    }
    
    while(1){
        for(int i=0;i<n;i=i+1){
            if(a[i]%2!=0||a[i]==0){b=true;}
            else {a[i]=a[i]/2;}
        }
        
        if(b==true){break;}
        else{time=time+1;}
    }
    
    cout<<time<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size() - 1 - i]) {
			ans++;
		}
	}
	cout << ans / 2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int h, w, k; cin >> h >> w >> k;
  int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
  --sx; --sy; --gx; --gy;
  vector<string> v(h); rep(i, h) cin >> v[i];
  v2i dis(h, v1i(w, -1));
  v2b see(h, v1b(w, 1));
  pii tmp = {gx, gy};
  deque<pii> d;
  d.push_back(tmp); dis[tmp.fi][tmp.se] = 0; see[tmp.fi][tmp.se] = 0;
  while(!d.empty()){
    d.pop_front();
    int td = dis[tmp.fi][tmp.se]+1;
    rep(i, k){
      if(tmp.se+i+1 >= w) break;
      if(v[tmp.fi][tmp.se+i+1] == '@') break;
      if(see[tmp.fi][tmp.se+i+1]){
        see[tmp.fi][tmp.se+i+1] = 0;
        d.push_back({tmp.fi, tmp.se+i+1});
        dis[tmp.fi][tmp.se+i+1] = td;
      }
      if(!see[tmp.fi][tmp.se+i+1] && dis[tmp.fi][tmp.se+i+1] < td) break;
    }
    rep(i, k){
      if(tmp.se-i-1 < 0) break;
      if(v[tmp.fi][tmp.se-i-1] == '@') break;
      if(see[tmp.fi][tmp.se-i-1]){
        see[tmp.fi][tmp.se-i-1] = 0;
        d.push_back({tmp.fi, tmp.se-i-1});
        dis[tmp.fi][tmp.se-i-1] = td;
      }
      if(!see[tmp.fi][tmp.se-i-1] && dis[tmp.fi][tmp.se-i-1] < td) break;
    }
    rep(i, k){
      if(tmp.fi+i+1 >= h) break;
      if(v[tmp.fi+i+1][tmp.se] == '@') break;
      if(see[tmp.fi+i+1][tmp.se]){
        see[tmp.fi+i+1][tmp.se] = 0;
        d.push_back({tmp.fi+i+1, tmp.se});
        dis[tmp.fi+i+1][tmp.se] = td;
      }
      if(!see[tmp.fi+i+1][tmp.se] && dis[tmp.fi+i+1][tmp.se] < td) break;
    }
    rep(i, k){
      if(tmp.fi-i-1 < 0) break;
      if(v[tmp.fi-i-1][tmp.se] == '@') break;
      if(see[tmp.fi-i-1][tmp.se]){
        see[tmp.fi-i-1][tmp.se] = 0;
        d.push_back({tmp.fi-i-1, tmp.se});
        dis[tmp.fi-i-1][tmp.se] = td;
      }
      if(!see[tmp.fi-i-1][tmp.se] && dis[tmp.fi-i-1][tmp.se] < td) break;
    }
    tmp = d.front();
  }
  cout << dis[sx][sy] << "\n";
  return 0;
}


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

ma = 0
for i in reversed(range(n)):
    mi = min(a[i+1], b[i])
    a[i+1] -= mi
    b[i] -= mi
    ma += mi
    mi = min(a[i], b[i])
    a[i] -= mi
    ma += mi
print(ma)


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

int main()
{
	long long n;
	char s[1000];
	int k = 0;
	cin >> n;
	while (n)
	{
		int a = n % 26;
		if (a == 0) a = 26;
		char ch = 'a' - 1 + a;
		s[k++] = ch;
		n /= 26;
		if (a==26) n--;
	}
	for (int i = k-1; i >= 0; i--)
	{
		cout << s[i];
	}

	return 0;
}

Measured memory_bytes: 3636
import java.math.BigInteger;

public class
Main
{

  public static void
  main (
    String[ ] args
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int n;
    int i;
    
    n = sc.nextInt ( );
    for ( i = 0; i < n; ++i )
    {
      BigInteger r;
      
      r = sc.nextBigInteger ( );
      r = r.add ( sc.nextBigInteger ( ) );

      if ( r.compareTo ( new BigInteger ( "100000000000000000000000000000000000000000000000000000000000000000000000000000000" ) ) >= 0 )
        System.out.println ( "overflow" );
      else
        System.out.println ( r );
    }
    
    return ;
  }
  
}

Measured memory_bytes: 18148
//
// Created by Kiran Chavhan on 02/08/2020.
//

#include<bits/stdc++.h>

#define int long long
#define MOD 1000000007
#define sort(a) sort(a.begin(),a.end())
#define endl '\n'

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){
    unsigned long long n, k;
    cin >> n >> k;

    vector<unsigned long long> h(n);
    for(unsigned long long i=0; i<n; i++){
        cin >> h.at(i);
    }

    if(n <= k){
        cout << 0 << endl;

        return 0;
    }

    sort(h.begin(), h.end(), greater<unsigned long long>());

    h.erase(h.begin(), h.begin() + k);

    unsigned long long init = 0;

    unsigned long long sum = accumulate(h.begin(), h.end(), init);

    cout << sum << endl;
}

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

typedef long long ll;

int a, b, c, d;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;

    return 0;
}



Measured memory_bytes: 3632
n,m,q = gets.split.map(&:to_i)
ar = []

q.times do
  ar << gets.split.map(&:to_i)
end

max = 0

(1..m).to_a.repeated_combination(n).each do |comb|
  sum = 0
  ar.each do |a,b,c,d|
    if comb[b-1] - comb[a-1] == c
      sum += d
    end
  end
  if sum > max
    max = sum 
  end
end

puts max


Measured memory_bytes: 14692
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int X = Integer.parseInt(sc.next());
        sc.close();

        int d = 0;
        boolean b = true;
        if (X==2) {
            System.out.println(2);
            return;
        } else if (X%2==0) d = 1;
        for (int i=X+d; ; i+=2) {
            b = true;
            for (int j = 3; j<X+d; j+=2) {
                if (i%j==0) {
                    b = false;
                    break;
                }
            }
            if (b) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 23764
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]

def hantei(x):
  if x in a:
    return 1
  elif x in b:
    return 2
  else:
    return 3

x,y=map(int,input().split())
print("Yes" if hantei(x)==hantei(y) else "No")


Measured memory_bytes: 9068
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int x,n;
int t;
map<int,int> mp;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>x>>n;
	 for(int i=1;i<=n;++i){
	 	cin>>t;
	 	mp[t]++;
	 }
	 int cnt=INF;
	 int ans=x;
	 for(int i=x;i<=1000;++i){
	 	if(!mp[i]){
	 		cnt=abs(x-i);
	 		ans=i;
	 		break;
	 	}
	 }
	 for(int i=x;i>=-1000;--i){
	 	if(!mp[i] && abs(x-i)<=cnt){
	 		ans=i;
	 		break;
	 	}
	 }
	 cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;cin>>s1>>s2;
	int res = 0,l = s1.length();
	for(int i=0;i<l;i++)
	{
		if(s1[i] != s2[i]) res++;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3856
from fractions import gcd


def cntTwo(n):
    i = 0
    while n % 2 == 0:
        i += 1
        n //= 2
    return i


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

A = list(map(int, input().split()))
B = [a // 2 for a in A]

c = 1
numTwo = cntTwo(B[0])
for b in B:
    if cntTwo(b) != numTwo:
        print(0)
        exit()
    c = b * c // gcd(c, b)

ans = M // c
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)


Measured memory_bytes: 16316
package main

import "fmt"

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

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := 0
	for i := range a {
		ans += count(a[i])
	}

	fmt.Println(ans)
}

func count(n int) int {
	cnt := 0
	for n%2 == 0 {
		n /= 2
		cnt++
	}
	return cnt
}

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

int main() {
  
  int N,M;
  
  cin >> N;
  vector<string> vec1(N);
  for (int i=0; i<N; i++) cin >> vec1.at(i);
  
  cin >> M;
  vector<string> vec2(M);
  for (int i=0; i<M; i++) cin >> vec2.at(i);
  
  int s=0;
  
  for (int i=0; i<N; i++) {
    int t=0;
    for (int j=0; j<N; j++) {
      if (vec1.at(j)==vec1.at(i)) t+=1;
    }
    for (int j=0; j<M; j++) {
      if (vec2.at(j)==vec1.at(i)) t-=1;
    }
    if (s<t) s=t;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int a[100010];
int main(){
	int n;
	cin>>n;
	for(int i = 1;i <= n; i++) 	cin>>a[i];
	sort(a + 1,a + n + 1);
	cout<<a[n]<<" ";
	int m = a[1];
	double mid = double(a[n])/2.0;
	for(int i = 2;i <= n; i++)
	if(abs(double(m) - mid) > abs(double(a[i]) - mid)) 
	  m = a[i];
	cout<<m<<endl;
	return 0;
}

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

using namespace std;

string s;

int main () {
    cin >> s;
    int n = s.size ();
    string s1, s2, r1, r2, r;
    s1 = s.substr (0, n / 2);
    s2 = s.substr (n / 2 + 1, n);
    r = s;
    r1 = s1;
    r2 = s2;
    reverse (r.begin (), r.end ());
    reverse (r1.begin (), r1.end ());
    reverse (r2.begin (), r2.end ());
    cout << (r1 == s1 && r2 == s2 && r == s ? "Yes" : "No");
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if "SUN" == s {
		fmt.Print(7)
	} else if "MON" == s {
		fmt.Print(6)
	} else if "TUE" == s {
		fmt.Print(5)
	} else if "WED" == s {
		fmt.Print(4)
	} else if "THU" == s {
		fmt.Print(3)
	} else if "FRI" == s {
		fmt.Print(2)
	} else if "SAT" == s {
		fmt.Print(1)
	}
}


Measured memory_bytes: 512
a, b = list(input().split())

if a == "A":
    a = "10"
if a == "B":
    a = "11"
if a == "C":
    a = "12"
if a == "D":
    a = "13"
if a == "E":
    a = "14"
if a == "F":
    a = "15"

if b == "A":
    b = "10"
if b == "B":
    b = "11"
if b == "C":
    b = "12"
if b == "D":
    b = "13"
if b == "E":
    b = "14"
if b == "F":
    b = "15"

a=int(a)
b=int(b)

if a>b:
    print(">")
elif a<b:
    print("<")
else:
    print("=")

Measured memory_bytes: 9148
#include <cstdio>
int N, X, a[200000];
int main()
{
	scanf("%d%d", &N, &X);
	if (X == 1 || X == N + N - 1)
	{
		puts("No");
		return 0;
	}
	int C2 = N + N - 1 - X;
	for (int i = N - 1; C2 && i; i--)
	{
		a[i] = 1;
		C2--;
	}
	for (int i = N + N - 1; C2; i--)
	{
		a[i] = 1;
		C2--;
	}
	puts("Yes");
	for (int i = 1, u0 = 1, u2 = N + N - 1; i <= N + N - 1; i++)
		printf("%d\n", i == N ? X : (a[i] ? u2-- : u0++));
	return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<algorithm>

constexpr int Maxn=100;

inline int rd(){
	static int _;
	return scanf("%d",&_),_;
}

int a[Maxn+1];

int main(){
	const int n=rd();int x=rd();
	for(int i=1;i<=n;++i)
		a[i]=rd();

	std::sort(a+1,a+n+1);
	int cnt=0;
	for(int i=1;i<n;++i)
		if(a[i]<=x)
			++cnt,x-=a[i];
	if(a[n]==x)
		++cnt;

	return printf("%d",cnt),0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long a,b,d,x;
int main()
{
    x=99999999999999;
    cin>>a;
    b=a;
    d=2;
    while(d*d<=a)
    {
        if(a%d==0)
            x=a/d+d-2;
        d++;
    }
    if(x!=99999999999999)
        cout<<x;
    else cout<<a-1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<pair<int, pair<int,int> > > data;
  rep(i,n){
    int x,y,h;
    cin >> x >> y >> h;
    pair<int,int> buf = make_pair(x,y);
    data.push_back(make_pair(h,buf));
  }
  sort(all(data));
  reverse(all(data));
  int ans = 0;
  int x,y;
  int bh = data[0].first;
  int bx = data[0].second.first;
  int by = data[0].second.second;
  rep(i,101) rep(j,101){
    int dx = abs(bx - i);
    int dy = abs(by - j);
    int maybe = bh + dx + dy;
    bool flag = true;
    rep(k,n-1){
      dx = abs(data[k+1].second.first - i);
      dy = abs(data[k+1].second.second - j);
      if(max(maybe - dx - dy,0) != data[k+1].first){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = maybe;
      x = i;
      y = j;
      break;
    }
  }
  cout << x <<" "<< y <<" "<< ans << endl;
}



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

int main(){
	int n;
	scanf("%d",&n);
	string c;
	cin>>c;
	int res=0;
	for(int i=0;i<n;i++){
		int ok=0;
		string s;
		cin>>s;
		for(int j=0;j<s.length();j++){
			for(int k=1;k<s.length();k++){
				for(int l=0;l<c.length();l++){
					if(j+k*l>s.length())break;
					if(s[j+k*l]!=c[l])break;
					if(l==c.length()-1)ok=1;
				}
				if(ok)break;
			}
			if(ok)break;
		}
		if(ok)res++;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char grid[1000][1000];
int steps[1000][1000];
queue<pair<int,int> > q;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cerr<<"0x3f="<<(int)0x3f<<endl;
	cin>>n>>m>>k;
	pair<int,int> stt;
	memset(steps,0x3f,sizeof(steps));
	for(int i=0;i<n;i++){
		scanf("%s",grid[i]);
		for(int j=0;j<m;j++){
			if(grid[i][j]=='S'){
				stt=make_pair(i,j);
			}
		}
	}
	steps[stt.first][stt.second]=0;
	q.push(stt);
	while(!q.empty()){
		stt=q.front();
		q.pop();
		if(steps[stt.first][stt.second]>=k)
			continue;
		for(int i=0;i<4;i++){
			int nx=stt.first+dx[i];
			int ny=stt.second+dy[i];
			if(nx>=0&&nx<n&&ny>=0&&ny<m){
				if(steps[nx][ny]>=1e9&&grid[nx][ny]!='#')
				{
					q.push(make_pair(nx,ny));
					steps[nx][ny]=steps[stt.first][stt.second]+1;
				}
			}
		}
	}
	int res=1e9;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(steps[i][j]<=k){
				int xx=min(min(i,j),min(n-i-1,m-j-1));
				res=min(res,(xx+k-1)/k+1);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

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

    ll a {}, b {}, c {};
    cin >> a >> b >> c;
    
    ll d {(c - a - b)};

    if (d > 0 && d*d > (4*a*b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

flag = 0
S = [0,0]
for i in range(N):
    t,x,y = [int(zz) for zz in input().split()]
    p = abs(S[0]-x)+abs(S[1]-y)
    if t < p or (t-p)%2 != 0:
        flag = 1

if flag:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <cstdio>

int parent[111111], check[111111];

int Find(int x)
{
	if (x == parent[x])
		return x;
	else
		return parent[x] = Find(parent[x]);
}

int main(void)
{
	int n, m, i, x, y;

	scanf("%d %d" ,&n, &m);

	for (i = 1; i <= n; i++)
		parent[i] = i;

	while (m--)
	{
		scanf("%d %d %*d" ,&x, &y);

		x = Find(x);
		y = Find(y);

		if (x != y)
			parent[y] = x;
	}

	for (i = 1; i <= n; i++)
		check[Find(i)] = 1;

	int ans = 0;
	for (i = 1; i <= n; i++)
		ans += check[i];

	printf("%d" ,ans);
	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-

n, y = map(int, input().split())

detected = False
ans1 = -1
ans2 = -1
ans3 = -1
for i in range(0, n + 1):
    if detected:
        break

    for j in range(0, n + 1 - i):
        if detected:
            break

        temp_x = y - (i * 10000) - (j * 5000) - ((n - i - j) * 1000)
        if temp_x == 0:
            detected = True
            ans1 = i
            ans2 = j
            ans3 = n - i - j
            break

print(ans1, ans2, ans3)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll n, ll x){
    if(x==0){
        return n;
    }
    else{
        return gcd(x,n%x);
    }
}
int main(void){
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    ll val=gcd(n,x);
    cout<<3*(n-val);
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, answer=0;
  cin >> N;
  vector<int> C(N), V(N);
  for(int i=0; i<N; i++)
    cin >> V.at(i);
  for(int i=0; i<N; i++)
    cin >> C.at(i);
  for(int i=0; i<N; i++){
    if(C.at(i) <= V.at(i))
      answer += V.at(i) - C.at(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n,m,x,sum=0;
	cin>>n>>m>>x;
	n-=x;
	while(n-x-m>=0){
		n-=x;
		n-=m;
		sum++;
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

#define YesNo(x) if(x) cout << "Yes" << endl; else cout << "No" << endl;
#define YESNO(x) if(x) cout << "YES" << endl; else cout << "NO" << endl;

#define WALL     0xFFFFFFFFFFFFFFFF
#define PATH     0xFFFFFFFFFFFFFFFE

typedef pair<u64, u64> point;

u64 map[60][60] = {WALL};

u64 get_value(point p) {
	return map[p.first][p.second];
}

bool is_searched(point a) {
	u64 v = get_value(a);
	return !(v == WALL || v == PATH);
}

void print(point p) {
	cerr << "(" << p.first << ", " << p.second << ") = " << get_value(p) << endl;
}

void printmap(u64 r, u64 c) {
	rep(i, r) {
		rep(j, c) {
			switch(map[i][j]) {
				case WALL:
					cerr << "#";
					break;
				case PATH:
					cerr << " ";
					break;
				default:
					cerr << map[i][j] % 10;

			}
		}
		cerr << endl;
	}
	cerr << endl;
}

int main(int argc, const char* argv[]) {
	u64 h, w;
	cin >> h >> w;
	u64 sy = 0;
	u64 sx = 0;
	u64 gy = h - 1;
	u64 gx = w - 1;

	u64 white = 0;
	rep(i, h) {
		string s;
		cin >> s;

		rep(j, w) {
			switch(s[j]) {
				case '#':
					map[i][j] = WALL;
					break;
				case '.':
					++white;
					map[i][j] = PATH;
					break;
				default:
					cerr << "Invalid character: c[" << i+1 << "][" << j+1 << "] = " << s[j] << endl;
					return 0;
			}
		}
	}

	printmap(h, w);

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

	queue<point> q;
	q.emplace(sy, sx);
	map[sy][sx] = 0;

	while(q.empty() == false) {
		point now = q.front();
		q.pop();

		print(now);

		rep(i, 4) {
			u64 ny = now.first  + dy[i];
			u64 nx = now.second + dx[i];

			if(ny < 0 || h <= ny || nx < 0 || w <= nx ) {
				continue;
			}

			cerr << "next: map[" << ny << ", " << nx << "] = " << map[ny][nx] << endl;

			if( map[ny][nx] == PATH ) {
				q.emplace(ny, nx);
				map[ny][nx] = map[now.first][now.second] + 1;
				cerr << "next: map[" << ny << ", " << nx << "] = " << map[ny][nx] << endl;
			}
		}
	}

	printmap(h, w);

	if(map[gy][gx] == PATH) {
		cout << "-1" << endl;
	 } else {
	 	cout << white - (map[gy][gx] + 1) << endl;
	 }

	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#define INF 1000000000000
const long long MOD = 1000000007;

using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    string S;
    cin >> S;
    if(S[S.size()-1]=='s'){
        cout << S+"es" << endl;
    }else{
        cout << S + 's' << endl;
    }
}





Measured memory_bytes: 3128
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

constexpr int inf = 1000000000;

int main() {

  int N, K, S;
  std::cin >> N >> K >> S;
  std::vector<int> ans(N);
  rep (i, K) ans[i] = S;
  int t = (S == inf ? 1 : inf);
  rep (i, K, N - 1) {
    ans[i] = t;
  }

  rep (i, N) {
    std::cout << ans[i];
    std::cout << (i + 1 == N ? '\n' : ' ');
  }

}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

ll gcd(ll a, ll b)
{
    while(b)
    {
        a %= b;
        swap(a, b);
    }

    return a;
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll cnt = 0;
    bool f = true;
    int n = s.size();
    for(int i = 1; i < n; i++){
        if(s[i - 1] != s[i]){
            f = false;
            break;
        }
    }
    ll ans = 0;
    if(f){
        ans = n * k / 2;
    }else{
        bool f2 = (s[0] == s.back()? true : false);
        ll a = 1, b = 1;
        if(f2){
            while(s[a - 1] == s[a]){ a++; }
            while(s[n - b] == s[n - b - 1]){ b++; }
        }
        for(int i = 1; i < n; i++){
            if(s[i - 1] == s[i]){
                s[i] = '0';
                ans++;
            }
        }
        if(f2){
            ans = ans * k - ((ll)(a / 2) + (ll)(b / 2) - (ll)((a + b) / 2)) * (k - 1);
        }else{
            ans *= k;
        }
        
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,k;
  int num = 1;
  cin >> n >> k;
  for(int i =0;i<n; i++){
    if(num*2 <num+k ){num=num*2;}else{num += k;}
  }
  cout << num << endl;
}

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6;
int A[N];

int mat[1005][1005];

int solve(int n)
{
    if(n%1000 == 0)
        return 0;
    return 1000 - (n % 1000);
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,k,i,j,x,y,a,b;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;

        cout<<solve(n)<<endl;
    }

	return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

class Route
{
private:
  int m_d;
  int m_p;
public:
  void setD(int d);
  void setP(int p);
  int getD();
  int getP();
  Route(int d, int p) {
    setD(d);
    setP(p);
  }
};

void Route::setD(int d) {
  m_d = d;
}

void Route::setP(int p) {
  m_p = p;
}

int Route::getD() {
  return m_d;
}

int Route::getP() {
  return m_p;
}

int main() {
  int N, M, d, p, p_sum;
  while (cin >> N >> M, N | M) {
    vector<Route> routes;
    while (N--) {
      cin >> d >> p;
      routes.pb(Route(d, p));
    }
    for (int i = 0; i < routes.size(); i++) {
      for (int j = i+1; j < routes.size(); j++) {
        if (routes[i].getP() < routes[j].getP()) {
          swap(routes[i], routes[j]);
        }
      }
    }
    for (int i = 0; i < routes.size(); i++) {
      if (M > routes[i].getD()) {
        M -= routes[i].getD();
        routes[i].setD(0);
      } else {
        routes[i].setD(routes[i].getD()-M);
        M = 0;
      }
    }
    p_sum = 0;
    for (int i = 0; i < routes.size(); i++) {
      p_sum += routes[i].getD() * routes[i].getP();
    }
    cout << p_sum << el;
  }
}

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

int main()
{
    long N, M, K;
    cin >> N >> M >> K;

    vector<long> A(N + 1);
    vector<long> B(M + 1);

    long sumA = 0;
    long a = 0;

    A.at(0) = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        sumA += a;
        A.at(i + 1) = sumA;
    }

    long sumB = 0;
    long b = 0;
    B.at(0) = 0;
    for (long i = 0; i < M; i++)
    {
        cin >> b;
        sumB += b;
        B.at(i + 1) = sumB;
    }

    // 冊数
    int count = 0;
    for (int i = 0; i < N + 1; i++)
    {
        if (A.at(i) <= K)
        {
            count++;
        }
        else
        {
            break;
        }
    }

    if (count > 0)
    {
        count--;
    }

    // nの冊数
    int nA = count;

    for (int i = 0; i < M + 1; i++)
    {
        if (A.at(nA) + B.at(i) <= K && count <= nA + i)
        {
            count = nA + i;
        }
        else
        {
            for (int j = 0; j <= nA; j++)
            {
                if (A.at(nA - j) + B.at(i) < K)
                {
                    nA = nA - j;
                    break;
                }
            }
        }
    }

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

Measured memory_bytes: 6432
#include <iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int l=0,r=0;
	for(int i=0; i<a.size(); i++)
	{
		if(a[i]=='A') 
		{
			l=i;
			break;
		}
	}
	for(int i=0; i<a.size(); i++)
	{
		if(a[i]=='Z') 
		{
			r=i;
		}
	}
	cout<<r-l+1;
	return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}
  


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

A.sort()
# どの r を選んでも、n が大きいほうが大きい。
n = A[-1]
# n を固定したとき、n/2 に近いほうが大きい。
r = A[0]
for a in A[:-1]:
    if abs(n / 2  - a) < abs(n / 2 - r):
        r = a
print(n, r)


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


int main() {
  int N  ; 
  cin >> N ; 
  vector<int> ans(N+1) ; 
  
  for( int x = 1 ; x <= 100 ; x++ ){
      for( int y = 1 ; y <= 100 ; y++ ){
          for( int z = 1 ; z <= 100 ; z++ ){
    		int s = x*x + y*y + z*z + x*y + y*z + z*x ; 
            if(s > N) {
              continue ; 
            }
              ans[s]++ ; 
            
  		  }
  	  }
  }
  
  for(int i = 1 ; i <= N ; i++){
    cout << ans[i] << endl ; 
  }
  
  return 0 ; 
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MOD = 1000000007;

ll mod_pow(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b & 1) return (a * mod_pow(a, b - 1, p)) % p;
    ll t = mod_pow(a, b / 2, p);
    return (t * t) % p;
}

ll mod_inv(ll a, ll p) { return mod_pow(a, p - 2, p); }

ll mod_comb(ll n, ll r, ll p) {
    ll tn = 1, tr = 1;
    for (int i = n; i > n - r; i--) {
        tn *= i;
        tn %= p;
    }
    for (int i = r; i > 0; i--) {
        tr *= i;
        tr %= p;
    }
    return tn * mod_inv(tr, p) % p;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = mod_pow(2, n, MOD) - 1 - mod_comb(n, a, MOD) - mod_comb(n, b, MOD);
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}

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

int main() {
    char c; cin >> c;
    string vowel = "aeiou";
    if (vowel.find(c) != string::npos) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    a.sort()
    neg_count = bisect.bisect_left(a, 0)

    a_abs = list(map(abs,a))
    a_abs.sort()

    if neg_count % 2 == 0:
        ans = sum(a_abs)
    else:
        ans = sum(a_abs[1:]) - a_abs[0]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 60816
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []B = new int[N];
		for(int i = 0; i < N; i++) {
			B[i] = scan.nextInt() - i - 1;
		}
		scan.close();
		if(N == 1) {
			System.out.println(0);
			System.exit(0);
		}
		Arrays.sort(B);
		long sum = 0;
		long min = 10000000000000000L;
		int k[] = {B[N/2], B[N/2 + 1]};
		for(int i = 0; i < 2; i++) {
			sum = 0;
			for(int j = 0; j < N; j++) {
				sum += abs(k[i], B[j]);
			}
			if(min > sum) {
				min = sum;
			}
		}
		System.out.println(min);

	}
	static int abs(int a, int b) {
		if(a > b) {
			return a - b;
		}else {
			return b - a;
		}
	}
}

Measured memory_bytes: 91716