akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()
    s.forEach {
        print('A' + (it - 'A' + n) % 26)
    }
    println()
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int a;
    string b;
    cin>>a>>b;
    string b2;
    b2.pb(b[0]);
    b2.pb(b[2]);
    b2.pb(b[3]);
    int b3=stoi(b2);
    int ans=a*b3/100;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>

int main(){
  int a,b,c,d,e;
  char z[8];
  scanf("%d",&a); 
  for(b=0;b<a;b++){
    c=d=e=0;
    while(c<3){
      scanf("%s",&z);
      if(z[1]=='U'){
        c++;
      }
      if(z[1]=='O'){
        d+=e+1;
        e=0;
      }
      if(z[1]=='I'){
        if(++e == 4){e--;d++;}
      }
    }
    printf("%d\n",d);
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = sS.Length - sS.Replace("2", "").Length;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

public class Main {
  public static void main (String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(br.readLine());
    int[] s = new int[n];
    String[] tmpS = br.readLine().split(" ");
    for(int i = 0; i < n; i++) {
      s[i] = Integer.parseInt(tmpS[i]);
    }
    tmpS = null;

    int q = Integer.parseInt(br.readLine());
    int[] t = new int[q];
    String[] tmpT = br.readLine().split(" ");
    for (int i = 0; i < q; i++) {
      t[i] = Integer.parseInt(tmpT[i]);
    }
    tmpT = null;

    int count = 0;
    for(int i : t) {
      if (binarySearch(s, i)) {
        count++;
      }
    }
    System.out.println(count);
  }

  private static boolean binarySearch(int[] array, int target) {
    int left = 0;
    int right = array.length;
    while (left < right) {
      int mid = (left + right) / 2;
      int temp = array[mid];
      if (target < temp) {
        right = mid;
        continue;
      }
      if (temp < target) {
        left = mid + 1;
        continue;
      }
      return true;
    }
    return false;
  }
}



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

#define N 255
typedef pair<int, int> pii;

pii f[N*3];
int n, m;

int dp[N<<1][N];

typedef long long ll;

void add(int &a, ll b) {
	a = (a + b) % m;
}

int main() {
	cin>>n>>m;
	for (int i = 0; i < n; i ++) f[i+1] = pii(sqrt(n * n - 1 - i * i) + 1, -i);
	for (int i = 0; i < 2 * n; i ++) f[n+i+1] = pii(min(2 * n - 1, (int)sqrt(4 * n * n - i * i)) + 1, 1);
	sort(f + 1, f + n * 3 + 1);
	int ans = 0;
	for (int up = 0; up <= n; up ++) {
		memset(dp, 0, sizeof dp);
		dp[0][0] = 1;
		int cu = 0, fu = 0;
		for (int i = 1; i <= 2 * n; i ++) {
			for (int j = 0; j <= up; j ++) if (dp[i-1][j]) {
				if (f[i].second == 1) {
					add(dp[i][j], 1ll * dp[i-1][j] * max(0, (f[i].first - cu - j)));
				}
				else {
					add(dp[i][j+1], -1ll * dp[i-1][j] * max(0, (f[i].first - cu - j)));
					int cur = -f[i].second;
					add(dp[i][j], 1ll * dp[i-1][j] * max(0, (f[3*n-cur].first - up - n - fu + j)));
				}
			}
			if (f[i].second == 1) cu ++;
			else fu ++;
		}
		add(ans, dp[2*n][up]);
	}
	if (ans < 0) ans += m;
	cout<<ans<<endl;
}


Measured memory_bytes: 768
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        for(int n=0; n<N; n++) H[n] = sc.nextInt();

        boolean[] highest = new boolean[N];
        Arrays.fill(highest, true);

        for(int m=0; m<M; m++){
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            if(H[A] <= H[B]) highest[A] =false;
            if(H[A] >= H[B]) highest[B] =false;
        }

        int ans = 0;
        for(int n=0; n<N; n++) if(highest[n]) ans++;
        System.out.println(ans);
    }
}


Measured memory_bytes: 59392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << (a <= b ? a : a - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b;

    while(1){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0)
             break;
        printf("%d %d\n",a < b ? a : b,a > b ? a : b);
    }
    return 0;
}

Measured memory_bytes: 596
s = list(input())
t = list(input())
mm = 0
min = len(t)
for i in range(len(s)-len(t)+1):
    sp = s[i:len(t)+i]
    for k in range(len(t)):
        if sp[k] != t[k]:
            mm += 1
    if min > mm:
        min = mm
    mm = 0
