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

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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

type Player struct {
	name string
	card []string
	top int
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	a, b, c := newPlayer("A"), newPlayer("B"), newPlayer("C")
	currentPlayer := &a
	for {
		if len(currentPlayer.card) == currentPlayer.top {
			fmt.Println(currentPlayer.name)
			break
		}
		switch currentPlayer.card[currentPlayer.top] {
		case "a":
			currentPlayer.top++
			currentPlayer = &a
		case "b":
			currentPlayer.top++
			currentPlayer = &b
		case "c":
			currentPlayer.top++
			currentPlayer = &c
		}
	}
}

func newPlayer(name string) Player {
	sc.Scan()
	return Player{
		name: name,
		card: strings.Split(sc.Text(), ""),
		top:  0,
	}
}

Measured memory_bytes: 1784
N, Q = map(int, input().split())
S = input()
cnt = [None] * N
cnt[0] = 0

for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(cnt[r-1] - cnt[l-1])

print('\n'.join(list(map(str, ans))))

Measured memory_bytes: 16488
#include <stdio.h>

int main(void) {
    int i, n,f=0;
    scanf("%d",&n);
    for(i=1;i<=9;i++){
        if(n % i == 0){
            if(1<=n/i && n/i<=9){
                f++;
            }
            if(n / i == i){
                f++;
            }
        }
    }
    
    if(f>=2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
N=int(input())
inf=float("inf")
A=[list(map(int,input().split())) for _ in range(N)]

def calc():
    ans=sum(map(sum,A))
    for i in range(N):
        for j in range(N):
            used=True
            for k in range(N):
                if i==k or k==j:continue
                if A[i][j]>A[i][k]+A[k][j]:
                    return -1
                elif A[i][j]==A[i][k]+A[k][j]:
                    used=False
            if not used:
                ans-=A[i][j]
    return ans//2
                
print(calc())

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a + b) > (c + d)) cout << "Left" << endl;
  else if ((a + b) == (c + d)) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

using vl    = vector<llong>;
using vvl   = vector<vl >;
using vvvl  = vector<vvl >;

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

int main(){
	int r,c,k;
	cin>>r>>c>>k;
	
	vvi v(r+1,vi(c+1,0));
	REP(i,k){
		int rr,cc;
		cin>>rr>>cc;
		cin>>v[rr][cc];
	}
	//REP(i,r+1) line(v[i]);
	//cerr<<endl;
	
	vvvl dp(4,vvl(r+1,vl(c+1,0LL)));
	FOR(i,1,r)FOR(j,1,c){
		if(v[i][j]==0){
			REP(cnt,4) dp[cnt][i][j]=dp[cnt][i][j-1];
			REP(cnt,4) chmax(dp[0][i][j],dp[cnt][i-1][j]);
		}else{
			dp[0][i][j]=dp[0][i][j-1];
			FOR(cnt,1,3) dp[cnt][i][j]=max(dp[cnt][i][j-1],dp[cnt-1][i][j-1]+v[i][j]);
			REP(cnt,4){
				chmax(dp[0][i][j],dp[cnt][i-1][j]);
				chmax(dp[1][i][j],dp[cnt][i-1][j]+v[i][j]);
			}
		}
	}
	/*REP(i,4){
		REP(j,r+1) line(dp[i][j]);
		cerr<<endl;
	}*/
	
	
	llong ans=0LL;
	REP(i,4) chmax(ans,dp[i][r][c]);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 390576
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

void dfs(int x, VI &dist, const vector<VI> &es) {
  FOR(y,es[x]) {
    if(dist[y] < 0) {
      dist[y] = dist[x] + 1;
      dfs(y, dist, es);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<VI> es(N);
  REP(i,0,N-1) {
    int a, b;
    cin >> a >> b;
    es[--a].push_back(--b);
    es[b].push_back(a);
  }
  vector<VI> dist(2, VI(N, -1));
  dist[0][0] = 0;
  dfs(0, dist[0], es);
  dist[1][N-1] = 0;
  dfs(N-1, dist[1], es);
  int fen = 0;
  REP(i,0,N) {
    if(dist[0][i] <= dist[1][i]) {
      fen++;
    }
  }
  cout << (fen > (N - fen) ? "Fennec" : "Snuke") << endl;
 
  return 0;
}


Measured memory_bytes: 11256
n, q = map(int,input().split())

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)

	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def search(self, a):
		tmpsum = 0
		i = 0
		k = (self.bitlen-1).bit_length()
		while k >= 0:
			tmpk = 2**k
			if i+tmpk <= self.bitlen-1:
				if tmpsum + self.bit[i+tmpk] < a:
					tmpsum += self.bit[i+tmpk]
					i += tmpk
			k = k - 1
		return i+1
	
	def output(self, a):
		return self.query(a+1)-self.query(a)
	
	def listout(self):
		return self.bit
	
	def __init__(self, a):
		self.bitlen = len(a)+1
		self.bit = [0]*(len(a)+1)
		for i, j in enumerate(a):
			self.add(i, j)

a = list(map(int,input().split()))
bit = BIT(a)

for _ in range(q):
	x, y, z = map(int,input().split())
	if x == 0:
		bit.add(y, z)
	else:
		print(bit.sum(y, z))

Measured memory_bytes: 132620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0;
  string s,t="keyence";
  cin >> s;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]!=t[cnt]){
      if(s.substr(s.size()-t.size()+cnt, t.size()-cnt)==t.substr(cnt, t.size()-cnt)){
        cout << "YES" << endl;
        return 0;
      }else{
        cout << "NO" << endl;
        return 0;
      }
    }else{
      cnt++;
    }
  }
  cout << "YES\n";
  return 0;
}


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

