akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

using u64 = unsigned long long;
constexpr u64 M = 2305843009213693951; // 2^61 - 1
constexpr u64 MASK31 = 2147483647; // 2^31 - 1
constexpr u64 MASK30 = 1073741823; // 2^30 - 1
constexpr u64 POSITIVIZER = 4*M;

u64 CalcMod(u64 x) {
    u64 res = (x >> 61) + (x&M);
    if (res >= M) res -= M;
    return res;
}
u64 mul(u64 x,u64 y) {
    u64 au = (x >> 31),ad = (x&MASK31),bu = (y >> 31),bd = (y&MASK31);
    u64 m = au * bd + ad * bu;
    u64 mu = (m >> 30),md = (m&MASK30);
    u64 ans = 2*au*bu + mu + (md << 30) + ad*bd;
    return CalcMod(ans);
}

struct RollingHash {
    static u64 B;
    int N;
    vector<u64> hash,power;
    RollingHash(const string &s) {
        N = (int)s.size();
        hash.resize(N + 1,0); power.resize(N + 1,0);
        hash[0] = 0; power[0] = 1;
        for (int i = 0; i < (int)s.size(); ++i) {
            hash[i + 1] = CalcMod(mul(hash[i],B) + s[i]);
            power[i + 1] = mul(power[i],B);
        }
    }
    u64 get() {return hash[N];}
    u64 get(int k) {return hash[k];}
    u64 get(int l,int r) {return CalcMod(hash[r] + POSITIVIZER - mul(hash[l],power[r - l]));}
};

mt19937_64 mt;
uniform_int_distribution<unsigned long long> rng(2,M - 2);
unsigned long long RollingHash::B = rng(mt);

int main() {
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    sort(S.begin(),S.end(),[](const string &a,const string &b){return a.size() < b.size();});
    set<u64> before;
    ll ans = 0;
    rep(i,N) {
        string s = S[i];
        reverse(s.begin(),s.end());
        u64 hash = 0;
        vector<int> alpha(26,0);
        rep(j,s.size()) alpha[s[j] - 'a'] ++;
        rep(k,26) {
            if (alpha[k]) {
                u64 now = CalcMod(k + 97);
                if (before.count(now)) ++ans;
            }
        }
        rep(j,s.size()) {
            hash = CalcMod(mul(hash,RollingHash::B) + s[j]);
            alpha[s[j] - 'a'] --;
            u64 x = mul(hash,RollingHash::B);
            rep(k,26) {
                if (alpha[k]) {
                    u64 now = CalcMod(x + k + 97);
                    if (before.count(now)) ++ans;
                }
            }
        }
        before.insert(hash);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 18652
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);

using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    return out;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}
int n,k;
vector<int> dp,a;

int solve(int n)
{
    if(dp[n]!=-1)
        return dp[n];
    dp[n]=0;
    for(int i: a)
    {
        if(n>=i && solve(n-i)==0)
        {
            dp[n]=1;
            break;
        }
    }
    return dp[n];
}

int main()    
{
    #ifdef SANS
        freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
    #endif
    fast
    int t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n>>k;
        dp.resize(k+1,-1);
        dp[0]=0;
        a.resize(n);
        cin>>a;
        cout<<(solve(k)?"First":"Second");
    }
    #ifdef SANS
        cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
    #endif
}

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

using namespace std;

typedef long long ll;
const ll mod = 1000000007;

#define fo(i, a, b) for (ll i = (a); i <= (b); ++i)
#define fd(i, b, a) for (ll i = (b); i >= (a); --i)

ll powmod(ll x, ll y)
{
    ll res = 1;
    fo(i, 1, y) res = res * x % mod;
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod) % mod; // (-2 % 5) = -3
    cout << ans;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main (void)
{ int x,y;
  int W,H;
  int r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);



  if(r<=x && x<=(W-r) && r<=y && y<=(H-r))
  	{printf("Yes\n");}
  else{printf("No\n");}

return 0;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long ,long long > pll;
typedef unsigned long long ull; 

