akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		String s = r.next();
		int ans = 0;
		if(s.charAt(0) == s.charAt(s.length()-1)) ans++;
		if(s.length()%2==0) ans++;
		if(ans%2==0) System.out.println("First");
		else System.out.println("Second");
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int X,Y; cin >> X >> Y;
	cout << X + (Y / 2) << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3552
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
int a,b;
cin>>a>>b;
if(a>9 || b>9) cout<<-1;
else cout<<a*b;
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3560
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
xhigh=0
xlow=0
if n==0:
    ans = x
else:
    if x not in p:
        ans=x
    else:
        xhigh=x+1
        xlow=x-1
        while xhigh in p and xlow in p:
            xhigh +=1
            xlow -=1
        else:
            if xlow in p:
                ans =xhigh
            else:
                ans = xlow
print(ans)

Measured memory_bytes: 8880
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	int a[n];
	REP(i,n) cin >> a[i];
	int cnt = 0,res = 1;
	for(int i = 2; i <= n; i++){
		if(cnt == k - 1){
			res++;
			cnt = 0;
		}
		cnt++;
	}
	cout << res << endl;
}

Measured memory_bytes: 640
w,h,n = (int(i) for i in input().split())
sq = [0,0,w,h]
answer = 0
#x1,y1 x2,y2
for j in range(n):
  x,y,a = (int(k) for k in input().split())
  if a == 1 and sq[0] < x:
    sq[0] = x
  elif a == 2 and sq[2] > x:
    sq[2] = x
  elif a == 3 and sq[1] < y:
    sq[1] = y
  elif a == 4 and sq[3] > y:
    sq[3] = y
if sq[2]-sq[0] > 0 and sq[3]-sq[1] > 0:
  answer = (sq[2]-sq[0])*(sq[3]-sq[1])
print(answer)

Measured memory_bytes: 3064
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}



