akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];

    sort(ALL(A));
    int alice = 0, bob = 0;
    REP(i, N) {
        if (i % 2 == 0) {
            alice += A[N - i - 1];
        }
        else {
            bob += A[N - i - 1];
        }
    }

    cout << alice - bob << endl;
    return 0;

}

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

unsigned long gcd(unsigned long a, unsigned long b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(void){
    unsigned long A, B;
    cin >> A >> B;
    cout << A * B / gcd(A, B) << endl;
}

Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n,m = map(int,ipt().split())
    go = [[] for i in range(n+1)]
    cm = [[] for i in range(n+1)]
    for i in range(n+m-1):
        a,b = map(int,ipt().split())
        cm[b].append(a)
        go[a].append(b)

    prnt = [-1]*(n+1)
    q = queue.Queue()
    for i in range(1,n+1):
        if not cm[i]:
            prnt[i] = 0
            for j in go[i]:
                q.put((j,i))
            break

    while not q.empty():
        qn,qp = q.get()
#        print(qn,qp)
        f = True
        for i in cm[qn]:
            if prnt[i] == -1 or prnt[i] == qp:
                f = False
                break

        if f:
            prnt[qn] = qp
            for i in go[qn]:
                q.put((i,qn))

    for i in prnt[1::]:
        print(i)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 101572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N=0;
    int flag=0;
    cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < N-1; i++) {
  if(vec.at(i)==vec.at(i+1)){
      flag=1;
      break;
  }
  }
  if(flag==0){
  cout << "YES" << endl;
  }
  else{
      cout << "NO" <<endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,a;
  int ans;
  cin >> h >> a;
  if(h%a==0){
    ans = h/a;
  }else{
    ans = h/a + 1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b, c;
    cin >> a >> b >> c;

    if(b/a >= c)
        cout << c << endl;
    else
        cout << b/a<< endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
fn main() {
    input!{
        a: i32,
        b: i32,
    }
    if let Some(v) = [a + b, a - b, a * b].iter().max() {
        println!("{}", v);
    }
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int64_t H, W, K;
    cin >> H >> W >> K;

    // P(H+W, K)
    int64_t all = 1;
    for(int i=0; i<K; i++) mul(all, H+W-i);
    
    // P(H+W-2, K-2)
    int64_t perm = 1;
    for(int i=H+W-K+1; i<=H+W-2; i++) mul(perm, i);

    int64_t corner = K * all % MOD;
    int64_t side = K*(K+1)/2 % MOD * all % MOD;

    int64_t inner = K*(K+1) % MOD * (2*K+1) % MOD * inv_mod(6) % MOD;
    add(inner, MOD - K*(K+1)/2 % MOD);
    mul(inner, H*W % MOD * perm % MOD);

    int64_t ans = (corner + side + inner) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll x[n],y[n];rep(i,0,n)cin>>x[i]>>y[i];
    double res = 0;
  	ll nn = 1;
    rep(i,1,n+1){
      nn *= i; 
      //cout << nn << endl;
    }
    rep(i,0,n){
        rep(j,0,n){
            res += (nn/n)*sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
        	//cout << res << ednl;
        }
    }
    cout << fixed << setprecision(10) << res / nn << endl;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

#define int uint64_t

using namespace std;

int calc_o(int x) {
    if (((x + 1) / 2) % 2 == 0) {
        return 0;
    } else {
        return 1;
    }
}

int calc(int x) {
    if (x % 2 == 0) {
        return x ^ calc_o(x - 1);
    } else {
        return calc_o(x);
    }
}

signed main()
{
    int A, B;
    cin >> A >> B;
    cout << (calc(A - 1) ^ calc(B)) << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(1000005);
    
    ll tmp = N;
    for (ll i = 2; i < 1000005; i++) {
        while(tmp % i == 0){
            A[i]++;
            tmp = tmp/i;
        }
    }

    ll ans = 0;

    if(tmp != 1){
        ans++;
    }

    ll tmp2;
    for (ll i = 2; i < 1000005; i++) {
        tmp = 1;
        tmp2 = A[i];
        while(tmp2 >= tmp){
            ans++;
            tmp2 -= tmp;
            tmp++;
        }
    }

    printf("%lld\n", ans);

}



Measured memory_bytes: 11176
S = input()

if S == "RRR":
    print(3)
elif S == "RRS":
    print(2)
elif S == "RSR":
    print(1)
elif S == "SSR":
    print(1)
elif S == "SRS":
    print(1)
elif S == "RSS":
    print(1)
elif S == "SRR":
    print(2)
else:
    print(0)

Measured memory_bytes: 9052
n = int(input())
li = [0]*5
for i in range(n):
  s = input()
  if s[0] == "M":
    li[0] += 1
  elif s[0] == "A":
    li[1] += 1
  elif s[0] == "R":
    li[2] += 1
  elif s[0] == "C":
    li[3] += 1
  elif s[0] == "H":
    li[4] += 1
ans = li[0]*li[1]*(li[2]+li[3]+li[4])+li[0]*li[2]*(li[3]+li[4])+li[0]*li[3]*li[4]
ans += li[1]*li[2]*(li[3]+li[4]) + + li[1]*li[3]*li[4] + li[2]*li[3]*li[4]
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

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

        int n;
        n = cin.nextInt();

        ArrayList<Integer> x  = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            x.add(cin.nextInt());
        }

        int xSquareMin = 1000000000;

        for (int i = 0; i < 101; i ++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                sum += (x.get(j) - i) * (x.get(j) - i);
            }
            if (sum < xSquareMin) {
                xSquareMin = sum;
            }
        }
        System.out.println(xSquareMin);
    }
}


