akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;
 
 
int main() {
  string s;
  cin >> s;
  rep(i, 3) {
    cout << s.at(i);
  }

 
}

Measured memory_bytes: 3624
N, K = map(int,input().split())
a, b = [], []
if(K % 2 == 0):
  for i in range(1,N+1):
    if(i % K == 0):
      a.append(i)
    elif(i % K == K//2):
      b.append(i)
else:
  for i in range(1,N+1):
    if(i % K == 0):
      a.append(i)
print(len(a)**3 + len(b)**3)

Measured memory_bytes: 10996
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,x,n;
  int p,q,r;
  int min,max;
  int tmp;
  int ff=0;
  int a[109]={999};
  int b[109] = {999};
  scanf("%d %d",&x,&n);
  
  if(n==0){
    printf("%d",x);
  	return 0;
  }
  
  for(i=0;i<=n;i++){
    scanf("%d ",&a[i]);
  }
  
  b[0]=x;
  for(i=1;i<=n;i+=2){
   b[i]= x-((1+i)/2);
   b[i+1]=x+((1+i)/2);
  }
  
  for(i=0;i<101;i++){
  	for(p=0;p<n;p++){
      if(b[i]==a[p]){
       ff=1; 
        p=n;
      }
    }
    if(ff==0){
      printf("%d",b[i]);
      return 0;
    }
    ff=0;
  }
  
 return 0; 
}




Measured memory_bytes: 1728
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    if (A == B and B == C)
    {
        if (A & 1)
        {
            OUT(0);
        }
        else
        {
            OUT(-1);
        }
    }
    else
    {
        ll ans = 0;
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0)
        {
            ll x = A;
            ll y = B;
            ll z = C;
            A = (y + z) / 2;
            B = (z + x) / 2;
            C = (x + y) / 2;
            ++ans;
        }
        OUT(ans);
    }
}

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

using namespace std;

