akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

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

  static class CID {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      int m = in.nextInt();
      InTriple[] tri = new InTriple[m];
      String[] res = new String[m];
      for (int i = 0; i < m; i++) {
        tri[i] = new InTriple(in.nextInt(), in.nextInt(), i);
      }

      Arrays.sort(tri, (tri1, tri2) -> {
        if (tri1.x - tri2.x != 0) {
          return tri1.x - tri2.x;
        }
        if (tri1.y - tri2.y != 0) {
          return tri1.y - tri2.y;
        }
        return 0;
      });

      int index = 1;
      for (int i = 0; i < m; i++) {
        if (i == 0 || tri[i].x != tri[i - 1].x) {
          index = 1;
        }
        res[tri[i].z] = String.format("%06d%06d", tri[i].x, index);
        index++;
      }

      for (int i = 0; i < m; i++) {
        System.out.println(res[i]);
      }
    }

  }

  static class InTriple {

    int x;
    int y;
    int z;

    public InTriple(int x, int y, int z) {
      this.x = x;
      this.y = y;
      this.z = z;
    }

    public String toString() {
      return "(" + this.x + ", " + this.y + ", " + this.z + ")";
    }

  }
}



Measured memory_bytes: 150008
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
	ios::sync_with_stdio(false);
	int ans = 0;
	cin >> n;

	int a = 0, b = 0, c = 0, d = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 1; j < int(s.size()); j++)
			if (s[j] == 'B' && s[j - 1] == 'A')
				ans++;
		if (s[0] == 'B' && s[int(s.size()) - 1] == 'A')
			c++;
		else if (s[0] == 'B')
			b++;
		else if (s[int(s.size()) - 1] == 'A')
			a++;
		else
			d++;
	}

	while (true) {

		if (a > 0 && c > 0) ans++, c--;
		else if (b > 0 && c > 0) ans++, c--;
		else if (a > 0 && b > 0) ans++, a--, b--;
		else break;
	}

	ans += max(0, c - 1);
	ans += min(a, b);
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int partition(int A[],int p,int r){
    int x = A[r];
    int i = p-1;
    for(int j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
 
int main(){
    int n,partition_point;
    scanf("%d",&n);
    int A[n];
    for(int i = 0; i < n; i++) scanf("%d",&A[i]);
 
    partition_point = partition(A,0,n-1);
 
    for(int i = 0; i < n-1; i++){
        if(i == partition_point){
            printf("[%d] ",A[i]);
        }else{
            printf("%d ",A[i]);
        }
    }
    if(partition_point == n-1){
        printf("[%d]\n",A[n-1]);
    }else{
        printf("%d\n",A[n-1]);
    }
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int MAXN=1e5+10;
ll n,m;
char a[MAXN],b[MAXN];
ll gcd(ll x,ll y)
{
	ll z=x%y;
	while (z) {
		x=y; y=z; z=x%y;
	}
	return y;
}
int main(){
	scanf("%lld%lld",&n,&m);
	scanf("%s",a);
	scanf("%s",b);
	ll t=gcd(n,m);
	if (a[0]!=b[0]) {
		printf("%d\n",-1); return 0;
	}
	if (t==n) {
		for (int i=0;i<n;i++)
		if (a[i]!=b[i*(m/n)]) {
			printf("%d\n",-1); return 0;
		} 
		printf("%lld\n",m);
	}
	else
	 if (t==m){
	 	for (int i=0;i<m;i++)
		if (b[i]!=a[i*(n/m)]) {
			printf("%d\n",-1); return 0;
		} 
		printf("%lld\n",n);
	 }
	 else
	 {
	 	for (int i=1;i<=t;i++)
	 	 if (a[n/t*i]!=b[m/t*i]) {
	 	 	printf("%d",-1); return 0;
		  }
	 	printf("%lld\n",n/t*m);
	 }
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define inRange(x,a,b) a <= x && x < b

int mat[90][90] = {};
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
bool used[90][90] = {};
int h, w, ans;

void dfs(int i, int j, int score){
    ans = max(ans, score);
    used[i][j] = true;
    for(int k = 0; k < 4; k++){
        int ni = i + dx[k];
        int nj = j + dy[k];
        if(inRange(ni, 0, h) && inRange(nj, 0, w) && !used[ni][nj] && mat[ni][nj]){
            dfs(ni, nj, score+1);
        }
    }
    used[i][j] = false;
}

int main(){
    while(cin >> w >> h){
        if(w + h == 0)  break;
        ans = 0;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> mat[i][j];
            }
        }

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(mat[i][j]){
                    dfs(i, j, 1);
                }
            }
        }

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


Measured memory_bytes: 3028
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, sum = 0, ans = 0; cin >> n >> a;
	int b[123];
	for (int h = 0; h < n; h++) {
		cin >> b[h];
	}
	sort(b, b + n);
	for (int h = 0; h < n; h++) {
		if (h == n - 1) {
			if (a == sum + b[h]) {
				ans++;
			}
		}
		else if (a >= sum + b[h]) {
			sum += b[h];
			ans++;
		}
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a = [input().split() for l in range(n)]
b=[int(input()) for i in range(m)]
du=0
for v in range(n):
    for k in range(m):
        du+=int(a[v][k])*b[k]
    print(du)
    du=0    


Measured memory_bytes: 6256
from collections import deque

S=deque(input())
Q=int(input())

st=False#順方向

for _ in range(Q):
    query=input()
    if len(query)==1:
        st= not st
    else:
        _,F,C=query.split()
        F=int(F)
        if st==False:
            if F==1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F==1:
                S.append(C)
            else:
                S.appendleft(C)

if st==False:
    ans=S
else:
    ans=reversed(S)

ans="".join(list(ans))
print(ans)
        
    

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

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

long long dp[101][100001];

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w.at(i) >> v.at(i);
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            if (sum_w - w.at(i) >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w.at(i)] + v.at(i));
            }

            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
        
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 78336
lines = readlines.join.split.map(&:to_i)

X = lines.join("").to_i
ary = []
X.times do |i|
    Y = X / (i+1)
    if Y * Y == X
        ary << Y
    end
end
if ary[0] == nil
    puts "No"
else
    puts "Yes"
end


Measured memory_bytes: 20308
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
vector< int > g[N];
bool ok[N];
int col[N], d[N], ans[N];
int n, m, s[N], t[N];
void f(int v){
	for(auto i : g[v]){
		int to = s[i] ^ t[i] ^ v;
		if(col[to] == -1){
			col[to] = col[v] ^ 1;
			ans[i] = d[v];
			f(to);
		}
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%d", &d[i]);
	for(int i = 1; i <= m; i++){
		scanf("%d%d", &s[i], &t[i]);
		if(d[s[i]] == d[t[i]]){
			g[s[i]].pb(i);
			g[t[i]].pb(i);
			ans[i] = d[s[i]];
			ok[s[i]] = ok[t[i]] = 1;
		}else{
			if(d[s[i]] < d[t[i]])	
				ok[t[i]] = 1;
			else
				ok[s[i]] = 1;
		}
	}   	
	for(int i = 1; i <= n; i++)
		if(!ok[i]){
			printf("-1");
			return 0;
		}

	for(int i = 1; i <= n; i++)
		col[i] = -1;

	for(int i = 1; i <= n; i++){
		if(col[i] == -1){
			col[i] = 0;
			f(i);
		}
	}
	for(int i = 1; i <= n; i++)
		if(col[i] == -1)
			col[i] = 0;
	for(int i = 1; i <= m; i++){
		if(d[s[i]] != d[t[i]]){
			if(col[s[i]] == col[t[i]])
				ans[i] = abs(d[s[i]] - d[t[i]]);
			else
				ans[i] = max(d[s[i]], d[t[i]]);
		}
	}
	for(int i = 1; i <= n; i++)
		printf("%c", (col[i] ? 'B' : 'W'));
	printf("\n");
	for(int i = 1; i <= m; i++)
		printf("%d\n", ans[i]);
}


Measured memory_bytes: 13952
import numpy as np

N = int(input())
A = list(map(int,input().split()))

A = np.array(A)
idx_minabs = np.argmin(np.abs(A))
n_minus = np.sum(A < 0) - (A[idx_minabs] < 0)

ans = np.sum(np.abs(A)) - np.abs(A[idx_minabs]) + (2*((n_minus+1)%2)-1)*A[idx_minabs]

print(ans)



Measured memory_bytes: 23292
def GetColor(point):
   color = point//400
   if color>=8:
      color = -1
   return color

N = int(input())
A = map(int,input().split())
Nc = [0 for i in range(9)]
for ai in A:
   Nc[GetColor(ai)]+=1

Nf = Nc[-1]
Ans = 0
for ic in range(len(Nc)-1):
   if Nc[ic]>0:
      Ans+=1
# maxNc = min(Ans+Nf, 8)
maxNc = Ans+Nf
minNc = max(1,Ans)
print("%d %d"%(minNc,maxNc))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int c[10][10];
int H,W,A,res;
int main()
{
    scanf("%d%d", &H,&W);
    for(int i=0;i<10;i++) for(int j=0;j<10;j++) scanf("%d",&c[i][j]);

    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d",&A);
            if(A>=0) res+=c[A][1];
        }
    }
    printf("%d\n",res);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

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

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
  int arr[5];
  int pos=0;
  for(int i=0;i<5;i++)
  {
    cin>>arr[i];
    if(arr[i]==0)
    {
      pos=i+1;
    }
  }
  cout<<pos;
  
}

