akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        char[] s_char = s.toCharArray();
        char[] t_char = t.toCharArray();

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<n; i++){
            sb.append(s_char[i]);
            sb.append(t_char[i]);
        }
        System.out.println(sb.toString());

    }

}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

ul knapsack(ul n, ul ga, ul sa, ul ba, ul gb, ul sb, ul bb) {
  vector< ul > dp(n+1, 0);
  for (ul i=1; i<=n; ++i) {
    dp[i] = dp[i-1]+1;
    if (i>=ga) dp[i] = max(dp[i], dp[i-ga]+gb);
    if (i>=sa) dp[i] = max(dp[i], dp[i-sa]+sb);
    if (i>=ba) dp[i] = max(dp[i], dp[i-ba]+bb);
  }
  return dp[n];
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, ga, sa, ba, gb, sb, bb;
  cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;

  n = knapsack(n, ga, sa, ba, gb, sb, bb);
  n = knapsack(n, gb, sb, bb, ga, sa, ba);

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 195584
n = int(input())
don = list(map(int, input().split()))
count = 0
while 1:
    if not don:
        break
    for i, k in enumerate(don):
        if k == 0:
            continue
        else:
            num = i
            break
    else:
        num = len(don)
    if num:
        del don[:num]
    for i, k in enumerate(don):
        if k == 0:
            num = i
            break
    else:
        num = len(don)
    for i in range(num):
        don[i] -= 1
    count += 1
print(count-1)


Measured memory_bytes: 3064
/*
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_C
*/
#include <bits/stdc++.h>
using namespace std;

bool is_prime(int n) {
    if (n < 2)
        return false;
    else if (n == 2)
        return true;

    // even number is not prime
    else if (n % 2 == 0)
        return false;
    else if (n == 5)
        return true;
    else if (n % 5 == 0)
        return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0)
            return false;
    }
    return true;
}

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

    int n;
    cin >> n;

    int count = 0;
    for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        if (is_prime(num)) {
            count++;
            // cout << "num, count = " << num << ", " << count << endl;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3164
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  a--;b--;
  if((b-a)%2==0){
    cout << (b-a)/2 << endl;
  }
  else{
    ll ans1,ans2;
    {
      ll a1 = a+1;
      ll b1 = b-a1;
      ans1 = a1+b1/2;    
    }
    {
      ll b1 = ((n-1)-b)+1;
      ll a1 = (n-1)-(a+b1);
      ans2 = a1/2+b1;
    }
    cout << min(ans1,ans2) << endl;
  }
  return 0;
}

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

struct UnionFind{
	vector<int> data;
	UnionFind(int n) : data(n, -1){ }

	int find(int x){
		return data[x] < 0 ? x : data[x] = find(data[x]);
	}
	bool unite(int x, int y){
		x = find(x); y = find(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

struct Edge{
	int src, dst, cst;
	Edge(int src, int dst, int cst) : src(src), dst(dst), cst(cst) { }
	bool operator==(const Edge &e)const{return src == e.src and dst == e.dst and cst == e.cst;}
	bool operator<(const Edge &e)const{return cst < e.cst;}
};

int N, M;

int kraskal(vector<Edge>& edges, vector<Edge>& tree, Edge rm){
	
	UnionFind uf(N);
	tree.clear();
	int ans = 0;
	
	for(auto e : edges){
		if(!(rm == e) && !uf.same(e.src, e.dst)){
			uf.unite(e.src, e.dst);
			ans += e.cst;
			tree.push_back(e);
		}
	}
	for(int i = 1; i < N; i++){
		if(!uf.same(0, i)){
			return 1e9;
		}
	}
	return ans;
}

vector<Edge> edges;
vector<Edge> tree;
vector<Edge> tmp;

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int c,s,d;
		cin >> s >> d >> c;
		edges.push_back(Edge(s - 1, d - 1, c));
	}
	sort(edges.begin(), edges.end());
	int w = kraskal(edges, tree, Edge(-1, -1, -1));
	int ans = 0;
	int sum = 0;
	for(Edge e : tree){
		if(w < kraskal(edges, tmp, e)){
			ans++;
			sum += e.cst;
		}
	}
	cout << ans << " " << sum << endl;	
}

Measured memory_bytes: 3800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str;
        while((str=br.readLine())!=null){
        String[] sp = str.split(" ");

        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);