signed main () {
    int x,y;cin >>x>>y;

    for(int i=x;i>=0;i--){
        if(2*i+4*(x-i)==y){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout <<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll L[87];
int n;
int main() {
  scanf("%d" ,&n);
  L[0]=2ll, L[1]=1ll;
  for(int i=2; i<=n; i++)
    L[i]=L[i-1]+L[i-2];
  printf("%lld\n", L[n]);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.search_i", "r", stdin );
	int n;
	scanf ("%d", &n );
	set<int> S;
	rep (i, n ){
		int in;
		cin >> in;
		S.insert (in );
	} // end rep
	int q;
	scanf ("%d", &q );
	vector<int> T (q, 0 );
	rep (i, q ){
		cin >> T[i];
	} // end rep

	int res = 0;
	rep (i, q ){
		if (S.count (T[i] ) ){
			++res;
		} // end if
	} // end rep
	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
//#define mp make_pair
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const ll INF = 1e18 + 5;
const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
std::vector<ll> divi[1000004];

void divisor(int n)
{
   for(ll i=1;i<=n;i++)
   {
     for(ll j=i;j<=n;j+=i)
     {
       divi[j].pb(i);
     }
   }
}

int n;
ll pt[55];

pair<ll,ll> check(ll i,ll pre,ll mid,ll k,ll m)
{
	if(i==k)
	{
		return {pre,pre};
	}
	ll x = 2LL*pre + 1 - mid;
	ll y = 2LL*pre + m- mid;
	for(int j= i+2;j<=k;j++)
	{
		x = 2LL*x;
		y = 2LL*y;
	}
	return {x,y};
}

pair<ll,ll> bs(int i, ll pre, ll r,ll k,ll m,ll b)
{

	ll x = 1;
	ll y = m;
	ll ans = -1;
	while(x<=y)
	{
		ll mid = (x+y)/2LL;
		ll num = 2LL*pre + mid-r;
		if(i==2)
		{
			num = pre + mid-r;
		}
		if(check(i,num,mid,k,m).first<=b && check(i,num,mid,k,m).second>=b)
		{
			ans = mid;
			y = mid-1;
		}
		else if(check(i,num,mid,k,m).second<b)
		{
			x = mid+1;
		}
		else y = mid-1;
	}
	
	ll num = 2LL*pre + ans - r;
	if(i==2)
		num = pre + ans-r;
	return {num,ans};


}
void solve(ll a,ll b,ll m)
{
	int flag = -1;
	if(a==b)
	{
		cout<<1<<" ";
		cout<<a<<endl;
		return;
	}
	if(a + 1<= b && a+m>=b)
	{
		cout<<2<<" ";
		cout<<a<<" "<<b<<endl;
		return;
	}
	ll prex = a+1LL;
	ll prey = a + m;
	// cout<<prex<<" "<<prey<<endl;
	for(int k = 3;k<=50;k++)
	{
		prex = 2LL*(prex);
		prey = 2LL*(prey);
		if(prex<=b && b<=prey)
		{
			flag = k;
			break;
		}
		else if(prex > b)
		{
			break;
		}
	}
	if(flag==-1)
	{
		cout<<-1<<endl;
		return;
	}
	cout<<flag<<" ";
	cout<<a<<" ";
	ll pre = a;
	ll r = 0;
	for(int i=2;i<=flag;i++)
	{
		pair<ll,ll> val  = bs(i,pre,r,flag,m,b);
		cout<<val.first<<" ";
		pre = val.first;
		r = val.second;
	}
	cout<<endl;

}

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

    cin>>n;
    
    ll x = n;
    ll ans = 0;
    while(x >0)
    {
    	ans = ans  + x%10;
    	x = x/10;
    }
    if(ans==1)
    {
    	cout<<10<<endl;
    }
    else cout<<ans<<endl;
   	return 0;


}


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

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
    A[i] -= 1;
  }
  
  vector<int> counter(N);
  rep(i, N)
  {
    counter[A[i]]++;
  }
  
  ll sum = 0;
  rep(i, N)
  {
    sum += n_c_2(counter[i]);
  }
  
  rep(i, N)
  {
    ll ans = sum;
    ans -= n_c_2(counter[A[i]]);
    ans += n_c_2(counter[A[i]] - 1);
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	bool dp[102][102][4] = {};
	UL G[102][102];

	void Solve() {
		const UL nx[6][4][2] = {
			{{4,0}, {3,1}, {1,2}, {2,3}},
			{{0,0}, {3,0}, {5,2}, {2,0}},
			{{4,1}, {0,1}, {1,1}, {5,1}},
			{{4,3}, {5,3}, {1,3}, {0,3}},
			{{5,0}, {3,2}, {0,2}, {2,2}},
			{{1,0}, {3,3}, {4,2}, {2,1}}
		};
		UL H, W; cin >> H >> W;
		rep(y, H + 2) rep(x, W + 2) G[x][y] = -1;
		rep(y, H) rep(x, W) {
			char c; cin >> c;
			if (c == '#') G[x + 1][y + 1] = -1;
			else G[x + 1][y + 1] = 6 - (c - '0');
		}
		queue<pair<pair<UL, UL>, UL>> Q;
		Q.push({ { 1, 1 }, 0 });
		while (Q.size()) {
			UL x = Q.front().first.first;
			UL y = Q.front().first.second;
			UL i = Q.front().second;
			Q.pop();
			if (dp[x][y][i]) continue;
			dp[x][y][i] = true;
			UL t = G[x][y];
			if (G[x][y + 1] == nx[t][i][0])
				Q.push({ {x, y + 1}, nx[t][i][1] });
			if (G[x - 1][y] == nx[t][(i + 3) & 3][0])
				Q.push({ {x - 1, y}, (nx[t][(i + 3) & 3][1] + 1) & 3 });
			if (G[x][y - 1] == nx[t][(i + 2) & 3][0])
				Q.push({ {x, y - 1}, (nx[t][(i + 2) & 3][1] + 2) & 3 });
			if (G[x + 1][y] == nx[t][(i + 1) & 3][0])
				Q.push({ {x + 1, y}, (nx[t][(i + 1) & 3][1] + 3) & 3 });
		}
		bool ans = false;
		rep(i, 4) if (dp[W][H][i]) ans = true;

		cout << (ans ? "YES" : "NO") << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



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

int main()
{
	int L[100] = {0}, N;
	cin >> N;
	int i, sum=0;
	for (i = 0; i < N;i++){
		cin >> L[i];
		sum += L[i];
	}

	sort(L, L+N, greater<int>());
	if((sum-L[0])>L[0])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long
using namespace std;
INT n, lb, ub, d;
string s, t;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n; lb = 0, ub = n-1;
    cout<<lb<<endl; cin>>t; s = t;
    if( t == "Vacant" ) return 0;
    cout<<ub<<endl; cin>>t;
    if( t == "Vacant" ) return 0;
    while(1)
    {
        d = (lb+ub-1)/2;
        cout<<d<<endl; cin>>t;
        if( t == "Vacant" ) return 0;
        if( d%2 )
        {
            if( t != s ) lb = d+1;
            else ub = d;
        }
        else
        {
            if( t == s ) lb = d+1;
            else ub = d;
        }
    }
}


Measured memory_bytes: 852
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ppi pair<int ,int >
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define MAXN 
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
const int MD = (int)1e9+7;
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
 	string s;
 	cin>>s;

 	if(s=="ARC") cout<<"ABC";
 	else cout<<"ARC";
 
	return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
using namespace std;
int read()
{
    char ch=getchar(); int x=0,f=1;
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while('0'<=ch&&ch<='9') { x=x*10+ch-'0';ch=getchar(); }
    return x*f;
}
int a,b,h;
int main()
{
	a=read();b=read();h=read();
	printf("%d\n",((a+b)*h)>>1); 
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
				int B = sc.nextInt();

				for(int i=1;Math.floor(i*0.08)<=A;i++){
					if(Math.floor(i*0.08)==A&&Math.floor(i*0.1)==B){
						System.out.println(i);
						return;
					}
				}
				System.out.println("-1");
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  rep(i, n-1) a.at(i+1) = (a.at(i) + a.at(i+1))/2;
  printf("%.7f\n", a.at(n-1)); 
}

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

vector<int> a(4);
string s("+-*");

int f(int x,int y,int c){
	switch(c){
	case 0:
		return x + y;
	case 1:
		return x - y;
	case 2:
		return x * y;
	}
}

int main(){
	while(cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]||a[1]||a[2]||a[3]){
		sort(a.begin(),a.end());
		int flag = 1;
		do{
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						if(f(f(f(a[0],a[1],i),a[2],j),a[3],k) == 10){
							cout<<"(("<<a[0]<<" "<<s[i]<<" "<<a[1]<<")"<<" "<<s[j]<<" "<<a[2]<<")"<<" "<<s[k]<<" "<<a[3]<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(f(a[0],a[1],i),f(a[2],a[3],k),j) == 10){
							cout<<"("<<a[0]<<" "<<s[i]<<" "<<a[1]<<") "<<s[j]<<" ("<<a[2]<<" "<<s[k]<<" "<<a[3]<<")"<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(f(a[0],f(a[1],a[2],j),i),a[3],k) == 10){
							cout<<"("<<a[0]<<" "<<s[i]<<" ("<<a[1]<<" "<<s[j]<<" "<<a[2]<<")) "<<s[k]<<" "<<a[3]<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(a[0],f(f(a[1],a[2],j),a[3],k),i) == 10){
							cout<<a[0]<<" "<<s[i]<<" (("<<a[1]<<" "<<s[j]<<" "<<a[2]<<") "<<s[k]<<" "<<a[3]<<")"<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
					}
				}
			}
		}while(next_permutation(a.begin(),a.end()) && flag);
		if(flag) cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3224
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a,b = I()
print(math.ceil((a+b)/2))

Measured memory_bytes: 10340
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
struct duilie {
    char name[10];
    int time;
} Q[MAX];

int head;
int tail;
int max;

void initialize(){
    head = tail = 0;
}

int isEmpty(){
    return head == tail;
}

int isFull(){
    return (head == tail+1) || (tail+1 == MAX && head == 0);
    //return head == (tail+1)%MAX
}

void enqueue(struct duilie x){
    if (isFull()){
        printf("Full, error\n");
        exit(-1);
    }
    Q[tail] = x;
    if (tail+1 == MAX)
        tail = 0;
    else
        tail++;
}

struct duilie dequeue(){
    if (isEmpty()){
        printf("Empty, error\n");
        exit(-1);
    }
    struct duilie tmp = Q[head];
    if (head+1 == MAX)
        head = 0;
    else
        head++;    

    return tmp;
}

int main (){
    initialize();
    int n, split;
    scanf("%d", &max);
    scanf("%d", &split);
    for (int i = 0; i < max; i++){
        scanf("%s", &Q[i].name);
        scanf("%d", &Q[i].time);
		tail++;
    }
    int totalTime = 0;
	while (!isEmpty()){
		if (Q[head].time <= split){
			totalTime += Q[head].time;
			printf("%s %d\n", Q[head].name, totalTime);
			dequeue();
		}
		else {
			totalTime += split;
            Q[head].time -= split;
			enqueue(dequeue());
		}
	}
    return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int n;
    cin >> n;

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

    int alice = 0;
    int bob = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) alice += v[i];
        else bob += v[i];
    }

    cout << alice - bob << endl;

}

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

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0;
	vector<int> dp(n+1,-1);
	for(int i=0;i<n;i++){
		if(dp[a[i]-1]==-1){
			dp[a[i]]=1;
		}
		else{
			dp[a[i]]=dp[a[i]-1]+1;
		}
	}
	for(int i=0;i<=n;i++){
		ans=max(ans,dp[i]);
	}
	cout << n-ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.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 endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    int n; cin >> n;
    string ans = "No";
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        if(a == b)cnt++;
        else cnt = 0;
        if(cnt == 3)ans = "Yes";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return mod_pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll dp[3010][3010][2];


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

    for(int i = 0; i < 3010; i++){
        for(int j = 0; j < 3010; j++){
            for(int k = 0; k < 2; k++){
                dp[i][j][k] = 0;
            }
        }
    }

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

    for(int i = 0; i < M; i++){
        for(int j = 0; j <= N; j++){
            //赤赤
            if(j == 1){
                dp[i+1][j-1][1] = add(dp[i+1][j-1][1], dp[i][j][0]);
            }
            else if(j > 1){
                dp[i+1][j-1][0] = add(dp[i+1][j-1][0], dp[i][j][0]);
            }
            if(j >= 1) {
                dp[i+1][j-1][1] = add(dp[i+1][j-1][1], dp[i][j][1]);
            }

            //赤青
            if(j == 1){
                dp[i+1][j][1] = add(dp[i+1][j][1], dp[i][j][0]);
            }
            else if(j > 1){
                dp[i+1][j][0] = add(dp[i+1][j][0], dp[i][j][0]);
            }
            if(j >= 1) {
                dp[i+1][j][1] = add(dp[i+1][j][1], dp[i][j][1]);
            }

            //青赤
            if(j <= N-1) {
                dp[i+1][j][0] = add(dp[i+1][j][0], dp[i][j][0]);
                dp[i+1][j][1] = add(dp[i+1][j][1], dp[i][j][1]);
            }

            //青青
            if(j <= N-1) {
                dp[i+1][j+1][0] = add(dp[i+1][j+1][0], dp[i][j][0]);
                dp[i+1][j+1][1] = add(dp[i+1][j+1][1], dp[i][j][1]);
            }
        }
    }

    ll res = 0;
    for(int j = 0; j <= N; j++){
        res = add(res, dp[M][j][1]);
    }

//    for(int i = 0; i <= M; i++){
//        for(int j = 0; j <= N; j++){
//            cout << dp[i][j][1] << " ";
//        }
//        cout << endl;
//    }

    cout << res << endl;



    return 0;
}