using namespace std;

typedef long long int ll;

vector < int > a;
int n;
ll m;

ll count (int val) {
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    int lo = 0, hi = n - 1;
    int idx = -1;
    while (lo <= hi) {
      int mid = (hi - lo) / 2 + lo;
      if (a[i] + a[mid] > val) {
        lo = mid + 1;
        idx = mid;
      } else {
        hi = mid - 1;
      }
    }

    if (idx == -1) continue;
    cnt += idx + 1;
  }

  return cnt;
}

ll solve (int val) {
  ll cnt = 0, sum = 0;
  vector < ll > psum (n);
  psum[0] = a[0];
  for (int i = 1; i < n; i++) psum[i] = a[i] + psum[i - 1];
  for (int i = 0; i < n; i++) {
    int lo = 0, hi = n - 1;
    int idx = -1;
    while (lo <= hi) {
      int mid = (hi - lo) / 2 + lo;
      if (a[mid] + a[i] > val) {
        lo = mid + 1;
        idx = mid;
      } else {
        hi = mid - 1;
      }
    }

    if (idx == -1) continue;
    cnt += idx + 1;
    sum += psum[idx] + (ll)(idx + 1) * a[i];
  }

  sum -= (cnt - m) * (val + 1);

  return sum;
}

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

  cin >> n >> m;
  a.resize (n);
  for (auto &i : a) cin >> i;

  sort (a.begin(), a.end(), greater < int > ());

  int mi_pair_sum = 0;
  int lo = 0, hi = 2e5 + 5;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    if (count (mid) >= m) {
      lo = mid + 1;
      mi_pair_sum = mid;
    } else {
      hi = mid - 1;
    }
  }

  cout << solve (mi_pair_sum) << '\n';
}


Measured memory_bytes: 4512
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    ans = 0
    for i in range(1,n+1):
        ni = n//i
        ans += i*ni*(ni+1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 68752
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int mx = max(a, max(b, c));
    if(sum - mx == mx){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import copy

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)


n,k,q = ips()
a = ipmultiplerow(q)
c = [0 for i in range(n)]
for i in range(q):
    c[a[i]-1]+=1
for i in c:
    if k-q+i>0:print("Yes")
    else:print("No")

Measured memory_bytes: 9128
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int d = sc.nextInt();
  int e = (a <= b ? a:b);
  int f = (c <= d ? c:d);
  System.out.println(e+f);
}}

Measured memory_bytes: 23764
X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

Y = make_divisors(X)