Measured memory_bytes: 3560
const main = (inputs) => {
  var S = inputs[0].split("");
  var tmp = {};
  S.forEach(v=>{
    tmp[v] = (tmp[v]||0)+1
  });
  var ans = true;
  if(Object.keys(tmp).length!=2) ans = false;
  else if(Object.keys(tmp).filter(v=>tmp[v]!=2).length != 0){
    ans = false;
  }
  
  console.log(ans?"Yes":"No");
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 21064
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    res = INF
    for i in range(N):
        if i == N-1:
            res = min(res, A[N-1] - A[0])
        else:
            res = min(res, K - (A[i+1] - A[i]))
    
    print(res)


if __name__ == '__main__':
    main()

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

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

	if (s.size() <= k) {
		cout << s << endl;
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3596
# ██╗     █████╗ ███╗   ███╗
# ██║    ██╔══██╗████╗ ████║
# ██║    ███████║██╔████╔██║
# ██║    ██╔══██║██║╚██╔╝██║
# ██║    ██║  ██║██║ ╚═╝ ██║
# ╚═╝    ╚═╝  ╚═╝╚═╝     ╚═╝
#
#
# ███╗   ███╗     █████╗     ██████╗     ██╗  ██╗    ██╗    ███╗   ██╗    ████████╗     ██████╗     ███████╗    ██╗  ██╗
# ████╗ ████║    ██╔══██╗    ██╔══██╗    ██║ ██╔╝    ██║    ████╗  ██║    ╚══██╔══╝    ██╔═══██╗    ██╔════╝    ██║  ██║
# ██╔████╔██║    ███████║    ██████╔╝    █████╔╝     ██║    ██╔██╗ ██║       ██║       ██║   ██║    ███████╗    ███████║
# ██║╚██╔╝██║    ██╔══██║    ██╔══██╗    ██╔═██╗     ██║    ██║╚██╗██║       ██║       ██║   ██║    ╚════██║    ██╔══██║
# ██║ ╚═╝ ██║    ██║  ██║    ██║  ██║    ██║  ██╗    ██║    ██║ ╚████║       ██║       ╚██████╔╝    ███████║    ██║  ██║
# ╚═╝     ╚═╝    ╚═╝  ╚═╝    ╚═╝  ╚═╝    ╚═╝  ╚═╝    ╚═╝    ╚═╝  ╚═══╝       ╚═╝        ╚═════╝     ╚══════╝    ╚═╝  ╚═╝
#
#
# ██████╗     ██╗    ████████╗     ██████╗    ██╗  ██╗
# ██╔══██╗    ██║    ╚══██╔══╝    ██╔════╝    ██║  ██║
# ██████╔╝    ██║       ██║       ██║         ███████║
# ██╔══██╗    ██║       ██║       ██║         ██╔══██║
# ██████╔╝    ██║       ██║       ╚██████╗    ██║  ██║
# ╚═════╝     ╚═╝       ╚═╝        ╚═════╝    ╚═╝  ╚═╝
n=int(input())
l=list(map(int,input().split()))
l=[10000]+l
dp=[0]*(n+1)
dp[0]=1e4+1
dp[1]=0
for i in range(2,n+1):
    dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
print(dp[-1])

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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a.at(i);
        x -= a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.size() + x / a.at(0) << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
    int A, B, C;

    cin >> A >> B >> C;
    if(A == B && A != C) cout << "Yes";
    else if(B == C && B != A) cout << "Yes";
    else if(C == A && C != B) cout <<"Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
N = int(input())                                                                                              
count = 0    
result = 'No'    
dice_list = []    
    
for i in range(N):    
    dice_list.append(list(map(int, input().split())))    
    
for i in range(N):    
    if dice_list[i][0] == dice_list[i][1]:    
        count += 1    
        if count >= 3:    
            break    
    else:    
        count = 0    
    
if count >= 3:    
    result = 'Yes'    
    
print(result)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N;
	cin >> N; 
	int P[20010] = {}; 
	for(int i = 1; i <= N; i++){
                int m; 
		cin >> m;
                P[m] = i;  
	}
	int A[20010] = {}, B[20010] = {}; 
	A[1] = 1, B[1] = 1000000000; 
	for(int i = 2; i <= N; i++){
		if(P[i-1] < P[i])
			{B[i] = B[i-1] - 1; A[i] = A[i-1] + P[i] - P[i-1] + 1;}
		else if(P[i-1] > P[i])
			{A[i] = A[i-1] + 1; B[i] = B[i-1] + P[i] - P[i-1] - 1;}
	}
	for(int i = 1; i <= N; i++){
		cout << A[i] << " "; 
	}
	cout << endl; 
	for(int i = 1; i <= N; i++){
		cout << B[i] << " "; 
	}
	cout << endl; 
}

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

int main(){
  int64_t A;
  int64_t B;
  int64_t K;
  cin >> A >> B >> K;
  if(A > K){
    cout << A-K << " "<< B;
  }
  else if(A+B > K){
    cout << 0 << " "<< B-K+A;
  }
  else{
    cout << 0 << " "<< 0;
  }
  }

Measured memory_bytes: 256
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
#n=int(input())
S=input()
T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#h=list(map(int,input().split()))
#v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
ans=0
for s,t in zip(S,T):
    if s==t:
        ans+=1
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN], dp[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    FOR(i,3,n) dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int h = ty - sy, w = tx - sx;
    FOR(i, 0, h)
        cout << 'U';
    FOR(i, 0, w)
        cout << 'R';
    FOR(i, 0, h)
        cout << 'D';
    FOR(i, 0, w)
        cout << 'L';
    // twice done
    cout << 'L';
    FOR(i, 0, h + 1)
        cout << 'U';
    FOR(i, 0, w + 1)
        cout << 'R';
    cout << 'D';
    // three times
    cout << 'R';
    FOR(i, 0, h + 1)
        cout << 'D';
    FOR(i, 0, w + 1)
        cout << 'L';
    cout << 'U';
    // four times
    cout << endl;
    return 0;
};