bool ok(int a,int b,int c)
{
	if(a==b || a==c || b==c) return false;
	if(a+b<=c || b+c<=a || a+c<=b) return false;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int l[n];
		for(int i=0;i<n;i++) cin>>l[i];
		int kolko=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				for(int k=j+1;k<n;k++)
				{
					if(ok(l[i],l[j],l[k])) kolko++;
				}
			}
		}
		cout<<kolko<<endl;
	}	
 	return 0;
}

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

int main() {
  int n, a = 0, b = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  rep(i, n){
    if(i % 2 == 0) a += v[i];
    else b += v[i];
  }
  cout << a - b << endl;
  return 0;
}

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

using ll=long long;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  
  vector<int> used(n,false);
  multiset<pair<ll,int>> as;
  for(int i=0;i<n;i++) as.insert(make_pair(a[i],i));

  int res=0;
  for(int i=0;i<n;i++){
    if(!used[i]){
      as.erase({a[i],i});
      for(int j=31;j>=0;j--){
	ll tar=(1LL<<j)-a[i];
	if(tar<=0) continue;
	auto it=as.lower_bound({tar,-1});
	if(it==as.end() || it->first!=tar) continue;
	pair<int,int> tmp=*it;
	used[tmp.second]=true;
	as.erase(tmp);
	res++;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()

{
	string s1,s2,s3;

	cin >>s1>>s2>>s3;
	char A, B, C;

	A = toupper(s1.at(0));
	B = toupper(s2.at(0));
	C = toupper(s3.at(0));

	
	cout << A << B << C << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int g[3100][3100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)scanf("%d",&g[i][j]);
	long long ret=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		bool need=true;
		for(int k=0;k<a;k++){
			if(g[i][k]+g[k][j]<g[i][j]){
				printf("-1\n");return 0;
			}
			if(i!=k&&k!=j&&g[i][k]+g[k][j]==g[i][j])need=false;
		}
		if(need)ret+=g[i][j];
	}
	printf("%lld\n",ret/2);
}

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

int main(){
    string w;cin >> w;
    map<char,int> mp;
    for (int i=0;i<w.size();i++){
        mp[w[i]]++;
    }

    for(auto& s:mp){
        if (s.second % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int N;

int main() {
    cin >> N;
    vector<int> order(N);
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        order[A - 1] = i + 1;
    }
    for (int i = 0; i < N; i++) {
        cout << order[i] << ' ';
    }
    cout << endl;
}



Measured memory_bytes: 1152
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    X = first_input[0]

    cash = 100
    count_year = 0
    while True:
        count_year = count_year+1
        cash = int(cash*1.01)
        if cash>=X:
            print(count_year)
            return

if __name__ == '__main__':
    main()


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[100];
ll x,y;
set<ll>set1;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>x>>n;
		ll ans;
		for(ll i=0;i<n;i++)
		{
			ll a;cin>>a;set1.insert(a);
		}
		ll min1 = 1e+9;
		for(ll i=-1000;i<=1000;i++)
		{
			if(set1.find(i)!=set1.end())continue;
			ll d = abs(i-x);
			if(d<min1)
			{
				ans = i;min1 = d;
			}
		}
		cout<<ans<<endl;



}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

Measured memory_bytes: 5992
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
ar<lld,2> pref[300000];
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     memset(pref,0,sizeof(pref));
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>n>>m;
         rep(i,0,n-1)cin>>arr[i],arr[i]--;
        // rep(i,0,m-1)cout<<pref[i][0]<<" "<<pref[i][1]<<"\n";
         lld ans=0;
         rep(i,1,n-1){
            if (arr[i]<arr[i-1]){
                lld dif=m-arr[i-1]-2;
                pref[arr[i-1]+2][0]++;
                pref[0][0]++;
                pref[arr[i]+1][0]--;
                pref[0][1]+=dif;
               // pref[arr[i]+1][1]-=dif;
                pref[arr[i]+1][1]-=(arr[i]-arr[i-1]+m)%m-1;
            }
            else {
                pref[arr[i-1]+2][0]++;
                pref[arr[i]+1][0]--;
                pref[arr[i]+1][1]-=arr[i]-arr[i-1]-1;
            }
            ans+=(arr[i]-arr[i-1]+m)%m;
         }
         lld maxi=0;
        // rep(i,0,m-1) cout<<pref[i][0]<<" "<<pref[i][1]<<"\n";
         rep(i,0,1)rep(j,1,m-1) pref[j][0]+=pref[j-1][0];
         //rep(j,0,m-1) pref[j][0]+=pref[j][1];
         rep(j,1,m-1) pref[j][1]+=pref[j-1][1];
         rep(i,0,m-1){maxi=max(maxi,pref[i][0]+pref[i][1]);}
         //rep(i,0,m-1) cout<<pref[i][0]<<" "<<pref[i][1]<<"\n";
         cout<<ans-maxi;
     }
    return 0;
}


Measured memory_bytes: 6400
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {

     string s;
     cin>>s;
     if(s == "SUN") cout<<7;
     else if(s == "MON") cout<<6;
     else if(s == "TUE") cout<<5;
     else if(s == "WED") cout<<4;
     else if(s == "THU") cout<<3;
     else if(s == "FRI") cout<<2;
     else cout<<1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,i;
	cin >> N;
	int h[N],dp[N];
	for(i=0;i<N;i++)
	{
		cin >> h[i];
		if(i == 0)
		dp[0] = 0;
		else dp[i] = INT_MAX;
	}
	for(i=1;i<N;i++)
	{
		dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
		if(i>1)
		dp[i] = min(dp[i],dp[i-2]+abs(h[i] - h[i-2]));
	}
	cout << dp[N-1];
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    double h, w, x, y, s;
    int ans;
    scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

    if (w / 2 == x && h / 2 == y) {
        ans = 1;
    } else {
        ans = 0;
    }

    s = w * h / 2;

    printf("%lf %d\n", s, ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N, M;
    cin >> N >> M;

    if (N == M) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int max_value = *max_element(A.begin(), A.end());
    int max_count = 0;
    int second_max = 0;
    for (int i = 0; i < N; i++) {
        if (max_value == A[i]) ++max_count;
        if (max_value != A[i]) second_max = max(second_max, A[i]);
    }
    if (max_count >= 2) {
        for (int i = 0; i < N; i++) cout << max_value << endl;
    } else {
        for (int i = 0; i < N; i++) {
            if (max_value != A[i]) cout << max_value << endl;
            else cout << second_max << endl;
        }
    }
}


Measured memory_bytes: 3200
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


 unsigned long long  int N;
 cin >> N;
 ll int wa=0;
 ll int counter=0;
	 counter += 1;
 ll int kazu = 26;
 while(counter >= 0){
	 if(N <= wa + kazu){
		 break;
	 }
	 else{
		 wa += kazu;
		 counter += 1;
		 kazu *= 26;
	 }
 }
//if(counter != 1){
 N = N - wa -1;
//}
//else{}

 vector<long long int> ans(counter+1);
 string base;
 base = 'a';
 kazu = 26;
 for( long long int i = 1;i<=counter;i++){
	ans[i] = N%26;
	if( N - ans[i] == 0){
		break;
	}
	else{
	N = (N-ans[i])/26;
	}
 }
  string put;
for(long long int i=1;i<=counter;i++){
	put = ans[counter+1-i] + 'a';

	cout << put;
}









	return 0;

}



Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();

	}
	static class Task{
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt(), b = in.nextInt();
			if (a > 12) out.print(b);
			else if(a > 5) out.print(b/2);
			else out.print(0);
		}//Solve
	}//task
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer == null || ! tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = -1; ++i < n;) a[i] = nextInt();
			return a;
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
    long long n,m,k; cin>>n>>m>>k;
    vector<int> cost;
    vector<vector<int>>vec;
    for(int i=0; i<n; ++i){
    	int v; cin>>v; cost.push_back(v);
    	vector<int> tt;
    	for(int j=0; j<m; ++j){
    		int e; cin>>e;
    		tt.push_back(e);
    	}
    	vec.push_back(tt);
    }
    int ppow = pow(2,n);
    vector<int> A;
    vector<int> B;
    for(int i=1; i<ppow; ++i){
    	// cout<<i<<"\n";
    	long long cst = 0;
    	vector<int> yy;
    	for(int j=0; j<m; ++j){
    		yy.push_back(0);
    	}
    	for(int j=0; j<n; ++j){
    		// cout<<j<<" "<<i<<" "<<((1<<j)&i)<<" \n";
    		if( ((1<<j)&i) >0){
    			// cout<<j<<" do we fe there\n";
    			cst +=cost[j];
    			for(int k=0; k<m; ++k){
    				yy[k]+=vec[j][k];
    			}
    		}
    	}
    	A.push_back(cst);
    	B.push_back(*min_element(yy.begin(), yy.end()));
    }
    // for(int i=0; i<A.size(); ++i){
    // 	cout<<A[i]<<" "<<B[i]<<"\n";
    // }
    int ans = 10000000;
    int sz = A.size();
    for(int i=0; i<sz; ++i){
    	if(B[i]>=k && A[i]<ans){
    		ans = A[i];
    	}
    }
    if(ans==10000000){
    	cout<<"-1";
    }
    else{
    	cout<<ans;
    }
	return 0;
}

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