Measured memory_bytes: 21844
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;

void main() {
	int n, m;
	scanf("%d %d\n", &n, &m);
	auto r = new int[m];
	foreach(i;0..n) {
		auto input = readln.chomp.split(" ").to!(int[]);
		foreach(a;input[1..$])
			++r[a-1];
	}
	size_t c;
	foreach(a; r)
		if (a == n)
			++c;
	c.write;
}


Measured memory_bytes: 256
wdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] 
answers = Array.new
while line = $stdin.gets
	yymm = line.chomp.split(/\s/).map{|n| n.to_i}
	break if yymm[ 0 ] == 0 
	day = Time.local( 2004, yymm[ 0 ], yymm[ 1 ], 0,0,0)
	answers << day.wday
end
answers.each{ |a| puts wdays[ a ] }


Measured memory_bytes: 6092
/************************************************
*Author        :  lrj124
*Created Time  :  2019.08.04.20:19
*Mail          :  1584634848@qq.com
*Problem       :  d
************************************************/
#include <bits/stdc++.h>
using namespace std;
int ans[100000],sum,posl;
string str;
bool w = true;
int main() {
	//freopen("d.in","r",stdin);
	//freopen("d.out","w",stdout);
	cin >> str;
	str += "R";
	for (size_t i = 1;i <= str.size();i++)
		if (w)
			if (str[i-1] == 'L') ans[i-1] += (sum+1)/2,ans[i] += sum/2,w ^= 1,sum = 1,posl = i;
			else sum++;
		else
			if (str[i-1] == 'R') ans[posl] += (sum+1)/2,ans[posl-1] += sum/2,w ^= 1,sum = 1;
			else sum++;
	for (size_t i = 1;i < str.size();i++) printf("%d ",ans[i]);
	//cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
// a,b,cの最大値、最小値をそれぞれminimumの参照先、maximumの参照先に代入する



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

    vector<int> a;
    int base =0;
    
    for (int i =0; i <n; i++)
    {
            int tmp;
            cin >>tmp;
            base+=tmp;
            a.push_back(tmp);
    }
    base = round((double)base/n);

    int result =0;
    for (int i =0; i <n; i++)
    {

        result +=(a.at(i)-base)*(a.at(i)-base);
    }

    cout << result <<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int change(char);

int main(void) {
  int n=0, sum=0;
  char c;
  while(scanf("%c", &c) != EOF) {
    if('0' <= c && c <= '9') {
      n *= 10;
      n += change(c);
    }
    else {
      sum += n;
      n = 0;
    }
  }
  cout << sum << endl;
  return 0;
}

int change(char c) {
  int n;
  if(c == '0') n = 0;
  if(c == '1') n = 1;
  if(c == '2') n = 2;
  if(c == '3') n = 3;
  if(c == '4') n = 4;
  if(c == '5') n = 5;
  if(c == '6') n = 6;
  if(c == '7') n = 7;
  if(c == '8') n = 8;
  if(c == '9') n = 9;
  return n;
}

Measured memory_bytes: 0
# include <bits/stdc++.h>
# define rr
const int N=20,INF=0x3f3f3f3f;
int c[N];
int a[N][N];
int tot[N];
int n,m,S;
int minx=1e9;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	n=read(),m=read(),S=read();
	for(rr int i=1;i<=n;++i){
		c[i]=read();
		for(rr int j=1;j<=m;++j){
			a[i][j]=read();
		}
	}
	for(rr int i=1;i<(1<<n);++i){
		int sum=0;
		memset(tot,0,sizeof(tot));
		for(rr int j=1;j<=n;++j){
			if(i&(1<<(j-1))){
				sum+=c[j];
				for(rr int k=1;k<=m;++k){
					tot[k]+=a[j][k];
				}
			}
		}
		for(rr int j=1;j<=m;++j){
			if(tot[j]<S){
				goto End;
			}
		}
		minx=std::min(minx,sum);
		End:;
	}
	printf("%d",minx==1e9?-1:minx);

	return 0;
}