Measured memory_bytes: 256
from fractions import Fraction

a, b, c, d = map(int, raw_input().split())
N = input()

A = a / Fraction(1, 4)
B = b / Fraction(1, 2)
C = c / Fraction(1, 1)
D = d / Fraction(2, 1)
ans = 0

if D < A and D < B and D < C:
    ans += N / 2 * d
    ans += min(A, B, C) * (N % 2)
else:
    ans += min(A, B, C) * N

print int(ans)


Measured memory_bytes: 4392
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    ld  n, m, d, ans ; 
    cin >> n >> m >> d ; 
    if (d == 0) ans = (1.0/n)*(m-1);
    else ans = ((2.0*(n-d))/(n*n))*(m-1);
    cout.precision(20); 
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3796
using System;
using System.Collections;


namespace Bcs
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var min_ = 1000;

            for (int i = 0; i < s.Length-2; ++i)
            {
                var x = int.Parse( s.Substring(i, 3) );
                min_ = Math.Min(min_, Math.Abs(x - 753));
            }

            Console.WriteLine(min_);

        }
    }
}


Measured memory_bytes: 11220
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a,b; cin >> a >> b;
    
    if(a>8 || b>8) cout << ":(" << ln;
    else cout << "Yay!" << ln;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	string s; cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		else if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
  int H;
  int N;

  scanf("%d", &H);
  scanf("%d", &N);
  int A[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  if (sum >= H) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int *A = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int *order = new int[N];
    for (int i = 0; i < N; i++) {
        order[A[i] - 1] = i; // 生徒の出席番号は1から。
    }
    
    for (int i = 0; i < N; i++) {
        std::cout << order[i] + 1 << " ";    // 生徒の出席番号は1から。
    }
    
    delete[] A;
    
    return 0;
}

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