Measured memory_bytes: 143744
s = list(input())
n = len(s)

for i in range(n):
    # if i == 0 and s[i] == "?":
    #     if s[i+1] == "D" or s[i+1] == "?":
    #         s[i] = "P"
    #     else:
    #         if s[i+1] == "P":
    #             s[i] = "D"
    # elif i != 0 and s[i] == "?":
    #     if s[i-1] == "P":
    #         s[i] = "D"
    #     elif s[i-1] == "D":
    #         s[i] = "P"
    if s[i] == "?":
        s[i] = "D"

print("".join(s))

Measured memory_bytes: 10804
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    cout << m * (m - 1) / 2 + n * (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,K,a,b,ans=0;
  cin>>N>>K;
  for(ll i=K;i<=N+1;i++){
  a=(2*N-i+1)*i/2;
  if(i==1){b=0;}
  if(i==2){b=1;}
  else{b=(i-1)*i/2;}
  ans+=a-b+1;
  }
  cout<<ans%1000000007<<endl;
}

Measured memory_bytes: 3636
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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

    return 0;
}


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

"""
name: A-500.py
プログラムの説明
"""

def main():
    a,b = map(int, input().split())
    all_a = str(a) * b
    all_b = str(b) * a

    # print(all_a)
    # print(all_b)

    if (all_a < all_b):
        print(all_a)
    else :
        print(all_b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[9];
    for(int i = 0; i < 9; i++){
        a[i] = (i + 1) * 100 + (i + 1) * 10 + (i + 1);
    }

    for(int i = 0; i < 9; i++){
        if(n <= a[i]){
            printf("%d\n",a[i]);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  int ah[h], aw[w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if (a[i][j] != '.'){
	ah[i] = 0;
	break;
      }
      else if(j == w-1) ah[i] = 1;
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if (a[i][j] != '.') {
	aw[j] = 0;
	break;
      }
      else if(i == h-1) aw[j] = 1;
    }
  }

  for(int i=0;i<h;i++){
    if(ah[i] == 0){
      for(int j=0;j<w;j++){
	if(aw[j] == 0){
	  cout << a[i][j];
	}
      }
      cout << endl;
    }
  }
}


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

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    int mat[n][m];
    int v[m];

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

    int a[n] = {};


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            a[i] += mat[i][j] * v[j]; 
        }
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }

    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}