using namespace std;
const int N = 5e3 + 5;
int a[N], p[N];
long long dp[N][N], mn[N][N], A, B;

int main() {
    int n; cin >> n >> A >> B;
    for (int i = 1; i <= n; i++) cin >> a[i], p[a[i]] = i;
    memset(dp, 63, sizeof dp);
    for (int x = 0; x <= n; x++) mn[0][x] = dp[0][x] = 0;
    for (int i = 1; i <= n; i++) {
        for (int x = 0; x <= n; x++) {
            dp[i][x] = (p[i] <= x ? A : B) + mn[i - 1][x];
            if (p[i] == x) dp[i][x] = min(dp[i][x], mn[i - 1][x - 1]);
            else if (x) dp[i][x] = min(dp[i][x], (p[i] < x ? A : B) + mn[i - 1][x - 1]);
            mn[i][x] = min((x ? mn[i][x - 1] : 1ll<<62), dp[i][x]);
        }
    }
    cout << mn[n][n] << "\n";

    return 0;
}


Measured memory_bytes: 394904
N = int(input())
A = list(map(int, input().split()))
m=1000
s=0
if A[0]<A[1]:
    s=int(1000/A[0])
    m=m-s*A[0]
for i in range(1,N-1,1):
    m=m+s*A[i]
    s=0
    if A[i+1]>A[i]:
        s=int(m/A[i])
        m=m-s*A[i]