int main(){
    long long N, j;
    cin >> N;
    for(long long i = sqrtl(N); i > 0; i--){
        if(N % i == 0){
            j = N/i;
            cout << i + j - 2 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int a,b;
  cin>>a>>b;
  cout<<a*b;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3656
n = int(input())
s = input()
w = [0]*(n + 2)
e = [0]*(n + 2)
ans = 100000000

for i in range(1, n + 1):
    w[i] += w[i - 1]
    e[-i - 1] += e[-i]
    if s[i - 1] == "W":
        w[i] += 1
    if s[-i] == "E":
        e[-i - 1] += 1

for i in range(1, n + 1):
    ref = e[i + 1]
    ref += w[i - 1]
    ans = min(ans, ref)

print(ans)

Measured memory_bytes: 27144
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>
using namespace std;
#define REP(n) for(int i=0;i<n;i++)

#define INF_32 0x7fffffff;



int main() {
	long long N;
	cin >> N;
	vector<long long> L(N);
	long long length = 0;

	REP(N) {
		cin >> L[i];
		length += L[i];
	}
	
	long long max_L = *max_element(L.begin(), L.end());
	length -= max_L;

	if (max_L < length) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cmath>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL;
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; }
string s,ans;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	cin>>s;
	int len=s.size(),pos=0,tmp=0;
	ans=s;
	rep(i,len){
		tmp=s.find("FESTIVAL");
		if(tmp!=string::npos) pos=i;
		s=s.substr(1,s.size()-1);
//		cout<<pos<<endl;
	}
	cout<<ans.substr(0,pos-1);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, M;



int main() {
    //freopen("x.in", "r", stdin);


    while (cin >> n) {
        multiset<int> S1, S2;
        F0(i, n) {
            cin >> j;
            S2.insert(j);
            cin >> j;
            S1.insert(j);
        }

        ll ans = 0;
        F0(start, 2) {
            ll at = 0;
            ll curr = 0;
            int dir = start;

            multiset<int>::iterator it1 = S1.begin();
            multiset<int>::iterator it2 = S2.end();


            while (1) {
                if (dir) {
                    if (it2 == S2.begin()) break;
                    it2--;
                    ll x = *it2;
                    if (x <= at) break;
                    curr += x - at;
                    at = x;
                } else {
                    if (it1 == S1.end()) break;
                    ll x = *it1;
                    if (x >= at) break;
                    curr += at - x;
                    at = x;
                    it1++;
                }
                dir ^= 1;
            }
            if (at < 0) curr -= at; else curr += at;
            ans = max(curr, ans);
            //cout << curr << " ";
        }
        cout << ans << endl;
   }
    return 0;
}


Measured memory_bytes: 9600
n,x = map(int,input().split())

tmp_p = 1
tmp_v = 1
p_li = [1]
v_li = [1]
b0_li = [0,1,2,3,3]

for i in range(n):
    tmp_p = tmp_p * 2 + 1
    tmp_v = tmp_v * 2 + 3
    p_li.append(tmp_p)
    v_li.append(tmp_v)

def dfs(x,sou,num):
    #print(x)
    if x == v_li[sou]:
        print(num+p_li[sou])
        return
    elif x == 1:
        print(num)
        return
    elif x <= v_li[sou-1]+1:
        if sou == 2:
            print(num+b0_li[x-2])
            return
        else:
            #print(x-1,sou-1,num)
            dfs(x-1,sou-1,num)
    elif x == v_li[sou-1] + 2:
        print(num+p_li[sou-1]+1)
        return
    elif x <= 2*v_li[sou-1]+2:
        dfs(x-2-v_li[sou-1],sou-1,num+p_li[sou-1]+1)

dfs(x,n,0)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();

		if(A+B >= 10)
		{
			System.out.println("error");
		}
		else
		{
			System.out.println(A+B);
		}
	}

}


Measured memory_bytes: 35660
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    s = [None] * n
    for _ in range(m):
        d, num = mi()
        if s[d-1] == num:
            continue
        if s[d-1] is None:
            s[d-1] = num
        else:
            print(-1)
            exit()
    for ind, elm in enumerate(s):
        if elm is None:
            s[ind] = 1 if ind == 0 and n != 1 else 0
    if n != 1 and s[0] == 0:
        print(-1)
        exit()
    for digit in s:
        print(digit, end='')
    print('')
    

if __name__ == "__main__":
    main()

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int count = 0; int first, second;
	scanf("%d", &first);
	int max = 0;
	forn(i, n - 1) {
		int input; scanf("%d", &input);
		if(input <= first)
			count++;
		else 
			count = 0;
		first = input;
		
		uax(max, count);
	}
	printf("%d", max);
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        int tmp=1;
        while(tmp*i<k)tmp*=2;
        ans+=(double)1/tmp;
    }
    ans/=(double)n;
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
b=[None]*(N+1)
b[0]=0
w=[None]*(N+1)
w[N]=0
for i in range(1,N+1):
    b[i]=b[i-1]+(S[i-1]=='#')
for i in range(N-1,-1,-1):
    w[i]=w[i+1]+(S[i]=='.')
print(min([x+y for x,y in zip(b,w)]))