for i in range(2*len(Y)):
    if i%2 == 0:
        t = Y[i//2]
    else:
        t = -1*Y[i//2]
    for j in range(400):
        s = j-200
        if (s+t)**5 - s**5 == X:
            print(s+t,s)
            break
        else:
            pass

Measured memory_bytes: 9408
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main() {
  long long n, ans=0, m;
  cin >> n;
  
  for (long long i=1; i*i<n; i++) { //i is p
    if(n%i==0) {
      m = n/i - 1;
      if(m>i) ans +=m ;
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;
int h,w;
const int vr = 8000;
int a[80][80], b[80][80];
int dp[80][80][vr]={};
int vis[80][80] = {};

void fill_table(int x, int y)
{
	
	
	if(x<h && x>=0 && y<w && y>=0)
	{
		if(vis[x][y])
		  return;
		vis[x][y] = 1;
		if(x == h-1 && y == w-1)
		{
			int ab = abs(a[x][y] - b[x][y]);
			dp[x][y][ab] = 1;

			//cout<<" x : "<<x<<" y : "<<y<<"   i : "<<ab<<endl;
		}
		else
		{
			//cout<<"x : "<<x<<" y: "<<y<<endl;
			fill_table(x+1,y);
			fill_table(x,y+1);
			int ab = abs(a[x][y] - b[x][y]);
		if(x+1<h && x+1>=0 && y<w && y>=0)	
			for(int i = 0; i<vr ; i++)
			{
				if(dp[x+1][y][i])
				{
					//cout<<"hoo x : "<<x<<" y: "<<y<<endl;

					if(abs(i+ab) < vr)
					{
						dp[x][y][abs(i+ab)] = 1;
			        //    cout<<" x : "<<x<<" y : "<<y<<"   i : "<<abs(i+ab)<<endl;

					}
					if(abs(i-ab)<vr)
					{
						dp[x][y][abs(i-ab)] = 1;
						//cout<<" x : "<<x<<" y : "<<y<<"   i : "<<abs(i-ab)<<endl;
					}	
				}
			}
		if(x<h && x>=0 && y+1<w && y+1>=0)
			for(int i = 0; i<vr ; i++)
			{
				if(dp[x][y+1][i])
				{
					//cout<<" hey  x : "<<x<<" y: "<<y<<endl;

					if(abs(i+ab) < vr)
					{
						dp[x][y][abs(i+ab)] = 1;
						//cout<<" x : "<<x<<" y : "<<y<<"   i : "<<abs(i+ab)<<endl;
					}
					if(abs(i-ab)<vr)
					{
						dp[x][y][abs(i-ab)] = 1;
						//cout<<" x : "<<x<<" y : "<<y<<"   i : "<<abs(i-ab)<<endl;
						
					}
				}
			}
		}
	}
	else
		return;
}
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	cin>>h>>w;
	
	for(int i = 0; i<h ; i++)
		for(int j = 0; j<w ; j++)
		{
			cin>>a[i][j];
		}
	for(int i = 0; i<h ; i++)
		for(int j = 0; j<w ; j++)
		{
			cin>>b[i][j];
		}

	fill_table(0,0);
	int minim = 1e9;
	for(int i = 0; i<400 ; i++)
		if(dp[0][0][i])
		minim = min(minim, i);

	cout<<minim<<endl;		

	return 0;
	
}

Measured memory_bytes: 199424
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 30) - 1LL;
const ll LINF = (1LL << 60) - 1LL;
const double eps = 1e-9;
const ll MOD = 10007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll k = min(a, min(b, min(c, min(d, e))));
    cout << n / k + (n % k > 0LL) + 4LL << endl;
}


Measured memory_bytes: 256
import math
x = int(input())

if x<=599:
    print(8)
elif x<=799:
    print(7)
elif x<=999:
    print(6)
elif x<=1199:
    print(5)
elif x<=1399:
    print(4)
elif x<=1599:
    print(3)
elif x<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9176
import java.util.*;
public class Main {

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

if(a.equals("ABC") ){
	System.out.println("ARC");
}else {
	System.out.println("ABC");
}

	}
}

Measured memory_bytes: 35748
def get_prime_array(N):
    f = [0] * (N + 1)
    for i in range(2, N + 1):
        if not f[i]:
            for j in range(i + i, N + 1, i):
                f[j] = 1
    return f


def ans():
    Q = int(input())
    f = get_prime_array(1000001)
    c = [0] * 1000002
    for i in range(3, 1000001, 2):
        if not f[i] and not f[(i + 1) // 2]:
            c[i] += 1

    for i in range(3, 1000000):
        c[i] = c[i] + c[i - 1]

    for _ in range(Q):
        l, r = map(int, input().split())
        print(c[r] - c[l-1])

ans()

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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int maxn = 200111;
typedef long double db;

LL a[maxn], c[maxn], P[maxn];
int n, b[maxn], stk[maxn], top;

bool check(int x, int y, int z) { return (P[y] - P[x]) * (z - x) < (P[z] - P[x]) * (y - x); }

int main()
{
	get1(n);
	for(int i=1; i<=n; i++) get1(a[i]);
	for(int i=1; i<=n; i++) get1(b[i]);
	int mx = std::max_element(a + 1, a + n + 1) - a;
	std::rotate(a + 1, a + mx, a + n + 1);
	std::rotate(b + 1, b + mx, b + n + 1);
	
	a[n + 1] = a[1];
	b[1] = 0;
	n++;
	
	for(int i=1; i<=n; i++) c[i] = c[i-1] + b[i-1];
	for(int i=1; i<=n; i++) c[i] += c[i-1];
	for(int i=1; i<=n; i++) c[i] <<= 1;
	
	for(int i=1; i<=n; i++)
	{
		P[i] = a[i] - c[i];
		while(top > 1 && check(stk[top-1], stk[top], i)) top--;
		stk[++top] = i;
	}
	
	db ans = 0;
	for(int i=1; i<n; i++) ans += c[i];
	for(int i=1; i<top; i++)
	{
		ans += (db)(P[stk[i]] + P[stk[i+1]]) * (stk[i+1] - stk[i] + 1) / 2;
		ans -= P[stk[i+1]];
	}
	ans /= (n - 1);
	printf("%.10Lf\n", ans);
	return 0;
}

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

int main()
{
	long long C[4], N;
	cin >> C[0] >> C[1] >> C[2] >> C[3] >> N;

	vector<pair<long long, int>> per( 4 );
	int n = 8;
	for( int i = 0; i < 4; i++ ) {
		per[i] = make_pair( n * C[i], i );
		n /= 2;
	}
	sort( per.begin(), per.end() );
	N *= 4;
	long long ans = 0;
	for( int i = 0; i < 4; i++ ) {
		if( N == 0 ) break;
		int num = per[i].second;
		int n = 1 << num;
		long long nn = N / n;
		ans += C[num] * nn;
		N -= nn * n;
	}

	cout << ans << endl;
}


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

int main() {
    ll n;
    cin >> n;

    vector<ll> arr(n);
    ll dp[n+1][2];

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

    dp[1][0] = arr[0] + arr[1];
    dp[1][1] = -arr[0] - arr[1];

    for (int i = 2; i < n; i++) {
        dp[i][0] = max(dp[i-1][0] + arr[i], dp[i-1][1] + arr[i]);
        dp[i][1] = max(dp[i-1][0] - 2*arr[i-1] - arr[i], dp[i-1][1] + 2*arr[i-1] - arr[i]);
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int tmp;
	if(a > b && a > c) {
		tmp = c;
		c = a;
		a = tmp;
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
	}
	if(a < b && b > c) {
		tmp = c;
		c = b;
		b = tmp;
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
	}
	if(c > a && c > b) {
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
	}
	cout << a << " " << b << " " << c << endl;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n; 
    cin >> n;
    v_int a(n);
    cin >> a;
    
    ll money = 1000;
    int l = 0;

    while(l < n) {
        v_int b;
        b.push_back(a[l]);
        while(l < n-1) {
            if(a[l] < a[l+1]) {
                b.push_back(a[l+1]);
                l++;
            } else {
                break;
            }
        }

        if(b.size() > 1) {
            irep(i, b.size()-1) {
                ll x = money / b[i];
                money -= x * b[i];
                money += x * b[i+1];
            }
        }
        l++;
        //cout << b << endl;
    }
    cout << money << endl;
    return 0;
}

/*atcoder*/




Measured memory_bytes: 3540
#include<iostream>
#include<queue>

using namespace std;

int main(void)
{
	int K, N;
	priority_queue<int> A;
	cin >> K >> N;

	int temp1, temp2, n1;
	cin >> temp1;
	n1 = temp1;
	for (int i = 0; i < N - 1; i++)
	{
		temp2 = temp1;
		cin >> temp1;
		A.push(temp1 - temp2);
	}
	A.push(K - temp1 + n1);
	
	cout << K - A.top() << endl;
	
	return 0;
	
}

Measured memory_bytes: 1400
N = int(input())
A = list(int(input())for i in range(N))+[0]
ans = 0
for i in range(N):
    ans += A[i]//2
    if A[i] % 2== 1 and A[i+1] > 0:
        ans += 1
        A[i+1]-=1
print(ans)

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

using namespace std;

int n, cnt[100005];
long long d[100005];
pair<long long, int> p[100005];
vector<int> to[100005];
int ta;
long long tb;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &p[i].first);
		p[i].second = i + 1;
		cnt[i] = 1;
	}
	sort(p, p + n);
	for (int i = n - 1; i; i--) {
		tb = p[i].first - n + 2 * cnt[i];
		ta = lower_bound(p, p + i, make_pair(tb, 0)) - p;
		if (p[ta].first != tb) {
			printf("-1\n");
			return 0;
		}
		d[ta] += d[i] + cnt[i];
		to[ta].push_back(i);
		cnt[ta] += cnt[i];
	}
	if (d[0] != p[0].first) {
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < n; i++)
		for (int j : to[i])
			printf("%d %d\n", p[i].second, p[j].second);
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int c,d,a,b,n, m,k;
	char str[5];
	scanf("%lld%lld",&a,&b);
	if (a<=b) { printf("%lld",a); }else{ printf("%lld", a-1); }
	
}