Measured memory_bytes: 3760
a, b, k = map(int, input().split())

ans = 0
ans_k = 0

n = min(a, b)

for i in range(0, min(a, b)):
    if a % (n-i) == 0 and b % (n-i) == 0:
        ans_k += 1
        ans = (n-i)
        if ans_k == k:
            break

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(){
    int k;
    int a, b;
    int  flag = 0;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    for(int i = a; i <= b; ++i){
        if((i % k) == 0){
            flag = 1;
            break;
        }
    }
    if(flag == 1){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
}

Measured memory_bytes: 1660
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>

using namespace std;

map<int,int> ans;
int main ()
{
   int n,x,y;
   cin >> n>>x>>y;
   x--;y--;
   for(int i=0;i<n-1;i++){
     for(int j=i+1;j<n;j++){
       int k;
       k = min(abs(j-i),abs(x-i) + abs(y-j) + 1);
       //k= min({j - i, 1 + abs(i - x) + abs(j - y), 1 + abs(i - y) + abs(j - x)});
       //if(abs(j-i) <= abs(x-i) + abs(y-j) + 1) { k = abs(j-i);}
       //else k = abs(x-i) + abs(y-j) + 1;
       ans[k]++;
     }
   }
   for(int i=1;i<n;i++){
     cout << ans[i] << endl;
   }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define HEIGHT 12
#define WIDTH 6

enum { YET, ALREADY, LEFT, UP, RIGHT, DOWN };

int calcChain( void );
int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char, int );
void deleteGroup( int, int );
void deleteGroup_body( int, int, char, int );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ HEIGHT ][ WIDTH ];

int main( void ) {
	int i, j, n;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( i = 0; i < HEIGHT; i++ ) {
			for ( j = 0; j < WIDTH; j++ ) {
				scanf( "%c", &field[ i ][ j ].color );
				field[ i ][ j ].state = YET;
			}

			scanf( "%*c" );
		}

		printf( "%d\n", calcChain() );
	}

	return 0;
}

int calcChain( void ) {
	int chain;

	for ( chain = 0; ; chain++ ) {
		if ( !deleteBlock() )
			break;

		fallBlock();
	}

	return chain;
}

int deleteBlock( void ) {
	int i, j, deleted;

	deleted = 0;
	for ( i = 0; i < HEIGHT; i++ )
		for ( j = 0; j < WIDTH; j++ )
			if ( field[ i ][ j ].color != '.' && field[ i ][ j ].color != 'O' && field[ i ][ j ].state == YET )
				if ( findGroup( i, j ) >= 4 ) {
					deleted = 1;
					deleteGroup( i, j );
				}

	return deleted;
}

int findGroup( int i, int j ) {
	field[ i ][ j ].state = ALREADY;

	return findGroup_body( i, j + 1, field[ i ][ j ].color, LEFT ) + findGroup_body( i + 1, j, field[ i ][ j ].color, UP ) + 1;
}

int findGroup_body( int i, int j, char color, int comeDir ) {
	int tmp;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH || field[ i ][ j ].state == ALREADY || field[ i ][ j ].color != color )
		return 0;

	field[ i ][ j ].state = ALREADY;

	tmp = 0;
	if ( comeDir != LEFT )
		tmp += findGroup_body( i, j - 1, color, RIGHT );
	if ( comeDir != UP )
		tmp += findGroup_body( i - 1, j, color, DOWN );
	if ( comeDir != RIGHT )
		tmp += findGroup_body( i, j + 1, color, LEFT );
	if ( comeDir != DOWN )
		tmp += findGroup_body( i + 1, j, color, UP );
	
	return tmp + 1;
}