Measured memory_bytes: 27240
#include<bits/stdc++.h>
using namespace std;
int c[10][10];
int H, W, A, res;
int main()
{
cin>>H>>W;
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[i][j];
	for (int k = 0; k < 10; k++)
		for (int i = 0; i < 10; i++)
			for (int j = 0; j< 10; j++)
				c[i][j]=min(c[i][k]+c[k][j],c[i][j]);
	for (int i = 0; i < H; i++)
		for (int  j = 0; j < W; j++)
		{
			cin >> A;
			if (A >= 0)res += c[A][1];
		}
	cout << res << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

vector<pii> m[800];
// map mp[from][to] = cost

bool isleaf[800][800];
// check if edge is connected to end(leaf) or not

int conn[800];
// how many nodes connected to

// dfs
int find_far(int from, int *to){
  int max=-INF;
  for(auto itr : m[from]){
    int nxt = itr.first;
    int cost = itr.second;
    if(isleaf[from][nxt]==false &&
       isleaf[nxt][from]==false){
      // check update
      isleaf[from][nxt]=isleaf[nxt][from]=true;
      int newto;
      int newcost = find_far(nxt, &newto);
      if(cost+newcost > max){ //update
	max = cost+newcost;
	*to = newto;
      }
      isleaf[from][nxt]=isleaf[nxt][from]=false;
    }
  }

  if(max==-INF){ //no update happen
    *to = from;
    return 0;
  }
  return max;
}

int main(){
  int n;
  while(cin>>n, n){
    rep(i,n) m[i].clear();

    fill(isleaf[0], isleaf[n], false);
    fill(conn, conn+n, 0);

    vector<int> p(n);
    rep(i,n-1) scanf("%d", &p[i]);

    int tcost=0; // total cost
    rep(i,n-1){
      int d;
      scanf("%d", &d);
      int a = i+1;
      int b = p[i]-1;
      m[a].pb(mp(b, d));
      m[b].pb(mp(a, d));
      tcost += d;
      conn[a]++;
      conn[b]++;
    }

    // check end point
    int endcost=0;
    rep(i,n){
      if(m[i].size()==1){
	endcost+=m[i][0].second;
	int to = m[i][0].first;
	isleaf[i][to]
	  = isleaf[to][i]
	  = true;
	conn[i]--;
	conn[to]--;
      }
    }

    int incost = tcost - endcost; //inner edge cost

    // search longest path
    int st=0;
    while(st<n && conn[st]==0) st++; //start point
    if(st==n){
      cout << tcost << endl;
      continue;
    }
    int goal;
    find_far(st, &goal);
    st = goal;
    int longest = find_far(st, &goal);

    int res = tcost + longest + (incost-longest)*2;

    cout << res << endl;
  }

  return 0;
}

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

int main() {

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

  int count = 0; 
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for (int i = 0; i < n; i++){
    if (i == 0){
      count++;
    } else if (a.at(i-1) > a.at(i)){
      count++;
    }
  }

  cout << count << endl;


}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

int main(){
	ll A,B,T;
	cin >> A >> B >> T;

	ll p = T/A;
	ll ret = p * B;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
slist=[]
sset=set()
for i in range(n):
    slist.append(input())
    sset.add(slist[i])
m=int(input())
ans=0
mlist=[]
for i in range(m):
    mlist.append(input())
for i in range(len(sset)):
    sstr=sset.pop()
    snum=slist.count(sstr)
    mnum=mlist.count(sstr)
    num=snum-mnum
    if num>ans:
        ans=num
print(ans)


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

int main() {
	
	int n, v, p, counter=0;
	
	vector<int> values={};
	vector <int> prize={};
	
	cin>>n;
	
	for (int i=0;i<n;i++)
	{
		cin>>v;
		values.push_back(v);
	}
	
		for (int i=0;i<n;i++)
	{
		cin>>p;
		prize.push_back(p);
	}
	
	for (int i=0;i<n;i++)
	{
		if ((values[i]-prize[i])>0)
		{
			counter+=values[i]-prize[i];
		}
	}
	
	cout<<counter;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
    	{
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (a >= 3200) Console.WriteLine(s);
            else Console.WriteLine("red");
            
        }
    
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int total = 0;

		if (N < K) {
			total = X * N ;
		} else {
			total = (X * K) + (Y * (N-K)) ;
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 23636
/* Bismillahirrahmanirrahim
   Semoga Dapet AC ya Allah
   Amin.................. :)
*/
#include<bits/stdc++.h>
#define forA for(int i=0; i<a; i++)
#define ll long long
#define F first
#define S second
using namespace std;

int main(){
	int a, b, cek, cnt=0;
	float c;
	cin >> a >> b >> c;
	c+=0.5;
	cek=a;
	while(a<c){
		a+=cek;
		cnt+=b;
	}
	cout << cnt;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    MAX = A[-1]+1
    num_tmp = [0]*MAX

    for a in A:
        num_tmp[a] += 1
        if num_tmp[a] == 1:
            for i in range(2*a,MAX,a):
                num_tmp[i] = 2

    print(num_tmp.count(1))
    
main()

Measured memory_bytes: 32172
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int k=1;
    for(int i=0;i<n;i++)
    {
        if(k*2<k+m)
            k=k*2;
        else
            k=k+m;
    }
    cout<<k;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;int main(){int n;while(scanf("%d",&n)&&n){int r=-n,m=sqrt(n);for(int i=1;i<=m;i++)if(n%i==0){r+=i+n/i;if(i==n/i)r-=i;}printf("%s\n",n>r?"deficient number":n<r?"abundant number":"perfect number");}}

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin>>n>>m;
	LL suma = 0;
	LL a;
	for(int i=0; i<m; i++) {
		cin>>a;
		suma += a;
	}
	if(suma > n)
		cout<<-1;
	else
		cout<<n-suma;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n, m;

class U {
public:
  int n;
  vector<int> p, s;

  U(int _) {
    n = _;
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
      s[i] = 1;
    }
  }

  bool connect(int a, int b) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap]);
    for (bp = p[b]; bp != p[bp]; bp = p[bp]);
    if (ap == bp)
      return true;
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    s[mi] += s[ma];
    s[ma] = 0;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }

  int q(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return s[ap];
  }

  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return p[ap];
  }

  bool query(int a, int b) { return parent(a) == parent(b); }
};