Measured memory_bytes: 128
class Node():
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right
def postorder(ns,i, post):
    if ns[i].left != -1:
        postorder(ns,ns[i].left ,post)
    if ns[i].right != -1:
        postorder(ns,ns[i].right ,post)
    post.append(str(i+1))
def poio_node(ns,po,io):
    root = po[0]
    i = io.index(root)
    if i!=0: # root의 왼쪽노드가 존재한다면 왼쪽으로 재귀
        ns[po[0]].left = po[1]
        ns[po[1]].parent = po[0]
        poio_node(ns,po[1:i+1],io[:i]) # po, io 안의 왼쪽 노드들로만 재귀
    if i!=len(io)-1: # root의 오른쪽 노드가 존재한다면 오른쪽으로 재귀
        ns[po[0]].right = po[i+1]
        ns[po[i+1]].parent = po[0]
        poio_node(ns, po[i+1:], io[i+1:]) # po, io 안의 오른쪽 노드들로만 재귀
def min1(n):
    return (n-1)
n = int(input())
po = list(map(int,input().split()))
io = list(map(int,input().split()))
po = list(map(min1,po))   ##0~(n-1)로 변환
io = list(map(min1,io))
ns =  [Node()for i in range(n)]

poio_node(ns, po, io)

post = []
postorder(ns, po[0], post)
print(" ".join(post))


