akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<cstdio>
#include<string>
#include<vector>

#define	mp		make_pair
#define	pb		push_back

using namespace std;

typedef	pair<int,int>	pii;

const int inf=1<<29;

int main(){
	for(int n;scanf("%d",&n),n;){
		int unum=0;
		pair<pii,int> edge[100];
		map<string,int> name;
		for(int i=0;i<n;i++){
			int pw;
			char u1[17],u2[17];
			scanf("%*d %s %*c %*d%*c%d %s",u1,&pw,u2);

			int id1,id2;
			if(name.count(u1)==0)	name[u1]=unum++;
			id1=name[u1];
			if(name.count(u2)==0)	name[u2]=unum++;
			id2=name[u2];

			edge[i]=mp(mp(id1,id2),pw);
		}

		static int wf[200][200];
		for(int i=0;i<unum;i++)for(int j=0;j<unum;j++)	wf[i][j]=(i==j?0:inf);
		for(int k=0;k<n;k++){
			int from=edge[k].first.first,to=edge[k].first.second,dis=edge[k].second;
			wf[from][to]=dis;
			wf[to][from]=-dis;
		}
		for(int k=0;k<unum;k++)for(int i=0;i<unum;i++)for(int j=0;j<unum;j++){
			wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
		}

		bool ok=true;
		for(int i=0;i<unum;i++)	if(wf[i][i]<0)	ok=false;

		puts(ok?"Yes":"No");

	}

	return 0;
}

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

int a[1000005];
int main()
{
    
	ios_base::sync_with_stdio(false); cin.tie(NULL);



	int x;
	cin>>x;
	if(x==0)
		cout<<"1\n";
	else if(x==1)
		cout<<"0\n";
    return 0;
		
}

Measured memory_bytes: 3636
S=input()
ans="Yes"
l=len(S)
if(l % 2 != 0):
    ans="No"
else:
    n = l // 2
    for i in range(n):
        if(S[2*i]!="h"):
            ans="No"
        if(S[(2*i)+1]!="i"):
            ans="No"
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a[5],b[3],ans,dai,n;
	for (int i = 1; i <= 4; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= 2; i++) {
		cin >> b[i];
	}
	ans = 0;
	for (int i = 1; i <= 3; i++) {
		dai = 0;
		for (int z = 1; z <= 4; z++) {
			if (a[z] >= dai) {
				dai = a[z];
				n = z;
			}
		}
		a[n] = 0;
		ans = ans + dai;
	}
	ans = ans + max(b[1], b[2]);
	cout << ans << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int ans = 0;