vector<int> deg;
vector<vector<int>> p;
vector<pair<int, int>> ans;

void dfs(int i, int from) {
  for (auto &j : p[i]) {
    if (j == from) continue;
    dfs(j, i);
  }
  if (from < 0) return;

  if (deg[i] % 2 == 1) {
    ans.emplace_back(i, from);
    deg[i]++;
  } else {
    ans.emplace_back(from, i);
    deg[from]++;
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  p.resize(n);
  deg.resize(n);
  U uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (uf.connect(a, b)) {
      deg[a]++;
      ans.emplace_back(a, b);
    } else {
      p[a].push_back(b);
      p[b].push_back(a);
    }
  }
  if (m % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  dfs(0, -1);

  for (auto &v : ans) cout << v.first + 1 << " " << v.second + 1 << endl;

  return 0;
}


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

int main() {
  int a;
  string b;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    if(b=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}

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

const int MAX = 1e5 + 5;
int n, k, a[MAX];

int main() {
	scanf("%d%d", &n, &k);

	int enter = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);

		if(a[i] == 0)
			enter = 1;
	}

	if(!enter)
		a[++n] = 0;

	sort(a + 1, a + n + 1);

	int p = lower_bound(a + 1, a + n + 1, 0) - a;

	int ans = INT_MAX;
	for(int i = 0; i < p; i++) {
		int lft = a[p - i];

		int up = p + k - i;

		if(enter)
			up--;

		if(up > n)
			continue;

		int rgt = a[up];

		ans = min(ans, abs(a[p] - lft) + abs(lft - rgt));
		ans = min(ans, abs(a[p] - rgt) + abs(lft - rgt));
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
string a;
int X[1<<26];
int M[1<<26];
int dp[200005];
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        X[i]=(1<<(a[i]-'a'));
        if(i)X[i]^=X[i-1];
    }
    for(int i=1;i<(1<<26);i++)M[i]=1<<28;
    for(int i=0;i<a.size();i++)
    {
        dp[i]=1+M[X[i]];
        for(int j=0;j<26;j++)
        {
            dp[i]=min(dp[i],1+M[X[i]^(1<<j)]);
        }
        M[X[i]]=min(M[X[i]],dp[i]);
    }
    cout<<dp[a.size()-1];
    return 0;
}


Measured memory_bytes: 264836
import numpy as np

H,W,K = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
    
Ans = np.zeros([H,W],dtype=int)
num=1

NoS = []

for i in range(H):
    n = S[i].count('#')
    if n==0:
        NoS.append(i)
        continue
    else:
        cn = 0
        for j in range(W):
            Ans[i][j] = num
            if S[i][j] == '#':
                cn += 1
                if cn < n:
                    num += 1
        num += 1
        if len(NoS)>0:
            for k in NoS:
                Ans[k]=Ans[i]
            NoS = []
if len(NoS)>0:
    for k in NoS:
        if NoS[0]!=0:
            Ans[k]=Ans[NoS[0]-1]
        else:
            Ans[k]=[0]*W