        System.out.println(a + b);
        }
	}

}

Measured memory_bytes: 24020
let MOD = 1000000007L

let [| N; K |] = stdin.ReadLine().Split() |> Array.map int64

let rec resolver s i =
    if i = N + 2L then s
    else
        let min = i * (i - 1L) / 2L
        let max = i * (2L * N - i + 1L) / 2L
        resolver ((s + max - min + 1L) % MOD) (i + 1L)

resolver 0L K |> stdout.WriteLine


Measured memory_bytes: 27968
import sys
sys.setrecursionlimit(pow(10, 7))

def dfs(v, c):
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		if color[u] != -1:
			continue
		if w%2 == 0:
			dfs(u, c)
		else:
			dfs(u, 1-c)
			
n = int(input())
color = [-1]*n
glaph = [[]*n for _ in range(n)]
for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0)
for i in color:
	print(i)

Measured memory_bytes: 79408
#include <iostream>

using namespace std;

int main()
{
	long long int N, Y;
	cin >> N >> Y;

	Y /= 1000;
	int t, f, o;
	o = Y % 5;
	f = ((Y - o) % 10) / 5;
	t = (Y - o - f) / 10;

	for (int m = t; m >= 0; m--)
	{
		int a = f + (t - m) * 2;
		for (int ft = a; ft >= 0; ft--)
		{
			if (m + ft + o + (a - ft) * 5 == N)
			{
				cout << m << " " << ft << " " << o + (a - ft) * 5 << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

bool ispal(string s) {
    string rev = s;
    reverse(ALL(s));
    return rev == s;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    string s;
    cin >> s;
    int n =s.size();
    string a = s.substr(0, n / 2);
    string b = s.substr((n + 1) / 2);
    bool good = ispal(s) && ispal(a) && ispal(b);
    cout << (good ? "Yes" : "No");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	char S1[20], S2[20], S3[20];

	scanf("%s%s%s", S1, S2, S3);

	printf("%c%c%c", S1[0] - 0x20, S2[0] - 0x20, S3[0] - 0x20);






}

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

children_map = [None] * n
vals = [0] * n

for i in range(1, n):
    a, b = map(int, input().split())
    children_map[b - 1] = a - 1

for j in range(q):
    p, x = map(int, input().split())
    vals[p - 1] += x

res = []
for i in range(n):
    parent = children_map[i]
    if parent is not None:
        vals[i] += vals[parent]
    res.append(str(vals[i]))

print(" ".join(res))

Measured memory_bytes: 41268
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n; scanf("%d", &n);
  int arr[n];
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int ans = 0;
  for (int i = 0; i < n; i++) 
    for (int j = i+1; j < n; j++) 
      ans += arr[i] * arr[j];
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d", (i))
#define pr printf("\n")

#define NUM (2000)

int asc(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main(int argc, char** argv){
    int n, *L;
    scani(n);

    L = (int * )malloc(n * sizeof(int));

    rep(i, n){
        scani(L[i]);
    }

    qsort(L, n, sizeof(int), asc);

    int a, b, c;
    int sum = 0;

    rep(i, n){
        a = L[i];

        for(int j = i + 1; j < n; j++){
            b = L[j];

            int sab = a - b;
            int aab = a + b;
            for(int k = j + 1; k < n; k++){
                c = L[k];
                if(aab <= c){
                    break;
                }
                sum++;
            }
        }
    }


    // a < b + c
    // b < c + a
    // c < a + b
    //
    // a - b < c
    // b - a < c
    // a + b > c

    // sab > - c
    // sab < c
    // aab > c
    printi(sum);
    pr;

    return 0;
}



Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class ARangeProduct {
public:
    void solve(istream& cin, ostream& cout) {
        int a, b;
        cin >> a >> b;
        if((a <= 0 && b > 0) || (a < 0 && b >= 0)) {
            cout << "Zero\n";
            return;
        }
        if(a > 0 && b > 0) {
            cout << "Positive\n"; return;
        }
        cout << ((b-a + 1) % 2 == 0 ? "Positive\n" : "Negative\n");
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    ARangeProduct solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int n;
  long long k;
  cin >> n >> k;
  int a[n];
  int visited[n];


  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    a[i]--;
    visited[i] = -1;
  }

  int sp = 0;
  int len = 0;
  int loop;
  while ( true ) {
    if ( visited[sp] != -1 ) { loop = len - visited[sp]; break; }
    visited[sp] = len;
    sp = a[sp];
    len++;
    k--;
    if ( k == 0 ) { break; }
  }

  if ( k != 0 ) {
    long long rem = k % loop;
    while ( rem-- > 0 ) { sp = a[sp]; }
  }

  cout << sp+1 << endl;;
  return 0;
}


Measured memory_bytes: 5112
def solve():
  N = int(input())
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i],B[i] = map(int, input().split())
  A.sort()
  B.sort(reverse=True)
  if N%2==1:
    b = A[N//2]
    u = B[N//2]
    return u-b+1
  b1 = A[N//2-1]
  b2 = A[N//2]
  u1 = B[N//2-1]
  u2 = B[N//2]
  return u1+u2-b1-b2+1
print(solve())

Measured memory_bytes: 25528
#include <stdio.h>
#define N 20
#define Q 200
#define T 1
#define F 0
int A[N],n;

int main()
{
  int q,i,judge;
  int M[Q];

  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[i]);
  }
  for(i=0;i<q;i++){
    judge = solve(0,M[i]);
    if(judge == T){
      printf("yes\n");
    }
    if(judge == F){
      printf("no\n");
    }
  }

  return 0;
}


int solve(int i,int m){
  int res;
  if(m==0){
    return T;
  }
  if(i>=n){
    return F;
  }
  res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
  
}
  



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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int x = 100 * a + 10 * b + c;
  if(x % 4 == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  ll sum = 0;
  unordered_map<ll, ll> m;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum += a;
    m[a]++;
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    ll b, c;
    cin >> b >> c;
    sum += (c - b) * m[b];
    m[c] += m[b];
    m[b] = 0;
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 7028
use std::ascii::AsciiExt;
use std::io::*;
use std::iter::FromIterator;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn to_lower(c: char) -> char {
    c.to_ascii_lowercase()
}

fn main() {
    let w: String = read();
    let mut done: bool = false;
    let mut count: u32 = 0;

    while !done {
        let t: String = read();
        let t_lower: String = String::from_iter(t.chars().map(to_lower).into_iter());
        if t == "END_OF_TEXT" {
            done = true;
        } else if t_lower == w {
            count += 1;
        }
    }
    println!("{}", count);
}



Measured memory_bytes: 5024
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()

	ans = -(-N // 1.08)
	ans2 = N / 1.08

	#print(ans2)

	if ans2.is_integer():
		print(int(ans))
	else:
		tmp = ans2 - int(ans2)
		if tmp < 0.1:
			print(":(")
		else:
			print(int(ans))







if __name__ == "__main__":
	main()


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

int main(){
	int a,b;
	a=b=1;
	while (a!=0 || b!=0){
		cin>>a>>b;
		if (b<a)swap(a,b);
		if (a!=0 || b!=0)cout<<a<<" "<<b<<endl;
	}
}


Measured memory_bytes: 3012
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i]=map(int,input().split())

def dfs(part_A,i):
    if i == N:
        A.append(part_A)
    else:
        for a in range(part_A[-1],M+1):
            dfs(part_A+[a],i+1)

A=[]
dfs([1],1)
max_score=0
for An in A:
    score = 0
    for q in range(Q):
        if An[b[q]-1]-An[a[q]-1] == c[q]:
            score += d[q]
    max_score = max(score, max_score)

print(max_score)

Measured memory_bytes: 16268
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力文字列
            var input = Console.ReadLine();

            // 0, 1の文字数を数える
            var count0 = input.Where(c => c == '0').Count();
            var count1 = input.Where(c => c == '1').Count();

            var result = (count0 > count1) ? count1 * 2 : count0 * 2;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13372
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main() {
	double n;
	VI a;
	cin >> n;

	while (n != 0) {
		int ini = n;
		n = ceil(n / (-2));
		a.push_back(ini - (n*(-2)));
	}
	reverse(all(a));
	if (a.size() == 0) {
		cout << 0 << endl;
	} else {
		for (auto x : a) {
			cout << x;
		}
		cout << "\n";
	}
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int n,i,j,k,num,data[5][50]; 
    char sut;
   	 
    for(i=1;i<=4;++i){
	  for(j=1;j<=13;++j){
	   data[i][j]=0;
      }
	 }	 	  
	  
 	  scanf("%d",&n);
 
 	 for(j=0;j<n;++j){
	  scanf(" %c",&sut); // ?????????????????¨???
	  scanf("%d",&num);
	     
       if (sut=='S') k=1;
       else if (sut=='H') k=2;      
       else if (sut=='C') k=3;
       else if (sut=='D') k=4;
	   else {
	   	printf("terminated");
			return 0;
		}	  
	  data[k][num]=1;
	 }	 
	
    for(i=1;i<=4;++i){
	  for(j=1;j<=13;++j){  
	   if (data[i][j]==0){
    
       if (i==1) sut='S';
       if (i==2) sut='H';      
       if (i==3) sut='C';
       if (i==4) sut='D';	 		  
		  
	   printf("%c %d\n",sut,j); 
      }
	 }
    }	
	      
	return 0;
}

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

signed main(void){
    int n;cin >> n;
    string s; cin>> s;
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }

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

Measured memory_bytes: 256
N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w1,v1=map(int,input().split())
    w[i]=w1
    v[i]=v1
dp=[[0 for i in range(W+1)] for j in range(N)]
for i in range(N):
    if i==0:
        dp[0][w[0]]=v[0]
    else:
        for w1 in range(W+1):
            if 0<=w1-w[i]:
                dp[i][w1]=max((dp[i-1][w1-w[i]]+v[i]),dp[i-1][w1])
            else:
                dp[i][w1]=dp[i-1][w1]
print(max(dp[N-1]))



Measured memory_bytes: 171400
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n;
ll ans=0;
string a;
unordered_map<string,int> mp;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a;
		sort(a.begin(),a.end());
		mp[a]++;
		a.clear();
	}
	for (auto t:mp){
		ll r=t.second;
		ans+=(((r-1)*r)>>1);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    tx -= sx;
    ty -= sy;

    string ans;
    REP(i, ty) ans += 'U';
    REP(i, tx) ans += 'R';
    REP(i, ty) ans += 'D';
    REP(i, tx) ans += 'L';
    ans += 'L';
    REP(i, ty+1) ans += 'U';
    REP(i, tx+1) ans += 'R';
    ans += 'D';
    ans += 'R';
    REP(i, ty+1) ans += 'D';
    REP(i, tx+1) ans += 'L';
    ans += 'U';

    pr(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main() 
{
	int a[250],i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		
	}
	for(i=1;i<=n;i++)
	{
	printf("node %d: key = %d, ",i,a[i]);
	if(i/2>0) printf("parent key = %d, ",a[i/2]);
	if(i*2<=n) printf("left key = %d, ",a[i*2]);
	if(i*2+1<=n) printf("right key = %d, ",a[i*2+1]);
	printf("\n");
    }
	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int h = Integer.parseInt(scanner.next());
    int w = Integer.parseInt(scanner.next());
    String[] a = new String[h];
    int[][] dp = new int[h + 1][w + 1];
    int MAX = 1000000007;
    for (int i = 0; i < h; i++) {
      a[i] = scanner.next();
      dp[i][0] = 0;
    }
    for (int i = 1; i < w; i++) {
      dp[0][i] = 0;
    }
    dp[0][1] = 1;
    for (int i = 1; i < h + 1; i++) {
      for (int j = 1; j < w + 1; j++) {
        if (a[i - 1].charAt(j-1) == '.') {
          dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
        } else {
          dp[i][j] = 0;
        }
        if (dp[i][j] >= MAX) {
          dp[i][j] -= (dp[i][j]/MAX)*MAX;
        }
      }
    }
    System.out.println(dp[h][w]);
  }
}


Measured memory_bytes: 33448
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    vi h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    int64_t minHeight = 0;
    vi dp(n);
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(0) - h.at(1));
    for(int i=2; i<n; i++){
        minHeight = 1000000007;
        for(int j=i-1; j>=i-k && j>=0; j--){
            minHeight = min(minHeight, dp.at(j) + abs(h.at(j) - h.at(i)));
        }
        dp.at(i) = minHeight;
    }
    cout << dp.at(n-1) << endl;
}


Measured memory_bytes: 1792
from itertools import product
n = int(input())
s = input()

for a, b in product('SW', repeat=2):
    ls = [None]*n
    ls[0] = a
    ls[-1] = b
    for i in range(n-2):
        if ls[i] == 'S':
            if s[i] == 'o':
                ls[i+1] = ls[i-1]
            else:
                ls[i+1] = 'W' if ls[i-1] == 'S' else 'S'
        else:
            if s[i] == 'o':
                ls[i+1] = 'W' if ls[i-1] == 'S' else 'S'
            else:
                ls[i+1] = ls[i-1]

    def is_ok(i):
        if ls[i] == 'S':
            if s[i] == 'o':
                if ls[i-1] != ls[i+1]:
                    return False
            else:
                if ls[i-1] == ls[i+1]:
                    return False
        else:
            if s[i] == 'o':
                if ls[i-1] == ls[i+1]:
                    return False
            else:
                if ls[i-1] != ls[i+1]:
                    return False
        return True

    if not is_ok(-2):
        continue
    elif not is_ok(-1):
        continue
    print(''.join(ls))
    break
else:
    print(-1)


Measured memory_bytes: 10536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int inf = 0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n,m;
	cin>>n>>m;
	int ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
	void add(int k, int val) {
        k += (n - 1);
        node[k] += val;
 
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }/*
    void add(int p, int x) {
        p += n-1;
        do {
            node[p] += x;
            p = (p-1) / 2;
        } while (p);
    }*/
    int get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y) << endl;
        }
    }
}


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

vector<int> t;

int main()
{
    int n, a, k = -1;

    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        if (a + 1 > k)
            k = a + 1;
        t.push_back(a - 1);
        t.push_back(a);
        t.push_back(a + 1);
    }

    ++k;


    sort(t.begin(), t.end());

    int top = 1, cur = 1;

    for (int i = 1; i < 3 * n; ++i)
    {
        if (t[i] == t[i - 1])
            ++cur;
        else
        {
            if (cur > top)
                top = cur;
            cur = 1;
        }
    }

    if (cur > top)
        top = cur;

    cout << top << '\n';
}

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

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

    int ans = 0;
    for (int i = 1; i <= t; i++) {
        if (i % a == 0) ans += b;
    }

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


Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
        s: String,
        t: String,
    }
    let s = s.as_bytes().to_vec();
    let t = t.as_bytes().to_vec();

    let mut ans = std::usize::MAX;
    for s in s.windows(t.len()) {
        let count = s.iter().zip(t.iter()).filter(|(c1, c2)| c1 != c2).count();
        ans = ans.min(count);
    }

    println!("{}", ans);
}


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