m=m+max(A[N-1],A[N-2])*s
print(m)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int64_t A;
  int64_t B;
  char C;
  int64_t D;
  int64_t E;
  cin >> A >> B >> C >> D;
  if(A == 0 )
  {
    cout << 0 << endl;
    return 0;
  }
  if((B == 0) && (D == 0))
  {
    cout << 0 << endl;
    return 0;
  }
  E = A;
  A = A*B;
  E = (E*D)/100;
  A = A+E;
  cout << A << endl;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;
import java.util.stream.*;
 
class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        Stream<String> lines = br.lines();
        
        // データからパラメータを割り出す
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);
 
        // 変換処理、出力
        int W = 0;
        boolean isFirst = true;
        for (Object item : a.map(item -> "#" + item + "#").toArray()) {
            String out = item.toString();
            if (isFirst) {
                isFirst = false;
                W = out.length();
                System.out.println(new String(new char[W]).replace("\0", "#"));
            }
            System.out.println(out);
        }
        System.out.println(new String(new char[W]).replace("\0", "#"));
    }
}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int sol;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        m[x]++;
    }
    for (auto p : m)
    {
        int a, b;
        tie(a,b)=p;
        if (b%2)sol++;
    }
    cout <<sol;
}


Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_greedy_takahashi(void) {
	long long a, b, k;
	cin >> a >> b >> k;

	if (k >= a) {
		k -= a;
		a = 0;
	}
	else {
		a -= k;
		k = 0;
	}

	if (k > 0) {
		b -= k;
		if (b < 0) b = 0;
	}

	cout << a << " " << b << endl;
}