int n, m;
int a[101][101];
int b[101];
int c[101];

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

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 3136
#include <stdio.h>

#define N 50

int main() {
	static int aa[N], bb[N], kk[N];
	int n, m, i;

	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &aa[i], &bb[i]);
		kk[aa[i]]++;
		kk[bb[i]]++;
	}
	for (i = 1; i <= n; i++)
		printf("%d\n", kk[i]);
	return 0;
}


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

int main(){
	ll n; cin >> n;
	vector<ll> amari(0);
    while( n-1 >= 26 ){
      ll k = (n - 1) % 26 + 1;    
      amari.push_back( k );
      n = (n-1)/26;
    }
      amari.push_back( n );

  reverse(amari.begin(), amari.end());
  string ans = "";
  rep(i, amari.size()){
    ans.push_back(char(amari[i] - 1 + 'a'));
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
n = int(input())
arr = [int(input()) for _ in range(n)]
btns = set()
count = 0
_next = 1
while True:
    count += 1
    btn = arr[_next-1]
    if btn == 2:
        print(count)
        break
    elif btn in btns:
        print(-1)
        break
    else:
        btns.add(btn)
    _next = btn

Measured memory_bytes: 56024
#include <bits/stdc++.h>
using namespace std;
const int MAX = (3e2)+2;
const long long MOD = (1e9)+7;

int n, m;
long long ans, dp[MAX][MAX][MAX];
vector<pair<int,int> > req[MAX];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0, l, r, x; i < m; i++) {
		cin >> l >> r >> x;
		req[r].emplace_back(l, x);
	}
	dp[0][0][0] = 1;
	for(int r = 0; r <= n; r++) for(int g = 0; g <= n; g++) for(int b = 0; b <= n; b++) {
		int k = max(r, max(g, b));
		for(auto p: req[k]) if((r >= p.first) + (g >= p.first) + (b >= p.first) != p.second) {
			dp[r][g][b] = 0;
			break;
		}
		if(k == n) ans = (ans + dp[r][g][b])%MOD;
		dp[k+1][g][b] = (dp[k+1][g][b] + dp[r][g][b])%MOD;
		dp[r][k+1][b] = (dp[r][k+1][b] + dp[r][g][b])%MOD;
		dp[r][g][k+1] = (dp[r][g][k+1] + dp[r][g][b])%MOD;
	}
	cout << ans;
}