int main() {
	cin >> H >> W;
	vector<vector<char>> g(H, vector<char>(W));
	vector<vector<int>> gh(H, vector<int>(W,0));
	vector<vector<int>> gw(H, vector<int>(W,0));
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			cin >> g[h][w];
		}
	}
	for (int h = 0; h < H; h++) {
		int tmp = 0;
		for (int w = 0; w < W; w++) {
			if (g[h][w] == '.') {
				tmp++;
			}
			else if(g[h][w] == '#') {
				for (int i = w-1; i >= w - tmp; i--) {
					gw[h][i] = tmp;
				}
				tmp = 0;
			}

			if (w == W - 1) {
				for (int i = w; i > w - tmp; i--) {
					gw[h][i] = tmp;
				}
				tmp = 0;
			}
		}
	}
	for (int w = 0; w < W; w++) {
		int tmp = 0;
		for (int h = 0; h < H; h++) {
			if (g[h][w] == '.') {
				tmp++;
			}
			else if(g[h][w] == '#') {
				for (int i = h-1; i >= h - tmp; i--) {
					gh[i][w] = tmp;
				}
				tmp = 0;
			}

			if (h == H - 1) {
				for (int i = h; i > h - tmp; i--) {
					gh[i][w] = tmp;
				}
				tmp = 0;
			}
		}
	}
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			ans = max(ans, gh[h][w] + gw[h][w] - 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define int long long



int32_t main(){
    int n,k;cin>>n>>k;
    vector<int> v(n);
    for(auto & i : v)cin>>i;
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=v[i];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
  int x,y,i,flag=0,mkou=1;

  scanf("%d%d",&x,&y);
  if(x<y) flag=1;

  if(flag==1)
    {
      flag=x;
      x=y;
      y=flag;
    }
  if(x != y)
    {
  x = x % y;
  for(i=x;i>=1;i--)
    {
      if(x%i==0)
	{
	  if(y%i==0)
	    {
	      mkou=i;
	      break;
	    }
	}
    }
    }
  else mkou = x;
  printf("%d\n",mkou);

  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1];
}   

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b, int c){
    int r;
    while(b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    while(c != 0){
        r = a % c;
        a = c;
        c = r;
    }
    return a;
}
int main(){
    int k;
    long long s = 0;
    cin >> k;
    for(int i = 1; i <= k; i ++)
        for(int j = 1; j <= k; j ++)
            for(int l = 1; l <= k; l ++)
                s += gcd(i, j, l);
    cout << s;
}

Measured memory_bytes: 3620
/*input
5 9
0 0
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let mut v: Vec<i32>;
    let mut tot;
    loop {
        tot = 0;
        v = input_vec!();
        if v[0] == 0 && v[1] == 0 {
            break;
        }
        for i in 1..v[0] - 1 {
            for j in i + 1..v[0] {
                for k in j + 1..v[0] + 1 {
                    if i + j + k == v[1] {
                        tot += 1;
                    }
                }
            }
        }
        println!("{}", tot);
    }
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll Q, H, S, D;
  cin >> Q >> H >> S >> D;

  ll N;
  cin >> N;

  ll L1 = min(min(Q*4, H*2), S);

  ll ans = 0;
  ans = min(L1*N, L1*(N%2) + D * (N/2));
  cout << ans << endl;



  return 0;
}


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

X = list(map(int, input().split()))


dp = [[[0 for _ in range(50*N + 1)] for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1


# i番目までのカードが選べる時にj-1枚選んでありｊ枚目にiを選ぶとき合計がA*(j)になるかどうか
# dp[i][j][k] : j-1枚選んでいてiを次に選んだ時に合計がｋになる組の数
for i in range(N+1):
    for j in range(i+1):
        for k in range(50*j + 1):
            # カードを選択するが、i番目のカードを選んでも合計がkに一致しない
            if i >= 1 and k < X[i-1]:
                # i番目を使っても合計がｋにならないなら、i-1枚目までで作った時と同じ組の数
                dp[i][j][k] = dp[i-1][j][k]
            
            # i番目のカードをj枚目に選んで合計がｋになるものがある場合。
            # k >= X[i-1] がなんとなく直感と一致しない気もするが、ｋは０～枚数＊目標平均値の範囲の値をとるのでこれでいい
            elif i >= 1 and j >= 1 and k >= X[i-1]:
                # i-1番目までで合計がｋになる個数＋ｊ-1番目までの合計がｋ-X[i]
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - X[i-1]]


ans = 0
# N枚目までからi枚選んだ時に平均がA（合計がA*i）になる個数をi=１～Nまで見る
for i in range(1, N+1):
    ans += dp[N][i][i*A]

print(ans)

Measured memory_bytes: 65504
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9
int x[100050],ans=inf;
int main() {
    int n,k;
    cin >> n >> k;
    for (int i=1;i<=n;i++) cin >> x[i];
    for (int i=1;i<=n-k+1;i++) {
        int dis = min(abs(x[i]),abs(x[i+k-1])) + x[i+k-1] - x[i];
        if (dis<ans) ans = dis;
    }
    cout << ans << endl;
    return 0;
}

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

#define FACE_LIMIT 6
#define FACE_NUMBER_LIMIT 100

typedef struct {
	int number[FACE_LIMIT];
} DICE_NUMBER_MAPPER;

typedef struct {
	DICE_NUMBER_MAPPER mapper[FACE_LIMIT];
} DICE;

typedef struct {
	int forward;
	int top;

	int answer;
} QNA;

int InputDice(DICE* dice);
void NumbersToMapper(int* numbers, DICE_NUMBER_MAPPER* mapper);
int Compare(DICE cmpA, DICE cmpB);

int main(void) {
	int compRes;
	DICE dices[2];
	InputDice(&dices[0]);
	InputDice(&dices[1]);

	compRes = Compare(dices[0], dices[1]);
	printf("%s\n", compRes == 1 ? "Yes" : "No");
}

int InputDice(DICE* dice) {
	int size;
	int nums[FACE_LIMIT];

	for (size = 0; size < FACE_LIMIT; size++) {
		scanf("%d", &nums[size]);
		if (nums[size] < 0 || nums[size] > 100) {
			return -1;
		}
	}

	NumbersToMapper(nums, dice->mapper);

	return 0;
}

void NumbersToMapper(int* numbers, DICE_NUMBER_MAPPER* mapper) {
	int id1;
	int id2;

	int set[][FACE_LIMIT] = {
			{ 0, 1, 2, 4, 3, 5 }
			,{ 1, 0, 3, 5, 2, 4 }
			,{ 2, 0, 1, 5, 4, 3 }
			,{ 3, 1, 0, 4, 5, 2 }
			,{ 4, 0, 2, 5, 3, 1 }
			,{ 5, 1, 3, 4, 2, 0 }
	};

	for (id1 = 0; id1 < FACE_LIMIT; id1++) {
		for (id2 = 0; id2 < FACE_LIMIT; id2++) {
			DICE_NUMBER_MAPPER* map = mapper + id1;
			map->number[id2] = *(numbers + set[id1][id2]);
		}
	}
}

int Compare(DICE cmpA, DICE cmpB) {
	int idx;
	int idi;

	for (idx = 0; idx < FACE_LIMIT; idx++) {
		int lineSame = 0;
		int pivot;

		DICE_NUMBER_MAPPER aMap = cmpA.mapper[idx];
		int finderTop = aMap.number[0];
		int finderBottom = aMap.number[FACE_LIMIT - 1];

		DICE_NUMBER_MAPPER bMap;
		int find = 0;
		for (idi = 0; idi < FACE_LIMIT; idi++) {
			DICE_NUMBER_MAPPER tmp = cmpB.mapper[idi];
			if (tmp.number[0] == finderTop &&
				tmp.number[FACE_LIMIT - 1] == finderBottom) {
				bMap = tmp;
				find = 1;
				break;
			}
		}
		if (!find) {
			return 0;
		}

		for (pivot = 0; pivot < FACE_LIMIT - 2; pivot++) {
			int notSame = 0;

			for (idi = 1; idi < FACE_LIMIT - 1; idi++) {
				int tmpIdx = idi + pivot;
				if (tmpIdx >= FACE_LIMIT - 1) {
					tmpIdx -= FACE_LIMIT - 2;
				}
				if (aMap.number[idi] != bMap.number[tmpIdx]) {
					notSame = 1;
					break;
				}
			}

			if (!notSame) {
				lineSame = 1;
				break;
			}
		}

		if (!lineSame) {
			return 0;
		}
	}

	return 1;
}


Measured memory_bytes: 2100
#include <stdio.h>

int main(void){
	int day, jap[2], math[2], tmp, J, M;
	scanf("%d%d%d%d%d", &day, &jap[0], &math[0], &jap[1], &math[1]);
	J = jap[0]/jap[1];
	M = math[0]/math[1];
	if(J < M)
		if(math[0]%math[1] == 0)
			tmp = M;
		else tmp = M + 1;
	else if(jap[0]%jap[1] == 0)
		tmp = J;
		else tmp = J + 1;
		
		printf("%d\n", day - tmp);
	return 0;
}

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


void solve(long long N, std::vector<long long> a){
  ll ans = 1000000007;
  for(int x=-100; x<=100; x++) {
    ll sum = 0;
    rep(i,N) {
      sum += pow(a[i]-x, 2);
    }
    ans = min(ans, sum);
  }
  std::cout << ans << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll A,B;cin>>A>>B;
    
	// 解法
	ll ans = -1;
	for (ll i = 1; i <= 20000; ++i){
		bool cond1 = (i*108)/100 - i == A;
		bool cond2 = (i*110)/100 - i ==B;
		if (cond1 & cond2){
			ans = i;
			break;
		}
	}

	//出力
	printf("%lld\n", ans);
}


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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, a, b) for(int i = a; i < b; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));

    int K, A, B;
    cin >> K >> A >> B;
    rep(i, A, B+1){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
        // cout << i / K << endl;
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int n;
    cin >> n;
    int p[n], count = 0;
    for(int i = 0; i < n; i++)cin >> p[i];
    for(int i = 1; i < n - 1; i++){
        if((p[i+1] - p[i]) * (p[i] - p[i-1]) > 0)count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	int d,t,s; cin >> d >> t >> s;
	if(double(d)/s <= double(t)){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(){
  string S;
  cin >> S;
  //入力終了


  char k[] = "keyence";
  
  //先頭がkでなければ，末尾がkeyenceになるしかない
  if(S[0] != k[0]){
    if(S.substr(S.size()-7) == k )
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  //末尾がeでなければ，先頭がkeyenceになるしかない                
  else if(S[S.size()-1] != k[6]){
    if(S.substr(0, 7) == k)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  else{
    int l = 0, r = 6;
    //左からkeyenceに一致している範囲を探索
    while(S[l]==k[l])
      l++;
    //右からkeyenceにん一致している範囲を探索
    while(S[r-6+S.size()-1]==k[r])
      r--;
    //lとrが交差していればOK
    if(l > r)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			int[] d = new int[100010];
			for(int i=0; i<N; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				for(int j = a; j <= b; j++) {
					d[j]++;
				}
			}
			int p;
			for(p = d.length-1; d[p] < p-1; p--) {
			}
			System.out.println(p-1);
		}
	}
}



Measured memory_bytes: 99884
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    S = input()
    T = input()
    p = -1
    for i in range(len(S) - len(T) +1):
        match = True
        for j in range(len(T)):
            if not(S[i+j] == '?' or S[i+j] == T[j]):
                match = False
                break
        if match:
            p = i

    if p == -1:
        print('UNRESTORABLE')
    else:
        print((S[:p] + T + S[p+len(T):]).replace('?','a'))

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#define  ms(a,b) memset(a,b,sizeof(a))

using namespace std;
typedef long long LL;
const LL INF=1e17L;
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;
const int Mod=1e9+7;
int n,a[maxn],color[maxn],pre[maxn];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        int t=a[i]/400+1;
        if(t>9) t=9;
        if(t>=9) color[t]++;
        else if(color[t]==0) color[t]++;
    }
    for(int i=1;i<=9;i++)
        pre[i]=pre[i-1]+color[i];
    if(pre[8]==0) pre[8]=1;
    cout<<pre[8]<<" "<<pre[9]<<endl;
    return 0;
}


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

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

    for (int i = 0; i < m; i++) {
        int tmp; cin >> tmp;
        n -= tmp;
    }

    if (0 <= n) cout << n << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int h, w; 
int n, m;
int main(){
    cin >> n >> m;
    if(n+m==15) cout << "+" << endl;
    else if(n*m==15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
seen = [False]*(n)
tmp = [-1]*n
from collections import deque
for i in range(n):
    q = deque([])
    if not seen[i]:
        q.append((i,i))
        tmp[i] = i
        while q:
            u,cnt = q.popleft()
            seen[u] = True
            tmp[u] = cnt
            for v in g[u]:
                if not seen[v]:
                    seen[v] = True
                    tmp[i] = cnt
                    q.append((v,cnt))

from collections import Counter
counter = Counter(tmp)

ans = sorted(counter.values())
print(ans[-1])


Measured memory_bytes: 112508
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
  }
  else if(n%10==0 ||n%10==1|| n%10==6 || n%10==8){
    cout<<"pon"<<endl;
  }
  else if(n%10==2 || n%10==4 || n%10==5 || n%10== 7 || n%10==9){
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <array>

using namespace std;
typedef long long ll;
int main()
{
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	tuple<double, int, int> ans;
	for (int i = 0; i * 100 * A <= F; i++) {
		for (int j = 0; j * 100 * B <= F; j++) {
			int w = i * 100 * A + j * 100 * B;
			if (w == 0) 
				continue;
			for (int k = 0; w + k * C <= F; k++) {
				for (int l = 0; w + k * C + l * D <= F; l++) {
					int s = k * C + l * D;
					if (100 * s <= w * E) {
						ans = max(ans, make_tuple((double)s / (s + w) * 100, s + w, s));
					}
				}
			}
		}
	}
	cout << get<1>(ans) << " " << get<2>(ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}
ll g = 1e18;

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	IOS;
	 
    ll p = 1;
    int n; cin>>n; bool ok=1;
    ll a[n]; forn(i,n){ cin>>a[i]; if(a[i]==0) ok=0; }
    if(!ok){ cout<<0; return 0; }
    forn(i,n)
    {
        ll j = a[i];
        if( g/j < p ){ ok=0; p = 0; break; }
        p = p*j; 
        if( p > g ){ ok=0; p = 0; break; }
        //cout<<p<<":"<<i<<endl;
    }
	if(ok) cout<<p;
	else cout<<-1;
	return 0;
}


Measured memory_bytes: 4436
#include<stdio.h>
 
int main(void)
{
    int a, b;
    int c, d;
 
 
    scanf("%d %d", &a, &b);
 
    c= a * b;
    d= 2 * a + 2 * b;
 
    printf("%d %d\n", c, d);
 
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  ll a, b, k; cin >> a >> b >> k;
  if(a >= k) {
    cout << a - k << " " << b << endl;
  } else {
    cout << 0 << " " << max(0ll, b - (k - a)) << endl;
  }

}


Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun calc(begin: Long, end: Long): Long {
    val n = end / begin
    return (begin + end) * n / 2
}

fun main() {
    val n = readLong()

    var ans = 0L
    for (i in 1..n) {
        ans += calc(i, n/i * i)
    }
    println(ans)
}

Measured memory_bytes: 34668
n = int(input())
h = [int(i) for i in input().split()]

# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
    
# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)

# 初期条件
dp[0] = 0

# 足場 i から足場 i+1 へ移動する。コストは|h[i]−h[i+1]|
# 足場 i から足場 i+2 へと移動する コストは |h[i]−h[i+2]|
for i in range(n-1):
    dp[i + 1] = chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    # n-2の時は2つ先はない
    if i < n-2:
        dp[i + 2] = chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[n-1])

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if(a >= k) drop(k);
  k -= a;
  if(b >= k) drop(a);
  k -= b;
  cout << a-k << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

#define MAX_H 110
#define MAX_W MAX_H

int A[26];  // 各アルファベット出現回数
vector< pair<int, char> > alph;    // 出てくる数, アルファベット
int H, W;

int main()
{
    ZERO(A);
    cin >> H >> W;
    REP(i, H * W) {
        char tmp;
        cin >> tmp;
        A[tmp - 'a']++;
    }
    REP(i, 26) {
        if(A[i] > 0) {
            alph.push_back(make_pair(A[i], i + 'a'));
        }
    }
    SORT(alph);
    int comp[3];    // i が許される数
    ZERO(comp);
    //int originMin = 1;      // 原点として最小限必要な数
    //int wMin = 2;           // 行として最小限必要な数
    //int hMin = 2;           // 列として最小限必要な数
    if(H % 2 != 0 && W % 2 != 0) {
        //originMin = 1;
        //wMin = 2;
        //hMin = 2;
        comp[1] += 1;
        comp[2] += H / 2;
        comp[2] += W / 2;
    }
    else if(H % 2 == 0 && W % 2 != 0) {
        //originMin = 2;
        //wMin = 4;
        //hMin = 2;
        comp[2] += 1;
        comp[2] += (H - 2) / 2;
    }
    else if(H % 2 != 0 && W % 2 == 0) {
        //originMin = 2;
        //wMin = 2;
        //hMin = 4;
        comp[2] += 1;
        comp[2] += (W - 2) / 2;
    }
    else {
        //originMin = 4;
        //wMin = 4;
        //hMin = 4;
    }
    for(auto a : alph) {
        int num = a.first;
        if(num % 2 != 0) {
            comp[1]--;
            if(comp[1] < 0) {
                printf("No\n");
                return 0;
            }
            num--;
        }
        int mod4 = num % 4;
        if(mod4 != 0) {
            comp[2]--;
            if(comp[2] < 0) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


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

ll solve(int l, int r, vector<ll> &sum, vector<vector<ll>> &dp){
	if(l == r)
		return 0;
	if(dp[l][r] != LLONG_MAX)
		return dp[l][r];
	ll &ret = dp[l][r];
	for(int i{l}; i < r; ++i){

		ret = min(ret, solve(l, i, sum, dp) + solve(i + 1, r, sum, dp) + sum[r + 1] - sum[l]);
	}
	return ret;
}

int main(){
	int n;
	cin>>n;
	vector<ll> inp(n);
	for(auto &x: inp)
		cin>>x;
	
	if(n == 1){
		cout<< 0;
		return 0;
	}

	vector<ll> sum(n + 1);
	for(int i{1}; i <= n; ++i)
		sum[i] = sum[i - 1] + inp[i - 1];

	vector<vector<ll>> dp(n, vector<ll>(n, LLONG_MAX));
	cout<< solve(0, n - 1, sum, dp)<<endl;
	return 0;
}

Measured memory_bytes: 4892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N;
    cin >> N;
    //Kの候補はNの約数に絞られた
    vector<ll> ds, ds2;
    rep2(i, 1, N){
        if(i*i > N) break;
        if(i*i == N) ds.pb(i);
        elif(N%i == 0) ds.pb(i), ds.pb(N/i);
    }
    rep2(i, 1, N-1){
        if(i*i > N-1) break;
        if(i*i == N-1) ds2.pb(i);
        elif((N-1)%i == 0) ds2.pb(i), ds2.pb((N-1)/i);
    }
    //for(auto &e: ds) cout << e << ' ';
    //cout << endl;
    ll cnt = ds2.size()-1;
    for(auto &e: ds){
        if(e == 1) continue;
        ll sub = N;
        while(sub%e == 0) sub /= e;
        if(sub%e == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

typedef complex<double> cm;
typedef vector<cm> vcm;

const double pi = acos(-1);

void make_zeta(int n, vcm &zeta){
    rep(i, n + 1){
        zeta[i] = polar(1.0, 2.0 * pi * i / n);
    }
}

void make_bit_reverse(int n, vector<int> &v){
    v.resize(n);
    rep(i,n) v[i] = i;
    for(int i = 1; (1<<i) <= n; ++i){
        int l = 1<<(i - 1), r = 1<<i;
        int plus = n >> i;
        for(int j = l; j < r; ++j){
            int temp = v[j - l] + plus;
            if(j < temp) swap(v[j], v[temp]);
        }
    }
    //rep(i,n) cout<<v[i]<<" \n"[i == n - 1];
}

void dft(int n, vcm &f, bool inv, vcm &zeta, vector<int> &id){
    vcm g(n);
    rep(i,n) g[i] = f[id[i]];
    swap(f, g);
    for(int l = n / 2, len = 1; l >= 1; l /= 2, len *= 2){
        //if(inv) cout<<len<<endl;
        for(int i = 0; i < n; i += len * 2){
            rep(j, len){
                cm z = inv ? zeta[n - l * j] : zeta[l * j];
                g[i + j] = f[i + j] + z * f[i + len + j];
                g[i + len + j] = f[i + j] - z * f[i + len + j];
                // if(inv) cout<<i + j<<' '<<i + len + j<<' '<<l * j<<endl;
            }
        }
        swap(f, g);
    }
    /*
    rep(i,n) g[id[i]] = f[i];
    swap(f, g);
     */
    if(inv) rep(i, n) f[i] /= cm(n);
}