int main()
{
    b_greedy_takahashi();

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(a>=b){
		b *= 2;
		--k;
	} 
	while(b>=c){
		c*= 2;
		--k;
	}
	cout << (k>=0? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int dp[3002][3002],dp2[3002][3002];
int main()
{
    string s1 , s2;
    cin >> s1 >> s2 ;
    for(int i = 0 ;i<=s1.size();++i)
    {
        dp[i][0] = 0 ;
    }
    for(int i = 0 ;i<=s2.size();++i)
    {
        dp[0][i] = 0 ;
    }
    for(int i = 1 ; i <= s1.size() ; ++i)
    {
        for(int j =1 ; j <=s2.size() ; ++j)
        {
            if(s1[i-1]==s2[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1 ;
                dp2[i][j] = 3 ;
            }
            else if(dp[i-1][j]>=dp[i][j-1])
            {
                dp[i][j] = dp[i-1][j];
                dp2[i][j] = 1;
            }
            else
            {
                dp[i][j] = dp[i][j-1];
                dp2[i][j] = 2 ;
            }
        }
    }
    //cout<<dp[s1.size()][s2.size()];
    stack<char> s;
//    cout<<endl;
    int h = s1.size() , k = s2.size();
    while(dp[h][k]!=0)
    {
        if (dp2[h][k]==3)
        {
            s.push(s1[h-1]);
            h--,k--;
        }
        else if (dp2[h][k]==1) h--;
        else k-- ;
    }
    while(!s.empty())
    {
        cout<<s.top();
        s.pop();
    }
    return 0 ;
}


Measured memory_bytes: 70656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

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

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

	ll sum = 0;
	ll minVal = 0;
	ll count = 0;

	for (int i = 0; i < n; ++i)
	{
		if (a[i] < 0)
		{
			++count;
			a[i] *= -1;
		}

		sum += a[i];

		if (i == 0) minVal = a[i];
		else minVal = min(a[i], minVal);
	}

	ll ans = 0;
	if (count % 2 == 0)
	{
		ans = sum;
	}
	else
	{
		ans = sum - 2 * minVal;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#define mod 1000000007
#define maxn 1003
using namespace std;
int h[maxn], a[maxn], b[maxn], _h[maxn], _a[maxn], f[maxn][maxn];
int fpw(int x, int y){
	if (y < 0)
		return 1;
	int ans = 1;
	for (int i = 1; i <= y; i <<= 1, x = 1LL * x * x % mod)
		if (y & i)
			ans = 1LL * ans * x % mod;
	return ans;
}
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		cin >> h[i];
		a[i] = h[i];
	}
	sort(a + 1, a + 1 + n);
	int _n = 0;
	for (int i = 1; i <= n; ++ i)
		if (a[i] != a[i - 1])
			_a[++ _n] = a[i];
	for (int i = 1; i <= n; ++ i)
		_h[i] = lower_bound(_a + 1, _a + 1 + _n, h[i]) - _a;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++ i){
		f[i][0] = f[i - 1][0] * 2 % mod;
		for (int j = _h[i] + 1; j <= _h[i - 1]; ++ j)
			f[i][0] = (f[i][0] + f[i - 1][j] * 2 % mod) % mod;
		int x = fpw(2, h[i] - h[i - 1]);
		for (int j = 1; j <= min(_h[i], _h[i - 1]); ++ j)
			f[i][j] = 1LL * f[i - 1][j] * x % mod;
		for (int j = _h[i - 1] + 1; j <= _h[i]; ++ j){
			if (j > 1)
				f[i][j] = 1LL * f[i - 1][0] * (fpw(2, _a[j] - _a[j - 1]) - 1) % mod * 2 % mod * fpw(2, h[i] - _a[j]) % mod;
			else
				f[1][1] = 1LL * f[0][0] * (fpw(2, _a[1]) - 2) % mod * fpw(2, h[i] - _a[1]) % mod;
		}
	}
	int ans = 0;
	for (int i = 0; i <= _h[n]; ++ i)
		ans = (ans + f[n][i]) % mod;
	cout << ans << endl;
}


Measured memory_bytes: 640
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	an := make([]int, 0)
	for N > 0 {
		N--
		// if N%26 == 0 {
		// 	an = append(an, 26)
		// } else {
		// 	an = append(an, N%26)
		// }
		// ans += string(N%26 + 'a')
		an = append(an, N%26+'a')
		N /= 26
	}
	ans := make([]rune, len(an))
	for i := 0; i < len(an); i++ {
		ans[len(ans)-1-i] = rune(an[i])

	}
	fmt.Println(string(ans))
}