Measured memory_bytes: 215424
a, b, h, m = map(int, input().split())

import math

x1, y1 = a, 0
x2, y2 = b, 0

alph = (h*60 + m)/(12*60) * 360
beta = m/60 * 360

x1 = a * math.cos(math.radians(alph))
y1 = a * math.sin(math.radians(alph))

x2 = b * math.cos(math.radians(beta))
y2 = b * math.sin(math.radians(beta))

ans = ((x1 - x2)**2 + (y1 - y2)**2)**(1/2)

print(ans)


Measured memory_bytes: 62460
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  ll A[N];
  for(ll i=0; i<N; ++i) cin>>A[i];
  
  map<ll,ll> P,Q;
  for(ll i=0; i<N; ++i) P[1+i+A[i]]++;
  for(ll i=0; i<N; ++i) Q[1+i-A[i]]++;
  
  FORE(v,P){
    ans+=v.second*Q[v.first];
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 39188
import java.io.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String inputed = new String(in.readLine());

		String value[] = inputed.split("[\\s]+");
		//int intInputed = Integer.parseInt(inputed);

		int first = Integer.parseInt(value[0]);
		int second = Integer.parseInt(value[1]);

		if (first == second) {
			System.out.println("a == b");
		} if (first > second) {
			System.out.println("a > b");
		} if (first < second) {
			System.out.println("a < b");
		}

	}
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, p;

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n >> p, n || p) {
		int tmp = p;
		int a[n];
		rep (i, n) a[i] = 0;
		for (int i = 0; i < n; ++i) {
			if (p != 0) {
				a[i]++;
				p--;
				if (p == 0 && a[i] == tmp) {
					cout << i << endl;
					break;
				}
			} else {
				p = a[i];
				a[i] = 0;
			}
			if (i == n - 1) i = -1;
		}
	}
	return 0;
}

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

        int main() {
          
        int N;
        cin>> N; 
		vector<int> A(N), B(N), C(N-1);
        for(int i =0 ; i<N; i++){
          cin>> A.at(i); 
        }
        for(int i =0 ; i<N; i++){
          cin>> B.at(i); 
        }
        for(int i =0 ; i<N-1; i++){
          cin>> C.at(i); 
        }
        
        int S =0;   
        for(int i =0 ; i<N; i++){
          int j = A.at(i); 
          S += B.at(j-1);
          if( i>0 && j > 0 && A.at(i-1)==j-1){
            S+= C.at(A.at(i-1)-1); 
          }
        }
          
          
        cout<< S <<endl;  

        }

