akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int dp[101][101][101];

struct elem
{
   int v[3];
};

elem que[100*100*100+1];

int main()
{
    for(int i = 0; i <= 100; i ++)
    {
        for(int j = 0; j <= 100; j ++)
        {
            for(int h = 0; h <= 100; h ++)
                dp[i][j][h] = 99999999;
        }
    }

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

    int st = 1;
    int dr = 0;
    que[++ dr] = {a, b, c};
    dp[a][b][c] = 0;

    int i, j;
    while(st <= dr)
    {
        elem cr = que[st ++];
        int a = cr.v[0];
        int b = cr.v[1];
        int c = cr.v[2];

        for(i = 0; i <= 2; i ++)
        {
            cr.v[i] += 2;
            if(cr.v[i] <= 100)
            if(dp[cr.v[0]][cr.v[1]][cr.v[2]] > dp[a][b][c] + 1)
            {
                dp[cr.v[0]][cr.v[1]][cr.v[2]] = dp[a][b][c] + 1;
                que[++ dr] = cr;
            }
            cr.v[i] -= 2;

            for(j = i + 1; j <= 2; j ++)
            {
                cr.v[i] ++;
                cr.v[j] ++;
                if(cr.v[i] <= 100 && cr.v[j] <= 100)
                if(dp[cr.v[0]][cr.v[1]][cr.v[2]] > dp[a][b][c] + 1)
                {
                    dp[cr.v[0]][cr.v[1]][cr.v[2]] = dp[a][b][c] + 1;
                    que[++ dr] = cr;
                }
                cr.v[i] --;
                cr.v[j] --;
            }
        }
    }

    int rez = 9999999;
    for(i = 0; i <= 100; i ++)
        rez = min(rez, dp[i][i][i]);

        cout << rez << "\n";

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    
int main(){
    int n;
    cin>>n;
    if(n%1000==0) cout<<'0';
    else cout<<1000-n%1000;
}

Measured memory_bytes: 3628
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    lint n, a, b;
    cin >> n >> a >> b;
    lint M = b * (n - 1) + a;
    lint m = a * (n - 1) + b;
    cout << max(M - m + 1, (lint)0) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	vec := make([]int, n)
	for i := 0; i < n; i++ {
		vec[i] = nextInt(sc)
	}
	sort.Ints(vec)
	sum := 0
	for _, v := range vec {
		sum += v
	}
	fmt.Println(vec[0], vec[len(vec)-1], sum)
}



Measured memory_bytes: 1312
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(-100, 201):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