vcm convolution(vcm g,vcm h){
    int sz = g.size() + h.size() - 1, n = 1;
    while(sz > n) n *= 2;
    g.resize(n);
    h.resize(n);
    vcm zeta(n + 1);
    make_zeta(n, zeta);
    vector<int> id;
    make_bit_reverse(n, id);
    dft(n, g, false, zeta, id);
    dft(n, h, false, zeta, id);
    vcm gh(n);
    rep(i,n) gh[i] = g[i] * h[i];
    dft(n, gh, true, zeta, id);
    return gh;
}
int main(){
    cin>>N;
    const int p = 200003;
    vec in(N), log_two(p, 0), pow_two(p);
    ll temp = 1;
    rep(i, p - 1){
        log_two[temp] = i;
        pow_two[i] = temp;
        (temp *= 2)%=p;
    }
    vcm a(p, cm(0.0, 0.0)), b(p, cm(0.0, 0.0));
    cm one(1.0, 0.0);
    rep(i,N){
        cin>>in[i];
        if(in[i] != 0) {
            a[log_two[in[i]]] += one;
            b[log_two[in[i]]] += one;
        }
    }
    vcm fftresult = convolution(a, b);
    ll res = 0;
    rep(i,p - 1){
        res += pow_two[i] * (ll(fftresult[i].real() + 0.5) + ll(fftresult[i + p - 1].real() + 0.5));
        /*
        if((ll(fftresult[i].real() + 0.5) + ll(fftresult[i + p - 1].real() + 0.5)) != 0){
            cout<<i<<' '<<(ll(fftresult[i].real() + 0.5) + ll(fftresult[i + p - 1].real() + 0.5))<<endl;
        }
         */
    }
    rep(i,N) res -= (in[i] * in[i]) % p;
    cout<<res / 2<<endl;
}