Measured memory_bytes: 5612
#include<cstdio>
using namespace std;
int main()
{
    int n,a,b,t,ans=0;
    scanf("%d%d%d\n",&n,&a,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d\n",&t);
        if(b<=t||t<a)ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
from collections import Counter
def resolve():
    N, M = map(int, input().split())
    d = Counter(list(map(int, input().split())))

    for _ in range(M):
        b, c = map(int, input().split())
        d[c] += b

    from collections import OrderedDict
    d = OrderedDict(sorted(d.items(), reverse=True))

    def main():
        cnt = 0
        ans = 0

        for k, v in d.items():
            if cnt + v < N:
                ans += (v * k)
                cnt += v
            else:
                ans += (N - cnt) * k
                print(ans)
                break

    main()



resolve()

Measured memory_bytes: 107040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	std::cin >> n;
	std::cout << ceil(float(n)/2)/n << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
// vector<int>adj[100005];
// int dp[100005];
// bool vis[100005];
// int in_degree[100005];
// void dfs(int src){
//     vis[src]=true;    
//     for(auto it:adj[src]){
//         dp[it]=max(dp[it],dp[src]+1);
//         --in_degree[it];
//         if(in_degree[it]==0)dfs(it);
//         }
//
//
//
// }
//


   
int main(){
ios_base::sync_with_stdio(0);
ll int t,n,i,j,k,m;
t=1;
// cin>>t;
int T;
Fo(T,1,t+1){
//  cout<<"Case #"<<T<<": ";
  cin>>n>>k;

  int a[n];
  fo(i,n)cin>>a[i];
vector<bool>dp(k+1);
  //memset(dp,false,sizeof dp);
  for(int stones=0;stones<=k;stones++){
      for(int x:a){
          if(stones>=x&&dp[stones-x]==false)dp[stones]=true;

      }
  }

if(dp[k]==true)cout<<"First";
else cout<<"Second";
}
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B) {
    cout << C << endl;
  } else if (B == C) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }

  
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var a = sc.NextLong();
        var b = sc.NextLong();
        var c = sc.NextLong();

        var t = c - a - b;
        if (t < 0)
        {
            Console.WriteLine("No");
            return;
        }

        Console.WriteLine(4 * a * b < t * t ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var n = fs.nextInt()
    var k = fs.nextInt()
    var a = fs.readIntArray(n)
    a = a.sortedArray()
    var sum:Long = 0
    for(i in 0 until k) sum += a[i]
    println(sum)

}
private fun gcd(i: Int, j: Int):Int {
    var max = max(i, j)
    var min = min(i, j)
    var rest:Int = max%min
    var oldRest:Int = min
    while (rest != 0) {
        max = min
        min = rest
        oldRest = rest
        rest = max%min
    }
    return oldRest
}
class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 38444
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();
		
		if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
V<pii> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 5){
    int a;
    cin >> a;
    v.pb(mp((a-1)%10, a));
  }
  sort(all(v));
  reverse(all(v));
  int ans = 0;
  for(pii p:v){
    ans = (ans+9)/10*10;
    ans += p.se;
  }
  cout << ans << endl;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ll A, B, C, X, Y;