print(min)

Measured memory_bytes: 9092
nm_ent = list(map(int, input().split()))
n = nm_ent[0]
m = nm_ent[1]
full_ent = []
for i in range(0, n):
    full = list(map(int, input().split()))
    full_ent.append(full)
for k in range(0, n):
    full_ent[k].pop(0)   #2次元リストの各リストの先頭の数字を除外


#while以下は，2次元リストの1と2の共通の数字をリストとしてlist[1]に代入
#ついでlist[0]を消去し，今できたlist[0](=list[1])と本来のlist[2]を比較する
#それを繰り返す．
while True:
    if len(full_ent) == 1:
        out_flag = len(full_ent[0])
        break
    full_ent[1] = list(set(full_ent[0]) & set(full_ent[1]))
    full_ent.pop(0)

def out(out_flag):
    print(out_flag)

out(out_flag)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		int[] A = new int[9];
		for (int i = 0; i < 9; i++) {
			A[i] = scanner.nextInt();
		}

		final int N = scanner.nextInt();

		int ana = 0;
		int b;
		for (int i = 0; i < N; i++) {
			b = scanner.nextInt();
			for (int j = 0; j < 9; j++) {
				if (A[j] == b) {
					ana |= (1l << j);
					break;
				}
			}
		}

		int[] mask = { 0b111000000, 0b111000, 0b111, 0b100100100, 0b10010010, 0b1001001, 0b100010001, 0b1010100 };

		for (int i = 0; i < 8; i++) {
			if ((ana & mask[i]) == mask[i]) {

				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");

	}

}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    int m; cin >> m;
    VI b(m);
    REP(i, m) cin >> b[i];
    cout << (lexicographical_compare(ALL(a), ALL(b)) ? 1 : 0)
        << endl;
    return 0;
}



Measured memory_bytes: 3108
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	a = sort(a)
	x = Array{Int}(2,m)
	for i in 1:m
		x[:,i] = readline() |> split |> parseMap
	end
	x = sortcols(x,by=x->x[2],rev=true)
	b = zeros(Int,n)
	now = 0
	for i in 1:m
		if now+x[1,i]>=n
			b[now+1:n] .+= x[2,i]
			now = n
			break
		else
			b[now+1:now+x[1,i]] .+= x[2,i]
			now += x[1,i]
		end
	end
	m = 0
	for i in 1:n
		m += max(a[i],b[i])
	end
	println(m)
end
main()


Measured memory_bytes: 160164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	multiset <string> s;
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++) s.insert("a");
	for(int i=1;i<=b;i++) s.insert("b");
	for(int i=1;i<=c;i++) s.insert("c");
	while(s.size()>1)
	{
		string x=*s.begin();
		string y=*s.rbegin();
		s.erase(s.lower_bound(x));
		s.erase(s.lower_bound(y));
		s.insert(x+y);  
	}
	cout<<*s.begin();
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		List<Long> red = new ArrayList<>();
		List<Long> green = new ArrayList<>();
		List<Long> no = new ArrayList<>();
		for(int i = 0; i < a; i++) {
			red.add(sc.nextLong());
		}
		for(int i = 0; i < b; i++) {
			green.add(sc.nextLong());
		}
		for(int i = 0; i < c; i++) {
			no.add(sc.nextLong());
		}
		Collections.sort(red);
		Collections.reverse(red);
		Collections.sort(green);
		Collections.reverse(green);
		Collections.sort(no);
		Collections.reverse(no);
		List<Long> eat = new ArrayList<>();
		for(int i = 0; i < x; i++) {
			eat.add(red.get(i));
		}
		for(int i = 0; i < y; i++) {
			eat.add(green.get(i));
		}
		Collections.sort(eat);
		for(int i = 0; i < no.size(); i++) {
			if(eat.get(i) < no.get(i)) {
				eat.set(i, no.get(i));
			} else {
				break;
			}
		}
		long ans = 0;
		for(Long e : eat) {
			ans += e;
		}
		System.out.println(ans);

	}

}


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