Measured memory_bytes: 256
#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 = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M, V, P; cin >> N >> M >> V >> P;
    ll A[N]; rep(i, N) cin >> A[i]; sort(A, A+N);
    int ok = N, ng = -1;
    int m = (ok+ng)/2;
    while(abs(ok-ng) > 1){
        //A[m]は採用されうるか
        ll eval = A[m]+M;
        if(m >= N-P) ok = m;
        else if(eval >= A[N-P]){
            ll distribute = M*V;
            distribute -= M*((m+1) + (P-1));
            if(distribute <= 0) ok = m;
            else{
                //A[m+1]からA[N-P]までにdistributeを均等になるように配る
                ll acc = 0;
                for(int i = m+1; i <= N-P; i++) acc += A[i];
                acc += distribute;
                ll res = (acc + (N-P-m - 1))/(N-P-m);
                if(eval >= res) ok = m;
                else ng = m;
            }
        }
        else ng = m;
        m = (ok+ng)/2;
    }
    cout << N-ok << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
mod = 10**9+7
N = int(input())
S = input()
cnt = 0
ans = 1
for i in range(N*2):
    if S[i]=='W':
        if cnt%2 == 0:
            ans*=cnt
            ans%=mod
            cnt-=1
        else:
            cnt+=1
    else:
        if cnt%2 == 0:
            cnt+=1
        else:
            ans*=cnt
            ans%=mod
            cnt-=1