// ABC117 B - Polygon
// 2020.07.01

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int maxL = 0;
  int sumL = 0;
  vector<int> L(N);
  REP(i, N){
    cin >> L[i];
    maxL = max(maxL, L[i]);
    sumL += L[i];
  }
  sumL -= maxL;
  if(maxL < sumL){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def parunyasu(a, b, p, q):
  reans = ans
  rd1, rq1, d1, nd1, nq1, q1, newans = naobou(a, q, reans)
  rd2, rq2, d2, nd2, nq2, q2, newans = naobou(b, p, newans)

  if reans <= newans:
    t[d1 - 1] = q1
    t[d2 - 1] = q2
    return newans
  else:
    ayaneru(rd2, rq2, d2, nd2, nq2)
    ayaneru(rd1, rq1, d1, nd1, nq1)
    return reans

def ayaneru(rd, rq, d, nd, nq):
  ZL[rd].insert(rq, d)
  del ZL[nd][nq + 1]

def naobou(d, q, ans):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  return rd, rq, d, nd, nq, q, newans

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

RD = [0] * 26
t = [0] * D
for i in range(D):
  RD[0] += 1
  ma = s[i][0] + RD[0] * c[0]
  man = 0
  for j in range(1, 26):
    RD[j] += 1
    k = s[i][j] + RD[j] * c[j]
    if k > ma:
      ma = k
      man = j
  t[i] = man + 1
  RD[man] = 0

ans = rieshon()
while time.time() - startTime < 1.8:
  l = random.randrange(min(D - 1, 13)) + 1
  d = random.randrange(D - l) + 1
  p = t[d - 1]
  q = t[d + l - 1]
  if p == q: continue
  ans = parunyasu(d, d + l, p, q)

for i in range(D):
  print(t[i])


Measured memory_bytes: 86796
#include <stdio.h>
int main()
{
  int row1[3][2];
  int row2[3][2];
  int row3[3][2];
  int N;
  int called[10];
  int i, j;
  int flag = 0;
  for(i = 0; i < 3; ++i){
    row1[i][1] = 0;
    row2[i][1] = 0;
    row3[i][1] = 0;
  }
  scanf("%d %d %d", &row1[0][0], &row1[1][0], &row1[2][0]);
  scanf("%d %d %d", &row2[0][0], &row2[1][0], &row2[2][0]);
  scanf("%d %d %d", &row3[0][0], &row3[1][0], &row3[2][0]);
  scanf("%d", &N);
  for(i = 0; i < N; ++i){
    scanf("%d", &called[i]);
    
    for(j = 0; j < 3; ++j){
      if(called[i] == row1[j][0])
        row1[j][1] = 1;
      else if(called[i] == row2[j][0])
        row2[j][1] = 1;
      else if(called[i] == row3[j][0])
        row3[j][1] = 1;
    }
  }
  /*横列*/
  flag |= ((row1[0][1] + row1[1][1] + row1[2][1]) == 3) ? 1 : 0;
  flag |= ((row2[0][1] + row2[1][1] + row2[2][1]) == 3) ? 1 : 0;
  flag |= ((row3[0][1] + row3[1][1] + row3[2][1]) == 3) ? 1 : 0;
  /*縦列*/
  flag |= ((row1[0][1] + row2[0][1] + row3[0][1]) == 3) ? 1 : 0;
  flag |= ((row1[1][1] + row2[1][1] + row3[1][1]) == 3) ? 1 : 0;
  flag |= ((row1[2][1] + row2[2][1] + row3[2][1]) == 3) ? 1 : 0;
  /*斜列*/
  flag |= ((row1[0][1] + row2[1][1] + row3[2][1]) == 3) ? 1 : 0;
  flag |= ((row3[0][1] + row2[1][1] + row1[2][1]) == 3) ? 1 : 0;
  
  if(flag == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
  


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(void){
  char S[10];

  scanf("%s", S);
  if (strcmp(S,"Sunny")==0) {
    puts("Cloudy");
  }
  if (strcmp(S,"Cloudy")==0) {
    puts("Rainy");
  }
  if (strcmp(S,"Rainy")==0) {
    puts("Sunny");
  }

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int a[3][3];
int mark[3][3];
bool check(){

	for(int i=0;i<3;i++){
		bool ok = true;
		for(int j=0;j<3;j++){
			if(!mark[i][j]) ok = false;
		}
		if(ok) return true;
	}
	for(int j=0;j<3;j++){
		bool ok = true;
		for(int i=0;i<3;i++){
			if(!mark[i][j]) ok = false;
		}
		if(ok) return true;
	}
	bool ok = true;
	for(int i=0;i<3;i++){

		if(!mark[i][i]) ok = false;
	}
	if(ok) return ok;
	ok = true;
	for(int i=0;i<3;i++){
		if(!mark[i][2-i]) ok =false;
	}
	return ok;
}

int main(){
	fastio();
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++) cin>>a[i][j];
	}
	
	int q;
	cin>>q;
	bool ok = false;
	while(q--){
		int b;
		cin>>b;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(!mark[i][j] and b==a[i][j]) mark[i][j] = 1;
			}
		}
		if(check()) ok = true;
	}

	(ok==true)?cout<<"Yes":cout<<"No";
}

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

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

Measured memory_bytes: 3612
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

ans = 0
for i in range(K, N+2):
    small = (i - 1) * i // 2
    large = (N - i + 1 + N) * i // 2
    temp = (large - small) % MOD
    ans = (ans + temp + 1) % MOD
    # print(temp + 1)