template<class T>bool chmin(T &a, const T &b) {return (b<a)?(a=b,1):0;}
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}

using R=long double; // __float128
const R EPS = 1E-11; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline int sgn(const R& a, const R &b){ return sgn(a-b); }
inline R sq(R x){return sqrt(max<R>(x,0.0));}

using P=complex<R>;
using VP=vector<P>;
using L=struct{P s,t;};
using VL=vector<L>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}


// dot det
inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}
inline P vec(L l){return l.t-l.s;}


// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {
	if (sgn(det(o,a,b)) > 0) return LEFT;    // counter clockwise
	if (sgn(det(o,a,b)) < 0) return RIGHT;   // clockwise
	if (sgn(dot(o,a,b)) < 0) return BACK;    // b--base--a on line
	if (sgn(norm(a-o)-norm(b-o)) < 0) return FRONT;   // base--a--b on line
	return ON;// base--b--a on line  semnet determination betwenn a and b 
}

// crossing point verify AOJ CGL_2_C
P cross(L a,L b){
	R s1=det(a.s,b.s,b.t);
	R s2=s1+det(a.t,b.t,b.s);
	return a.s+s1/s2*(a.t-a.s);
}

// Polygon
// area Verify AOJ 1100 CGL_3_A
R area(const VP& pol){
	int n=pol.size();
	R sum=0;
	rep(i,n) sum+=det(O,pol[i],pol[(i+1)%n]);
	return abs(sum/2.0);
}