func numToAlphabet(n int) string {
	var s string
	switch n {
	case 1:
		s = "a"
	case 2:
		s = "b"
	case 3:
		s = "c"
	case 4:
		s = "d"
	case 5:
		s = "e"
	case 6:
		s = "f"
	case 7:
		s = "g"
	case 8:
		s = "h"
	case 9:
		s = "i"
	case 10:
		s = "j"
	case 11:
		s = "k"
	case 12:
		s = "l"
	case 13:
		s = "m"
	case 14:
		s = "n"
	case 15:
		s = "o"
	case 16:
		s = "p"
	case 17:
		s = "q"
	case 18:
		s = "r"
	case 19:
		s = "s"
	case 20:
		s = "t"
	case 21:
		s = "u"
	case 22:
		s = "v"
	case 23:
		s = "w"
	case 24:
		s = "x"
	case 25:
		s = "y"
	case 26:
		s = "z"
	}
	return s
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 1820
#include <iostream>
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
  int n=5;
  int arr[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    if(arr[i]==0)
    {
      cout<<(i+1)<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll n, m, ans = 0;
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	
	ll num = min(n, m/2);
	ans += num;
	m -= num * 2;
	ans += m / 4;

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (int i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=2e6;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        readll(n);
        vi a(4,0);
        fr(i,n){
            readstr(s);
            if(s=="AC") a[0]++;
            else if(s=="TLE") a[2]++;
            else if(s=="RE") a[3]++;
            else a[1]++;
        }
        fr(i,4){
            if(i==0){
                cout << "AC x " << a[0] << '\n';
            }
            else if(i==1){
                cout << "WA x " << a[1] << '\n';
            }
            else if(i==2){
                cout << "TLE x " << a[2] << '\n';
            }
            else cout << "RE x " << a[3] << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mo 1000000007
#define ll long long
#define pll pair<ll,ll>
#define db double
#define fi first
#define se second
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
int a[200005];
int q[200005];
int n;
long long ans;
int main(){
	scanf("%d",&n);
	int last=0; a[0]=-1;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (a[i]>a[i-1]+1) return puts("-1"),0;
		if (a[i-1]&&a[i]!=a[i-1]+1) ans+=a[i-1];
	}
	printf("%lld\n",ans+a[n]);
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll A, B, K;

    cin >> A >> B >> K;

    if(A+B<=K) {
        cout << 0 << " " << 0 << endl;
    } else {
        if(A>=K) {
            cout << A-K << " " << B << endl;
        } else {
            cout << 0 << " " << B-(K-A) << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 256
from collections import deque


def main():
    H, W = map(int, input().split())
    field = [list(input().rstrip()) for _ in range(H)]

    black = 0

    for f in field:
        for s in f:
            if s == "#":
                black += 1

    dir_h = [0, 0, 1, -1]
    dir_w = [1, -1, 0, 0]

    print(H * W - black - bfs(H, W, field, dir_h, dir_w))


def bfs(H, W, field, dir_h, dir_w):
    q = deque([])
    seen = [[-1 for _ in range(W)] for _ in range(H)]

    q.append([0, 0])
    seen[0][0] = 1

    while q:
        h, w = q.popleft()

        for dh, dw in zip(dir_h, dir_w):
            nh, nw = h + dh, w + dw

            if nh < 0 or nh >= H or nw < 0 or nw >= W:
                continue
            elif field[nh][nw] == "#":
                continue
            elif seen[nh][nw] != -1:
                continue

            seen[nh][nw] = seen[h][w] + 1
            q.append([nh, nw])

    if seen[H - 1][W - 1] == -1:
        print(-1)
        exit()

    return seen[H - 1][W - 1]


if __name__ == "__main__":
    main()


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    long long n, m;
    cin >> n >> m;
    if (2 * n > m){
        cout << m / 2 << endl;
    }else{
        cout << n + (m - 2 * n) / 4 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        cnt+=(r-l+1);
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3636
#include <cstdio>

using namespace std;

int parse_int()
{
    int n = 0, c;
    while (1)
    {
        c = getchar_unlocked();
        if ('0' <= c && c <= '9')
            n = n * 10 + c - '0';
        else
            break;
    }
    return n;
}

template <size_t N>
struct Solver
{
    bool is_prime[N + 1];
    short ans[N + 1];
    constexpr Solver() : is_prime(), ans()
    {
        is_prime[0] = false;
        is_prime[1] = false;
        for (size_t i = 2; i <= N; i++)
        {
            is_prime[i] = true;
        }
        for (size_t prime = 2; prime <= N; prime++)
        {
            if (is_prime[prime])
            {
                for (size_t q = prime * 2; q <= N; q += prime)
                {
                    is_prime[q] = false;
                }
            }
        }
        for (size_t i = 1; i <= N; i++)
        {
            ans[i] += ans[i - 1];
            if (is_prime[i] && is_prime[(i + 1) / 2])
            {
                ans[i] += 1;
            }
        }
    }
};

int main()
{
    constexpr auto M = 100000;
    auto solver = Solver<M>();

    int Q = parse_int();
    for (size_t i = 0; i < Q; i++)
    {
        int l = parse_int();
        int r = parse_int();
        auto ans = solver.ans[r] - solver.ans[l - 1];
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 896
n,x,y,h,w,T;
main(){
	for(;scanf("%d",&n),n;){
		T=0;
		for(;n--;){
			scanf("%d%d%d%d",&x,&y,&h,&w);
			x=(x+y+h-1)/20-2;
			w=w<3?0:(w+4)/5;
			x=x>w?x:w;
			T+=x>5?0:x*200+600;
		}
		printf("%d\n",T);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

#define ll long long int

#define SAY_YES cout << "YES" << endl
#define SAY_NO cout << "NO" << endl
#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)

#define vec vector

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

  rep(i, n+1) {
    ll m;
    cin >> m;
    a.push_back(m);
  }

  rep(i, n) {
    ll m;
    cin >> m;
    b.push_back(m);
  }

  ll r=0, ans=0;
  rep(i, n) {
    ll hp = a[i];
    if (hp <= r) {
      ans += hp;
      r = b[i];
    } else {
      ans += r;
      hp -= r;
      if(hp <= b[i]){
        ans += hp;
        r = b[i]-hp;
      }else {
        ans += b[i];
        r = 0;
      }
    }
  }
  if(a[n] <= r) {
    ans += a[n];
  } else {
    ans += r;
  }

  say(ans);

  return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
 
int main() {
  std::string a;
  std::cin >>a;
  if(a == "a"||a == "i"||a=="u"||a=="e"||a=="o"){
    std::cout <<"vowel";
  }else{
    std::cout<<"consonant";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll a;
  cin >> a;

  cout << (ll)(a + pow(a, 2) + pow(a, 3)) << '\n';

  




  
  return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>

int main(void) {
	int a, b, c, x;
	int ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	int i, j, k;
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				int t = 500 * i + 100 * j + 50 * k;
				if (t == x)
					ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e5+7;
int cnt[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        cnt[tmp]++;
        if(tmp)
            cnt[tmp-1]++;
        cnt[tmp+1]++;
    }
    int ans=0;
    for(int i=0;i<maxn;i++) ans=max(ans,cnt[i]);
    print(ans);
}

Measured memory_bytes: 640
n = int(input())
y = 0.0
b = 0.0
for i in range(n):
    x, u = map(str, input().split())
    if u == "JPY":
        y += float(x)
    else:
        b += float(x)
print("{:.10f}".format(y + b * 380000.0))

Measured memory_bytes: 3060
S = input()
K = int(input())

if S.count(S[0]) == len(S):
    print(len(S)*K//2)
    exit()

count = 0
i = 1
flg = [False] * len(S)
while i < len(S):
    if S[i] == S[i-1]:
        count += 1
        flg[i] = True
        i += 2
    else:
        i += 1
count *= K
if (not flg[len(S)-1]) and S[0] == S[-1]:
    a = 1
    for i in range(1, len(S)):
        if S[0] == S[i]:
            a += 1
        else:
            break
    if a % 2 == 1:
        count += (K-1)
print(count)


Measured memory_bytes: 9112
#include<iostream>
#include<cmath>
using namespace std;
typedef pair<int,int> P;

int dist(P a, P b)
{
  return abs(a.first-b.first)+abs(a.second-b.second);
}

int main()
{
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  int G[n+1][n+1];
  P pos[n+1];
  int mex = (1<<29),x,y;
 
  for(int i=1;i<=n;i++)
    {
      x = y = 0;
      
      for(int j=0;j<n;j++)
	{
	  if(x >= i)
	    x = 0,y++;
	  pos[j+1] = P(x++,y);
	}
      mex =  min(mex,dist(pos[a],pos[b])+dist(pos[c],pos[d]));
    }
  cout << mex << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    vector<string> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    rep(i, N - M + 1) {
        rep(j, N - M + 1) {
            bool flg = true;
            rep(k, M) {
                rep(m, M) {
                    if (A[i + k][j + m] != B[k][m]) {
                        flg = false;
                    }
                }
            }

            if (flg) {
                // cout << "Yes: (" << i << ", " << j << ")" << endl;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3600
from collections import deque
h, w = map(int ,input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for i in range(h):
  t = input()
  s.append(t)

dx = [1,0,-1,0]
dy = [0,1,0,-1]

queue = deque([[ch,cw]])
visited = [[1000000 for i in range(w)] for j in range(h)]
visited[ch][cw] = 0
while queue:
  l,m = queue.popleft()
  d = visited[l][m]
  for k in range(4):
    x = l + dx[k]
    y = m + dy[k]
    if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d or s[x][y] == "#":
      continue
    visited[x][y] = d
    queue.appendleft([x,y])
  for i in range(-2,3):
    for j in range(-2,3):
      if (i== 1 and j == 0)or(i==-1 and j == 0)or(i==0 and j == 1)or(i==0 and j==-1)or(i==0 and j==0):
        continue
      x = l + i
      y = m + j
      if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d+1 or s[x][y] == "#":
        continue
      visited[x][y] = d + 1
      queue.append([x,y])
  #print (queue)
if visited[dh][dw] == 1000000:
  print (-1)
else:
  print (visited[dh][dw])

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

ll a, b;

bool check(ll u) {
  if(a >= u) {
    return b >= 2 * u;
  }
  ll p = a, q = b;
  q -= (u - a) * 2;
  return (q >= u * 2);
}

int main() {
  cin >> a >> b;
  ll l = 0, r = 1e12 + 10, md;
  for (int i = 0; i < 66; i++) {
    md = (l + r) >> 1;
    if (check(md)) l = md + 1;
    else r = md;
  }
  cout << md - 1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int x;
  char s[1001];
  scanf("%s",s);
  x=strlen(s);
  if(s[x-1]=='s'){
    s[x]='e';
    s[x+1]='s';
    s[x+2]='\0';
  }
  else{
    s[x]='s';
    s[x+1]='\0';
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 1728
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        // スペース区切りの整数の入力
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        //a 高橋攻撃数
        double a = (C + (B - 1))/B;
        double b = (A + (D - 1))/D;

       // (割られる数 + 割る数 – 1) / 割る数
        if (a <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 35600