void deleteGroup( int i, int j ) {
	int color = field[ i ][ j ].color;

	field[ i ][ j ].color = '.';

	deleteGroup_body( i, j - 1, color, RIGHT );
	deleteGroup_body( i - 1, j, color, DOWN );
	deleteGroup_body( i, j + 1, color, LEFT );
	deleteGroup_body( i + 1, j, color, UP );
}

void deleteGroup_body( int i, int j, char color, int comeDir ) {
	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH )
		return;

	if ( field[ i ][ j ].color != color ) {
		if ( field[ i ][ j ].color == 'O' )
			field[ i ][ j ].color = '.';

		return;
	}

	field[ i ][ j ].color = '.';

	if ( comeDir != LEFT )
		deleteGroup_body( i, j - 1, color, RIGHT );
	if ( comeDir != UP )
		deleteGroup_body( i - 1, j, color, DOWN );
	if ( comeDir != RIGHT )
		deleteGroup_body( i, j + 1, color, LEFT );
	if ( comeDir != DOWN )
		deleteGroup_body( i + 1, j, color, UP );
}

void fallBlock( void ) {
	int i, j, cnt;

	for ( j = 0; j < WIDTH; j++ ) {
		cnt = 0;
		for ( i = HEIGHT - 1; i >= 0; i-- )
			if ( field[ i ][ j ].color == '.' )
				cnt++;
			else {
				field[ i + cnt ][ j ].color = field[ i ][ j ].color;
				field[ i + cnt ][ j ].state = YET;
			}

		for ( i = cnt - 1; i >= 0; i-- )
			field[ i ][ j ].color = '.';
	}
}

Measured memory_bytes: 596
#include <stdio.h>