// convex_cut verify AOJ CGL_4_C
VP convex_cut(const VP& pol,const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i],b=pol[(i+1)%n];
		if(ccw(l.s,l.t,a)!=RIGHT) reg(res,a);
		if((ccw(l.s,l.t,a)|ccw(l.s,l.t,b))==(LEFT|RIGHT)) reg(res,cross({a,b},l));
	}
	return res;
}


L bisector(P a, P b){P mid=(a+b)/P(2,0);return L{mid, mid+(b-a)*P(0,1)};}
VP voronoi_cell(VP pol,VP v,int s){rep(i,v.size())if(i!=s)pol=convex_cut(pol,bisector(v[s],v[i]));return pol;}


int main(void){
	int n,m;
	while(cin >> n >> m,n){
		VP island(n),lord(m);
		rep(i,n) cin >> island[i];
		rep(i,m) cin >> lord[i];

		cout.precision(20);
		rep(i,m) cout << fixed << area(voronoi_cell(island,lord,i)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
an = []
alfa = 'abcdefghijklmnopqrstuvwxyz'
N -= 1
while True:
    amari = N % 26
    an.append(amari)
    if N < 26:
        break
    N = N // 26 - 1
ans = ''
for x in an :
    ans = alfa[x] + ans
print(ans)



Measured memory_bytes: 8900
import math

n, d = map(int, input().split(" "))

positions = []

for i in range(n):
  positions.append([int(i) for i in input().split(" ")])

count = 0
for position in positions:
  dist = math.sqrt(position[0]**2 + position[1]**2)
  if dist <= d:
    count += 1
print(count)

Measured memory_bytes: 106744
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string[] Reader = ReadLine().Split(' ');
            int N = int.Parse(Reader[0]);
            int X = int.Parse(Reader[1]);
            int T = int.Parse(Reader[2]);

            if (N % X != 0)
                WriteLine((N / X + 1) * T);
            else
                WriteLine((N / X) * T);

            return;
        }
    }
}


