akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
 
using namespace std;


int main() {
	string a,b,c;
  	cin >> a ;
  	cin >> b ;
  	cin >> c ;
	int aa = a.size();
  	int bb = b.size();
  	int cc = c.size();
  	int curr_a =0;
  	int curr_b =0;
  	int curr_c =0;
  	char te = 'a';
  	while(1) {
          //cout<<aa << " " << bb<< " " << cc<< endl;
        
    	if(te=='a'){
          if(a[curr_a] == 'a') {
          	curr_a +=1;
            aa-=1;
            if (aa==0) {
              cout<< 'A';
              break;
            }
          }else {
            te = a[curr_a];
            curr_a +=1;
            aa-=1;
            if (te == 'b' && bb==0) {
                cout<< 'B';
                break;
            } else if (te == 'c' && cc==0) {
                cout<< 'C';
                break;
            }
          }
        } else if(te=='b') {
          if(b[curr_b] == 'b') {
          	curr_b += 1;
            bb-=1;
            if (bb==0) {
              cout<< 'B';
              break;
            }
          }else {
            te = b[curr_b];
           	curr_b += 1;
            bb-=1;
            if (te == 'a' && aa==0) {
                cout<< 'A';
                break;
            } else if (te == 'c' && cc==0) {
                cout<< 'C';
                break;
            }
          }
          
        } else if (te=='c') {
          if(c[curr_c] == 'c') {
          	curr_c += 1;
            cc-=1;
            if (cc==0) {
              cout<< 'C';
              break;
            }
          }else {
            te = c[curr_c];
            curr_c += 1;
            cc-=1;
            if (te == 'a' && aa==0) {
                cout<< 'A';
                break;
            } else if (te == 'b' && bb==0) {
                cout<< 'B';
                break;
            }
          }
          
        }
    }
  
  
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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(){
  char s[3],t[3];
  rep(i,0,3) cin>>s[i];
  rep(i,0,3) cin>>t[i];

  int cnt=0;
  rep(i,0,3){
    if(s[i]==t[i]) cnt++;
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (n*a<b){
            System.out.println(n*a);
        }else{
            System.out.println(b);
        }

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>

#define N 1000000
using namespace std;

int arr[N];

//??¨????????????????????????
void Eratosthenes(){
  for(int i = 0; i < N; i++){
    arr[i] = 1;
  }
  for(int i = 2; i < sqrt(N); i++){
    if(arr[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        arr[i *(j + 2)] = 0;
      }
    }
  }
}

  
int main(void){
  Eratosthenes();
  while(1){
    int a,d,n;
    cin >> a >> d>> n;
    //cout << a << d << n;
    if(a==0 && d==0 && n==0)break;
    
    int x,i=0,j=0;
    while(1){
      if(j==n)break;
      x=a+i*d;
      if (x>1 && arr[x])j++;
      i++;
    }
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
def main():
    N = int(input())
    *A, = map(int, input().split())
    minuscount = 0
    A.sort(key=abs)
    for i in A:
        if i < 0:
            minuscount += 1
    maxi = 0
    for i in A:
        maxi += abs(i)
    if minuscount % 2 == 0:
        print(maxi)
    else:
        print(maxi - 2*abs(A[0]))
main()


Measured memory_bytes: 14252
#include<stdio.h>

int A[2000001],B[2000001];

int main(){
  int C[10001];
  int n,i;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]); 

  for(i = 0; i < 10001; i++) C[i]=0;
  for(i = 0; i < n; i++) C[A[i]]++;
  for(i = 1; i < 10001; i++) C[i] = C[i] + C[i-1];

  for(i = n-1;i >= 0 ; i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  for(i = 0; i < n; i++){
    if(i) printf(" ");
    printf("%d",B[i+1]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 17460
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;
#include <algorithm>
#include <stack>
#include <vector>
#include <array>
#include <queue>
#include <bitset>
#include <math.h>

int main(){

  int a,b;
  cin >> a >> b;

  if(a+b==3){
    cout << 3;
  }else if(a+b==4){
    cout << 2;
  }else{
    cout << 1;
  }

  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n), c(n);
  ll sumb = 0;
  rep(i, n) {
    cin >> a[i] >> b[i];
    c[i] = a[i] + b[i];
    sumb += b[i];
  }

  sort(ALL(c));
  reverse(ALL(c));

  ll ans = 0;
  rep(i, n) {
    if (!(i & 1)) {
      ans += c[i];
    }
  }
  ans -= sumb;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

	int N;
	cin >> N;
	vector<pair<ll,ll>> p(N);
	for (ll i = 0; i < N; i++) {
		cin >> p[i].first;
		p[i].second = i + 1;
	}
	sort(all(p));
	reverse(all(p));
	set<int>st;
	st.insert(0);
	st.insert(N + 1);
	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		ll l1, l2, r1, r2;
		int idx = p[i].second;
		auto itrr1 = st.lower_bound(idx);
		r1 = *itrr1;
		auto itrr2 = ((*itrr1 == N + 1) ? itrr1 :++itrr1);
		r2 = *itrr2;
		auto itrl1 = --st.lower_bound(idx);
		l1 = *itrl1;
		auto itrl2 = ((*itrl1 == 0) ? itrl1 : --itrl1);
		l2 = *itrl2;
		ans += p[i].first*((r2-r1)*(idx-l1) + (l1-l2)*(r1-idx));
		st.insert(p[i].second);
	}
	puts(ans);


	return 0;
}


Measured memory_bytes: 6528
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=readln.split.to!(int[]);

  auto pos=new int[](n+1);
  foreach(int i; 0..n) pos[a[i]]=(i+1);
  import std.container;
  auto rbt=new RedBlackTree!(int, "a<b");
  rbt.insert(0); rbt.insert(n+1);
  long sum=0;
  for(int v=1; v<=n; v++){
    int i=pos[v];
    long l=rbt.lowerBound(i).back,
         r=rbt.upperBound(i).front;
    sum+=(i-l).to!(long)*(r-i).to!(long)*v;
    rbt.insert(i);
  }
  writeln(sum);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

vector<int> u, v, w;
vector<vector<pair<int, int>>> graph;
vector<int> color;

void dfs(int node){
  REP(i, graph[node].size()){
    int nx = graph[node][i].first;
    int w = graph[node][i].second;
    if(color[nx] != -1){
      continue;
    }
    if(w % 2){
      color[nx] = (color[node] + 1) % 2;
    }
    else{
      color[nx] = color[node];
    }
    dfs(nx);
  }
}
int main(){
  int N;
  cin >> N;
  u.resize(N-1), v.resize(N-1), w.resize(N-1);
  graph.resize(N);
  REP(i, N-1){
    cin >> u[i] >> v[i] >> w[i];
    u[i]--, v[i]--;
    graph[v[i]].push_back({u[i], w[i]});
    graph[u[i]].push_back({v[i], w[i]});
  }
  color.resize(N, -1);
  color[0] = 0;
  dfs(0);
  REP(i, N){
    cout << color[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8576
//STANLEGENDS_STANEXO
//EXO_WEAREONE
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c;
	d=a-b;
	if(d>c){cout<<"0";}
	else{
	e=c-d;
	cout<<e;}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<=VMAX;++i)C[i]=0;

  for(i=1;i<=n;++i){
    scanf("%d",&A[i]);
  }
  
  for(j=1;j<=n;++j){
    C[A[j]]=C[A[j]]+1;
  }

  for(i=1;i<=VMAX;++i){
    C[i]=C[i]+C[i-1];
  }
  
  for(j=n;j>0;--j){
    B[C[A[j]]]=A[j];
    C[A[j]] -= 1;
  }

  for(i=1;i<n;i++)printf("%d ",B[i]);
  printf("%d\n",B[n]);


  return 0;
}



Measured memory_bytes: 9636
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int a[MAXN];
int cnt[16];
int dp[(1<<15)];
int solve(int mask)
{
    if(mask==0) return 0;
    if(dp[mask]!=-1) return dp[mask];
    int ans=INF;
    for(int i=0;i<15;i++)
    {
        if(!(mask&(1<<i))) continue;
        for(int j=i+1;j<15;j++)
        {
            if(!(mask&(1<<j))) continue;
            int newmask=mask^(1<<i)^(1<<j);
            int to=((i+1)^(j+1))-1;
            if(mask&(1<<to)) ans=min(ans,solve(newmask^(1<<to))+2);
            else ans=min(ans,solve(newmask^(1<<to))+1);
        }
    }
    return dp[mask]=ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n-1;i++)
    {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);u++;v++;
        a[u]^=w;a[v]^=w;
    }
    for(int i=1;i<=n;i++) cnt[a[i]]++;
    int ans=0,mask=0;
    for(int i=1;i<=15;i++)
    {
        ans+=cnt[i]/2;
        cnt[i]&=1;
        if(cnt[i]) mask+=1<<(i-1);
    }
    memset(dp,-1,sizeof(dp));
    printf("%d\n",ans+solve(mask));
    return 0;
}



Measured memory_bytes: 768
import java.io.*;
import java.util.*;
import java.util.function.*;

class Cost<T> {
	int cost;
	T thing;

	Cost(int cost, T thing) {
		this.cost = cost;
		this.thing = thing;
	}
}

class Pair {
	int x, y;

	Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int H = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());


		Queue<Cost<Pair>> queue = new ArrayDeque<>(H*W);

		BitSet[] black = new BitSet[H];
		Arrays.setAll(black, $ -> new BitSet(W));
		for (int i = 0; i < H; i++) {
			char[] data = sc.get().toCharArray();
			for (int j = 0; j < W; j++) {
				if (data[j] == '#') {
					black[i].set(j);
					queue.add(new Cost<>(0, new Pair(j, i)));
				}
			}
		}

		int[] vx = {1, 0, -1, 0};
		int[] vy = {0, 1, 0, -1};

		int max = 0;

		while (!queue.isEmpty()) {
			Cost<Pair> next = queue.remove();
			max = Math.max(max, next.cost);
			for (int i = 0; i < 4; i++) {
				int x = next.thing.x + vx[i];
				int y = next.thing.y + vy[i];
				if (x < 0 || x >= W || y < 0 || y >= H) continue;
				Pair pair = new Pair(x, y);
				if (black[y].get(x)) continue;
				queue.add(new Cost<>(next.cost + 1, pair));
				black[y].set(x);
			}
		}

		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}


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

/*最大公約数*/
int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

/*最小公倍数*/
int lcm(int a,int b){
  return a / gcd(a,b) * b;
}

int main(){
  int a,b;

while(cin >> a >> b){
  cout << gcd(a,b) << " " << lcm(a,b) << "\n"; 
}
  return 0;
}

Measured memory_bytes: 1156
def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

N,A,B = input_multiple_number()
list_X = input_multiple_number_as_list()

ans = 0 
for i in range(1,len(list_X)):
	ans += min((list_X[i]-list_X[i-1])*A,B)

print(ans)

Measured memory_bytes: 14228
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll a,b,k;
cin>>a>>b>>k;
ll h=max(0ll,a-k);
k=max(0ll,k-a);
b=max(0ll,b-k);
cout<<h<<" "<<b<<endl;
}

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

using namespace std;

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

	vector<long long> A;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	long long sum = 0;
	long long base = A[0];
	for (int i = 1; i < A.size(); ++i) {
		if (base > A[i]) {
			sum += base - A[i];
		}
		else if (base < A[i]) {
			base = A[i];
		}
	}

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

Measured memory_bytes: 4776
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
typedef struct {
	int flag;
	int cost;
}moji_t;

int main(void) {
	char s[100] = { 0 };
	int len;
	moji_t moji[26] = { 0 };

	scanf("%s", s);
	len = strlen(s);
	for (int i = 0; i < len; i++) moji[s[i] - 97].flag = 1;

	for (int i = 0; i < 26; i++) {
		int left = -1,temp=-1;
		if (moji[i].flag) {
			for (int j = 0; j < len; j++) {
				if (j == 0 && s[j] == i - 97)left = 0;
				else if (s[j] == i+97) {
					temp = j - left - 1;
					if(temp>moji[i].cost) moji[i].cost = temp;
					left = j;
				}
				else if (j == len - 1) {
					temp= len - 1 - left;
					if (temp > moji[i].cost) moji[i].cost = temp;
					left = j;
				}
			}
		}
	}
	int min = INT_MAX;
	for (int i = 0; i < 26; i++) {
		if (moji[i].flag&&min > moji[i].cost)min = moji[i].cost;
	}
	printf("%d",min);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
	char s[11];
	int p;
	int no;
} data;

int cmpstr(const void *x, const void *y) {
	int res = strcmp(((data *)x)->s, ((data *)y)->s);
	if (res == 0)
		return ((data *)y)->p - ((data *)x)->p;
	else
		return res;
}

int main() {
	int n;
	data d[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", d[i].s, &d[i].p);
		d[i].no = i + 1;
	}
	qsort(d, n, sizeof(data), cmpstr);
	for (int i = 0; i < n; i++) {
		printf("%d\n", d[i].no);
	}
	return 0;
}

Measured memory_bytes: 1744
import math
H, W = map(int, input().split())
L = max(H, W)
S = min(H, W)

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    sq1 = (L//3+1) * S
    sq2 = (L-L//3-1)*(S//2)
    S1 = abs(sq1-sq2)
    sq3 = (L//3) * S
    sq4 = (L-L//3) * math.ceil(S/2)
    S2 = abs(sq4-sq3)
    sq5 = (S//3+1) * L
    sq6 = (S-S//3-1)*(L//2)
    S3 = abs(sq5-sq6)
    sq7 = (S//3) * L
    sq8 = (S-S//3) * math.ceil(L/2)
    S4 = abs(sq7-sq8)
    print(min(S, S1, S2, S3, S4))


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

int main(){
  int n;
  cin >> n;
  vector<string> name(n);
  vector<int> l(n);
  rep(i, n) {
    cin >> name.at(i);
    cin >> l.at(i);
  }
  string song ;
  cin >> song;
  
  int m;
  rep(i,n){
    if(name.at(i) == song){
      m = i;
      break;
    } 
  }

  int ans = 0;

  for(; m+1 < n; m++){
    ans += l.at(m+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
values = []
for i in range(N):
    values.append([])
for i in range(M):
    s,c = map(int,input().split())
    values[s-1].append(c)

#同じ桁に2つ以上候補があるなら-1
for i in values:
    if len(set(i)) >= 2:
        print(-1)
        exit()

#最上位桁に候補がないときは1を補う
if values[0] == list():
    if N != 1:
        values[0].append(1)

#候補がない桁は0を補う
for i in range(N):
    if len(values[i]) == 0:
        values[i].append(0)

#探索
for i in range(1000):
    i = [int(j) for j in list(str(i))]
    if len(i) != N:
        continue
    if N==3:
        if i[0] in values[0] and i[1] in values[1] and i[2] in values[2]:
            print("".join([str(j) for j in i]))
            exit()
    elif N==2:
        if i[0] in values[0] and i[1] in values[1]:
            print("".join([str(j) for j in i]))
            exit()
    else:
        if i[0] in values[0]:
            print("".join([str(j) for j in i]))
            exit()
print(-1)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll n, k;
	cin >> n >> k;
	cout << min(n%k, k-n%k) << endl;
	return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
typedef long long ll;
const ll mod=1e9+7;
int T,n,x,y,z,es,t;
ll dp[42][1<<19],f[42];
ll dfs(int p,int c) {
    if(p>=n) return 0;
    if(dp[p][c]!=-1) return dp[p][c];
    ll &res=dp[p][c];res=0;
    for(int i=1;i<=10;i++) {
        int to=c<<i|1;to%=1<<t;
        if((to&es)==es) res+=f[n-p-1],res%=mod;
        else res+=dfs(p+1,to),res%=mod;
    }
    return res;
}
int main() {
    f[0]=1;for(int i=1;i<=40;i++) f[i]=f[i-1]*10%mod;
    //scanf("%d",&T);
    //while(T--) {
        scanf("%d%d%d%d",&n,&x,&y,&z);
        es=1<<(x+y+z)|1<<(y+z)|1<<z;t=x+y+z+1;
        for(int i=0;i<n;i++) for(int j=0;j<1<<t;j++) dp[i][j]=-1;
        printf("%lld\n",dfs(0,1));
    //}
    return 0;
}


Measured memory_bytes: 151808
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      mut a: [usize; n]
   }

   a.insert(0, 0);
   for i in 0..n {
      a[i + 1] += a[i];
      a[i + 1] %= m;
   }

   let mut ans = 0usize;
   let mut c = std::collections::BTreeMap::new();
   for &a in a.iter() {
      c.entry(a)
         .and_modify(|v| {
            ans += *v as usize;
            *v += 1
         })
         .or_insert(1);
   }
   println!("{}", ans);
}


Measured memory_bytes: 5080
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
 
double dp[3005][3005] = {0.0};
 
signed main()
{
    tezz
      
  //  memset(dp,0,sizeof(dp));
  for(int i=0;i<3005;i++){
  	for(int j=0;j<3005;j++){
    	dp[i][j]=0;
    }
  }
    int n;
    cin>>n;
    vector<double> v(n);
    for(double &x:v) cin>>x;
 
    dp[0][0] = 1.0 - v[0];
    dp[0][1] = v[0];
    for(int i=1;i<n;i++){
        dp[i][0] = dp[i-1][0]*(1 - v[i]);
    }
 
 
    for(int i=1;i<n;i++){
        for(int j=1;j<=i+1;j++){
            dp[i][j] = v[i]*dp[i-1][j-1] + (1-v[i])*dp[i-1][j];
        }
    }
 
    /*for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++) cout<<dp[i][j]<<' ';
            cout<<endl;
    }*/
 
    double ans=0;
    for(int i=0;i<n+1;i++) {if(i>n-i)ans += dp[n-1][i]; }//cout<<dp[n-1][i]<<" ";}
 
    cout<<setprecision(15)<<ans;
}


Measured memory_bytes: 141440
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner scan = new java.util.Scanner(System.in);
    int S = scan.nextInt();
    int h, m, s;
    int subH; 
    h = S / 3600;
    subH = S - (3600 * h);
    m = subH / 60;
    s = subH - (60 * m);
    System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 26140
#include <stdio.h>
int main(void)
{
  char c[7];
  int i;
  for(i=0;i<7;i++)
  scanf("%s", c);
  if(c[2]==c[3] && c[4]==c[5])
  printf("Yes");
  else
  printf("No");

  return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
const int INF = 1e9;
const int MOD = 1e9+7;

vi f(10), inv(10);

void trans(string &n)
{
    REP(i, n.length())
    {
        n[i] = f[n[i]-'0'] + '0';
    }
}

void invtrnas(string &n)
{
    REP(i, n.length())
    {
        n[i] = inv[n[i]-'0'] + '0';
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N, M; cin >> N >> M;
    vi num(N+1, -1);
    vi s(M), c(M); REP(i, M) cin >> s[i] >> c[i];
    REP(i, M) 
    {
        if(N > 1 && s[i] == 1 && c[i] == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        if(num[s[i]] != -1 && num[s[i]] != c[i])
        {
            cout << -1 << endl;
            return 0;
        }
        num[s[i]] = c[i];
    }
    if(num[1] == -1 && N > 1) num[1] = 1;
    else if(num[1] == -1 && N == 1) num[1] = 0;
    for(int i = 2; i <= N; i++) if(num[i] == -1) num[i] = 0;
    REPS(i, N) cout << num[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

void normalize(vector<plglg> &nums) {
    ll len = nums.size();
    if (len > 1) {
        if (nums[len - 1].first == nums[len - 2].first) {
            nums[len - 2].second += nums[len - 1].second;
            nums.pop_back();
        }
    }
}

void add(vector<plglg> &nums) {
    if (nums.back().second == 1) {
        nums.back().first += 1;
    } else {
        nums.back().second--;
        nums.push_back(plglg(nums.back().first + 1, 1));
    }
    normalize(nums);
}

int main() {
    ll N;
    cin >> N;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    ll hi = 200010;
    ll lo = 0;
    while (hi - lo > 1) {
        ll mid = (hi + lo) / 2;
        bool ok = true;
        vector<plglg> nums;
        nums.push_back(plglg(0, A[0]));
        REP(i, 1, N) {
            if (A[i] > A[i - 1]) {
                nums.push_back(plglg(0, A[i] - A[i - 1]));
            } else {
                ll sum = 0;
                while (nums.size() > 0 && sum + nums.back().second <= A[i - 1] - A[i]) {
                    sum += nums.back().second;
                    nums.pop_back();
                }
                nums.back().second -= A[i - 1] - A[i] - sum;
                if (nums.back().first == mid - 1) {
                    if (nums.size() == 1) {
                        ok = false;
                        break;
                    } else {
                        ll num = nums.back().second;
                        nums.pop_back();
                        add(nums);
                        nums.push_back(plglg(0, num));
                    }
                } else {
                    add(nums);
                }
                normalize(nums);
            }
        }
        if (ok) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << hi << endl;
}


Measured memory_bytes: 9788
#!/usr/bin/env python3
def main():
    import numpy as np

    N, K = map(int, input().split())
    P = np.array(input().split(), np.int32)

    P[:] += 1
    Pcum = np.zeros(N + 1, np.int32)
    Pcum[1:] = np.cumsum(P)
    length_K_sums = Pcum[K:] - Pcum[:-K]
    print(length_K_sums.max() / 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48284
package main
 
import (
	"fmt"
)
 
func main() {
  var n,m,min,max int
  fmt.Scanf("%d %d",&n, &m)
  if n < m {
    min = n
    max = m
  } else {
    min = m
    max = n
  }
  for i := 0; i < max; i++ {
    fmt.Print(min)
  }
}

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

int A(const string &s) {
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '#') return i;
  }
  return -1;
}

int B(const string &s) {
  for(int i = s.size()-1; i >= 0; --i) {
    if(s[i] == '#') {
      bool a = i == 0 || s[i-1] != 'A';
      bool b = i+1 == s.size() || s[i+1] != 'A';
      if(a && b) return i;
    }
  }
  return A(s);
}

int C(const string &s) {
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] != '#') {
      if(i+1 < s.size() && s[i+1] == '#') return i+1;
      if(i && s[i-1] == '#') return i-1;
    }
  }
  return s.size()/2;
}

int D(const string &s) {
  pair<int,int> res(0,-1);
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] != '#') continue;
    int l = s.size(), r = s.size();
    for(int j = i-1; j >= 0; --j) {
      if(s[j] != '#') {
        l = i - j;
        break;
      }
    }
    for(int j = i+1; j < s.size(); ++j) {
      if(s[j] != '#') {
        r = j-i;
        break;
      }
    }
    if(l == s.size() && i != 0) continue;
    if(r == s.size() && i+1 != s.size()) continue;
    res = min(res, make_pair(-min(l,r), i));
  }
  if(res.second == -1) return A(s);
  return res.second;
}

int main() {
  for(int n, m; cin >> n >> m && (n|m);) {
    string s(n, '#');
    while(m--) {
      char c;
      cin >> c;
      int pos;
      switch(c) {
      case 'A': pos = A(s); break;
      case 'B': pos = B(s); break;
      case 'C': pos = C(s); break;
      case 'D': pos = D(s); break;
      }
      s[pos] = c;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class RAMQ{
public: 
  typedef long long ll;
  const ll INF = 1LL<<60;
  
  struct T{
    bool type; //0 - empty   , 1 - update
    int value;
    T():type(0),value(0){}
    T(bool type,int value):type(type),value(value){}
  };

  struct D{
    int value;
    D():value(0){} //**//
    D(int value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };
  
  ll n;
  vector<D> dat;
  vector<T> td;
  int toMax;
  
  RAMQ(){n=-1;}
  RAMQ(int n_,int toMax = 0){
    this->toMax = toMax;
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  D merge(D a,D b){return min(a,b);}
  
  void delay(int k){
    if(td[k].type==0) return;
    int v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    int l = k*2+1,r = k*2+2;
    dat[l].value += v; td[l].type = 1; td[l].value += v;
    dat[r].value += v; td[r].type = 1; td[r].value += v;
  }

  D update(int k,int x){
    td[k].type = 1;
    td[k].value += x;
    dat[k].value += x;
    return dat[k];
  }
  
  //[a,b)の値をxに変更　add(a,b,x)
  D add(int a,int b,int x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r==-1 && toMax) x *= -1; 
    if(r==-1) r=n, assert(a < n && b <= n);
    if(r<=a||b<=l) return flg? dat[k]:D();
    if(a<=l&&r<=b) return flg? update(k,x):dat[k];
    
    delay(k);
    D vl = add(a,b,x,flg,k*2+1,l,(l+r)/2);
    D vr = add(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg) dat[k] = merge(vl,vr);
    return merge(vl,vr);
  }
  
  //[a,b)の最小値を得る　find(a,b);
  D find(int a,int b){
    D res = add(a,b,0,false);
    if(toMax) res.value *= -1; 
    return res;
  }
};


signed main(){
  int n;
  cin>>n;
  vector<P> A(n);
  cin>>A;
  sort(A.begin(),A.end());

  RAMQ  S(n,1);
  int ans = -INF;
  for(int i=0;i<n;i++){
    S.add(i,i+1,A[i].first); //mn
    S.add(0,i+1,A[i].second); //value
    if(i) S.add(0,i,A[i-1].first); //mx
    S.add(0,i+1,-A[i].first);
    int val = S.find(0,n).value;
    Max(ans,val);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 35312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll Min = A * (N - 1) + B, Max = A + B * (N - 1);
    cout << max(Max - Min + 1, 0LL);
    return 0;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())

    sum_prob = 0

    for dice in range(1, n+1):
        if dice >= k:
            sum_prob += (1 / n)
            continue
        coin = 1
        while dice * (2 ** coin) < k:
            coin += 1

        sum_prob += (1 / n) * (0.5 ** coin)

    print(sum_prob)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, [input() for i in range(n)]))

visited = [False] * (n + 1)
b = 1
cnt = 0
while b != 2:
    cnt += 1
    if visited[b]:
        print(-1)
        exit()
    else:
        visited[b] = True
        b = a[b - 1]
print(cnt)


Measured memory_bytes: 13356
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();   
        long C = sc.nextLong();   
        long D = sc.nextLong();
        long AC = A*C;
        long AD = A*D;
        long BC = B*C;
        long BD = B*D;
        System.out.println(Math.max(Math.max(AC, AD), Math.max(BC, BD)));
    }
    
}


Measured memory_bytes: 35656
# ABC109D - Make Them Even
def main():
    H, W, *A = map(int, open(0).read().split())
    A = [[i % 2 for i in a] for a in zip(*[iter(A)] * W)]
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j + 1] ^= 1
                ans += ["{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)]
    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i + 1][W - 1] ^= 1
            ans += ["{} {} {} {}".format(i + 1, W, i + 2, W)]
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

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

using namespace std;

struct expand_type {
    template <typename... T>
    expand_type (T&&...) {}
};
template <typename... ArgTypes>
void print (ArgTypes... args) {
    expand_type {0, (cerr << args << ", ", 0)...};
    cerr << "\b\b \n";
}
#define printv(x) cerr << "["; for(auto i : (x)) cerr << i << ", "; cerr << "\b\b]\n";

typedef unsigned long long ull;
typedef long double ld;


int main () {
    std::ios::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
    }
    else if (k <= a + b) {
        cout << a << endl;
    }
    else if (k <= a + b + c) {
        cout << (a - (k - a - b)) << endl;
    }
    else {
        cout << (a - c) << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>


void do_command(int *dice, char command) {
  int targets[4] = {0, -1, 5, -1};
  int temp;

  switch (command) {
    case 'E':
      targets[1] = 3;
      targets[3] = 2;
      break;
    case 'W':
      targets[1] = 2;
      targets[3] = 3;
      break;
    case 'S':
      targets[1] = 4;
      targets[3] = 1;
      break;
    case 'N':
      targets[1] = 1;
      targets[3] = 4;
      break;
  }

  temp = dice[targets[0]];
  for (int i = 1; i < 4; i ++) 
    dice[targets[i - 1]] = dice[targets[i]];
  dice[targets[3]] = temp;

}


int main() {
  int dice[6];
  char command;
  for (int i = 0; i < 6; i ++) 
    std::cin >> dice[i];

  while (std::cin >> command) {
    do_command(dice, command);
  }

  std::cout << dice[0] << std::endl;
  return 0;
}



Measured memory_bytes: 3084
fun main(args: Array<String>) {
    val s = readLine()!!
    var ans = 1
    var i = 1
    var before = s[0].toString()
    while (i < s.length) {
        ans++
        if (before == s[i].toString()) {
            if (s.length == i + 1) {
                ans--
                break
            }
            before = s.substring(i, i + 2)
            i += 2
        } else {
            before = s[i].toString()
            i++
        }
    }
    println(ans)
}

Measured memory_bytes: 41460
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
vector<int> shortest_path(int src, vector<vector<int> >& G) {
	vector<int> dist(G.size(), inf);
	dist[src] = 0;
	queue<int> que;
	que.push(src);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : G[u]) {
			if (dist[i] == inf) {
				dist[i] = dist[u] + 1;
				que.push(i);
			}
		}
	}
	return dist;
}
bool dfs(int pos, int pre, int tar, vector<vector<int> >& G, vector<int>& holder) {
	if (pos == tar) {
		holder.push_back(pos);
		return true;
	}
	for (int i : G[pos]) {
		if (i != pre && dfs(i, pos, tar, G, holder)) {
			holder.push_back(pos);
			return true;
		}
	}
	return false;
}
vector<int> getperm(int n, vector<int> cnt) {
	vector<int> ans;
	int sum = 0;
	for (int i = 0; i < cnt.size(); ++i) {
		for (int j = 1; j <= cnt[i]; ++j) {
			ans.push_back(sum + j);
		}
		ans.push_back(sum);
		sum += cnt[i] + 1;
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	vector<vector<int> > G(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> d1 = shortest_path(0, G);
	int v1 = max_element(d1.begin(), d1.end()) - d1.begin();
	vector<int> d2 = shortest_path(v1, G);
	int v2 = max_element(d2.begin(), d2.end()) - d2.begin();
	vector<int> path;
	dfs(v1, -1, v2, G, path);
	vector<int> cnt(path.size(), 0);
	vector<bool> used(N, false);
	for (int i : path) used[i] = true;
	int all = path.size();
	for (int i = 0; i < path.size(); ++i) {
		for (int j : G[path[i]]) {
			if (!used[j]) {
				++cnt[i];
				++all;
			}
		}
	}
	if (all != N) {
		cout << -1 << endl;
	}
	else {
		vector<int> p1 = getperm(N, cnt);
		reverse(cnt.begin(), cnt.end());
		vector<int> p2 = getperm(N, cnt);
		vector<int> ans = min(p1, p2);
		for (int i = 0; i < N; ++i) {
			if (i) cout << ' ';
			cout << ans[i] + 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 16876
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	defer out.Flush()
	a *= b
	if a%2 == 0 {
		out.WriteString("Even")
	} else {
		out.WriteString("Odd")
	}
	out.Flush()
	fmt.Println()

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main(){
	int valA = 0;
	int valB = 0;
	int valC = 0;
	int valMax = 0;
	int valResult = 0;
	
	scanf("%d %d %d", &valA, &valB, &valC);
	
	valMax = valA;
	if(valB > valMax){
		valMax = valB;
	}
	if(valC > valMax){
		valMax = valC;
	}
	
	if(valMax == valA){
		valResult = valMax*10 + valB + valC;
	} else if(valMax == valB){
		valResult = valMax*10 + valC + valA;
	} else {
		valResult = valMax*10 + valA + valB;
	}
	printf("%d", valResult);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
const long long con = 1000000000 + 7;

long long Factorial(long long p) {
	long long ret = 1;
	for (long long i = 1; i <= p; i++) {
		ret *= i;
		ret %= con;
	}
	return ret;
}

int main() {
	long long maxNM, minNM, N, M, ans;
	cin >> N >> M;
	maxNM = max(N, M);
	minNM = min(N, M);
	if (maxNM - minNM >= 2) {
		ans = 0;
	}
	else if (maxNM - minNM == 1) {
		ans = (Factorial(maxNM)*Factorial(minNM)) % con;
	}
	else {
		ans = (Factorial(maxNM)*Factorial(minNM)) * 2 % con;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main() {
    ll n; cin >> n;
    vl c(n-1),s(n-1),f(n-1);
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n){
        ll arrive = 0;
        REP(j,i,n-1){
            if(arrive < s[j]){
                arrive = s[j] + c[j];
            }else{
                arrive = s[j] + ((arrive - s[j] + f[j] - 1) / f[j]) * f[j] + c[j];
            }
        }
        cout << arrive << endl;
    }
}


Measured memory_bytes: 256
function Main(input) {
    input = input.trim();
    input = input.split("\n")
    var a = input[0].split(" ");
    var b = input[1].split(" ");

a = a.map(e=>{
    return parseInt(e);
})

b = b.map(e=>{
    return parseInt(e);
})

    var flag = false;

    for(var i=b[0];i<=b[1];i++){
        if(i%a[0]==0){
            flag = true;
            break;
        }
    }
if(flag){
    console.log("OK");
}else{
    console.log("NG");
}

}

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


Measured memory_bytes: 29640
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<int> data(3);
  for(int i = 0; i < 3; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  cout << data.at(0) + data.at(1) << endl;
  return 0;
}


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

int main(void){

  string s;
  cin>>s;
 int odd[2]={0,0},even[2]={0,0};
   int n=s.length();
   int o=n/2;
   int e=n-o;
   
  for(int i=0;i<n;i++){
      if(i%2==0){
          if(s[i]=='1'){
              even[1]++;
          }
          else{
              even[0]++;
          }
          
      }
      else{
          if(s[i]=='1'){
              odd[1]++;
          }
          else{
              odd[0]++;
          }
      }
    }
    
    int a=(e-even[0])+(o-odd[1]),b=(e-even[1])+(o-odd[0]);
    if(a<b) cout<<a;
    else cout<<b;
    cout<<endl;
  
  
  
    return 0;
}

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

class dictionary{
public:
  dictionary(string value){
    this->value = value;
    left = NULL;
    right = NULL;
  }
  ~dictionary(){
    delete left;
    delete right;
  }
  bool find(string s){
    if(s==value) return true;

    else if(s<value){
      if(left==NULL) return false;
      else return left->find(s);

    }else if(s>value){
      if(right==NULL) return false;
      else return right->find(s);
    }
  }
  void insert(string s){
    if(s==value) return;

    else if(s<value){
      if(left==NULL){
        left = new dictionary(s);
      }
      else left->insert(s);
    }

    else if(s>value){
      if(right==NULL){
        right = new dictionary(s);
      }
      else right->insert(s);
    }
  }
private:
  string value;
  dictionary *left;
  dictionary *right;
};

class root{
public:
  root(){
    node=NULL;
  }
  ~root(){
    delete node;
  }
  bool find(string s){
    if(node==NULL) return false;
    else return node->find(s);
  }
  void insert(string s){
    if(node==NULL) node = new dictionary(s);
    else node->insert(s);
  }
private:
  dictionary *node;
};

int main(){
  root myRoot;
  int n; cin >> n;
  string fun, var;

  vector<string> ans;
  for(int i=0; i<n; i++){
    cin >> fun >> var;
    if(fun=="insert"){
      myRoot.insert(var);
    }
    else if(fun=="find"){
      if(myRoot.find(var)) ans.push_back("yes");
      else ans.push_back("no");
    }
  }

  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 51360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_w = 1000;
const int MAX_N = 1000;

int w, N;
int dp[MAX_N+1][MAX_w];
int V[MAX_N];
int W[MAX_N];

void solve() {
  for (int i = N-1; i >= 0; i--) {
    for (int j = 0; j <= w; j += 1) {
      if (j < W[i]) {
        dp[i][j] = dp[i+1][j];
      } else {
        dp[i][j] = max(dp[i+1][j], dp[i+1][j-W[i]] + V[i]);
      }
    }
  }
}

int main (int argc, char const* argv[]) {
  char com;
  int tv, tw, z = 1, max_value;
  while (true) {
    cin >> w;
    if (w == 0) break;
    cin >> N;
    memset(dp, 0, sizeof dp);
    memset(V, 0, sizeof V);
    memset(W, 0, sizeof W);
    for (int i = 0; i < N; i += 1) {
      cin >> V[i] >> com >> W[i];
    }
    solve();
    cout << "Case " << z << ":" << endl << dp[0][w] << endl;
    max_value = dp[0][w];
    for (int i = w;; i--) {
      if (max_value != dp[0][i]) {
        cout << i+1 <<endl;
        break;
      }
    }
    z++;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
ll h[maxn] , a , b , n;
bool check(ll x)
{
    ll y = x;
    for(int i = 0; i < n; i++)
    {
        if(h[i] <= b * x)
            continue;
        y -= ceil((long double)(h[i] - b * x) / (a - b));
    }
    return y >= 0;
}
ll bs(ll l , ll r)
{
    if(r - l == 1)
    {
        if(check(l))
            return l;
        return r;
    }
    ll mid = (r + l) / 2;
    if(check(mid))
        return bs(l , mid);
    return bs(mid , r);
}
int main()
{
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << bs(1 , 1e10);
}


Measured memory_bytes: 1024
N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)

Measured memory_bytes: 9176
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
ave=A.inject(:+).to_f/N.to_f
dif=A.map{|x| (x.to_f-ave).abs}
puts dif.index(dif.min)

Measured memory_bytes: 1788