int main()
{
    int i,n,a[100000],count=0,k,j;
  scanf("%d\n",&n);
  
   for(i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
      
       
   }
   for(i=1;i<n;i++)
   {
       if(a[a[i]]==i)
       {
           count++;
           
           a[a[i]]=0;
       }
    
   }
    
   printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 512
def main():
    sx, sy, tx, ty = map(int, input().split())
    result = "U" * (ty - sy)
    result += "R" * (tx - sx)
    result += "D" * (ty - sy)
    result += "L" * (tx - sx)

    result += "L"
    result += "U" * (ty - sy + 1)
    result += "R" * (tx - sx + 1)
    result += "D"
    result += "R"
    result += "D" * (ty - sy + 1)
    result += "L" * (tx - sx + 1)
    result += "U"
    print(result)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

long long gcd(int a, int b) {
    if (a < b) {
        return gcd(b, a);
    } else if (b == 0) {
        return a;
    } else if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    long long A, B; cin >> A >> B;
    cout << (A / gcd(A, B)) * B << endl;
}

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

int main(){
    double a,b,c,degree,S;
    scanf("%lf %lf %lf",&a,&b,&degree);
    S=(0.5)*a*b*sin(M_PI*degree/180);
    c=sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
    printf("%.6f\n%.6f\n%.6f\n",S,a+b+c,2*S/a);
}


Measured memory_bytes: 3444
n = gets.to_i
k = gets.to_i
ar = []
sum = 1

["0","1"].repeated_permutation(n).to_a.each do |v|
  v.count{|t| t == "0"}.times do
    sum *= 2
  end

  v.count{|s| s == "1"}.times do
    sum += k
  end
  ar << sum
  sum = 1
end

puts ar.min


Measured memory_bytes: 2172
#include <iostream>
#include <map>
#include <functional>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>

int rmax, n;
int d[260];
std::vector<std::set<int> > edges, edges2;

/*
0: テゥツ卍催」ツつ甘・ツ?コテ」ツ??
1~n: テ」ツδ榲」ツつケ
n + 1: テ、ツクツ甘」ツ?古」ツつ?
*/

int check(int idx) {
    idx += d[idx];
    if(idx <= 0) {
        return 0;
    }

    if(idx >= n + 1) {
        return n + 1;
    }

    return idx;
}

int main() {
    while(std::cin >> rmax, rmax) {
        std::cin >> n;

        edges.clear();
        edges.resize(n + 2);
        edges2.clear();
        edges2.resize(n + 2);

        for(int i = 1; i <= n; ++i) {
            std::cin >> d[i];
        }
        for(int i = 0; i <= n; ++i) {
            for(int j = 1; j <= rmax; ++j) {
                int to = check(i + j);

                if(i == to) {
                    continue;
                }
                edges[to].insert(i);
                edges2[i].insert(to);
            }
        }

        /*for(int i = 0; i < edges.size(); ++i) {
            for(std::set<int>::iterator it = edges[i].begin(); it != edges[i].end(); ++it) {
                std::cout << i << " " <<  *it << std::endl;
            }
        }*/

        bool used[260] = {}, used2[260] = {};
        std::queue<int> que;
        {
            que.push(n + 1);
            used[n + 1] = true;
            while(!que.empty()) {
                int p = que.front(); que.pop();

                for(std::set<int>::iterator it = edges[p].begin(); it != edges[p].end(); ++it) {
                    if(!used[*it]) {
                        que.push(*it);
                        used[*it] = true;
                    }
                }
            }
        }

        {
            que.push(0);
            used2[0] = true;
            while(!que.empty()) {
                int p = que.front(); que.pop();

                for(std::set<int>::iterator it = edges2[p].begin(); it != edges2[p].end(); ++it) {
                    if(!used2[*it]) {
                        que.push(*it);
                        used2[*it] = true;
                    }
                }
            }
        }

        bool ok = true;
        for(int i = 0; i <= n + 1; ++i) {
            //std::cout << i << " " << used2[i] << " " << used[i] << std::endl;
            if(used2[i] && !used[i]) {
                ok = false;
                break;
            }
        }

        std::cout << (ok ? "OK" : "NG") << std::endl;
    }
}

Measured memory_bytes: 1328
import math
input_line = input().rstrip().split()
N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
C = int(input_line[3])
D = int(input_line[4])

x = math.ceil(N/A)
x_t = B * x 
y = math.ceil(N/C)
y_t = D * y

print(min(x_t, y_t))





Measured memory_bytes: 5660
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

vector<pii> v;
int n;

const ll M = 1e9+7;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	
	for(int i = 0; i < n; ++i) {
		int c;
		cin >> c;
		v.push_back(pii(c,-1));
	}
	
	for(int i = 0; i < n; ++i) {
		int c;
		cin >> c;
		v.push_back(pii(c,1));
	}
	
	sort(v.begin(),v.end());
	ll c=0,t=1,d=1;
	for(int i = 0; i < 2*n; ++i) {
		if(!c || ((v[i].second < 0 )==(c < 0))) {
			if(!c) d = (d*t)%M;
			if(!c) t=1;
			c += v[i].second;
				
		} else {
			t = (t*abs(c))%M;
			c = c+v[i].second;
		}
	}
	cout << (abs(d*t))%M << "\n";
	
}

Measured memory_bytes: 2420
// Problem : E - Dividing Chocolate
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

string s[10];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int h, w, k;
    cin >> h >> w >> k;
    for (int i=0; i<h; i++)
        cin >> s[i];
    
    // cut i is between row i and row i+1
    int ret = INT_MAX;
    for (int mask=0; mask<1<<(h-1); mask++) {
        vector<int> cuts;
        for (int i=0; i<h-1; i++)
            if (mask & (1 << i))
                cuts.push_back(i);
        
        int cnt = cuts.size();
        bool ok = true;
        vector<int> blocks;
        for (int j=0; j<w && ok; j++) {
            int ptr = 0;
            vector<int> temp{0};
            for (int i=0; i<h; i++) {
                temp.back() += s[i][j] - '0';
                if (ptr < cuts.size() && cuts[ptr] == i) {
                    temp.push_back(0);
                    ptr++;
                }
            }
            bool cut = false;
            for (int i=0; i<temp.size(); i++)
                if (temp[i] + (j > 0 ? blocks[i] : 0) > k) {
                    if (temp[i] > k) {
                        ok = false;
                        break;
                    }
                    cut = true;
                }
            if (j == 0 || cut) {
                blocks = temp;
                if (cut) cnt++;
            } else {
                for (int i=0; i<temp.size(); i++)
                    blocks[i] += temp[i];
            }
        }
        
        if (ok)
            ret = min(ret, cnt);
    }
    
    cout << ret << "\n";

    return 0;
}


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