Measured memory_bytes: 17872
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 降順
	return s.idx < t.idx;
}


int main() {
	int n, m;
	cin >> n >> m;
	VI v(m);

	VI diff(m - 1);
	REP(i, m) {
		cin >> v[i];
	}
	SORT(v);
	REP(i, m - 1) {
		diff[i] = v[i + 1] - v[i];
		
	}

	SORT(diff);
	long long ans = 0;
	FOR(i, 0, m - n - 1) {
		ans += diff[i];
	}

	ANS(ans);



	return 0;
}


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

sita_maxi = [0 for i in range(n+1)]
sita_maxi[n] = a[n]
for i in range(n-1, -1, -1):
    sita_maxi[i] = sita_maxi[i+1] + a[i]

if a[0] > 1:
    print(-1)
    exit()

lst = [1]
for i in range(1, n+1):
    lst.append(min((lst[i-1]-a[i-1])*2, sita_maxi[i]))
    if lst[-1] < a[i]:
        print(-1)
        exit()

print(sum(lst))

Measured memory_bytes: 88500
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAX=1e6;
int d[MAX];
int main()
{  
   long long int a,b,c,i;
   long long int s=0;
  scanf("%lld",&a);
  for(i=1;i<1000000;i++)
  {
  	a=a/2;
  	s=s+pow(2,i-1);
  	if(a==0)
  	break;
  }
  printf("%lld\n",s);
}

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

using namespace std;
using ll = long long;

char Solve(int m, int f, int r){
    if(m == -1 or f == -1){
        return 'F';
    }
    if(m+f >= 80){
        return 'A';
    }
    if(m+f >= 65){
        return 'B';
    }
    if(m+f >= 50){
        return 'C';
    }
    if(m+f >= 30){
        if(r>=50){
            return 'C';
        }
        else{
            return 'D';
        }
    }
    return 'F';
}

int main(){
    int m,f,r;
    while(cin>>m>>f>>r and (m != -1 or f != -1 or r != -1)){
        cout<<Solve(m,f,r)<<endl;
    }
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var difference = new List<long>();
            var sumFlag = (long)0;

            for (int i = 0; i < N; i++)
            {
                var dif = A[i] - B[i];
                difference.Add(dif);
                sumFlag += dif;
            }

            if (sumFlag < 0)
            {
                Console.WriteLine("-1");
                return;
            }

            //昇順ソート
            difference.Sort();

            //変更されたか記録
            var change = new bool[difference.Count];
            for (int i = 0; i < difference.Count; i++)
            {
                change[i] = false;
            }

            var changeCount = 0;
            var startCount = 0;
            for (int index = 0; index < difference.Count; index++)
            {
                //昇順ソートなので0よりでかいのが来たら以降全部でかい => break
                if (difference[index] >= 0)
                {
                    break;
                }

                var need = difference[index] * -1;
                change[index] = true;
                changeCount++;

                var buffer = (long)0;

                for (int bring = startCount; bring < difference.Count; bring++)
                {
                    var bringPoint = difference.Count - bring - 1;

                    //bringPointから持ってくる数 == val
                    var val = (long)0;
                    if (need <= difference[bringPoint])
                    {
                        //足りないところから
                        val = need - buffer;
                    }
                    else
                    {
                        val = difference[bringPoint];
                        startCount++;
                    }

                    difference[bringPoint] -= val;
                    if (change[bringPoint] == false)
                    {
                        change[bringPoint] = true;
                        changeCount++;
                    }
                    
                    buffer += val;
                    if (difference[index] + buffer >= 0)
                    {
                        difference[index] += buffer;
                        break;
                    }
                }
            }

            Console.WriteLine(changeCount);
        }
    }
}


Measured memory_bytes: 31584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#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;

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

    int N; cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
}


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

using namespace std;