Measured memory_bytes: 57732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

bool func(string s, int l, int r) {
  cout << s.size() << " " << l << " " << r << endl;
  while (l != r) {
    if (s[l] != s[r]) return false;
    l ++, r --;
  }
  return true;
}

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

  int n = s.size();
  int j = n-1;
  for (int i = 0; i < n/2; ++i) {

    if (s[i] != s[j]) {
      cout << "No" << endl;
      return 0;
    }

    j--;
  }

  int li = (n-1)/2;
  j = li-1;
  li /= 2;
  // cout << li << endl;
  for (int i = 0; i < li; ++i) {
    if (s[i] != s[j]) {
      // cout << i << " " << j << endl;
      cout << "No" << endl;
      return 0;
    }

    j--;
  }
  j = n-1;
  // cout << li << endl;
  // cout << (n+3)/2-1 << " " << j << endl;
  for (int i = (n+3)/2-1; i!=j ; ++i){
    if (s[i] != s[j]) {
      cout << "No" << endl;
      return 0;
    }

    j--;
    if (i == j) break;
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val c = Iterator.continually(in.readLine)
    .take(3)
    .map(_.split(" ").map(_.toInt))
    .toArray

  val b1 = 0
  val b2 = c(0)(1) - c(0)(0)
  val b3 = c(0)(2) - c(0)(0)
  val a1 = c(0)(0)
  val a2 = c(1)(0)
  val a3 = c(2)(0)
  
  debug(a1,a2,a3,b1,b2,b3)

  val a = Array(a1, a2, a3)
  val b = Array(b1, b2, b3)
  val res = for {
    i <- 0 until 3
    j <- 0 until 3
  } yield {
    a(i) + b(j) == c(i)(j)
  }

  val ans = if(res.forall(_ == true)) "Yes" else "No"
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString == "class Main$") return
    println(any.mkString(" "))
  }
}

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