int main(){
  string A,S="abcdefghijklmnopqrstuvwxyz";
  long memo[26]={},ans=1;
  cin>>A;
  for(int i=0;i<A.size();i++){
    for(int j=0;j<26;j++){
      if(A[i]==S[j]){
        ans+=i-memo[j];
        memo[j]+=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    if(N % 2 == 1) ++N;
    cout << N/2-1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class  Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true){
            int n=scan.nextInt();
            if(n==0){
                break;
            }
            String[] str=new String[n];
            int[] format={5,7,5,7,7};
            int count=0,ans=0;
            for(int i=0;i<n;i++){
                str[i]=scan.next();
            }
            int temp=0,now=0;
            while (true){
                int len=0;
                temp++;
                for(int i=0+now;i<temp+now;i++){
                    len=len+str[i].length();
                }
                if(len>format[count]){
                    count=0;
                    temp=0;
                    now=ans+1;
                    ans++;
                }
                else if(format[count]==len){
                    if(count==0){
                        ans=now;
                    }
                    count++;
                    now=now+temp;
                    temp=0;
                }
                if(count==format.length){
                    break;
                }
            }
            System.out.println(ans+1);
        }
    }
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll N, M;
	cin >> N >> M;
	if (M == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (N % M < M / 2) {
		cout << N % M <<endl;
	}else{
		cout << M - N % M << endl;
	}
	// int A[N];
	// int sum = 0;
	// for (int i = 0;i < N;i++) {
	// 	cin >> A[i];
	// 	sum += A[i];
	// }
	// int sup = sum / (4 * M);
	// int cnt = 0;
	// if (sum == 0) {
	// 	cout << "Yes" << endl;
	// 	return 0;
	// }
	// rep(i,0,N) {
	// 	if (A[i] > sup) cnt++;
	// }
	// if (cnt >= M) cout << "Yes" << endl;
	// else cout << "No" << endl;
	// cout << sup << " " << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b;i<e;i++)
using lll = __int128;

int main(){
        int n;
        scanf("%d", &n);
        lll a[n];
        REP(i, 0, n){
                int x;
                scanf("%d", &x);
                a[i] = x;
        }

        int ans = 0;
        REP(i, 1, 1<<n){
                lll l = 1;
                REP(j, 0, n) if((i>>j)&1) {
                        l = l * a[j] / std::__gcd<lll>(l,a[j]);
                }

                bool ok = true;
                REP(j, 0, n) if(((i>>j)&1)==0) {
                        if(l%a[j]==0) ok = false;
                }
                if(ok) ans++;
        }

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


Measured memory_bytes: 3212
n = int(input())
a = sorted(list(map(int,input().split())))
if a[n-1] < 0:
    ans = 2*a[n-1]-sum(a)
    print(ans)
    p,q =a[n-1],a[0]
    for i in range(n-1):
        print(p,q)
        p = p-q
        q = a[i+1]
elif a[0] >= 0:
    ans = sum(a)-2*a[0]
    print(ans)
    p,q = a[0],a[1]
    for i in range(n-2):
        print(p,q)
        p = p-q
        q = a[i+2]
    print(q,p)

else:
    num = 0
    ans = 0
    for i in range(n):
        if a[i] < 0:
            ans -=a[i]
        else:
            if a[i-1] < 0 and a[i] >= 0:
                num = i
            ans += a[i]
    print(ans)
    p = a[0]
    for i in range(num,n-1):
        print(p,a[i])
        p -= a[i]
    q = a[n-1]
    print(q,p)
    q -= p
    for i in range(1,num):
        print(q,a[i])
        q -= a[i]

Measured memory_bytes: 61452
#include <cstdio>
#include <cstring>

char s[100001];

int main() {
  int i, j, n;
  scanf("%s", s);
  n = strlen(s);
  for (i = 0; s[n / 2] == s[(n + 1) / 2 - i - 1] && s[n / 2] == s[n / 2 + i]; i++);
  printf("%d\n", i + n / 2);
}


Measured memory_bytes: 256
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let print str a b =
  let rec doit i =
    if i > b then print_newline ()
    else begin
      print_char (String.get str i);
      doit (i + 1);
    end
  in
  doit a; str

let reverse str a b =
  let n = String.length str in
  let rec doit i ret =
    if i >= n then ret
    else
      let j = if i >= a && i <= b then b + a - i else i in
      doit (i + 1) (ret ^ (Char.escaped (String.get str j)))
  in
  doit 0 ""

let replace str a b p =
  String.sub str 0 a ^ p ^ String.sub str (b + 1) (String.length str - 1 - b)

let () =
  let str = read_line () in
  let n = read_int () in
  let rec doit i str =
    if i > n then ()
    else
      let l = read_line () in
      match split l ' ' with
      | [] | [_] | _::_::[] -> exit 1
      | "print" :: a :: b :: _ -> doit (i + 1) (print str (int_of_string a) (int_of_string b))
      | "reverse" :: a :: b :: _ -> doit (i + 1) (reverse str (int_of_string a) (int_of_string b))
      | "replace" :: a :: b :: p :: _ -> doit (i + 1) (replace str (int_of_string a) (int_of_string b) p)
      | _ -> exit 1
  in
  doit 1 str

Measured memory_bytes: 4592
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := floatScanner()
	b := floatScanner()
	h := floatScanner()
	m := floatScanner()
	p, q := math.Cos(2.*math.Pi*(h+m/60)/12)*a, math.Sin(2.*math.Pi*(h+m/60)/12)*a
	r, s := math.Cos(2.*math.Pi*m/60)*b, math.Sin(2.*math.Pi*m/60)*b
	fmt.Println(math.Sqrt((p-r)*(p-r) + (q-s)*(q-s)))
}


Measured memory_bytes: 1760
#include <iostream>

using namespace std;

int main()
{
    int d[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<d[k-1]<<endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by 黄道煜 on 2018/9/22.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#define LL long long
using namespace std;

int n, ans;
LL x, a[105];

int main()
{
    scanf("%d%lld", &n, &x);
    for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
    sort(a+1, a+n+1);
    for(int i=1; i<=n; i++) a[i]+=a[i-1];
    for(int i=1; i<=n; i++)
    {
        if(a[i]>x) {printf("%d\n", i-1); break;}
        if(a[i]==x) {printf("%d\n", i); break;}
    }
    if(a[n]<x) printf("%d\n", n-1);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, vector<long long> a, vector<long long> b, vector<long long> c) {
    vector<long long> sec(n);
    vector<long long> fir(n);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sec[0] = lower_bound(a.begin(), a.end(), b[0]) - a.begin();
    for (int i = 1; i < n; i++) {
        sec[i] = sec[i-1] + lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    }
    int tar = lower_bound(b.begin(), b.end(), c[0]) - b.begin() - 1;
    fir[0] = tar < 0 ? 0 : sec[tar];
    for (int i = 1; i < n; i++) {
        tar = lower_bound(b.begin(), b.end(), c[i]) - b.begin() - 1;
        fir[i] = tar < 0 ? 0 : fir[i-1] + sec[tar];
    }
    std::cout << fir[n-1] << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> c[i];
    }
    solve(n, a, b, c);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define ldb long double
const int N=305;
ldb dp[N][N][N];
int n;
bool was[N][N][N];
ldb DP(int a, int b, int c)
{
	if(a<0 || b<0 || c<0) return 0;
	if(a+b+c==0) return 0;
	if(was[a][b][c]) return dp[a][b][c];
	was[a][b][c]=1;
	dp[a][b][c]=(ldb)n/(a+b+c)+(DP(a,b+1,c-1)*c+DP(a+1,b-1,c)*b+DP(a-1,b,c)*a)/(a+b+c);
	return dp[a][b][c];
}
int main()
{
	int x,i,a=0,b=0,c=0;
	scanf("%i",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%i",&x);
		if(x==1) a++;
		if(x==2) b++;
		if(x==3) c++;
	}
	cout<<fixed<<setprecision(12)<<DP(a,b,c)<<"\n";
	return 0;
}

Measured memory_bytes: 465280
#include <stdio.h>

int main(void)
{
	int w_uni[10], k_uni[10];
	int i, j;
	int tmp1, tmp2;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &w_uni[i]);
	}
	
	for (i = 0; i < 10; i++){
		scanf("%d", &k_uni[i]);
	}
	
	for (i = 0; i < 10; i++){
		for (j = 9; j > i; j--){
			if (w_uni[j] < w_uni[j - 1]){
				tmp1 = w_uni[j - 1];
				w_uni[j - 1] = w_uni[j];
				w_uni[j] = tmp1;
			}
			
			if (k_uni[j] < k_uni[j - 1]){
				tmp2 = k_uni[j - 1];
				k_uni[j - 1] = k_uni[j];
				k_uni[j] = tmp2;
			}
		}
	}
	
	printf("%d %d\n", w_uni[7] + w_uni[8] + w_uni[9], k_uni[7] + k_uni[8] + k_uni[9]);
	
	return (0);
}

Measured memory_bytes: 596
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
//#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
const int N = 1e7+1;
int divs[N+1];
int32_t main()
{ 
   IOS
  

  int n;
  cin>>n;

  ll ans = 0;
  for(int i = 1;i<=n;i++){
    for(int j = i;j<=n;j+=i){
      divs[j]++;
    }
    ans += ((ll)i)*((ll)divs[i]);
  }

  cout<<ans<<endl;



  
}

Measured memory_bytes: 42708
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int K = in.nextInt();
            long start = 1;
            for (int i = 0; i < n; ++i) {
                start = Math.min(start + K, 2 * start);
            }
            out.println(start);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  priority_queue<P> q;
  int X, Y, A, B, C, o;
  cin >> X >> Y >> A >> B >> C;
  for (int i=0; i<A; i++) {
    cin >> o;
    q.push(make_pair(o, 1));
  }
  for (int i=0; i<B; i++) {
    cin >> o;
    q.push(make_pair(o, 2));
  }
  for (int i=0; i<C; i++) {
    cin >> o;
    q.push(make_pair(o, 0));
  }
  int a = 0;
  int b = 0;
  int c = 0;
  ll ret = 0;
  while (c + a + b < X + Y) {
    P p = q.top();
    q.pop();
    if (p.second == 1) {
      if (a >= X) continue;
      a++;
      ret += p.first;
    } else if (p.second == 2) {
      if (b >= Y) continue;
      b++;
      ret += p.first;
    } else {
      c++;
      ret += p.first;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 6256