if cnt==0:
    for i in range(1, N+1):
        ans*=i
        ans%=mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 40596
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 0){
        if (S.substr(0, N / 2) == S.substr(N / 2, N / 2)){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}


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

int main()
{
	int n,l[2005],ans=0;
	cin >> n;
	for (int i = 1; i <=n; i++) {
		cin >> l[i];
	}
	sort(l+1, l + n+1);
	for (int a = n ; a >= 3; a--) {
		for (int b = a - 1; b >= 2; b--) {
			if (l[a] >= l[b] + l[b - 1]) break;
			for (int c = b - 1; c >= 1; c--) {
				if (l[a] >= l[b] + l[c]) {
					break;
				}
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N;
	cin >> N;
	vector<int>p(N + 1);
	rep(i, N) {
		cin >> p[i];
		p[i]--;
	}
	int ans = 0;
	rep(i, N) {
		if (p[i] == i) {
			ans++;
			swap(p[i], p[i + 1]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int N=1e3+5;

int n,m;
char s[N][N];
int dp[N][N];

int main()
{
	
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	dp[0][1]=1;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
		if(s[i][j-1]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	cout<<dp[n][m]<<'\n';
	
	return 0;
}

Measured memory_bytes: 5120
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: String -> String
solve [] = []
solve (c:cs)
    | isAsciiUpper c = toLower c:solve cs
    | otherwise      = toUpper c:solve cs

main :: IO() 
main = do
    line <- getLine
    putStrLn (solve line)



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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

// ============================
// Codigo Original
// ============================
int N, _W;
int W[101], V[101];
ll dp[101][100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    ini(dp, 0);
    for1(i, N) 
        for(int w = 1; w <= _W; w++)
			if(W[i] > w) dp[i][w] = dp[i-1][w];
			else dp[i][w] = max(dp[i-1][w], dp[i-1][w - W[i]] + V[i]);

    cout << dp[N][_W] << endl;
}

// ============================
// Otimizando Memoria
// Removendo uma dimensao da DP
// ============================
/*int N, _W;
int W[101], V[101];
ll dp[100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    ini(dp, 0);
    for1(i, N) 
        for(int w = _W; w >= W[i]; w--) 
            dp[w] = max(dp[w], dp[w - W[i]] + V[i]);

    cout << dp[_W] << endl;
}*/

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


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

typedef int int_;
#define int long long
#define enable_fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)

const int MAX = 1e5+10;
const int MOD = 1e9+7;

//----------------------

#define pi pair<int,int>
#define pb push_back

int_ main()
{	
	enable_fast;
	int n,h,c; cin>>h>>c>>n;
	vector<int> a(n); vector<pi> v;
	for(int i=0;i<n;i++) cin >> a[i];
	int i=0;
	bool rev=0;
	while(i<h){
		if(rev){
			for(int j=c-1;j>=0;j--) v.pb({i,j});
			rev=false;	
		}
		else {
			for(int j=0;j<c;j++) v.pb({i,j});
			rev=true;
		}
		i++;
	}
	int ans[105][105];
	i=0;
	for(int j=0;j<n;j++){
		int x=a[j];
		for(int k=0;k<x;k++,i++) {
			pi t = v[i];
			ans[t.first][t.second]=j+1;
		}
	}

	for(i=0;i<h;i++){
		for(int j=0;j<c;j++) cout<<ans[i][j]<<" ";
		cout << endl;	
	}
}













Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];

    sort(all(a));

    cout << a[0] + a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d %d',$H,$W);
fscanf(STDIN,'%d %d',$h,$w);

// echo $h;

$sum = $H * $W;

$sum = $sum - $h * $W;
$left_row = $H - $h;

$sum = $sum - $left_row * $w;

echo $sum;

// if($a * $c < $b){
//   echo $c;
// } else if($b >= $a) {
//   echo floor($b / $a);
// } else{
//   echo 0;
// }

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
#define all(v) (v).begin(),v.end()
int main(){
 ll x,y;
 cin>>x>>y;
 ll cnt=0;
 while(x<=y){
     cnt++;
     x<<=1LL;
 }
 cout<<cnt<<endl;
}


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

namespace AtCoder.Probrems.Solvers.ABC127
{
    public class C
    {
        static void Main(string[] args)
        {
            var nm = ReadLine().Split().Select(int.Parse).ToArray();
            var gates = Enumerable.Range(0, nm[1]).Select(_ => ReadLine().Split());
            WriteLine(Solve(nm[0], nm[1], gates));
        }

        public static long Solve(int n, int m, IEnumerable<string[]> gates)
        {
            int h = 0;
            int t = int.MaxValue;
            foreach (var gate in gates)
            {
                h = Math.Max(int.Parse(gate[0]), h);
                t = Math.Min(int.Parse(gate[1]), t);
                if (h > t)
                    return 0;
            }

            return t - h + 1;
        }

        private const int MOD = 1000000007;
    }
}


Measured memory_bytes: 17476
package main

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

func solve() {
	a, b := getInt(), getInt()
	k := getInt()

	if a >= k {
		a -= k
		k = 0
	} else {
		k -= a
		a = 0
	}

	b = max(0, b-k)

	fmt.Fprintln(wr, a, b)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#!/usr/bin/env ruby
def read_input()
  edge_num = gets(chomp: true).to_i
  edges = []
  graph = {}
  (1...edge_num).each do
    edge = gets(chomp: true).split()
    edges << edge
    a,b = edge
    if (!graph.has_key?(a))
      graph[a] = []
    end
    graph[a] << b
  end
  [edges, graph]
end

def solve(graph, node, base_color, color_edge, max)
  children = graph[node]
  return [max, color_edge] if children.nil?
  edge_num = children.length
  edge_num += 1 unless (base_color.nil?)
  max = edge_num if (edge_num > max)
  color = 0
  children.each { |child|
    color += 1
    color += 1 if (color == base_color)
    color_edge[node] = {} if (color_edge[node].nil?)
    color_edge[node][child] = color
    max, color_fedge = solve(graph, child, color, color_edge, max)
  }
  [max, color_edge]
end

edges, graph = read_input
max, color_edge = solve(graph, "1", nil, {}, -1)

puts max
edges.each do |a,b|
  puts color_edge[a][b]
end


Measured memory_bytes: 126852
#include <iostream>
#include <map>

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

using namespace std;

int main()
{
    int N,M;
    map<string,int> m;
    
    cin>>N;
    rep(i,N){
        string s; cin>>s;
        m[s]+=1;
    }
    cin>>M;
    rep(i,M){
        string s; cin>>s;
        m[s]-=1;
    }
    int ans=0;
    for(auto p : m){
        if(ans<p.second) ans=p.second;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
s = input()

n = -1
if len(s) % 2 == 0:
    n = -2
while len(s) > abs(n):
    hanbun = len(s[:n])//2
    if s[:hanbun] == s[hanbun:n]:
        print(len(s[:n]))
        break
    n -= 2

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long

const int N = 3e5 +  2333;
int n, L, a[N];

signed main(void) {
	read(n); read(L);
	rep (i, n) read(a[i]);
	int pos = -1;
	rep (i, n - 1) if (a[i] + a[i + 1] >= L) pos = i;
	if (pos == -1) return puts("Impossible"), 0;
	puts("Possible");
	rep (i, pos - 1) cout << i << "\n";
	for (int i = n - 1; i >= pos + 1; i--) cout << i << "\n";
	cout << pos << "\n";
}


Measured memory_bytes: 1664
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
grad = 0
for i in range(N-1, 0, -1):
    if A[i-1] + 1 == A[i]:
        grad += B[A[i] - 1] + C[A[i - 1]-1]
    else:
        grad += B[A[i] - 1]
grad += B[A[0]-1]
print(grad)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String max = a.compareTo(b) < 0 ? a : b;
        String min = a.compareTo(b) >= 0 ? a : b;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < Integer.parseInt(min); i++) {
            builder.append(max);
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  int ans = 0;
  ans = 10*a + b +c;
  ans = max(ans,a + 10*b + c);
  ans = max(ans,a + b + 10*c);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str1,str2;
  int a,b,c[10];
  while(cin >> str1 >> str2,str1!="0"||str2!="0"){
    a=0;
    b=0;
    for(int i=0;i<10;i++) c[i] = 0;
    for(int i=0;i<4;i++){
      if(str1[i] == str2[i]) a++;
      else {
	c[str1[i]-'0']++;
	if(c[str1[i]-'0'] == 2) b++;
	c[str2[i]-'0']++;
	if(c[str2[i]-'0'] == 2) b++;
      }
    }
    cout << a << " " << b << endl;
  }
  return (0);
}



Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>

using namespace std;

int main( void )
{
	int cnt[1001];
	fill(cnt, cnt+1001, 0);
	for(int i=1; i < 500; ++i) {
		for(int j=i+1; j < 501; ++j) {
			int sum = 0;
			for(int k=i; k <= j; ++k) {
				sum += k;
			}
			if(sum <= 1000) ++cnt[sum];
		}
	}
	int n;
	while(cin >> n, n) {
		cout << cnt[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 0