print(ans)



Measured memory_bytes: 63676
#include<bits/stdc++.h>
using namespace std;
long long a,b,c[200005],n,d,ans,x[200005],y[200005],l,k;
struct node
{
    long long x,y;
} w[200005];
inline bool cmp(node x,node y)
{
    return x.x<y.x;
}
int main()
{
    scanf("%lld%lld%lld",&n,&d,&a);
    d*=2;
    for(int i=1; i<=n; ++i)
    {
        scanf("%lld%lld",&w[i].x,&w[i].y);
        w[i].y=(w[i].y+a-1)/a;
    }
    sort(w+1,w+n+1,cmp);
    l=1;
    for(int i=1; i<=n; ++i)
    {
        while(l<i&&w[i].x-w[l].x>d)
            k-=c[l++];
 
        c[i]=w[i].y-k;
        if(c[i]<0)
            c[i]=0;
        ans+=c[i];
        k+=c[i];
    }
    printf("%lld",ans);
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  ll d;
  map<ll, int> D;
  REP(i, N) {
    cin >> d;
    if (D.find(d) == D.end()) {
      D.insert(make_pair(d, 1));
    } else {
      ++D.at(d);
    }
  }

  int M;
  cin >> M;
  ll t;
  REP(i, M) {
    cin >> t;
    if (D.find(t) == D.end()) {
      cout << "NO" << endl;
      return 0;
    }

    if (D.at(t) == 0) {
      cout << "NO" << endl;
      return 0;
    }

    --D.at(t);
  }

  cout << "YES" << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  int count =0;
  for(int i=0; i<N; i=i+2){
    if(A[i]%2 ==1) count ++;
  }
  
  cout << count << endl;

}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