for i in range(H):
    print(*Ans[i])        

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

int n, m;
LL dp[N];

LL func(int n, int m)
{
    if (dp[n] != -1) return dp[n];
    if (n == 0) return 1;
    if (n == 1) return (m - 1) % mod;

    LL v1 = (n - 1) * func(n - 2, m - 2);
    LL v2 = (m - 1) * func(n - 1, m - 1);
    return dp[n] = (v1 + v2) % mod;
}

LL f1[N];
LL f2[N];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    f1[1] = 1;
    for (int i = 2; i <= 5e5; i++) f1[i] = f1[i - 1] * i % mod;

    f2[0] = 1;
    f2[1] = 1;
    for (int i = 2; i <= 5e5; i++) f2[i] = f2[mod % i] * (mod - mod / i) % mod;
    for (int i = 2; i <= 5e5; i++) f2[i] = f2[i - 1] * f2[i] % mod;

    while (cin >> n >> m)
    {
        LL ans = f1[m];
        ans = (ans * f2[m - n]) % mod;
        clr(dp, -1);
        LL v = func(n, m);
        // debug(v);
        ans = (ans * v) % mod;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 26984
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dx[] = {0,0,0,1,1,1,2,2,2};
int dy[] = {0,1,2,0,1,2,0,1,2};

int main(){
	int N;cin >> N;
	while(N--){
		int data[9][9];
		bool bad[9][9] = {0};
		rep(i,9)rep(j,9)cin >> data[i][j];
		
		rep(i,3)rep(j,3){
			rep(d,9){
				int sx = j*3+dx[d] , sy = i*3+dy[d];
				rep(k,9){
					int tx = j*3+dx[k] , ty = i*3+dy[k];
					if(tx == sx && ty == sy)continue;
					if(data[sy][sx] == data[ty][tx])bad[sy][sx] = true;
				}
			}
		}
		
		rep(i,9){
			rep(j,9){
				rep(k,9){
					if(j == k)continue;
					if(data[i][j] == data[i][k])bad[i][j] = true;
				}
			}
		}
		rep(j,9){
			rep(i,9){
				rep(k,9){
					if(i == k)continue;
					if(data[i][j] == data[k][j])bad[i][j] = true;
				}
			}
		}
		rep(i,9){
			rep(j,9){
				cout << (bad[i][j]?"*":" ") << data[i][j];
			}
			cout << endl;
		}
		if(N)cout << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector < int > vint;
typedef pair < int, int > pii;
typedef pair < int, bool > pib;
typedef unsigned long long ull;

#define PB push_back
#define MP make_pair
#define RANGE(V) V.begin(), V.end()
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORN(i,n) for(int i=1;i<=n;++i)
#define debug(x) cerr<<#x<<":"<<x<<"\n";
#define FORS(i,n) for(int i=0;i<n.length();++i)
const int INF = INT_MAX;
const int MAX = 10000001;
const int M = 1000000007;
int mod{ 1000000007 };

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt", "r", stdin);
	string s;
	cin >> s;
	int res{ 0 };
	int len = s.length();
	for (int i = 0; i < len; ++i) { res += s[i] - '0'; };
	if (res % 9 == 0) cout << "Yes";
	else cout << "No";
	return 0;
}






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

void swap(int a[], int k, int l) {
    int tmp = a[k];
    a[k] = a[l];
    a[l] = tmp;
}

int main(void) {
    int w, n, k, l;
    int a[31];
    cin >> w;
    cin >> n;
    for(int i = 1; i <= w; i++) {
        a[i] = i;
    }
    for(int j = 0; j < n; j++) {
        scanf("%d,%d", &k, &l);
        swap(a, k, l);
    }
    for(int i = 1; i <= w; i++) {
        printf("%d\n", a[i]);
    }
}

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

int main() {
    string S;
    cin >> S;
    bool flag = true;
    for(int i = 0; i < S.size(); i++){
        for(int j = 0; j < S.size(); j++){
            if(i == j) continue;
            if(S.at(i) == S.at(j)) flag = false;
        }
    }
    if(flag) puts("yes");
    else puts("no");
}

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

int arr[105],freq[105];

int main() {
    int x ,n,element;
    cin>>x>>n;


    for(int i=0;i<n;i++){
        cin>>element;
        freq[element]++;
    }

    if(freq[x]==0){
        cout<<x<<endl;
        return 0;
    }



    for(int i=0,j=0;i<=101;i++){
        if(freq[i]==0){
            arr[j]=i;
            j++;
        }
    }

    /*int i=x;

    while(true){
        if(freq[i]==0){
            maxi = i;
            break;
        }
        i++;
    }

    int j = x;

    while(true){
        if(i<0){
            mini = i;
            break;
        }
        if(freq[i]==0){
            mini = i;
            break;
        }
        i--;
    }
    */
    sort(arr,arr+105);


    int low = *lower_bound(arr,arr+105,x);

    int mini = low-x;
    int ans = low;
    for(int i=0;i<x;i++){
        if(freq[i]==0){
            if(x-i<=mini){
                ans=i;
            }
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3632
n = int(input())
s = input()
S = list(s)
max = 0
tmp = 0
for i in range(1,n+1):
    tmp = 0
    for j in range(i):
        if S[j] in s[i:n+1] and S[j] not in s[0:j]:
            tmp += 1
    if tmp > max:
        max = tmp
print(max)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#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(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll A,B,C,K;
    ll ans=0;
    cin >> A >> B >> C >> K;
    if(K<=A){
        ans = K;
    }else{
        ans+=A;
        if(K-A>B){
            ans -= K-A-B;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
N,K,Q=map(int,input().split())
A=[0]*N
for i in range(Q):
    a=int(input())
    A[a-1] += 1
for i in range(N):
    #print(A[i])
    if A[i] <= Q-K:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 76492
long n,k,a[1<<17],b[1<<17],ans;
main()
{
	scanf("%ld%ld",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%ld%ld",a+i,b+i);
		if((a[i]&~k)==0)ans+=b[i];
	}
	for(long i=1;i<=k;i<<=1)
	{
		if((k&i)==0)continue;
		long now=0;
		long K=(k&~(i|(i-1)))|(i-1);
		for(int j=0;j<n;j++)if((a[j]&~K)==0)now+=b[j];
		ans=ans<now?now:ans;
	}
	printf("%ld\n",ans);
}

Measured memory_bytes: 1792
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

BB = [1, 1, 1, 1]
DD = [-1, 1, -1, 1]
B = [sc, sc, sr, sr]
UB = [W, W, H, H]
C = "LRUD"
ok = 0

def check(l, r, sz, ps):
    lb = 0; rb = sz+1
    for i in range(N-1, -1, -1):
        s = S[i]; t = T[i]
        if t == l:
            rb = min(rb+1, sz+1)
        elif t == r:
            lb = max(lb-1, 0)
        if s == l:
            lb += 1
        elif s == r:
            rb -= 1
        if rb <= lb+1:
            return 0
    if ps <= lb or rb <= ps:
        return 0
    return 1

if not check("L", "R", W, sc) or not check("U", "D", H, sr):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 45724
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (A,B) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
    var ans = A-2*B
    println(if (ans < 0) 0 else ans)
}

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)

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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  
  if (s == u){
    cout << a - 1 << " " << b << endl;
  }
  else{
    cout << a << " " << b - 1 << endl;
  }
}

Measured memory_bytes: 3580
n = int(input())

out_set = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for _ in range(n):
    in_test = input()
    out_set[in_test] += 1

for key in out_set:
    print(f'{key} x {out_set[key]}')


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint a,b;std::cin>>a>>b;
    lint r=a%b;
    std::cout<<std::min(r,b-r)<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int a,b,c;
int main(void) {
	char s[4];

	scanf("%s", s);
	for(int c = 0; c < 3; c++){
		if(s[c] == 'R'){
			a++;
			if(c == 2){
				b = a;
			}
		}else{
			if(a > b){
				b = a;
			}
			a = 0;
		}
	}
	printf("%d", b);

	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
string sa;
int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    int s=0;
    bool flag=true;
    cin>>s>>a>>b;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>sa;
        if(sa[0]=='n')s+=a;
        else if(sa[0]=='t')s+=b;
        else s=0;
        if(s<=0)s=0;
    }
    cout<<s<<endl;
}


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

using namespace std;

typedef long long ll;

int main(){
	int A,B;

	cin >> A >> B;
	if (1<=A && A <= 9 && 1 <= B && B <= 9)
	{
		cout << A*B << endl;
	}
	else cout << -1 << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    if(H != W){
        if( (A==1) && (B==1) ) cout << "No";
    }

    int flg = 0;

    REP(i,H){
        if(i >= B){
            flg = 1;
        }
        REP(j,W){
            if(flg == 0){
                if(j < A){
                    cout << 1;
                }
                else{
                    cout << 0;
                }
            }
            else{
                if(j < A){
                    cout << 0;
                }
                else{
                    cout << 1;
                }
            }        
        }
        cout << "\n";
    }

return 0;
}

Measured memory_bytes: 1280
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll k;
     cin >> k;
     string f;
     while(k--)
        f += "ACL";

    cout << f;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 1e5 + 2;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int a[N], s[N], fa[N], p[N];
int n, g[4], ll[4];
bool v[4];

I int findfa(cr x) {return fa[x] == x ? x : fa[x] = findfa(fa[x]);}

I void del(cr x) {
	s[a[x]]--;
	fa[x] = findfa(x + 1);
}

I void dfs(cr k) {
	if(k == 4) {
		bool bk = 0;
		fo(i, 0, 2) if(a[ll[i]] == ll[i + 1]) {bk = 1; break;}
		if(!bk) {
			fo(i, 1, n - 3) pr1(p[i]);
			fo(i, 1, 3) pr1(ll[i]);
			exit(0);
		} return ;
	} fo(i, 1, 3) if(!v[i]){
		v[i] = 1, ll[k] = g[i];
		dfs(k + 1);
		v[i] = 0;
	}
}

int main() {
	n = read();
	if(n == 2) {puts("-1"); return 0;}
	fo(i, 1, n) a[i] = read(), s[a[i]]++, fa[i] = i; fa[n + 1] = n + 1;
	fo(i, 1, n - 1) {
		reg x = findfa(1), y = findfa(x + 1), o = 0;
		if(s[a[x]] < s[a[y]]) swap(x, y), o = 1;
		if(s[a[x]] == n - i && fa[a[x]] == a[x]) {
			if(i != 1 && a[p[i - 1]] == a[x]) {puts("-1"); return 0;}
			p[i] = a[x], del(a[x]);
		} else {
			if(o) swap(x, y);
			if(i == 1 || a[p[i - 1]] != x) p[i] = x, del(x);
			else p[i] = y, del(y);
		}
	} p[n] = findfa(1);
	ll[0] = p[n - 3], g[1] = p[n - 2], g[2] = p[n - 1], g[3] = p[n];
	sort(g + 1, g + 4);
	dfs(1); puts("-1");
	return 0;
}



Measured memory_bytes: 2432
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if (n == 1){
		printf("Hello World\n");
	}else if(n == 2){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",a+b);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,x,res=0;
  cin>>n>>x;
  auto w = [](int k){return (1l<<(k+2l))-3l;};
  auto p = [](int k){return (1l<<(k+1l))-1l;};
  while(x>0){
    if(!n){res+=!!x;break;}
    if(w(n)==x){res+=p(n);break;}
    if(w(n-1)+2<=x){res+=p(n-1)+1;x-=w(n-1)+2;n--;}
    else if(1<x){x--;n--;}
    else break;
  }
  cout<<res;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(cin >> n){
		m=n%39;
		if(m==0){
			cout << "3C39" << endl;
		}else if(m<10&&m!=0){
			cout << "3C" << "0" << m << endl;
		}else{
			cout << "3C" << m << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    ll x = 0;
    rep(i, n) {
        if(i&1) x -= a[i];
        else x += a[i];
    }
    vi ans(n);
    ans[0] = x;
    rep(i, n-1) {
        ans[i+1] = a[i] - ans[i]/2;
        ans[i+1] <<= 1;
    }

    rep(i, n) {
        cout << ans[i] << (i == n-1 ? '\n':' ');
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> qua;
const double epx=1e-7;
int ccw(qua a,qua b,qua c)
{
    b-=a,c-=a,a=c*conj(b);
    if(a.imag()>epx) return 1;
    if(a.imag()<-epx) return -1;
    if(a.real()<-epx) return 2;
    if(abs(b)+epx<abs(c)) return -2;
    return 0;
}
int isintersect(qua a,qua b,qua c,qua d)
{
    return (ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0);
}
double dot(qua a,qua b)
{
    return real(b*conj(a));
}
double cross(qua a,qua b)
{
    return imag(b*conj(a));
}
double dist(qua a,qua b,qua c)
{
    if(dot(b-a,c-a)<0) return abs(c-a);
    if(dot(a-b,c-b)<0) return abs(c-b);
    return abs(cross(b-a,c-a))/abs(b-a);
}
double dist(qua a,qua b,qua c,qua d)
{
    if(isintersect(a,b,c,d)) return 0;
    double ab=min(dist(a,b,c),dist(a,b,d));
    double cd=min(dist(c,d,a),dist(c,d,b));
    return min(ab,cd);
}
int main()
{
    int t ;
    double x1,x2,x3,x4,y1,y2,y3,y4;
    for(scanf("%d",&t);t;--t)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        printf("%.12f\n",dist(qua(x1,y1),qua(x2,y2),qua(x3,y3),qua(x4,y4)));
    }
}



Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, m;
    cin >> n >> m;
    int maxleft = 0, minright = n;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        maxleft = max(maxleft, x);
        minright = min(minright, y);
    }
    cout << max(0, minright - maxleft + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll ans = -99999999999;
    ll n, k;
    std::cin >> n >> k;
    std::vector<ll> P;
    std::vector<ll> P_inv(n, 0);
    std::vector<ll> C;
    std::vector<ll> S(n, 0);
    std::vector<ll> S_temp(n, 0);
    std::vector<std::array<ll, 2>> T(n, {0, 0});
    for (ll i = 0; i < n; ++i) {
        ll temp = 0;
        std::cin >> temp;
        P.push_back(temp - 1);
        //P_inv[temp - 1] = i;
    }
    /*for (auto v : P) {
        std::cout << v << std::endl;
    }*/
    for (ll i = 0; i < n; ++i) {
        ll temp = 0;
        std::cin >> temp;
        C.push_back(temp);
    }

    for (ll i = 0; i < n; ++i) {
        T[i][1] = i;
    }
    for (ll i = 0; i < n; ++i) {
        ll count = 0;
        do {
            ++count;
            // std::cout << T[i][1] << P[(T[i][1])] << std::endl;
            T[i][1] = P[(T[i][1])];
            // std::cout << T[i][1] << std::endl;
            T[i][0] += C[(T[i][1])];
            //std::cout << "a" << count << " " << i << " " << T[i][0] << " " << T[i][1] << std::endl;
            ans = std::max(ans, T[i][0]);
        } while (!(T[i][1] == i || count == k));
        if (k > count) {
            ll rev = (k / count) - 1;

            count = count * rev;
            T[i][0] *= rev;
            //std::cout << "b" << count << " " << i << " " << T[i][0] << " " << T[i][1] << std::endl;
            ans = std::max(ans, T[i][0]);
        }
        while (count != k) {
            ++count;
            T[i][1] = P[(T[i][1])];
            T[i][0] += C[(T[i][1])];
            // std::cout << "c" << count << " " << i << " " << T[i][0] << " " << T[i][1] << std::endl;
            ans = std::max(ans, T[i][0]);
        }
    }

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


/*
for (ll j = 0; j < k; ++j) {
    for (ll i = 0; i < n; ++i) {
        S_temp[i] = S[P_inv[i]] + C[i];
    }
    for (ll i = 0; i < n; ++i) {
        S[i] = S_temp[i];
    }
    for (ll i = 0; i < n; ++i) {

       
}


*/

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  repi(i, 1, 10000) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256