int main(){

    cin >> A >> B >> C >> X >> Y;
    ll min_cost = 1LL<< 60;
    for(ll c = 0; c <= (1 + max(X, Y)) / 2 * 2 * 2; c+= 2){
        ll x = X;
        ll y = Y;
        ll cost = c * C;
        {
            ll cnt = min(x, c / 2);
            x -= cnt;
            cost += x * A;
        }
        {
            ll cnt = min(y, c / 2);
            y -= cnt;
            cost += y * B;
        }
        min_cost = min(min_cost, cost);
    }
    cout << min_cost << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i=0,l;
	char a[10001];
	cin>>n>>a;
	l=strlen(a);
	for(int i=0;i<l;i++){ 
		a[i]+=n;
		while(a[i]>'Z'){
			a[i]-=26;
		}
	} 
	for(int i=0;i<l;i++)
		cout<<a[i];
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
  public static void Main(string[] args){
    var S = new char[600000];
    string input = Console.ReadLine();
    int stidx = (600000 - input.Length) / 2, edidx = stidx + input.Length;
    for(var i=0; i<input.Length; i++){
      S[stidx + i] = input[i];
    }
    Console.ReadLine();
    bool reverse = false;
    while((input = Console.ReadLine()) != null){
      if(input == "1"){
        reverse = !reverse;
      }else{
        var prms = input.Split(' ');
        if(prms[1] == "1" ^ reverse){
          S[--stidx] = prms[2][0];
        }else{
          S[edidx++] = prms[2][0];
        }
      }
    }
    if(reverse){
        for(var i=0; i<(edidx-stidx+1)/2; i++){
          char a = S[stidx+i];
          S[stidx+i] = S[edidx-i-1];
          S[edidx-i-1] = a;
        }
    }
    Console.WriteLine(new string(S, stidx, edidx-stidx));
  }
}

Measured memory_bytes: 17460
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, mx, a[100005][3], dp[100005][3];

int solve(int days, int prev) {
    if (days == n) return 0;
    if (dp[days][prev] != -1) return dp[days][prev];

    int res = 0;
    if (prev != 0) res = max(res, a[days][0] + solve(days+1, 0));
    if (prev != 1) res = max(res, a[days][1] + solve(days+1, 1));
    if (prev != 2) res = max(res, a[days][2] + solve(days+1, 2));

    return dp[days][prev] = res;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 3) << '\n';
 
    return 0;
}


Measured memory_bytes: 7296
# coding: utf-8
import sys


def main(argv=sys.argv):

    a, b = map(int, input().split(' '))
    if (a * b) % 2 == 0:
        print('Even')
    else:
        print('Odd')

    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
//using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
using pii=pair<ll,ll>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__);