template <typename T>
vector<T> _divisor(T a) {
    vector<T> res;
    for (T i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            res.push_back(i);
            if (i != 1 && i * i != a)
                res.push_back(a / i);
        }
    }
    return res;
}

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

    ll n;
    cin >> n;

    vll a = _divisor(n);
    a.push_back(n);

    ll cnt = 0;
    rep(i, a.size()) {
        if (a[i] > sqrt(n)+1) {
            cnt += a[i] - 1;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;
 
signed main(){
	string t,s = "0";
	cin >> t;
	s += t;
	int d1 = 0,d2 = 1;
	RREP(i,s.size()){
		int nd1 = INF,nd2 = INF;
		int s1 = s[i] - '0',s2 = s[i] - '0' + 1;
		CHMIN(nd1,d1+s1);
		CHMIN(nd1,d2+s2);
		CHMIN(nd2,d1+10-s1);
		CHMIN(nd2,d2+10-s2);
		d1 = nd1,d2 = nd2;
	}
	out(min(d1,d2));
}

Measured memory_bytes: 2308
n, d = gets.chomp.split(' ').map{|i| i.to_i }
x = []
n.times{|i|
  x[i] = gets.chomp.split(' ').map{|i| i.to_i }
}

count = 0
n.times{|i|
  a = x[i]
  (n - i - 1).times{|ii|
    j = ii + i + 1
    b = x[j]

    sum = 0
    d.times{|k|
      sum += (b[k] - a[k]) ** 2
    }
    dis = Math.sqrt(sum)
    if dis == dis.floor
      count += 1
    end
  }
}

puts count


Measured memory_bytes: 3836
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	
	private void doit(){
		while(sc.hasNext()){
			solve();
		}
	}

	private void solve() {
		int n = sc.nextInt();
		int res = n % 39;
		if(res == 0) res = 39;
		System.out.printf("3C%02d\n",res);
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 17376
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vector<string> v(n);
        vector<string> end_a;
        vector<string> begin_b;
        vector<string> both;
        vector<string> other;
        rep(i, n) {
            cin >> v[i];
            if (v[i].back() == 'A' && v[i][0] == 'B') both.eb(v[i]);
            else if (v[i].back() == 'A') end_a.eb(v[i]);
            else if (v[i][0] == 'B') begin_b.eb(v[i]);
            else other.eb(v[i]);
        }

        ll ans = 0;
        rep(i, n) {
            for (int j = 0; j < v[i].size() - 1; j++) {
                if (v[i][j] == 'A' && v[i][j + 1] == 'B') {
                    ans++;
                    j++;
                }
            }
        }
        ll enda = end_a.size();
        ll begb = begin_b.size();
        ll b = both.size();

        if (b > 0) ans += b - 1;
//        if (p) ans--;

        if (b > 0) {
            if (enda >= 1) enda--, ans++;
            if (begb >= 1) begb--, ans++;
        }

        ans += min(enda, begb);
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int N;
        intReadLine(out N);
        int[] P = ReadLine().Split().Select(int.Parse).ToArray();
        int ans = 1;
        int nowMin = P[0];
        for (int i = 1; i < N; i++)
        {
            if(P[i] < nowMin)
            {
                ans++;
                nowMin = P[i];
            }
        }
        
        WriteLine(ans);
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 34012
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll r = (n / (a + b)) * a;
  ll s = n % (a + b);
  if(s > a) {
    r += a;
  } else {
    r += s;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 1e5+3; //AREGLAAAAAAAAR!!!!

int d,cnt[30],val[30];
map<pair<int,ll>,int > dp;

int solve(int p,ll g){
	if(g<=0) return 0;
	if(p>=d) return 1e9; 
	if(dp.count({p,g})) return dp[{p,g}];
	int &ret = dp[{p,g}];
	ret = 1e9;
	ret = solve(p+1,g);
	FOR(i,0,cnt[p]-1)
		ret = min(solve(p+1,g-(i+1)*(p+1)*100)+i+1,ret);
	ret = min(solve(p+1,g-(cnt[p])*(p+1)*100-val[p])+cnt[p],ret);
	return ret;
}


int main(){
	ll g;
	ri(d);
	lri(g);
	FOR(i,0,d){
		rii(cnt[i],val[i]);
	}
	printf("%d\n",solve(0,g));
}


Measured memory_bytes: 7936
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p,q,r;
    cin >> p >> q >> r;
    cout << min({p+q,q+r,r+p}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int i, j;

	for( i = 1 ; i <= 9 ; i++ )
	{
		for( j = 1 ; j <= 9 ; j++ )
		{
			printf("%dx%d=%d\n",i, j, i*j );
		}
	}

    return 0;
}

Measured memory_bytes: 524
#!/usr/bin/env python
# coding: utf-8
#


def main(n, k, s):
    l = list(s)
    # print(l)
    l[k - 1] = l[k - 1].lower()
    print(''.join(l))
        
if __name__ == '__main__':
    try:
        n, k = list(map(int, input().strip().split(' ')))
        s = input().strip()
        main(n, k, s)
    except EOFError:
        pass


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a;
	cin >> a;
	REP(i,2){
		if(a[i] == '9'){
			cout << "Yes" << endl;
			goto owari;
		}
	}
	cout << "No" << endl;
	owari:
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll a , b, v , w, t;
  cin>>a>>v>>b>>w>>t;
  ll d = abs( a - b );
  ll c = (v-w)*t;
  cout<<( c>=d ? "YES" : "NO" );



  return 0;

}


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

int main(void){
    int a,b,w;
    cin>>w>>a>>b;
    if(a>b)swap(a,b);
    int ans =abs(a+w-b);
    if(a+w>=b)ans=0;

    cout<<ans <<endl;







  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<61);

int main() {
  int n; cin >> n;
  vl a(n), dp(n+1,0);
  ll ans = INFL;
  rep(i,n) {
    cin >> a[i];
    dp[i+1] = a[i] + dp[i];
  }
  rep(i,n-1) {
    ll l = dp[i+1], r = dp[n] - dp[i+1];
    cerr << l << ", " << r << endl;
    ll cost = abs(l - r);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


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


int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

#define _LL long long

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

_LL lcm(int a, int b)
{
    return ((_LL)a) * b / gcd(a, b);
}

_LL lcm(int *a, int n)
{
    _LL ans;
    ans = a[0];
    for( int i = 1; i < n; i++ )
    {
        ans = lcm(ans, a[i]);
    }
    return ans;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int *a = inputint(n);
    for( int i = 0; i < n; i++ ) a[i] /= 2;

    _LL slcm = lcm(a, n);

//    cout << slcm << endl;

    for( int i = 0; i < n; i++ )
    {
        if( (slcm / a[i]) % 2 == 0 ) 
        {
            cout << 0;
            return 0;
        }
    }

    _LL t = m / slcm;
    cout << (t + 1) / 2;
}

Measured memory_bytes: 3952
#include<stdio.h>
int main()
{
    int n,m,i,x,count=0,y;
    scanf("%d %d",&n,&m);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        count=count+a[i];
    }
    y=count;
    count=0;
    x=(y+4*m-1)/(4*m);

    for(i=0;i<n;i++)
    {

        if(x<=a[i])
            {

                count++;
            }

    }

    if(count>=m)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 128
#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;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main()
{
  char S[200];
  int i,cnt=0,j,k;
  scanf("%s",S);
  i=strlen(S);
  i-=1;
  while(1)
    {
      if(S[0]=='\0')break;
      S[i]='\0';
      j=strlen(S);
      if(j%2==0)
	{
	  j=j/2;
	  for(k=0;k<j;k++)
	    {
	      if(S[k]!=S[j+k])cnt++;
	    }
	if(cnt==0)
	  {
	    printf("%d",strlen(S));
	    break;
	  }
	}
      cnt=0;
      i-=1;
    }
  return 0;
}


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

int main() {
  int N,a,b;
  cin >> N;

  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin >> P[i];
  }

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

  int num=0;
  vector<int> perm(N, 0);
  for (int i = 0; i < perm.size(); i++) perm[i] = i+1;
  do {
    num++;
    for(int i=0;i<N;i++){
      if(perm[i] == P[i]){
        if(i == N-1){
          a = num;
        }
      }else{
        break;
      }
    }

    for(int i=0;i<N;i++){
      if(perm[i] == Q[i]){
        if(i == N-1){
          b = num;
        }
      }else{
        break;
      }
    }

  } while(next_permutation(perm.begin(), perm.end()));

  int result = a-b;
  if(result < 0){
    result*=-1;
  }

  cout << result << endl;

}


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

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

    vector<int> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    int sum = X;
    int res = 0;

    for (int i = 0; i < N; i++) {
        sum -= vec.at(i);
        res++;
    }

    res += (sum / vec.at(0));
    cout << res << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element



signed main()
{
	int K, X;
	cin >> K >> X;
	YesNo(K * 500 >= X);
}




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

int main(){
  long n;
  long tmp,min=10000000000;
  long x,y,a;
  cin >> n;
  
  for(long i=1; i<=100000; i++){
    if(n%i == 0){
      tmp = 0;
      x = i;
      y = n/i;
      
      if(x < y){
        a = y;
      }else{
        a = x;
      }
      
      while(a){
        tmp++;
        a /= 10;
      }
      
      if(tmp < min){
        min = tmp;
      }
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    long long h,w;
    h = w = 0;
    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            h = A[i];
            A[i] = -1;
            A[i-1] = -2;
            break;
        } 
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            w = A[i];
            break;
        }
    }
    cout << h * w << endl;
}


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

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    int minA = 1e9, minB = 1e9;
    for (int i = 0; i < A; i++) {
        cin >> a[i];
        minA = min(minA, a[i]);
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
        minB = min(minB, b[i]);
    }

    int ans = minA + minB;
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  for(int i=0; i<19; i++) {
    if(s[i] == ',') s[i] = ' ';
  }
  cout << s << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define num_check(x) '0'<=(x)&&(x)<='9'


struct Siki{
	int num;
	char type;
	int left, right;
};

int index[10];//各演算子のインデックス
int pri[10];//各演算子の計算順序
int min_pri[6];//各演算子のdepthごとの計算順序の最低値、これを破るとNG
int op_size;
Siki siki[30];
Siki temp[30];
int siki_size;
string input;


bool check_pri(){
	rep(i, 0, op_size){
		if (min_pri[siki[index[pri[i]]].num] > i)
			return(false);
	}
	return(true);
}

map<int, int> data;
void init(){
	data.clear();
	rep(i, 0, 30)siki[i].num = 0;
	int d=0;siki_size =op_size= 0;
	rep(i, 0, 6)min_pri[i] = 0;
	//(3)+(1+(2*3-3)+5)+2*3
	rep(i, 0u, input.length()){
		if (num_check(input[i])){
			siki[siki_size].num *= 10, siki[siki_size].type = 'c', siki[siki_size].num += input[i] - '0';
			if (i + 1 == input.length() || !(num_check(input[i+1])))
				siki_size++;
		}
		else if (input[i] == '(')d++;
		else if (input[i] == ')')d--;
		else
		{
			siki[siki_size].type = input[i];
			siki[siki_size].num = d;
			pri[op_size] = op_size;
			rep(j, d + 1, 6)min_pri[j]++;
			index[op_size++] = siki_size++;
		}
	}
	rep(i, 0, op_size){
		siki[index[i] - 1].right = siki[index[i] + 1].left = index[i];
		siki[index[i]].left = index[i] - 1;
		siki[index[i]].right = index[i] + 1;
	}
	siki[0].left = -1;siki[siki_size - 1].right = -1;
	
}



int calc(int l, char op, int r){
	switch (op){
	case '+':return(l + r);
	case '-':return(l - r);
	case '*':return(l * r);
	case '/':return(l / r);
	}
	return(0);
}

void parse(){
	int result; Siki *p,*r,*l;
	rep(i, 0, siki_size)temp[i] = siki[i];
	rev(i, 0, op_size){
		p = &temp[index[pri[i]]];
		l = &temp[p->left];
		r = &temp[p->right];

//		cout << l->num << p->type << r->num << "=";
		if (r->num == 0 && p->type == '/')return;
		result=p->num = calc(l->num, p->type, r->num);
//		cout << p->num << endl;
		if(r->right>=0)temp[r->right].left = index[pri[i]];
		if (r->left >=0 )temp[l->left].right = index[pri[i]];
		p->left =l->left;
		p->right = r->right;
	}
//	cout << result << endl;
	data[result]++;
}


void p(int d, int dm){
	if (d == dm){
		if (check_pri()){
			parse();
		}
	}
	rep(i, d, dm){
		swap(pri[d], pri[i]);
		p(d + 1, dm);
		swap(pri[d], pri[i]);
	}
}



int main(void){
	while (true){
		cin >> input;
		if (input[0] == '#')break;
		init();
		/*	
		rep(i, 0, siki_size)if (siki[i].type == 'c')printf("%d", siki[i].num); else printf("%c", siki[i].type); cout << endl;
		rep(i, 0, op_size)printf("%c", siki[index[i]].type); cout << endl;
		rep(i, 0, op_size)printf("%d", min_pri[siki[index[i]].num]); cout << endl;
		*/
		p(0, op_size);
		cout << data.size() << endl;
	}
	return(0);
}

Measured memory_bytes: 1220
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, i, ans int64
	fmt.Scan(&N)

	for i = 1; i <= int64(math.Sqrt(float64(N))); i++ {
		if N%i == 0 {
			n := i + (N / i) - 2
			if ans == 0 {
				ans = n
			} else if n < ans {
				ans = n
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let p: usize = scan(tokens);
    let s: String = scan(tokens);
    let s: Vec<usize> = s.bytes().rev().map(|b| (b - b'0') as usize).collect();
    if p == 2 || p == 5 {
        let mut ans: usize = 0;
        for i in 0..n {
            if s[i] % p == 0 {
                ans += n - i;
            }
        }
        println!("{}", ans);
    } else {
        let mut ans: usize = 0;
        let mut count: Vec<usize> = vec![0; p];
        let mut r: usize = 0;
        let mut u: usize = 1;
        for i in 0..n {
            r = (r + u * s[i]) % p;
            if r == 0 {
                ans += 1;
            }
            ans += count[r];
            count[r] += 1;
            u = u * 10 % p;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
#define test int t; cin>>t; while(t--)
int h[100003]={0},dp[100003]={0},k,n;
int solve(int n);
signed main()
{
    
     cin>>n>>k;
    repp(i,1,n)cin>>h[i];
    repp(i,1,k+1)
    {
        dp[i]=abs(h[i]-h[1]);
    }
    repp(i,k+2,n)
    {
        dp[i]=solve(i);
    }
    cout<<dp[n];
}
int solve(int n)
{
    dp[n]=10000000000;
    for(int j=n-1;j>=max(n-k,1);j--)
    {
        dp[n]=min(dp[n],dp[j]+abs(h[n]-h[j]));
    }
    return dp[n];
}


Measured memory_bytes: 1024
import numpy as np
n, m = map(int, input().split())
if abs(n - m) > 1:
  print(0)
  quit()
mod = 10 ** 9 + 7


def cumprod(L, mod=mod):
    A = np.arange(L, dtype=np.int64)
    A[0] = 1
    Lsq = int(L**.5 + 1)
    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        A[:, n] *= A[:, n - 1]
        A[:, n] %= mod
    for n in range(1, Lsq):
        A[n] *= A[n - 1, -1]
        A[n] %= mod
    return A.ravel()[:L]


fact = cumprod(2 * 10**6 + 10, mod)
res = fact[n] * fact[m]
if n == m:
  res *= 2
print(res % mod)

Measured memory_bytes: 61384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef pair<ll, vi> Data;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    ll A[X], B[Y], C[Z];
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];

    sort(A, A + X, greater<ll>());
    sort(B, B + Y, greater<ll>());
    sort(C, C + Z, greater<ll>());

    priority_queue<Data, vector<Data>, less<Data>> q;
    q.push(Data(A[0] + B[0] + C[0], vi({0, 0, 0})));
    set<Data> s;

    int cnt = 0;
    while (cnt < K) {
        Data d = q.top(); q.pop();
        int ca = d.se[0], cb = d.se[1], cc = d.se[2];
        if (s.count(d)) continue;
        s.insert(d);
        ++cnt;

        cout << d.fi << endl;

        if (ca < X - 1) q.push(Data(A[ca + 1] + B[cb] + C[cc], vi({ca + 1, cb, cc})));

        if (cb < Y - 1) q.push(Data(A[ca] + B[cb + 1] + C[cc], vi({ca, cb + 1, cc})));

        if (cc < Z - 1) q.push(Data(A[ca] + B[cb] + C[cc + 1], vi({ca, cb, cc + 1})));
    }

}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int a,b,c,i,j,tmp;
  int x[3];
  scanf("%d %d %d",&a,&b,&c);
  
  x[0] = ((10*a)+b)+c;
  x[1] = a+((10*b)+c);
  x[2] = a+(b+(10*c));
  
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(x[i]<x[j]){
        tmp = x[i];
        x[i] = x[j];
        x[j] = tmp;
      }
    }
  }
  
  printf("%d\n",x[0]);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
  
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
          
        int n=sc.nextInt();
          
        for(int i=0;i<n;i++){
            int x=sc.nextInt();
            int y=sc.nextInt();
            int b=sc.nextInt();
            int p=sc.nextInt();
              
            int kin=x*b+y*p;
              
            if(b>=5 && p>=2){
                kin = (x*b + y*p)*4/5;
            }else{
                if(b<5){
                b=5;
                }
                if(p<2){
                p=2;
                }
                int wari = (x*b + y*p)*4/5;
                  
                if(kin>wari){
                    kin = wari;
                }
            }
            System.out.println(kin);
        }
    }
      
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23312
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt() * 2;
        int[] l = IntStream.rangeClosed(1, k).toArray();
        int m = sc.nextInt();
        while (m-- > 0) {
            int n = sc.nextInt();
            int[] t = new int[k];
            if (n == 0) {
                for (int i = 0; i < k; i++) {
                    t[i] = l[(i % 2 == 0 ? i : k + i) / 2];
                }
            } else {
                for (int i = 0; i < k; i++) {
                    t[i] = l[(i + n) % k];
                }
            }
            l = t;
        }
        for (int i : l) {
            System.out.println(i);
        }
    }
}



Measured memory_bytes: 34552
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <assert.h>
#include <set>
#include <cstring>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

LL n;

int main(){
  
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  cin >> n;
  n--;
  LL base = 26;
  int len = 1;
  while ( base <= n ){
    n -= base;
    len++;
    base *= 26;
  }
  string s = "";
  for ( int i = 1; i <= len; i++ ){
    s += (char)('a'+(n%26));
    n /= 26;
  } 
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}








    

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]