int main(){

  


  int a,b,c;


  cin >> a>>b>>c;

  int f = a+b-c;

  if (f>=0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if (A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	int q,h,s,d;	
	int n;
	cin >> q >> h >> s >> d;
	cin >> n;
	int a = min({4LL * q,2LL * h,s,h + 2LL * q});
	int b = min(2 * a,d);
	int ans = 0;
	ans += b * (n / 2);
	if(n & 1) ans += a;
	rc(ans);
}


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

int main(void){
	int w,h,x,y,n;
	int dp[17][17];
	
	for(;;){
		scanf("%d%d",&w,&h);
		if(w==0 || h==0)break;
		scanf("%d",&n);
		for(int i=0;i<17;i++)for(int j=0;j<17;j++)dp[i][j]=1;
		for(int i=0;i<n;i++){
			scanf("%d%d",&x,&y);
			dp[x-1][y-1]=0;
		}
		for(int i=0;i<w;i++){
			for(int j=0;j<h;j++){
				if(dp[i][j]!=0){
					if(i!=0 || j!=0)dp[i][j]=0;
					if(i!=0)dp[i][j]+=dp[i-1][j];
					if(j!=0)dp[i][j]+=dp[i][j-1];
				}
			}
		}
		printf("%d\n",dp[w-1][h-1]);
	}
	
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int sum=0,x=a[0];
    for(int i=1;i<n;i++){
        if(a[i]<x){
            sum+=abs(x-a[i]);
        }
        else x=a[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 5176
#include<stdio.h>

int main(void)
{
	int n;
	
	scanf("%d", &n);
	
	int i, j, R[n];

	for(i=0; i<n; i++)
	{
		scanf("%d", &R[i]);
	}
	
	int min=R[0], max=R[1]-R[0];
	
	for(i=1; i<n; i++)
	{
		if(R[i]-min>max)
		{
			max = R[i]-min;
		}
		
		if(R[i]<min)
		{
			min = R[i];
		}
	}
	
	printf("%d\n", max);
	
//	printf("max = %d, min = %d", max, min);
	
	return 0;
}



Measured memory_bytes: 2508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

const int V=10000;
using P=pair<int,int>;
vector<P> G[V];
int dist[V];
bool used[V];
void dijkstra(int s){
  fill_n(dist,V,INF);
  fill_n(used,V,false);
  priority_queue<P,vector<P>,greater<P>> q;
  q.push(P(0,s));
  while(!q.empty()){
    int d; int t;
    tie(d,t)=q.top();q.pop();
    if(used[t])continue;
    used[t]=true;dist[t]=d;
    for(P e: G[t]){
      if(dist[e.second]<=d+e.first)continue;
      q.push(P(d+e.first,e.second));
    }
  }
}

int main(){
  ll H,W;cin>>H>>W;
  ll w;
  FOR(i,0,10){
    FOR(j,0,10){
      cin>>w;
      G[i].emplace_back(w,j);
    }
  }
  vector<ll> v(10);
  rep(i,10){
    dijkstra(i);
    v[i]=dist[1];
  }
    
  ll ans=0,a;
  rep(i,H){
    rep(j,W){
      cin>>a;
      if(a!=-1){
        ans+=v[a];
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
	ll int a,b,c;
	cin>>a;
	b=100;
	int n=0;
	while(b<a)
	{
		b+=b*0.01;
		n++;
	}
	cout<<n;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    int a[n];int b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(b[i]==a[n-1])
        cout<<a[n-2]<<endl;
        else
        cout<<a[n-1]<<endl;
    }

return 0;

}

Measured memory_bytes: 3200
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];
    int maxv = -2000000000;
    int minv = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      a[i] = stdIn.nextInt();
      maxv = Math.max(maxv, a[i] - minv);
      minv = Math.min(minv, a[i]);
    }
    System.out.println(maxv);
  }
}

Measured memory_bytes: 101972
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long N){
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        if(i% 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
 
#define endl	"\n"
#define pb 		push_back
#define mp 		make_pair
#define MOD 	1000000007
#define INF 	(long long int)1e9
#define EPS 	1e-9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ret     return
#define NUM 	100020
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	fastio();
	//input();

	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
		int mn = INF;
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				int x = dp[i-j]+abs(v[i]-v[i-j]);
				mn = min(x,mn);
			}
		}
		dp[i] = mn;
	}
	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
function Main(input) {
	input = input.trim();
  var output = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i , i + 1);
    if(tmp == "2"){
       output++;
       }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s; cin>>s;
  int K; cin>>K;
  int sz = s.size();
  vector<string> ss;
  rep(i, sz) REPC(j, 1, 5) ss.emplace_back(s.substr(i, j));
  sort(ALL(ss));
  ss.erase(unique(ALL(ss)), ss.end());
  cout << ss[K-1] << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 1660