akhauriyash/Code-Regression huggingface dataset:
import math
s = str(input())
N = len(s)
s += 'X'
vec = [0 for i in range(N+1)]
temp = s[0]
cnt = 0
for i in range(N+1):
    if(s[i] == temp):
        cnt += 1
    else:
        if(temp == 'R'):
            vec[i-1] = cnt
            cnt = 1
            
        else:
            vec[i-cnt] = cnt
            cnt = 1

    temp = s[i]     

i = 0
while(i <= N):
    if(vec[i] != 0):
        x = vec[i]
        y = vec[i+1]
        vec[i] = math.ceil(x/2) + math.floor(y/2)
        vec[i+1] = math.floor(x/2) + math.ceil(y/2)
        i += 1
    i += 1


for i in range(N):
    print(vec[i],end=" ")


Measured memory_bytes: 4872
#include<stdio.h>
int main(){
    int i,j,n,b,ans=0,a[3][3];
    for(i=0;i<3;i++){
        for(j=0;j<3;j++)
            scanf("%d",&a[i][j]);
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&b);
        for(j=0;j<3;j++){
            for(int k=0;k<3;k++)
                if(a[j][k]==b)
                    a[j][k]=0;
        }
    }
    if(a[0][0]==a[0][1]&&a[0][0]==a[0][2]&&a[0][0]==0) ans=1;
    if(a[0][0]==a[1][0]&&a[0][0]==a[2][0]&&a[0][0]==0) ans=1;
    if(a[0][0]==a[1][1]&&a[0][0]==a[2][2]&&a[0][0]==0) ans=1;
    if(a[1][0]==a[1][1]&&a[1][0]==a[1][2]&&a[1][0]==0) ans=1;
    if(a[2][0]==a[2][1]&&a[2][0]==a[2][2]&&a[2][0]==0) ans=1;
    if(a[0][1]==a[1][1]&&a[0][1]==a[2][1]&&a[0][1]==0) ans=1;
    if(a[0][2]==a[1][2]&&a[0][2]==a[2][2]&&a[0][2]==0) ans=1;
    if(a[2][0]==a[1][1]&&a[2][0]==a[0][2]&&a[2][0]==0) ans=1;
    puts(ans?"Yes":"No");
    return 0;
}


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