def convert(n):
    list_q = []
    while True:
        a = n % 4
        n //= 4
        list_q.insert(0, a)
        if n == 0:
            break
    list_q = [str(i) for i in list_q]
    return list_q


MP = -1
for i in range(21, 4**N):
    mp_a = 0
    mp_b = 0
    mp_c = 0
    use = [int(j) for j in ''.join(convert(i)).zfill(N)]
    a_n = use.count(1)
    b_n = use.count(2)
    c_n = use.count(3)
    if a_n == 0 or b_n == 0 or c_n == 0:
        pass
    else:
        mp_a += 10 * (a_n - 1)
        mp_b += 10 * (b_n - 1)
        mp_c += 10 * (c_n - 1)
        b_a = 0
        b_b = 0
        b_c = 0
        idx = 0
        for i in use:
            if i == 1:
                b_a += l[idx]
            elif i == 2:
                b_b += l[idx]
            elif i == 3:
                b_c += l[idx]
            idx += 1
        mp_a += abs(A-b_a)
        mp_b += abs(B-b_b)
        mp_c += abs(C-b_c)
        mp = mp_a + mp_b + mp_c
        if MP == -1 or mp < MP:
            MP = mp
print(MP)


Measured memory_bytes: 3316
X,Y = list(map(int,input().split()))
def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod
if (X+Y)%3!=0:
    print(0)