void call(int n)
{
	int i = 1;
	int x;

	do {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);
	putchar('\n');
}

#if 1
int main()
{
	int n;

	scanf("%d", &n);
	call(n);
	return 0;
}
#endif



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

int task(int n){
  int sum=0;
  if(n>36) return 0; if(n==36) return 1;

  for(int a=0;a<10;a++){
    if(n>(a+9+9+9)) continue;
    for(int b=0;b<10;b++){
      if(n>(a+b+9+9)) continue;
      for(int c=0;c<10;c++){
        if(n>(a+b+c+9))continue;
        for(int d=0;d<10;d++){
          if(n==(a+b+c+d)) sum++;
        }
      }
    }
  }
  return sum;
}

int main(){
  int n;
  while(cin>>n){
    int sum=0;
    sum=task(n);
    cout<<sum<<"\n";
  }
}




Measured memory_bytes: 2980
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 107 A "Train"
 *   https://abc107.contest.atcoder.jp/tasks/abc107_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Task task = new Task();
		task.run(in, out);

		in.close();
		out.close();
	}

	static class Task {

		public void run(InputScanner in, PrintWriter out) {

			int N = in.nextInt();
			int i = in.nextInt();

			out.println(N - i + 1);
		}
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public boolean hasNext() {
			return scanner.hasNext();
		}

		public int nextInt() {
			return Integer.parseInt(scanner.next());
		}

		public long nextLong() {
			return Long.parseLong(scanner.next());
		}

		public double nextDouble() {
			return Double.parseDouble(scanner.next());
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21204
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[3010][3010][3] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin >> N >> S;
    ll A[3010];
    rep(i,0,N) cin >> A[i];
    ll ans = 0;
    dp[0][0][0] = 1;
    rep(i,0,N){
        rep(j,0,S+1){
            if(j - A[i] >= 0){
               (dp[i+1][j][1] += dp[i][j - A[i]][0]) %= MOD;
               (dp[i+1][j][2] += dp[i][j - A[i]][0]) %= MOD;
               (dp[i+1][j][1] += dp[i][j - A[i]][1]) %= MOD;
               (dp[i+1][j][2] += dp[i][j - A[i]][1]) %= MOD;
            }
            (dp[i+1][j][0] += dp[i][j][0]) %= MOD;
            (dp[i+1][j][1] += dp[i][j][0]) %= MOD;
            (dp[i+1][j][1] += dp[i][j][1]) %= MOD;
            (dp[i+1][j][2] += dp[i][j][1]) %= MOD;
            (dp[i+1][j][2] += dp[i][j][2]) %= MOD;

        }
    }
    print(dp[N][S][2]);

}

Measured memory_bytes: 211968
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
bool DP[81][81][16001];
int main() {
  int H,W;
  cin >> H >> W;
  int A[H][W];
  int B[H][W];
  // A : +
  // B : -
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> B[i][j];
    }
  }
  DP[0][0][8000 + A[0][0] - B[0][0]] = true;
  DP[0][0][8000 - A[0][0] + B[0][0]] = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i != H-1) {
        for (int k = 0; k <= 16000; k++) {
          if (DP[i][j][k]) {
            DP[i+1][j][k+A[i+1][j]-B[i+1][j]] = true;
            DP[i+1][j][k-A[i+1][j]+B[i+1][j]] = true;
          }
        }
      }
      if (j != W-1) {
        for (int k = 0; k <= 16000; k++) {
          if (DP[i][j][k]) {
            DP[i][j+1][k+A[i][j+1]-B[i][j+1]] = true;
            DP[i][j+1][k-A[i][j+1]+B[i][j+1]] = true;
          }
        }
      }
    }
  }
  int ans = 100000;
  for (int i = 0; i <= 16000; i++) {
    if (DP[H-1][W-1][i]) {
      ans = min(ans, abs(i-8000));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 92924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	string ans="";
	string s;cin >> s;
	REP(i,s.size()){
		if(s[i]=='0') ans+='0';
		else if(s[i]=='1') ans+='1';
		else{
			if(!ans.size()) continue;
			else ans.erase(ans.end()-1);
		}
	}
	cout << ans << endl;
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 1e5 + 20;

int a[N][5], dp[N][5];

int32_t main(){

    sync;

    int n; cin >> n;
    for(int i = 1; i <= n; i++) for(int j = 1; j <= 3; j++) cin >> a[i][j];
  	for(int i = 1; i <= n; i++) {
  		dp[i][1] = a[i][1] + max(dp[i - 1][2], dp[i - 1][3]);
  		dp[i][2] = a[i][2] + max(dp[i - 1][1], dp[i - 1][3]);
  		dp[i][3] = a[i][3] + max(dp[i - 1][1], dp[i - 1][2]);
  	}
  	cout << max(dp[n][1], max(dp[n][2], dp[n][3]));

    return 0;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, M;
vector<pair<int, int>> edge;
vv<int> graph;
vector<double> E;

int main() {
    cin >> N >> M;
    edge.resize(M);
    graph.resize(N);
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        edge[i] = { s, t };
        graph[s].push_back(t);
    }

    E.assign(N, 1e18);
    E[N - 1] = 0;
    for (int v = N - 2; v >= 0; --v) {
        double a = 0;

        for (int u : graph[v]) {
            a += E[u] + 1.0;
        }

        double b = graph[v].size();
        E[v] = a / b;
    }

    double ans = E[0];

    rep(s, N) {
        double M = 0;
        int t = -1;
        for (int u : graph[s]) {
            if (chmax(M, E[u])) {
                t = u;
            }
        }
        if (t == -1) continue;

        for (int v = N - 2; v >= 0; --v) {
            double a = 0;

            for (int u : graph[v]) {
                if (v == s && u == t) continue;
                a += E[u] + 1.0;
            }

            double b = v == s ? graph[v].size() - 1 : graph[v].size();
            E[v] = a / b;
        }

        ans = min(ans, E[0]);
    }

    write(ans);
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   map<string, int> poll;
   cin >> N;
   rep(i, N) {
     string S;
     cin >> S;
     poll[S]++;
   }

   int max_poll = 0;
   for (auto p : poll) {
     max_poll = max(max_poll, p.second);
   }

   for (auto p : poll) {
     if (p.second == max_poll) cout << p.first << endl;
   }
 }


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

int main (){
  vector<int> A(9);
  for (int i=0;i<9;i++){
    cin>>A.at(i);
  }
  
  vector<int> ans(9);
  
  int N;
  cin >>N;
  
  for (int i=0;i<N;i++){
    int b;
    cin>>b;
    for (int j=0;j<9;j++){
      if(b==A.at(j)){
        ans.at(j) = 1;
      }
    }
  }
  int x=0;
  for (int i=0;i<3;i++){
    if (ans.at(i)==1 && ans.at(i+3)==1 && ans.at(i+6)==1){
      x++;
    }
  }
  if (ans.at(0)==1 && ans.at(1)==1 && ans.at(2)==1){
    x++;
  }
  if (ans.at(3)==1 && ans.at(4)==1 && ans.at(5)==1){
    x++;
  }
  if (ans.at(6)==1 && ans.at(7)==1 && ans.at(8)==1){
    x++;
  }
  if (ans.at(0)==1 && ans.at(4)==1 && ans.at(8)==1){
    x++;
  }
  if (ans.at(2)==1 && ans.at(4)==1 && ans.at(6)==1){
    x++;
  }
         
  if (x==0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

char shift_char(int shift_count, char char_in)
{
	char str[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int i, j;
	
	for (i = 0; i < 26; i++){
		if (char_in == str[i]) break;
	}
	
	j = (i + shift_count) % 26;
	
	if (j < 0) {
		j += 26;
	}
	return str[j];
}
int main(void)
{
	char str[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char str1[10000], str2[10000];
	int x, i, j, len;

	cin >> x >> str1;


	len = strlen(str1);

	for (i = 0; i<len; i++)
	{
		str2[i] = shift_char(x, str1[i]);
	}
	//終端にNULLを付加する
	str2[i] = '\0';
	cout << str2;

	return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  var line0 = tmp[0].split(" ");
  var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var n = Number(line0[0]);
  var k = Number(line1[0]);
//  var b = Number(line0[2]);

  var ans = 1;

  //console.log( n+" "+ k +" "+ " hoge ")
  
  for(var i=1; i <=n; i++){
    if(ans < k) ans *= 2;
    else ans += k;
  }

  console.log(ans);
  
  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>

using namespace std;

int main()
{
    long X;
    cin >> X;

    if (X >= 30 && X <= 40) {
        std::cout << "Yes" << std::endl;
    }
    if (X >= -40 && X < 30){
        std::cout << "No" << std::endl;
    }

}

Measured memory_bytes: 3132
void main()
{
    long n = rdElem;
    long[] p = rdRow;
    long[] q = rdRow;

    long num = 1;
    foreach (i; 2 .. n)
    {
        num *= i;
    }

    bool[] used = new bool[n+1];
    long a;
    long anum = num;
    foreach (i, x; p)
    {
        long cnt;
        foreach (j; 1 .. x)
        {
            if (used[j]) ++cnt;
        }

        a += anum * (x - cnt);
        used[x] = true;
        if (i != n - 1) anum /= (n - i - 1);
    }

    used[] = false;
    long b;
    long bnum = num;
    foreach (i, x; q)
    {
        long cnt;
        foreach (j; 1 .. x)
        {
            if (used[j]) ++cnt;
        }

        b += bnum * (x - cnt);
        used[x] = true;
        if (i != n - 1) bnum /= (n - i - 1);
    }

    abs(a-b).writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
s = input()
t = input()

s_char = []
t_char = []
for s_c in s:
    s_char.append(ord(s_c))
for t_c in t:
    t_char.append(ord(t_c))

s_char.sort()
t_char.sort(reverse=True)

s_len = len(s_char)
t_len = len(t_char)
min_len = min(s_len, t_len)
for i in range(min_len):
    if s_char[i] == t_char[i]:
        continue
    if s_char[i] < t_char[i]:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if s_len < t_len:
    print('Yes')
else:
    print('No')




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

int main()
{
    long long n;
    cin>>n;
    if(n%2==1){
        cout<<"0"<<endl;
        return 0;
    }
    long long t=n;
    long long num=0;
    t/=2;
    while(t){
        num+=t/5;

        t/=5;

    }
    cout<<num<<endl;



    return 0;
}


Measured memory_bytes: 256
N = int(input())
T = [int(TN) for TN in input().split()]
SumT = sum(T)
M = int(input())
PX = [[] for TM in range(0,M)]
for TM in range(0,M):
    PX[TM] = [int(TPX) for TPX in input().split()]
for TM in range(0,M):
    print(SumT-T[PX[TM][0]-1]+PX[TM][1])

Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

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

    int check[3];
    int checker;
    for(int i = N; i <= 999; ++i) {
        checker = i;
        check[0] = checker%10; checker /= 10;
        check[1] = checker%10; checker /= 10;
        check[2] = checker%10; checker /= 10;

        if (check[0] == check[1] && check[1] == check[2]) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

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

    string s;
    cin >> s;

    VI ans(s.length(), 0);
    int cnt[2] = {};
    FOR(i, 0, s.length()) {
        if (s[i] == 'R')cnt[i % 2]++;
        else {
            ans[i] += cnt[i % 2];
            ans[i - 1] += cnt[(i - 1) % 2];
            cnt[0] = 0, cnt[1] = 0;
        }
    }
    for (int i = s.length() - 1; i >= 0; i--) {
        if (s[i] == 'L')cnt[i % 2]++;
        else {
            ans[i] += cnt[i % 2];
            ans[i + 1] += cnt[(i + 1) % 2];
            cnt[0] = 0, cnt[1] = 0;
        }
    }

    cout << ans[0];
    FOR(i, 1, s.length())cout << " " << ans[i];
    cout << "\n";
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
int N;
map<pair<int, int>, long long> mp;
long long count (int a, int b) {
    pair<int, int> c = make_pair(a, b);
    if (mp.find(c) != mp.end())  return mp[c];
    int l = to_string(N).length();
    long long res = 0;
    if (a == b && a <= N) res++;
    for (int i = 0; i < l-2; i++) res += pow(10, i);
    long long m = a*pow(10, l-1) + b;
    long long M = m + (pow(10, l-2) - 1) * 10;
    if (m > N) {
        return mp[c] = res;
    }
    if (M <= N) {
        res += pow(10, l-2);
        return mp[c] = res;
    }
    res += (N/10 - a*pow(10, l-2));
    if (N >= (N/10)*10+b) res++;
    return mp[c] = res;
}
int main () {
    cin >> N;
    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            if (i == j) {
                ans += pow(count(i, j), 2);
            }
            else {
                ans += count(i, j) * count(j, i) * 2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256