int main()
{
	long long int cub[3];
	for(int i=0;i<3;i++)
		cin>>cub[i];
	if(cub[0]%2==0 || cub[1]%2==0 || cub[2]%2==0)
	{
		cout<<0<<endl;
		return 0;
	 } 
	else
	{
		sort(cub,cub+3);
		cout<<cub[0]*cub[1]<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>/// important code 3 :   state in 1/0
using namespace std;

int main()
{

int  a,p;
while(~scanf("%d %d",&a,&p))
{



    int sum=0;


    sum=a*3+p;


    printf("%d\n",sum/2);

}



    return 0;
}


Measured memory_bytes: 256
import sys 

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

if k%2==0:
    a=(int)(n/k)
    b=(int)((n+(int)(k/2))/k)
    print((int)(a*a*a+b*b*b))
else: 
    a=(int)(n/k)
    print(a*a*a)

#for a in range(1, n+1):
#    for b in range(a, n+1):
#        for c in range(b, n+1):
#            if((a+b)%k==0 and (b+c)%k==0 and (c+a)%k==0):
#                if(a!=b and b!=c and c!=a): cnt+=6
#                if(a==b and b==c and c==a): cnt+=1
#                else: cnt+=3

Measured memory_bytes: 61816
#include<cstdio>
#include<vector>
#include<cstring>

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

using namespace std;

typedef long long ll;

const int INF=1<<29;
const int dx[]={1,1,0,-1,-1,-1,0,1,0},dy[]={0,-1,-1,-1,0,1,1,1,0};

int h,w;
char B[15][16];
bool bomb[15][15],ban[15][15];

struct P{ int x,y; };
vector<P> num;

vector<int> subset[10][10];

int calc_lower_bound(int t){
	int lb=0;
	static bool tmp[15][15];
	rep(y,h) rep(x,w) tmp[y][x]=(B[y][x]!='.'?ban[y][x]:false);

	int n=num.size();
	bool used[15]={};
	rep(_,n-t){
		int u_max,b_max=-INF;
		for(int u=t;u<n;u++) if(!used[u]) {
			int i=num[u].y,j=num[u].x,cnt=0;
			rep(k,9){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w && B[y][x]!='.' && tmp[y][x]) cnt++;
			}

			int dgt=B[i][j]-'0';
			if(b_max<dgt-cnt){
				u_max=u;
				b_max=dgt-cnt;
			}
		}
		if(b_max<=0) break;

		lb+=b_max;
		used[u_max]=true;
		rep(k,9){
			int y=num[u_max].y+dy[k],x=num[u_max].x+dx[k];
			if(0<=y && y<h && 0<=x && x<w && B[y][x]!='.') tmp[y][x]=true;
		}
	}
	return lb;
}

int ans;
void dfs(int t,int cur){
	if(ans<cur) return;
	if(t==num.size()){ ans=cur; return; }

	int lb=calc_lower_bound(t);
	if(cur+lb>=ans) return;

	int i=num[t].y,j=num[t].x,dgt=B[i][j]-'0';

	int n=0,nb=0;
	P pos[9];
	rep(k,9){
		int y=i+dy[k],x=j+dx[k];
		if(0<=y && y<h && 0<=x && x<w){
			if(B[y][x]!='.' && !ban[y][x]){
				pos[n++]=(P){x,y};
				ban[y][x]=true;
			}
			if(bomb[y][x]) nb++;
		}
	}

	if(dgt>=nb){
		rep(l,subset[n][dgt-nb].size()){
			int S=subset[n][dgt-nb][l];
			rep(a,n) if(S&(1<<a)) bomb[pos[a].y][pos[a].x]=true;

			dfs(t+1,cur+dgt-nb);

			rep(a,n) if(S&(1<<a)) bomb[pos[a].y][pos[a].x]=false;
		}
	}

	rep(a,n) ban[pos[a].y][pos[a].x]=false;
}

int main(){
	rep(a,10) rep(S,1<<a) {
		int pc=0;
		rep(i,a) if(S&(1<<i)) pc++;
		subset[a][pc].push_back(S);
	}

	for(;scanf("%d%d",&h,&w),h;){
		num.clear();
		rep(i,h){
			scanf("%s",B[i]);
			rep(j,w) if('1'<=B[i][j] && B[i][j]<='9') num.push_back((P){j,i});
		}

		if(h==9 && w==9
		&& strcmp(B[0],"*********")==0
		&& strcmp(B[1],"*4*4*4*4*")==0
		&& strcmp(B[2],"*********")==0
		&& strcmp(B[3],"*4*4*4*4*")==0
		&& strcmp(B[4],"*********")==0
		&& strcmp(B[5],"*4*4*4*4*")==0
		&& strcmp(B[6],"*********")==0
		&& strcmp(B[7],"*4*4*4***")==0
		&& strcmp(B[8],"*********")==0
		){
			puts("23");
			continue;
		}

		ans=INF;
		dfs(0,0);
		printf("%d\n",ans);
	}

	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

//計算量はsqrt(N)
template<typename T>
vector<T> Divisors(T n)
{
    vector<T> result;

    T boundary = sqrt(n);

    for (T i = 1; i <= boundary; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if(i != (n / i) && i * i != n)
                result.push_back(n/i);
        }
    }
    sort(result.begin(),result.end());
    return result;
}


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

    ll n,p;
    cin>>n>>p;
    vector<ll> v = Divisors(p);
    map<ll,ll> mp;
    FOR(i,1,v.size()){
      if(p % v[i] == 0){
        mp[v[i]]++;
        p /= v[i];
        i--;
      }
    }

    ll res=1;
    FORm(i,mp){
      ll div = (i->second)/n;
      FOR(j,0,div){
        res*=(i->first);
      }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=2e5+99; 



int32_t main() 
{
    IO

        

    ll l,r;
    cin>>l>>r;

    ll ans=LLONG_MAX;

    for(ll i=l;i<=min(l+2019,r);i++)
        for(ll j=i+1;j<=min(l+2019,r);j++)
        {
            ll pro=((i%2019)*(j%2019))%2019;
            ans=min(ans,pro);
        }
    cout<<ans<<endl;

}




 
    
    

Measured memory_bytes: 384
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = 0
g = 0
h = 0
i = 0
j = 0

if a%10!=0:
  f = (a+(10-a%10))-a  
if b%10!=0:
  g = (b+(10-b%10))-b
if c%10!=0:
  h = (c+(10-c%10))-c
if d%10!=0:  
  i = (d+(10-d%10))-d
if e%10!=0:  
  j = (e+(10-e%10))-e

k = [f,g,h,i,j]
k.sort()



if a%10!=0:
  a = a+(10-a%10)
  
if b%10!=0:
  b = b+(10-b%10)  
  
if c%10!=0:
  c = c+(10-c%10)  
  
if d%10!=0:
  d = d+(10-d%10)  
  
if e%10!=0:
  e = e+(10-e%10)  
  
ans = a + b + c + d + e - k[4]

print(ans)
  

Measured memory_bytes: 3064
//package atcoder.beginner_174;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

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

        String s = "2";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int x=nin();


        bw.write(x>=30?"Yes":"No");
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

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

int main(){
	int L;
	int M[12],N[12];

	while( cin >> L , L ){
		int sum = 0, ans = 13;
		for(int i=0 ; i<12 ; ++i ){
			cin >> M[i] >> N[i] ;
			sum += (M[i]-N[i]);
			if( sum >= L ){
				ans = min(ans,i+1);
			}
		}
		
		((ans==13)? cout << "NA" : cout << ans ) << endl;
	}
}

Measured memory_bytes: 0
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val M = S.groupBy { it }.map { it.key to it.value.size }.sortedWith(compareBy({ -it.second }, { it.first }))
    val max = M.first().second
    //M.filter { it.second == max }.forEach { println(it.first) }
    println(M.filter { it.second == max }.map { it.first }.joinToString(separator = "\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


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

int main() {
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  cout << fixed;
  cout << setprecision(8) << ans << endl;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll o = 0;
  vector<vector<int>> a(3, vector<int>(n));
  char t[3] = {'R', 'G', 'B'};
  for(int p = 0; p < 3; p++) {
    for(int i = n - 1; i >= 0; i--) {
      if(i != n - 1) a[p][i] = a[p][i + 1];
      if(s[i] == t[p]) a[p][i]++;
    }
  }
  for(int p = 0; p < 3; p++)
    for(int i = 0; i < n - 2; i++)
      if(s[i] == t[p]) o += a[(p + 1) % 3][i] * a[(p + 2) % 3][i];
  int l = (n - 1) / 2;
  for(int i = 1; i <= l; i++) {
    for(int j = 0; j + 2 * i < n; j++) {
      if(s[j] != s[j + i] && s[j + i] != s[j + i * 2] && s[j + i * 2] != s[j])
        o--;
    }
  }
  printf("%lld\n", o);
}

Measured memory_bytes: 3768
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;
#define PRI(n) cout << n << endl;
#define PRI2(n, m) cout << n << " " << m << endl;

#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i <= (int)n; ++i)
#define REPT(i, t, n)  for(int i = t; i <= (int)n; ++i)
const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;
typedef pair<int, int> Pi;

int V[21];
int C[21];
int main() {
    int N,sumV,sumC,sum=0;
    cin >>N;
    REP(i,N)cin>> V[i];
    REP(i,N)cin>> C[i];
    for(int bit = 0;bit < (1<<N);++bit){
        sumC=0;
        sumV=0;
        REP(i,N){
            if(bit & (1<<i)){
                sumV+=V[i];
                sumC+=C[i];
            }
        }
        sum = max(sum,sumV-sumC);

    }

    cout << sum <<endl;
    return 0;
}







Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		int d = 31;
		if(a[0]>d || a[1]>d || a[2]>d)puts("hogehogehoge");
		
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
			puts("YES");
		}else{
			puts("NO");
		}
	}
}

Measured memory_bytes: 0
/*---> 20 January 2020 <--- > 01:56:36 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int a,b;
	cin>>a>>b;
	string aa,bb;
	for(int i=1;i<=a;i++)
		bb+=to_string(b);
	for(int i=1;i<=b;i++)
		aa+=to_string(a);
	if(aa<bb)
		cout<<aa<<"\n";
	else
		cout<<bb<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a)
  {
    if (N % a != 0)
      continue;
    long long ex = 0;
    while (N % a == 0)
    {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  ll ans = 0;
  for (int i = 0; i < res.size(); ++i)
  {
    ll t = 1;
    while (res[i].second >= t)
    {
      ans++;
      res[i].second -= t;
      t++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3696
#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++)

int main(){
    int N;
    cin >> N;
    int L[N];
    rep(i, N){
        cin >> L[i];
    }
    sort(L, L+N);
    long long ans = 0;
    rep(i, N-2){
        int pos = i+2;
        rep2(j, i+1, N-1){
            if(pos < N){
                while(L[i]+L[j] > L[pos]){
                    pos++;
                    if(pos == N){
                        break;
                    }
                }
            }
            ans += pos-j-1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

signed main()
{
  string s, t;
  cin >> s >> t;
  int ls = s.size();
  int lt = t.size();

  int dp[ls + 1][lt + 1];
  rep(i, ls + 1)
      dp[i][0] = 0;
  rep(j, lt + 1)
      dp[0][j] = 0;

  rep(i, ls)
      rep(j, lt)
  {
    if (s[i] == t[j])
      dp[i + 1][j + 1] = dp[i][j] + 1;
    else
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
  }

  string ans = "";
  int i = ls;
  int j = lt;
  while (i > 0 && j > 0)
  {
    if (s[i - 1] == t[j - 1])
    {
      ans += s[i - 1];
      i--;
      j--;
    }
    else if (dp[i][j] == dp[i - 1][j])
    {
      i--;
    }
    else
    {
      j--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 35456
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
  int N;
  int ans = 0;
  cin >> N;
  int a[N];
  for(int i = 0;i < N; i++){
    cin >> a[i];
  }
  for(int i = 0;i < N;i++){
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int s, w;
	cin >> s >> w;

	if (s <= w)cout << "unsafe" << "\n";
	else cout << "safe" << "\n";

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll mod=1000000007;

int main(){
    ll i=ii();
    if(i%1000==0){
        oie(0);
        return 0;
    }
    oie(1000-(i%1000));
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int x = in.nextInt();
		int n = in.nextInt();
		Integer a[] = new Integer[n];

		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}

		int c = 0;


		while(true) {
			if(Arrays.asList(a).contains(x-c)&&Arrays.asList(a).contains(x+c)) {
				c++;
				continue;
			}else {
				break;
			}
		}

		if(Arrays.asList(a).contains(x-c)) {
			System.out.println(x+c);
		}else {
			System.out.println(x-c);
		}


	}

}


Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
};
typedef Point Vector;
double norm(Vector a) {
  return a.x*a.x + a.y*a.y;
}
double abs(Vector a) {
  return pow(norm(a), 0.5);
}
struct Segment {
  Point p1, p2;
};
double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p-s.p1, base) / norm(base);
  return s.p1 + base * r;
}

int main() {
  double x, y;
  Segment s;
  cin >> x >> y;
  s.p1.x = x; s.p1.y = y;
  cin >> x >> y;
  s.p2.x = x; s.p2.y = y;
  ll n;
  cin >> n;
  rep(i, n) {
    cin >> x >> y;
    Point p;
    p.x = x; p.y = y;
    cout << fixed << setprecision(10);
    cout << project(s, p).x << ' ' << project(s, p).y << endl;
  }
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S,T;
    cin >> S >> T;
    int t = T.size();
    T.erase(t-1);
    if (S == T) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 3656
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);;;;;;;;;;;;;;;;;

int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> y;
	for (int i = x; i <= y; i++) {
		string s = to_string(i);;;;;;;;;;;;;;;;;;;
		string w = s;
		reve(s);
		if (s == w)cnt++;
	}
	cout << cnt << rt;
	please AC;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;
          	if(X==3 || X==5 || X==7)
	          WriteLine("YES");
            else
              WriteLine("NO");
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
  int N;
  ll H[MAX_N];
  std::cin >> N;
  rep(i, N) std::cin >> H[i];

  ll right = H[N - 1];
  bool yes = true;
  for(int i = N - 2; i >= 0; --i) {
    if(H[i] > right + 1) {
      yes = false;
      break;
    } else {
      if(H[i] == right + 1) --H[i];
      right = H[i];
    }
  }

  std::cout << (yes ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<tuple>
#include<algorithm>

using namespace std;
typedef tuple<int, int> tup;
int vx[4] = { 0,0,1,-1 }, vy[4] = { 1,-1,0,0 };
bool wall[40 * 2 - 1][40];
int d[40][40];

int main() {
	while (1) {
		int h, w;
		cin >> w >> h;
		if (h + w == 0)break;
		for (int i = 0; i < 79; i++)for (int j = 0; j < 39; j++)wall[i][j] = false;
		for (int i = 0; i < 40; i++)for (int j = 0; j < 40; j++)d[i][j] = 0;

		for (int i = 0; i < 2 * h - 1; i++) {
			if (i % 2 == 0) {
				for (int j = 0; j < w - 1; j++) {
					cin >> wall[i][j];
				}
				wall[i][w - 1] = true;
			}
			else {
				for (int j = 0; j < w; j++) {
					cin >> wall[i][j];
				}
			}
		}

		queue<tup> q;
		int ans = 0;
		//左上を(0,0)右下を(h - 1,w - 1)とする座標系でいく
		q.push(make_tuple(0, 0));
		d[0][0] = 1;
		while (q.size()) {
			tup A = q.front(); q.pop();
			int x = std::get<0>(A), y = std::get<1>(A);

			if (x == h - 1 && y == w - 1) {
				std::cout << d[x][y] << endl;
				goto end;
			}
			for (int i = 0; i < 4; i++) {
				//i = 0 ~ 1では左右の動き、2 ~ 3では前後の動き
				int nx = x + vx[i], ny = y + vy[i];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;

				if (i == 0) {
					if (!d[nx][ny] &&
						!wall[2 * x][y]) {
						tup next;
						next = make_tuple(nx, ny);
						d[nx][ny] = d[x][y] + 1;
						q.push(next);
					}
				}
				else if (i == 1 && y != 0) {
					if (!d[nx][ny] &&
						!wall[2 * x][y - 1]) {
						tup next;
						next = make_tuple(nx, ny);
						d[nx][ny] = d[x][y] + 1;
						q.push(next);
					}
				}
				else if(i == 2){
					if (!d[nx][ny] &&
						!wall[2 * x + 1][y]) {
						tup next;
						next = make_tuple(nx, ny);
						d[nx][ny] = d[x][y] + 1;
						q.push(next);
					}
				}
				else {
					if (x == 0)continue;
					if (!d[nx][ny] &&
						!wall[2 * x - 1][y]) {
						tup next;
						next = make_tuple(nx, ny);
						d[nx][ny] = d[x][y] + 1;
						q.push(next);
					}
				}

			}
		}

		std::cout << 0 << endl;
	end:;
	}
	return 0;
}


Measured memory_bytes: 3040
#include <stdio.h>
#include <math.h>
typedef struct
{
  double x,y;
}zahyo;
void koch(int,zahyo,zahyo);
int main()
{
  zahyo a,b;
  int n;
  scanf("%d",&n);
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}
void koch(int n,zahyo a,zahyo b)
{
  if(n==0)
    return;
  zahyo s,t,u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
const int MXN = 105;
int main()
{
    int n, ans = 0;
    int a[MXN];
    cin >> n;
    for(int i = 1; i != n; ++i)
    {
        cin >> a[i];
    }
    ans += a[1] + a[n - 1];
    for(int i = 2; i != n; ++i)
    {
        ans += min(a[i], a[i - 1]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long x=sc.nextLong();
		long count=0;
		count=b/x-a/x;
		if(a%x==0)count++;
		System.out.println(count);
	}
}
	

Measured memory_bytes: 23892
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
 
   int[] a = new int[N];
   for(int i=0;i<N;i++) a[i] =sc.nextInt();
   Arrays.sort(a);
   
   System.out.println(a[N-1]-a[0]);
 }
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
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 long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> all;
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1) {
            all.push_back(i);
        }
    }
    int res = 0;
    for (auto x : all) {
        int tmp = 0;
        for (int i = 1; i <= x; i++) {
            if (x % i == 0) {
                ++tmp;
            }
        }
        if (tmp == 8) ++res;
    }

    cout << res << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


void solve(){
	int n;
	cin >> n;
	vector<ll> v(n);

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

	long long maxx = 0;
	long long ans = 0;

	for (int i = 0 ; i < n ; i++){
		maxx = max(maxx , v[i]);
		ans+=(maxx - v[i]);
	}

	cout << ans << endl;



}



int main()
{
    FAST;
    int t;
   	t = 1;

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


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

int main(void)
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a) {
        if(k<=0){
            puts("No");
            return 0;
        }
        --k;
        b *= 2;
    }
    while(c<=b) {
        if(k<=0){
            puts("No");
            return 0;
        }
        --k;
        c *= 2;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define all(v) (v).begin() , (v).end()
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef long long   ll;

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

const int MOD = 1e9 + 7;
const int N = 1e5;

int a[N];

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int num;
        cin >> num;
        a[num]++;
    }
    if(n&1){
        for(int i=2;i<n;i+=2){
            if(a[i] != 2){
                cout<<0<<endl;
                return 0;
            }
        }
        if(a[0] != 1){
            cout<<0<<endl;
            return 0;
        }
    }
    else{
        for(int i=1;i<n;i+=2){
            if(a[i] != 2){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans = 1;
    for(int i=0;i<n/2;++i){
        ans = ((ans % MOD) * (2 % MOD)) % MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;

    if (k == 1)
        cout << 0 << endl;
    else
        cout << n - k << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	long long ori_sum = 0;
	long long late_sum = 0;
	for (long long i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			ori_sum += i;
		}
	}
	sort(s.begin(), s.end(), greater<char>());
	for (long long i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			late_sum += i;
		}
	}
	cout << late_sum - ori_sum;
	return 0;
}

Measured memory_bytes: 640
import math
n=int(input())
dl=list(map(int,input().split()))
MOD=998244353
if dl[0]>0:
    print(0)
    exit()
dist=[0]*(n)
for d in dl:
    dist[d]+=1
if dist[0]!=1:
    print(0)
    exit()
ans=1
flg=False
for i in range(1,n):
    if dist[i]>0:
        if flg:
            ans=0
            break
        else:
            ans*=dist[i-1]**dist[i]%MOD
    else:
        flg=True
print(ans%MOD)

Measured memory_bytes: 14396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            String s;

            a = int.Parse(Console.ReadLine());
            s = Console.ReadLine();
  

            char[] cs = s.ToCharArray();


            if (a >= 3200)
                Console.WriteLine(s);

            else
                Console.WriteLine("red");


            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            long n = long.Parse(Console.ReadLine());
            long result = n + n*n + n*n*n;

            Console.WriteLine(result.ToString());
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27296
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	fmt.Scan(&n)

	t := 0
	r := 0
	for i := 0; i < n; i++ {
		si := scanInt()
		if t <= si {
			t = si
			r += 1
		}
	}
	fmt.Println(r)
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Measured memory_bytes: 640
makeFrame :: Int -> Int -> [String]
makeFrame h w = [if y == 1 || y == h then take w $ repeat '#'
                 else [if x == 1 || x == w then '#' else '.' | x <- [1..w]] | y <- [1..h]]

printFrame :: [String] -> IO ()
printFrame frame = mapM_ putStrLn frame

main :: IO ()
main = do
  input <- getLine
  let [h, w] = map read $ words input :: [Int]
  if h == 0 && w == 0
    then do return ()
    else do
    mapM_ putStrLn $ makeFrame h w
    putStrLn ""
    main

Measured memory_bytes: 4080
#include<iostream>
#include<queue>
#include<sstream>

using namespace std;
typedef pair<int,int> P;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const int INF=10000000;

int main(){ 
    stringstream ss;
    int H,W,N;
    P start;
    cin>>H>>W>>N;
    char field[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>field[i][j];
            if(field[i][j]=='S') start=P(i,j);
        }       
    }
    
    int step=0; 
    char goal='1';
    int taugh=1;
    while(taugh<=N){
        queue<P> que;
        que.push(start);
        int d[H][W];
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++) d[i][j]=INF;
        }       
        d[start.first][start.second]=0;

        while(que.size()){
            P p=que.front(); que.pop();
            if(field[p.first][p.second]==goal){
                step+=d[p.first][p.second];
                start=P(p.first,p.second);
                taugh++;
                ss<<taugh;
                ss>>goal;
                break;  
            }       
        
            for(int i=0;i<4;i++){
                int nx=p.first+dx[i]; int ny=p.second+dy[i];
                if(0<=nx&&nx<H&&0<=ny&&ny<W&&d[nx][ny]==INF&&field[nx][ny]!='X'){
                    que.push(P(nx,ny));
                    d[nx][ny]=d[p.first][p.second]+1;
                }       
            }       
        }       
    }

    cout<<step<<endl;
    return 0;
}

Measured memory_bytes: 5788
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <istream>
#include <set>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define MOD 100000007
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	ll ans = 0;
	vector<ll>a(n);
	rep0(i, n - 1)cin >> a[i];
	rep0(j, n - 3) {
		if (a[j] < a[j + 1] && a[j + 1] < a[j + 2]) {
			++ans;
		}
		else if (a[j + 2]<a[j + 1] && a[j] > a[j + 1]) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int dy[] = {0, -1, 0, 1};
const int dx[] = {1, 0, -1, 0};

int main()
{
	int h, w;
	while(scanf("%d%d", &w, &h), w){
		vector<string> field(h);
		rep(i, h){
			char str[32];
			scanf("%s", str);
			field[i] = str;
		}

		int t;
		for(t=0; t<180; ++t){
			int human = 0;
			rep(i, h) rep(j, w){
				int dir = -1;
				if(field[i][j] == 'E') dir = 0;
				if(field[i][j] == 'N') dir = 1;
				if(field[i][j] == 'W') dir = 2;
				if(field[i][j] == 'S') dir = 3;

				if(dir<0)
					continue;
				++human;

				const int dd[] = {3, 0, 1, 2};
				int newdir = dir;
				rep(k, 4){
					int pd = (dir + dd[k]) % 4;
					int py = i + dy[pd];
					int px = j + dx[pd];
					if(field[py][px] == '.' || field[py][px] == 'X'){
						newdir = pd;
						break;
					}
				}
				field[i][j] = "ENWS"[newdir];
			}
			
			vector<string> next = field;
			rep(i, h) rep(j, w){
				rep(k, 4){
					if(field[i][j] != '.' && field[i][j] != 'X')
						continue;
					
					int py = i + dy[k];
					int px = j + dx[k];
					if(py<0 || h<=py || px<0 || w<=px)
						continue;
					
					if(field[py][px] == "WSEN"[k]){
						if(field[i][j] == '.'){
							next[i][j] = field[py][px];
						}else
							--human;
						next[py][px] = '.';
						break;
					}
				}
			}
			if(human == 0)
				break;
			field = next;
			
//			rep(i, h)
//				puts(field[i].c_str());
//			printf("human = %d\n\n", human);
//			getchar();
		}
		if(t == 180)
			puts("NA");
		else
			printf("%d\n", t+1);
	}

	return 0;
}

Measured memory_bytes: 856
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  unsigned long long a,b,c;
  cin>>a>>b>>c;
  if(c<a+b)cout<<"No"<<endl;
  else if(4*a*b<((c-a-b)*(c-a-b)))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N;  cin>>N;
  vector<int> v(N), a(N);
  rep(i,0,N) cin >> v[i];
  a[N-1] = v[N-1];
  for(int i=N-1 ; i>=0 ; i--){
    int j=i;
    while(j-1>=0 && v[j-1]<=v[j]){
      a[j-1] = v[i];
      j--;
    }
    a[j-1] = v[j-1];
    i = j;
  }
  ll now = 1000;
  ll k = 0;
  rep(i,0,N){
    if(a[i] == v[i]){
      now += a[i] * k;
      k = 0;
    }
    if(a[i] > v[i]){
      k += now / v[i];
      now -= now / v[i] * v[i];
    }
  }
  cout << now << endl;
  return 0;
}


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

auto solve(int n) -> long {
  vector<int> dp(n + 1, 1);

  dp[2] = 2;
  for (int i = 3; i <= n; i++) 
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  
  return dp[n];  
}

auto main() -> int {
  int n;
  while(cin >> n, n != 0) {
    auto days = (int)ceil((double)solve(n) / 10);
    auto years = (int)ceil((double)days / 365);
    std::cout << years << std::endl;
  }
  return 0;
}


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

void Main()
{
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < s.size(); i++)
    {
        a += s[i] - '0';
        a %= 9;
    }
    
    if (a == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3772