class UnionFind {
public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) : n(n), par(n), rank(n) {
        for (int i=0; i<n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x != y) {
            if (rank[x] > rank[y]) swap(x, y);
            par[x] = y;
            if (rank[x] == rank[y]) ++rank[y];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

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

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

    UnionFind uf(N);

    int ans = N;
    int x, y, z;
    for (int i=0; i<M; ++i) {
        cin >> x >> y >> z;
        
        if ( ! uf.same(x-1, y-1)) {
            ans --;
        }
        uf.unite(x-1, y-1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
s = gets.chomp.chars

ans = s.size - 1

("a".."z").each do |c|
  count = 0
  t = s.dup

  until t.uniq.size == 1
    (t.size - 1).times do |i|
      t[i] = [t[i], t[i + 1]].include?(c) ? c : t[i]
    end

    count += 1
    t.pop
  end

  ans = count if count <= ans
end

puts ans


Measured memory_bytes: 1788
n = int(input())
li = list(map(int,input().split()))
sum = 0
max = 0
for a_i in li:
    # 最大値判定
    if max <= a_i:  # あたらしく最大値になるパターン
        max = a_i
    else:  # 踏み台をおくパターン
        sum += max - a_i
print(sum)


Measured memory_bytes: 32236
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
while(true){
 char[] str=ir.next().toCharArray();
 int ans=0;
 for(int i=0;i<str.length;i++){
  ans+=str[i]-'0';
 }
 if(ans==0) break;
 out.println(ans);
}
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24324
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long cnt[1000];
int main() {
#define int long long
	int n;
	cin >> n;
	vector<long long> inputs;
	REP(i, n) {
		long long a;
		cin >> a;
		inputs.push_back(a);
		REP(q, 61) {
			if (((1LL << q) & a) != 0) {
				cnt[q]++;
			}
		}
	}
	long long tmp_ans = 0;
	REP(q, 61) {
		if (cnt[q] % 2 == 1) {
			tmp_ans += (1LL << q);
			REP(j, n) {
				if (((1LL << q) & inputs[j])) {
					inputs[j] -= 1LL << q;
				}
			}
		}
	}
	long long ans = 0;
	REP(q, n) {
		ans ^= inputs[q];
	}
	long long bobo = 0;
	for (long long q = 60; q >= 0;--q) {
		REP(j, n) {
			if (((1LL << q) & inputs[j])) {
				int ok = 1;
				for (long long t = q + 1; t <= 60; ++t) {
					if (((1LL << t) & inputs[j]) != 0) {
						ok = 0;
						break;
					}
				}
				if (ok == 0) continue;
				for (int t = 0; t < n; ++t) {
					if (t == j) continue;
					if ((1LL << q) & inputs[t]) {
						inputs[t] ^= inputs[j];
					}
				}
				break;
			}
		}
	}
	REP(q, n) {
		bobo ^= inputs[q];
	}
	tmp_ans += bobo + (ans ^ bobo);
	cout << tmp_ans << endl;
}
/*
int n;
string s;
long long gogo[20000];
int solve(int len) {
	long long dying = 1;
	long long gekoa = 1;
	int itr = 0;
	long long now = 0;
	long long aa = 0;
	for (int q = 0; q < s.length(); ++q) {
		now *= 26LL;
		now += s[q] - 'a';
		now %= MAX_MOD;
		aa *= 26LL;
		aa += s[q] - 'a';
		aa %= MOD;
		if (q >= len) {
			now += (MAX_MOD - ((dying * (s[q - len] - 'a') % MAX_MOD))) % MAX_MOD;
			now %= MAX_MOD;
			aa += (MOD - ((gekoa * (s[q - len] - 'a') % MOD))) % MOD;
			aa %= MOD;
		}
		else {
			dying *= 26LL;
			dying %= MAX_MOD;
			gekoa *= 26LL;
			gekoa %= MOD;
		}
		if (q >= len - 1) {
			gogo[itr] = now * MOD + aa;
			itr++;
		}
	}
	set<long long> nya;
	for (int i = itr - len - 1; i >= 0; --i) {
		nya.insert(gogo[i + len]);
		if (nya.find(gogo[i]) != nya.end()) return true;
	}
	return false;
}
int main() {
	cin >> n >> s;
	int bot = 0;
	int top = s.length();
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == true) {
			bot = mid;
		}
		else top = mid;
	}
	cout << bot << endl;
}

*/

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

int main() {
  int r,D,x_2000;
  cin >> r >> D >> x_2000;
  
  int ans = 0;
  int xi = x_2000;
  
  rep(i,10){
    ans = r * xi - D;
    cout << ans << endl;
    xi = ans;
  }
  
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)

N = int(input())

S = [input() for _ in range(N)]

for string in S:
    d[string] += 1

sorted_d = sorted(d.items(), key=lambda x:x[1], reverse=True)

ans = []

tmp = sorted_d[0][1]
for i in range(len(sorted_d)):
    if sorted_d[i][1] == tmp:
        ans.append(sorted_d[i][0])
        tmp = sorted_d[i][1]
    else:
        break

ans_sorted = sorted(ans) 
for i in range(len(ans_sorted)):
    print(ans_sorted[i])

Measured memory_bytes: 50548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int a,b;
	cin >> a >> b;
	cout << (max(max(a+b,a-b),a*b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void nabeatsu(int n) {
	int x;
	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else if (x % 10 == 3) {
			cout << " " << i;
		}
		else {
			x /= 10;
			if (x % 10 == 3) {
				cout << " " << i;
			}
			else if (x/10 % 10 == 3) {
				cout << " " << i;
			}
			else if (x/100 % 10 == 3) {
				cout << " " << i;
			}
		}
		
	}
	cout << endl;
}
int main() {
	int n;
	cin >> n;
	nabeatsu(n);
	return 0;
}

Measured memory_bytes: 3092
def resolve():
    n=int(input())
    B=list(map(int,input().split()))
    ans=0
    for i in range(n):
        if i==0: ans+=B[i]
        elif i==n-1: ans+=B[i-1]
        else: ans+=min(B[i-1],B[i])
    print(ans)



resolve()

Measured memory_bytes: 38384
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i]!=L[j] and  L[i]!=L[k] and  L[k]!=L[j]:
        if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[i]+L[k]>L[j]:
          ans+=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <stdio.h>
#include <vector>
 
using namespace std;

int min( int p, int q ){
	if( p < q ) return p;
	return q;
}

int main(void){

	int N;
	cin >> N;
	
	//データ取得
	vector< vector< int > > C( N, vector< int >( N, 0 ) );

	for( int i = 0; i < N; i++ )
		for( int j = 0; j < N; j++ )
			cin >> C[i][j];
	
	unsigned long long int ans = 0;
	for( int i = 0; i < N; i++ )
		for( int j = 0; j < i; j++ ) 
			ans += min( C[i][j], C[j][i] );
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1248
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#define GRAPH_MATRIX_SIZE 256

typedef enum {
  WHITE,
  GRAY,
  BLACK,
} color_t;

typedef struct {
  uint32_t index;
  size_t len;
  uint32_t array[GRAPH_MATRIX_SIZE];
  color_t color;
} graph_vertex_t;

typedef void (*graph_depth_first_search_callback_t)(uint32_t);
typedef void (*graph_breadth_first_search_callback_t)(uint32_t, uint32_t);

typedef struct {
  graph_vertex_t *vertex;
  uint32_t timer;
} graph_bread_first_search_queue_t;

void graph_breadth_first_search(graph_vertex_t *vertexes, size_t num, graph_breadth_first_search_callback_t callback)
{
  graph_bread_first_search_queue_t queue[GRAPH_MATRIX_SIZE];
  int32_t queue_top = 0, queue_bottom = 0;

  if ((vertexes == NULL) || (num == 0)) return;

  vertexes[0].color = GRAY;
  callback(vertexes[0].index, 0);
  queue[queue_top].vertex = &vertexes[0];
  queue[queue_top].timer = 0;
  queue_top++;

  while (queue_top != queue_bottom) {
    graph_vertex_t *vertex = queue[queue_bottom].vertex;
    uint32_t timer = queue[queue_bottom].timer;
    queue_bottom++;
    timer++;
    uint32_t j;
    for (j = 0; j < vertex->len; j++) {
      graph_vertex_t *next = &vertexes[vertex->array[j] - 1];
      if (next->color == WHITE) {
        queue[queue_top].vertex = next;
        queue[queue_top].timer = timer;
        queue_top++;
        next->color = GRAY;
        callback(next->index, timer);
      }
    }
    vertex->color = BLACK;
  }
  return;
}

#if !defined(TEST)
#include <stdio.h>

static graph_vertex_t vertexes[GRAPH_MATRIX_SIZE];

static int32_t timestamp[GRAPH_MATRIX_SIZE];

static void callback(uint32_t index, uint32_t time)
{
  timestamp[index - 1] = time;
}

int32_t main(void)
{
  uint32_t i;
  for (i = 0; i < GRAPH_MATRIX_SIZE; i++) {
    timestamp[i] = -1;
  }

  int32_t num;
  scanf("%d", &num);

  for (i = 0; i < num; i++) {
    scanf("%u", &vertexes[i].index);
    scanf("%lu", &vertexes[i].len);
    uint32_t j;
    for (j = 0; j < vertexes[i].len; j++) {
      scanf("%d", &vertexes[i].array[j]);
    }
  }

  graph_breadth_first_search(vertexes, num, callback);

  for (i = 0; i < num; i++) {
    printf("%d %d\n", i + 1, timestamp[i]);
  }

  return 0;
}
#endif

Measured memory_bytes: 700
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<Int> time(5);
	for (Int i = 0; i < 5; i++) {
		cin >> time[i];
	}

	Int ans = INF;
	Int temp;
	Int res;
	for (Int a = 0; a < 5; a++) {
		for (Int b = 0; b < 5; b++) {
			if (a==b) {
				continue;
			}
			for (Int c = 0; c < 5; c++) {
				if (a==c) {
					continue;
				}
				if (b==c) {
					continue;
				}
				for (Int d = 0; d < 5; d++) {
					if (a==d) {
						continue;
					}
					if (b==d) {
						continue;
					}
					if (c==d) {
						continue;
					}
					for (Int e = 0; e < 5; e++) {
						if (a==e) {
							continue;
						}
						if (b==e) {
							continue;
						}
						if (c==e) {
							continue;
						}
						if (d==e) {
							continue;
						}

						res = 0;
						temp = time[a];
						if (time[a] % 10 == 0) {
							res += temp;
						}
						else {
							res += temp + (10 - temp % 10);
						}

						temp = time[b];
						if (time[b] % 10 == 0) {
							res += temp;
						}
						else {
							res += temp + (10 - temp % 10);
						}

						temp = time[c];
						if (time[c] % 10 == 0) {
							res += temp;
						}
						else {
							res += temp + (10 - temp % 10);
						}

						temp = time[d];
						if (time[d] % 10 == 0) {
							res += temp;
						}
						else {
							res += temp + (10 - temp % 10);
						}

						res += time[e];
						ans = min(ans, res);
					}
				}
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int H ,W;
    int i, j;
    while(1){
    scanf("%d %d" ,&H ,&W);
    if(H == 0 && W == 0) break;
    for ( i = 0; i < H; i++ ){
        for ( j = 0; j < W; j++ ){
            if(j==0||j==W-1||i==0||i==H-1){
            printf("#");
            }else{ 
            printf(".");
            }
        }
    printf("\n");
    }
    puts("");
    }
    return 0;
}



Measured memory_bytes: 2064
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    char a[55],b[55];
    cin>>a>>b;
    int t1=strlen(a);
    int t2=strlen(b);
    int flag=0,c;
    for(int i=t1-t2+1;i>=0;i--)
    {
        int p=i,q=0;
        for(p=i,q=0;q<t2;p++,q++)
        {
            if(a[p]=='?') continue;
            else if(a[p]==b[q]) continue;
            else break;
        }
        if(q==t2) {flag=1;c=i;break;}

    }
    if(!flag) cout<<"UNRESTORABLE"<<endl;
    else
    {
        for(int i=c,j=0;j<t2;i++,j++){
            a[i]=b[j];
        }
        for(int i=0;i<t1;i++)
            if(a[i]=='?') a[i]='a';
        cout<<a<<endl;

    }
	return 0;
}


Measured memory_bytes: 256