else:
    n = (2*Y - X)//3
    m = (2*X - Y)//3
    if n<0 or m<0:
        print(0)
    else:
        print(nCk(n+m, m)%(7+10**9))

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

int main(void){

  int n;
  int triangle[3];

  cin >> n;

  while(n--){

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

  sort( triangle , triangle + 3 );

  if( triangle[2] * triangle[2] == triangle[1] * triangle[1] + triangle[0] * triangle[0] ) cout << "YES" << endl;
  else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
/*
string change_hands(string U, char c, int K){
    for(int i=K; i<U.size();i++){
        if(U[i-K] == U[i]){
            if(U[i] == 'r'){
                sum -= R;
            }else if(U[i] == 's'){
                sum -= S;
            }else{
                sum -= P;
            }
        }
    }
}*/

int main(){
    int N,K,R,S,P,sum=0;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    string U;
    U = T;
    rep(i,T.size()){
        if(T[i] == 'r'){
            U[i] = 'p';
            sum += P;
        }else if(T[i] == 's'){
            U[i] = 'r';
            sum += R;
        }else{
            U[i] = 's';
            sum += S;
        }
    }
    for(int i=K; i<U.size();i++){
        if(U[i-K] == U[i]){
            if(U[i] == 'r'){
                sum -= R;
                U[i] = 'a';
            }else if(U[i] == 's'){
                sum -= S;
                U[i] = 'a';
            }else{
                sum -= P;
                U[i] = 'a';
            }
        }
    }

    cout << sum << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string s; cin >> s;
  s.insert(4, " ");
  cout << s << endl;
}

Measured memory_bytes: 256