int main(){
    dcl(n);
    string a,b;get(a,b);
    rep(i,n){
        bool ok=true;
        rep(j,n-i){
            if(a[i+j]!=b[j])ok=false;
        }
        if(ok){
            cout<<n*2-(n-i)<<endl;
            return 0;
        }
    }
    cout<<n*2<<endl;
	return 0;
}


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

int main() {
	long long a, b, c;
	cin >> a >> b >> c;

	long long ans = LLONG_MAX;
	ans = min(ans, (a + 1) / 2 * b * c - a / 2 * b * c);
	ans = min(ans, (b + 1) / 2 * a * c - b / 2 * a * c);
	ans = min(ans, (c + 1) / 2 * a * b - c / 2 * a * b);

	cout << ans << endl;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 45;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	LL n, c, k;
	cin >> n >> c >> k;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	sort(ALL(a));
	int ans = 1;
	int start = a[0];
	int ye = 1;
	FOR(i, 1, n)
	{
		if (a[i] - start > k || ye == c)
		{
			ye = 1;
			start = a[i];
			++ans;
		}
		else
		{
			++ye;
		}
	}

	cout << ans;
	cin >> n;
	return 0;
}

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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll l, n, s[410000];
int main() {
	ll l, n;
	cin >> l >> n;
	REP(i, n) {
		cin >> s[i];
	}
	s[n] = l + s[0];
	ll ans = INF;
	REP(i, n) {
		ans = min(ans,l - (s[i + 1] - s[i]));
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int l=0,r=s.size()-1;
  int ans=0;
  while(l<r){
    if(s[l]==s[r]){l++;r--;}
    else{
      if(s[r]=='x'){
	r--;
	ans++;
      }else if(s[l]=='x'){
	l++;
	ans++;
      }
      else{cout<<-1<<endl;return 0;}
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define inf 1000000005
#define mod 1000000007
#define eps 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrepeat*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrepeat*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrepeat*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrepeat*/
#define isin(x,l,r) ((l) <= (x) && (x) < (r)) /*l以上r未満のx*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define pct __builtin_popcountll /*1bitの数*/
#define all(a) a.begin(),a.end() /*範囲*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大*/
#define cmn(x,y) x=min(x,y) /*最小*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はい・いいえ*/
#define dame { puts("-1"); return 0;}/*だめ*/
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;

using ll = long long;
using unit = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vt = vector<T>;
using vs = vector<string>;

int main() {
    int a, b;
    cin>>a>>b;
    int p = 0;
    if (a == 1 && b == 1) {
        cout << 1000000 << endl;
        return 0;
    }
    if (a ==1||b==1) {
        p = p + 300000;
    }
    if (a == 2) {
        p = p + 200000;
    }
    if (b == 2) {
        p = p + 200000;
    }
    if (a == 3) {
        p = p + 100000;
    }
    if (b == 3) {
        p = p + 100000;
    }
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 3592
// C - Attention

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string S;
	cin >> S;

	int E = 0;
	for (int i=0; i<N; i++) {
		if (S[i] == 'E') E++;
	}

	int LW = 0;
	int RE = E;

	int ans = INF;
	for (int i=0; i<N; i++) {
		if (i > 0 && S[i-1] == 'W') LW++;
		if (S[i] == 'E') RE--;
		ans = min(ans, LW + RE);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    String N = sc.next();
	    
	    for (char c : N.toCharArray()) {
	    	if (c == '1') {
	    		System.out.print('9');
	    	} else if (c == '9' ) {
	    		System.out.print('1');
	    	} else {
	    		System.out.print(c);
	    	}
	    }
	    
	    System.out.println();
	    
	}    
}	

Measured memory_bytes: 24916
#include <stdio.h>
int n,A[20];
int solve(int count,int num)
{
	if(num==0)	
	return 1;
	if(count>n||num<0)
	return 0;
	if(solve(count+1,num-A[count])||solve(count+1,num))
	return 1;
	return 0;
}

int main(int argc, char *argv[])
{
	int q,m,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&m);
		if(solve(0,m))
		printf("yes\n");
		else
		printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
int N;
int a[100004];
long long int ans=1;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int temp=0,Count=0;
  sort(a,a+N,greater<int>());
  
  for(int i=0;i<N;i++){
    if(temp!=a[i])temp=a[i];
    else {ans*=temp;Count++;temp=0;}
    if(Count==2)break;
  }
  if(Count<2)ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640