int main()
{
	int x, y;
	cin >> x >> y;
	int temp = y - 2*x;
	if(temp < 0 || temp%2) 
	{
		cout << "No" << endl;
		return 0;
	}
	int temp2 = x-(temp/2);
	if(temp2 < 0)	
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main()
{
	long long N,K,Q,j,i,A[109000],B[100900],c[109000];
	while(cin>>N>>K>>Q)
	{
		for(i=0;i<N;i++)
		{
			c[i]=0;
		}
		for(i=0;i<Q;i++)
		{
			cin>>B[i];
			c[B[i]-1]+=1;
		}
		for(i=0;i<N;i++)
		{
			if(c[i]>Q-K){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}
	}
}

Measured memory_bytes: 2176
def D_RainFlowsintoDams():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    x = total - 2*sum([A[i] for i in range(1, N -1, 2)])
    for i in range(N):
        print(x, end=" ")
        x = 2 * A[i] - x
def D_Determinant():
    # 行列式を使うと時間がかかりすぎる
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    # XB = A のXを求める
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    # X^{-1} を求める
    B = np.linalg.solve(X, A.T)
    # 両辺に左からX^{-1}をかける
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()


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

#define MOD 1000000007

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << (n - 1) * (n - 3) / 2 + n - 1 << endl;
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (i + j != n) {
					cout << i << " " << j << endl;
				}
			}
			cout << i << " " << n << endl;
		}
	} else {
		cout << n * (n - 2) / 2 << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i + j != n + 1) {
					cout << i << " " << j << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()
S = S[:len(S)-1]

while len(S)!=0:
    l = len(S)
    if l%2==0:
        n = l//2
        A = S[:n]
        B = S[n:]
        # print(A,B)
        if A==B:
            print(l)
            exit()
        else:
            S = S[:l-1]
    else:
        S = S[:l-1]
print("Error")

Measured memory_bytes: 38512
N = int(input())
K = len(str(N))
MS = int(str(N)[0])
ML = int(str(N)[-1])
res = 0

for i in range(1, N+1):
    AS = int(str(i)[0])
    AL = int(str(i)[-1])

    if AL == 0:
        continue

    for k in range(1, K+1):
        if k == 1:
            if AS == AL and AS <= N:
                res += 1
            continue
        if k == 2:
            if int(str(AL) + str(AS)) <= N:
                res += 1
            continue
        if k < K:
            res += 10 ** (k - 2)
            continue
        if k == K:
            if AL > MS:
                continue
            if AL < MS:
                res += 10 ** (k - 2)
                continue
            if AL == MS:
                if AS <= ML:
                    res += (int(str(N)[1:])+9) // 10
                    continue
                else:
                    res += (int(str(N)[1:])) // 10
                    continue


print(res)


Measured memory_bytes: 43116
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int h;
    int w;
    char tmp_a;
    int f_h=0;
    int f_w=0;
    bool skip_hw;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    vector<vector<char>> a_h(h, vector<char>(w));
    vector<vector<char>> a_w(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> tmp_a;
            a[i][j]=tmp_a;
        }
    }

    for(int j=0; j<w; j++){
        skip_hw=true;
        for(int i=0; i<h; i++){
            if(a[i][j]=='#'){
                skip_hw=false;
            }
        }
        if(skip_hw==false){
            for(int i=0; i<h; i++){
                a_w[i][f_w]=a[i][j];
            }
            f_w++;
        }
    }

    for(int i=0; i<h; i++){
        skip_hw=true;
        for(int j=0; j<f_w; j++){
            if(a_w[i][j]=='#'){
                skip_hw=false;
            }
        }
        if(skip_hw==false){
            for(int j=0; j<f_w; j++){
                a_h[f_h][j]=a_w[i][j];
            }
            f_h++;
        }
    }
    //cout << f_h << " " << f_w << endl;

    for(int i=0; i<f_h; i++){
        for(int j=0; j<f_w; j++){
            cout << a_h[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
 
	int n,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0 || x%10==3 || x/10%10==3 || x/100%10==3 || x/1000%10==3){
			printf(" %d",i);
		} 
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int n,k;cin>>n>>k;

  int mul = 1;
  int d = 0;
  while(true){
    if (mul>n){
      cout << d << endl;
      return 0;
    }
    mul *= k;
    d++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string re(string S){
    string T = S;
    int n = S.size();
    for(int i = 0;i < n;i++){
        T[i] = S[n-i-1];
    }
    return T;
}
int main(){
    string S;
    cin >> S;
    re(S);
    bool frag = 1;
    long long int N = S.size();
    int a =0;
    S = re(S);
    for(int i = 0;i < 1000000;i++){
        bool A = 0;
        if(S.substr(0,5) == "maerd" || S.substr(0,5) == "esare"){
            S = S.substr(5,N-5);
            N = S.size();
            A = 1;
           
        }
        if(S.substr(0,6) == "resare"){
            S = S.substr(6,N-6);
            N = S.size();
            A = 1;
            
        }
        if(S.substr(0,7) == "remaerd"){
            S = S.substr(7,N-7);
            N = S.size();
            A = 1;
           
        }
        if(N == 0){
            frag = 1;
            break;
        }
        if(A){
            a++;
        }else{
            frag = 0;
        }
    }
    if(frag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
const int N=5007;
typedef long long i64;
int n,m,a[N],b[207][N],ls[N],rs[N],ss[N],sp=0;
i64 s[N][N],ans=0;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;++i)scanf("%d",a+i);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)scanf("%d",b[j]+i);
	}
	for(int i=1;i<=m;++i){
		int*B=b[i];
		for(int j=1;j<=n;++j){
			while(sp&&B[ss[sp]]<B[j])rs[ss[sp--]]=j-1;
			ss[++sp]=j;
		}
		while(sp)rs[ss[sp--]]=n;
		for(int j=n;j>=1;--j){
			while(sp&&B[ss[sp]]<=B[j])ls[ss[sp--]]=j+1;
			ss[++sp]=j;
		}
		while(sp)ls[ss[sp--]]=1;
		for(int j=1;j<=n;++j){
			int x1=ls[j],x2=j+1,y1=j,y2=rs[j]+1,a=B[j];
			s[x2][y2]+=a,s[x2][y1]-=a;
			s[x1][y2]-=a,s[x1][y1]+=a;
		}
	}
	for(int i=1;i<=n;++i){
		i64 s1=0,v1=0;
		for(int j=1;j<=n;++j)s[i][j]+=s[i][j-1];
		for(int j=1;j<=n;++j)s[i][j]+=s[i-1][j];
		for(int j=i;j<=n;++j){
			v1=s[i][j]-s1;
			if(v1>ans)ans=v1;
			s1+=a[j];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 200064
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    if s-i>2*k:
        continue
    else:
        for j in range(k+1):
            if s-i-j>k or s-i-j<0:
                continue
            else:
                ans+=1
print(ans)

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

using ll = long long;

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  int x[N], y[N];
  for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

  ll ans = 5e18;
  for (int i = 0; i < N; i++) { // x座標の左端
    for (int j = 0; j < N; j++) { // x座標の右端
      for (int k = 0; k < N; k++) { // y座標の下端
        for (int l = 0; l < N; l++) { // y座標の上端
          if (x[i] > x[j] || y[k] > y[l]) continue;
          
          // 4点で作られる長方形に囲まれる点の数を数える
          int cnt = 0;
          for (int m = 0; m < N; m++) {
            if (x[i] <= x[m] && x[m] <= x[j] && y[k] <= y[m] && y[m] <= y[l]) cnt++;
          }

          if (cnt >= K) ans = min(ans, 1LL * (x[j] - x[i]) * (y[l] - y[k]));
        }
      }
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int A,B,C;


int main(){

	cin >> A >> B >> C;

	if(A <= C && B >= C)
		cout << "Yes";
	else
		cout << "No";


}

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

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

    int answer = 0;

    if (N % 2 == 0){
        N = N - 1;
    }

    for (int i = 1; i <= N; i += 2){
        int count = 0;

        for (int j = 1; j <= i; j++){
            if (i % j == 0){
                count++;
            }
        }
        if (count == 8){
            answer++;
        }

    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#include<iomanip>
int main()
{
  double x[2],y[2];
  double length;
  cin >> x[0] >> y[0];
  cin >> x[1] >> y[1];
  length = sqrt(pow((x[0] - x[1]),2.0) + pow((y[0] - y[1]),2.0));
  setprecision(10);
  cout << fixed <<length<< endl;
  return 0;
}



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

int H, W;
char a[100][100];

int main() {
	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 + 2; i++){
		for(int j = 0; j< W + 2; j++){
			if(i == 0 || i == H + 1 || j == 0 || j == W + 1){
				cout<<"#";
			}else{
				//cout<<"("<<i<<", "<<j<<")";
				cout<<a[i-1][j-1];
			}
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <string.h>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#define ll long long int
#define pb push_back
#define x first
#define y second
#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 ri(x) scanf("%d", &x)
#define rl(x) scanf("%lld", &x)
using namespace std;

vector<ll> a;

void solve(){
	int n;
	ri(n);
	FOR(i, 0, n){
		ll u; 
		rl(u);
		a.pb(u);
	}
	ll s = 0;
	FOR(i, 0, n)
		s += a[i];
	s = s - n;
	printf("%lld",s);
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();	//トッピングの種類
		int baseprice = sc.nextInt();	//生地の値段
		int	topprice  = sc.nextInt();	//トッピングの値段
		int basecal = sc.nextInt();	//生地のカロリー
		int topcal [] = new int[N];
		for(int i = 0; i < N; i++){
			topcal [i] = sc.nextInt();	//トッピングのカロリー
		}
		Arrays.sort(topcal);
		for(int i = N;i > 0;i--){
			int sumcal = basecal + topcal[i-1];
			int sumprice = baseprice + topprice;
			if((sumcal)/(sumprice)>=(basecal/baseprice)){
				basecal += topcal[i-1];
				baseprice += topprice;
				}
			}
		System.out.println(basecal/baseprice);
	}

}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, count, ans = 1;
	
	cin >> N;
	
	int H[N];
	
	for(int i=0; i<N; i++)
		cin >> H[i];
	
	for(int i=1; i<N; i++){
		count = 0;
		for(int j=0; j<i; j++){
			if(H[i] >= H[j])
				count++;
		}
		if(count == i)
			ans++;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
using namespace std;
int main() {
	long long sum = 0;
	int n; cin >> n;
	for (int i = 1; i < n; ++i) sum += i;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    set<string> S;
    REP(i, N)
    {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 19096
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    int d=0;
    int m=0;
    for(int i=0; i<n; i++){
      int x = sc.nextInt();
      if(i==0){
        m=x;
      }
      else if(i==1){
        d=x-m;
        ans=x-m;
        if(x<m){
          m = x;
        }
      }
      else{
        d=x-m;
        if(d>ans){
          ans = d;
        }
        if(x<m){
          m = x;
        }
      }
    }
    System.out.println(ans);
  }
}



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string S;
  cin >> S;
  int len = S.length();
  int bcount = 0;
  int ans = 0;
  rep(i, len) {
    if (S[i] == 'B') {
      bcount++;
    } else {
      ans += bcount;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

char color[] = "RYGB";
int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  vector<string> a(n, string(m, ' '));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int u = (i + j) / d;
      int v = (i - j + m - 1) / d;
      a[i][j] = color[(u + 2 * v) % 4];
    }
  }
  for (int i = 0; i < n; ++i) {
    puts(a[i].c_str());
  }
  return 0;
}


Measured memory_bytes: 768
def main():
    _, x = map(int, input().split())
    a = [int(s) for s in input().split()]

    print(solve(a, x))

def solve(a, x):
    b = 0
    s = 0

    for t in a:
        b = min(x - b, t)
        s += t - b
    
    return s

main()


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

inline int read(){
	int res=0,f=1;char ch=' ';
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){res=res*10+ch-'0';ch=getchar();}
	return res*f;
}
const int N=1e5+5;
const int mod=998244353;
int n,S,T;
int d[N],flag[N];
int head[N*20],to[N*20],w[N*20],nxt[N*20],cnt;
inline void qxx(int x,int y,int z){
	cnt++;nxt[cnt]=head[x];head[x]=cnt;to[cnt]=y;w[cnt]=z;
}
inline void SPFA(){
	memset(d,63,sizeof(d));
	queue<int>q;q.push(S);d[S]=0;flag[S]=1;
	while(!q.empty()){
		int k=q.front();q.pop();flag[k]=0;
		for(register int i=head[k];i;i=nxt[i]){
			int kk=to[i];
			if(d[kk]>d[k]+w[i]){
				d[kk]=d[k]+w[i];
				if(!flag[kk]){
					flag[kk]=1;q.push(kk);
				}
			}
		}
	}
}
int main(){
	n=read();
	S=0;T=1;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=9;j++)
			qxx(i,((i-1)*10+j)%n+1,j);
	for(register int i=1;i<=9;i++) qxx(0,i+1,i);
	SPFA();
	printf("%d\n",d[1]);
	return 0;
}

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

typedef unsigned int hash_t;

constexpr int MAX_LEN = 5000;
constexpr hash_t base = 1000000007;
hash_t pows[MAX_LEN + 1];

class rolling_hash {
private:
	vector<hash_t> hashes;

public:
	rolling_hash(const string &s):hashes(s.size() + 1) {
		hashes[0] = 0;
		for(unsigned i = 0; i < s.size(); ++i) {
			hashes[i + 1] = hashes[i] * base + s[i];
		}
	}

	hash_t hash(int l, int r) const {
		return hashes[r] - hashes[l] * pows[r - l];
	}

	static hash_t hash(const string &s) {
		hash_t res = 0;
		for(const auto &c : s) {
			res *= base;
			res += c;
		}
		return res;
	}
};

void init() {
	pows[0] = 1;
	for(int i = 1; i <= MAX_LEN; ++i) {
		pows[i] = pows[i - 1] * base;
	}
}

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

	init();

	for(int n, m; cin >> n >> m && n;) {
		vector<string> query(n);
		vector<hash_t> query_hashes(n);

		for(int i = 0; i < n; ++i) {
			cin >> query[i];
			query_hashes[i] = rolling_hash::hash(query[i]);
		}

		string text = "";
		for(int i = 0; i < m; ++i) {
			string s;
			cin >> s;
			text += move(s);
		}

		const int len = text.size();
		rolling_hash rh(text);

		vector<vector<bool>> dp(len + 1, vector<bool>(1 << n, false));

		for(auto &vec : dp) {
			vec[0] = true;
		}

		for(int i = 0; i < len; ++i) {
			for(int j = 0; j < (1 << n) - 1; ++j) {
				if(!dp[i][j]) continue;

				for(int k = 0; k < n; ++k) {
					const int r = i + query[k].size();
					if((j & (1 << k)) || r > len) continue;
					if(query_hashes[k] == rh.hash(i, r)) {
						dp[r][j | (1 << k)] = true;
					}
				}
			}
		}

		int ans = 0;
		for(const auto &vec : dp) {
			if(vec[(1 << n) - 1]) ++ans;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4056
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a >>b;
	c = 1;
	
	for (int i = 0; i < a; i++) {
		if (c < b) {
			c *= 2;
		}
		else {
			c += b;
		}
	}

	cout << c << endl;
	

	return 0;

}


Measured memory_bytes: 2304
function main()
  n,d=parse.(split(readline()))
  m=[[parse(Int,j) for j=split(readline())]for i=1:n]
  ans=0
  for i=1:n-1
    for j=i+1:n
      ans+=isinteger((sum([i^2 for i=m[i]-m[j]]))^(1/2))
    end
  end
  print(ans)
end
main()

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

typedef long long ll;
using namespace std;

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

	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << a[2]*10+a[1]+a[0] << endl;	

	return 0;

}


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



int main() {
	int n; cin >> n;
	int a[20]; for (int i = 0; i < n; i++) { cin >> a[i]; }
	int b = 0; for (int i = 0; i < n; i++) { int bb; cin >> bb; b += bb; }
	int c[20]; for (int i = 0; i < n - 1 ; i++) { cin >> c[i]; }

	int ans = b;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1] + 1) ans += c[a[i - 1] - 1];
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mz 1000000007

using namespace std;

double dp[606][605];
int cnt[606];
bool life[606][606];

int main()
{
    int n,m,x,y,now=1;
    double maxx,minn;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        cnt[x]++;
        life[x][y]=1;
    }
    for(int i=n-1;i>=1;i--)
    {
        maxx=-1;
        minn=1;
        for(int j=i+1;j<=n;j++)
            if(life[i][j])
            {
                dp[i][0]+=dp[j][0];
                maxx=max(maxx,dp[j][0]);
                for(int k=i+1;k<=n;k++)
                    dp[i][k]+=dp[j][k];
            }
        for(int j=1;j<=i;j++)
            dp[i][j]=dp[i][0]/cnt[i]+1;
        for(int j=i+1;j<=n;j++)
            dp[i][j]=dp[i][j]/cnt[i]+1;
        if(cnt[i]!=1)
            dp[i][i]=(dp[i][0]-maxx)/(cnt[i]-1)+1;

        dp[i][0]=dp[i][0]/cnt[i]+1;
        //cout<<i<<":"<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }
    for(int i=1;i<=n;i++)
        dp[1][0]=min(dp[1][0],dp[1][i]);
    printf("%.8f\n",dp[1][0]);
	return 0;
}


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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Read();
		var b = Read();

		var m = 1 << 30;
		for (BInt x = 0; x.V < (1 << n); x++)
		{
			var c = new (int, bool)[n];
			for (int i = 0; i < n; i++)
				c[i] = (x[i] ? b[i] : a[i], x[i]);
			m = Math.Min(m, Swap(c));
		}
		Console.WriteLine(m == 1 << 30 ? -1 : m);

		int Swap((int v, bool rev)[] c)
		{
			var g = Array.ConvertAll(c, _ => _.v);
			Array.Sort(g);
			var u = new bool[n];

			var map = new int[n];
			for (int i = 0; i < n; i++)
			{
				map[i] = -1;
				for (int j = 0; j < n; j++)
				{
					if (u[j] || g[i] != c[j].v || (i - j) % 2 != 0 != c[j].rev) continue;
					u[j] = true;
					map[i] = j;
					break;
				}
				if (map[i] == -1) return 1 << 30;
			}

			var t = 0;
			for (int i = 0; i < n; i++)
				for (int j = i + 1; j < n; j++)
					if (map[i] > map[j]) t++;
			return t;
		}
	}
}

struct BInt
{
	public int V;
	public bool this[int i] => (V & (1 << i)) != 0;
	public BInt(int v) => V = v;

	public static implicit operator BInt(int v) => new BInt(v);
	public static BInt operator ++(BInt v) => v.V + 1;
}


Measured memory_bytes: 47020
#include <stdio.h>
#include <string.h>

typedef struct {
	char c;
	char *code;
} TABLE;

TABLE table1[] = {
	{'A', "00000"},
	{'B', "00001"},
	{'C', "00010"},
	{'D', "00011"},
	{'E', "00100"},
	{'F', "00101"},
	{'G', "00110"},
	{'H', "00111"},
	{'I', "01000"},
	{'J', "01001"},
	{'K', "01010"},
	{'L', "01011"},
	{'M', "01100"},
	{'N', "01101"},
	{'O', "01110"},
	{'P', "01111"},
	{'Q', "10000"},
	{'R', "10001"},
	{'S', "10010"},
	{'T', "10011"},
	{'U', "10100"},
	{'V', "10101"},
	{'W', "10110"},
	{'X', "10111"},
	{'Y', "11000"},
	{'Z', "11001"},
	{' ', "11010"},
	{'.', "11011"},
	{',', "11100"},
	{'-', "11101"},
	{'\'', "11110"},
	{'?', "11111"}
};
	
TABLE table2[] = {
	{' ', "101"},
	{'\'', "000000"},
	{',', "000011"},
	{'-', "10010001"},
	{'.', "010001"},
	{'?', "000001"},
	{'A', "100101"},
	{'B', "10011010"},
	{'C', "0101"},
	{'D', "0001"},
	{'E', "110"},
	{'F', "01001"},
	{'G', "10011011"},
	{'H', "010000"},
	{'I', "0111"},
	{'J', "10011000"},
	{'K', "0110"},
	{'L', "00100"},
	{'M', "10011001"},
	{'N', "10011110"},
	{'O', "00101"},
	{'P', "111"},
	{'Q', "10011111"},
	{'R', "1000"},
	{'S', "00110"},
	{'T', "00111"},
	{'U', "10011100"},
	{'V', "10011101"},
	{'W', "000010"},
	{'X', "10010010"},
	{'Y', "10010011"},
	{'Z', "10010000"}
};


int main(void)
{
	char str[1000];
	int i, j;
	char bin[4000];
	int pos;
	
	while (fgets(str, 1000, stdin) != NULL){
		i = 0;
		bin[0] = '\0';
		while (str[i] != '\n'){
			for (j = 0; table1[j].c != str[i]; j++);
			strcat(bin, table1[j].code);
			i++;
		}
		
		pos = 0;
		while (1){
			for (i = 0; i < 32; i++){
				if (strncmp(&bin[pos], 
				    table2[i].code,
					strlen(table2[i].code)) == 0){
					
					printf("%c", table2[i].c);
					pos += strlen(table2[i].code);
					break;
				}
			}
			if (i == 32){
				break;
			}
		}
		
		printf("\n");
		
//		printf("%s\n", bin);
	}
	
	return (0);
}

Measured memory_bytes: 0