akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define N_MAX 100001
#define NIL -1

struct node{
  int parent, sibiling, child;
};

int n;
node T[N_MAX];
int D[N_MAX];

void insert(){
  int i, j;
  int s, p, c, m, tmp_s;
  
  for(i=0; i<n; i++) T[i].parent=T[i].sibiling=T[i].child=NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &p, &m);

    for(j=0; j<m; j++){
      scanf("%d", &s);
      T[s].parent=p;
      
      if(j==0) T[p].child=s;
      else T[tmp_s].sibiling=s;

      tmp_s=s;	    
    }
  }  
}

void setd(int i, int d){
  D[i]=d;

  if(T[i].sibiling != NIL) setd(T[i].sibiling, d);
  if(T[i].child != NIL) setd(T[i].child, d+1);
}

void depth(){
  int i, root;
  
  for(i=0; i<n; i++){
    if(T[i].parent==NIL){
      root=i;
      break;
    }
  }

  setd(root, 0);
}

void print(int i){
  int j, s=T[i].child;
  printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);

  if(T[i].parent==NIL){
    printf("root, [");
    for(j=0; ; j++){
      if(j==0){
	if(s==NIL) break;
	printf("%d", s);
	s=T[s].sibiling;
      }
      else{
	if(s==NIL) break;
	printf(", %d", s);
	s=T[s].sibiling;
      }
    }
    printf("]\n");
  }
  else if(T[i].child==NIL) printf("leaf, []\n");
  else{
    printf("internal node, [");
    for(j=0; ; j++){
      if(j==0){
	if(s==NIL) break;
	printf("%d", s);
	s=T[s].sibiling;
      }
      else{
	if(s==NIL) break;
	printf(", %d", s);
	s=T[s].sibiling;
      }
    }
    printf("]\n");
  }
}

int main(void){
  int i;

  scanf("%d", &n);
  insert();
  depth();
  
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 7864
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string T,W;
    int count=0;
    int len_w,len_t,i;
    cin >> W;
    len_w=W.size();
    for(i=0;i<len_w;i++) if(W[i]>='A'&&W[i]<='Z') W[i]+=32;
    
    while(1) {
        cin >> T ;
        if(T=="END_OF_TEXT") break;
        len_t=T.size();
        for(i=0;i<len_t;i++) if(T[i]>='A'&&T[i]<='Z') T[i]+=32;
        if(T==W) count++;
    }
    
    cout <<count<<endl;
}



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

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

  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) {
    string s;
    cin >> s;
    if (s == "snuke") {
      cout << char('A'+j) << i+1 << endl;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair <int, int>
#define pb emplace
#define f first
#define s second

char g[1100][1100];
int h, w, dist[1100][1100];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
queue <pi> q;

void bfs() {
	while(q.size()) {
		int y = q.front().f;
		int x = q.front().s;
		q.pop();
		for(int i = 0; i < 4; ++i) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 1 || ny > h || nx < 1 || nx > w) continue;
			if (g[ny][nx] == '#') continue;
			if (dist[ny][nx] == -1) {
				q.pb(ny, nx);
				dist[ny][nx] = dist[y][x] + 1;
			}
		}
	}
}


int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int ans = 0;
	cin >> h >> w;
	memset(dist, -1, sizeof(dist));
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			cin >> g[i][j];
			if (g[i][j] == '#') {
				q.pb(i, j);
				dist[i][j] = 0;
			}
		}
	}
	bfs();
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 30052
#include <cstdio>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

typedef unsigned long long ull;

map<ull,int> memo;

int dfs2(ull, int, int);

int dfs1(ull s){
	if(s <= 0xff){
		return s / 10;
	}
	if(memo.count(s)){
		return memo[s];
	}
	int k;
	for(k = 8; !(s >> ((k - 1) * 8)); --k);

	int a = dfs2(s - (1ull << ((k - 1) * 8)), 10 - k, k);
	int b = dfs1(s & ((1ull << ((k - 1) * 8)) - 1));
	int res = max(a, b);

	memo[s] = res;
	return res;
}

int dfs2(ull s, int t, int u){
	if(t != 9 && s >> ((t - 1) * 8) & 0xff){
		return dfs1(s - (1ull << ((t - 1) * 8))) + 1;
	}
	if(t == 1){
		return 0;
	}
	if(t == 2){
		if((s & 0xff) >= 2){
			return dfs1(s - 2) + 1;
		}
		return 0;
	}
	if(t == 3){
		if(s & 0xff && s & 0xff00){
			return dfs1(s - 0x101) + 1;
		}
		if((s & 0xff) >= 3){
			return dfs1(s - 3) + 1;
		}
		return 0;
	}
	
	int res = 0;
	for(u = min(t, u); u >= 1; --u){
		if(s >> ((u - 1) * 8) & 0xff){
			int a = dfs2(s - (1ull << ((u - 1) * 8)), t - u, u);
			res = max(res, a);
		}
	}
	return res;
}

int main(){
	int n, x;
	while(scanf("%d", &n), n){
		int cnt[10] = {};
		for(int i = 0; i < n; ++i){
			scanf("%d", &x);
			++cnt[x];
		}
		
		int ans = 0;
		x = min(cnt[1], cnt[9]);
		cnt[1] -= x;
		cnt[9] -= x;
		ans = x;
		
		ull s = 0;
		for(int i = 1; i <= 8; ++i){
			s |= (ull)cnt[i] << ((i - 1) * 8);
		}
		
		memo.clear();
		ans += dfs1(s);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int ans=1e9;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    for(int i=0;i<s.size()-2;i++){
    	int x=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
    	ans=min(ans,abs(x-753));
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 256
import cmath
import math
ph = math.pi
A, B, H, M = map(float, input().split())
Aarg = 2*ph*H/12
Aarg += 2*ph*M/720
#a = cmath.rect(A, Aarg)
Barg = 2*ph*M/60
#b = cmath.rect(B, Barg)
#print(abs(a-b))
#print(Aarg/ph)
#print(Barg/ph)
print(math.sqrt(A**2+B**2-2*A*B*math.cos(Aarg-Barg)))

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

int main() {

long long t;
//cin >> t;
t = 1;
while(t--){
	int n,i;
	cin >> n;
	vector<int> v = {100, 101, 102,103,104,105};
	int z = v.size();
	int ispossible[1000001];
	ispossible[0] = 1;
	for(int i = 0; i < z; ++i){
		int value = v[i];
		if(ispossible[value]) continue;
		for(int j = 0; j + value < 1000001; ++j){
			if(ispossible[j])
				ispossible[j + value] = 1;
		}
	}
	if(ispossible[n]) cout << 1;
	else cout << 0;
}
return 0;
}

Measured memory_bytes: 4096
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	l := a + b
	r := c + d
	if l == r {
		fmt.Println("Balanced")
		return
	} else if l > r {
		fmt.Println("Left")
		return
	}
	fmt.Println("Right")
}


Measured memory_bytes: 512
#include<stdio.h>

int Binary(int);

int S[100000],ns;

int main(){
  int  nt, i, C=0;
  int T[100000];

  scanf("%d", &ns);

  for( i = 0 ; i < ns ; i++ ){
    scanf("%d", &S[i]);
  }

  scanf("%d", &nt);

  for( i = 0 ; i < nt ; i++ ){
    scanf("%d", &T[i]);
    if(Binary(T[i])){
       C++;
     }
  }

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

int Binary(int t){
  int l=0, r=ns, mid;
  while( l < r ){
    mid = ( l + r ) / 2;
    if( t == S[mid] ) {
      return 1;
    }
    if( t > S[mid] ){
      l = mid + 1;
    }
    else if( t < S[mid] ) {
      r = mid;
    }
  }
  return 0;
}



Measured memory_bytes: 2288
n = int(input())
list =['1','2','3','4','5','6','7','8','9','10','11','12','13']
S_list = list.copy()
H_list = list.copy()
C_list = list.copy()
D_list = list.copy()
for i in range(n):
    a = input()
    b = a.split(' ')
    if b[0] == 'S':
        S_list.remove('%s'%(b[1]))
    elif b[0] == 'H':
        H_list.remove('%s'%(b[1]))
    elif b[0] == 'C':
        C_list.remove('%s'%(b[1]))
    elif b[0] == 'D':
        D_list.remove('%s'%(b[1]))
for i in S_list:
    print('S '+i)
for e in H_list:
    print('H '+e)
for f in C_list:
    print('C '+f)
for g in D_list:
    print('D '+g)

Measured memory_bytes: 7752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// O(HW)
int H,W;
char maze[30][310];
int d[30][30];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(int sx,int sy){
    queue<pair<int,int>> que;
    rep(i,H){
        rep(j,W){
            d[i][j]=INF;
        }
    }

    int res=0;
    que.push(make_pair(sx,sy)); // (0,0)スタート
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
                res=max(res,d[nx][ny]);
            }
        }
    }

    return res;
}

int main(){
    cin>>H>>W;
    rep(i,H) rep(j,W) cin>>maze[i][j];

    int ans=0;
    rep(i,H){
        rep(j,W){
            if(maze[i][j]=='#') continue;
            ans=max(ans,bfs(i,j));
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;

int main()
{
	long long x,k,d,t;
	scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x);
	t=x/d;
	if(t>=k)
		x-=k*d;
	else
	{
		x-=t*d;
		k-=t;
		if(k%2)x-=d;
	}
	printf("%lld\n",abs(x));
}


Measured memory_bytes: 3796
(let* ((n (read))
       (m (read-line)))
  (defun f (j)
    (code-char (if (<= (+ (char-code j) n) 90)
                   (+ (char-code j) n)
                   (+ 64 (mod (+ (char-code j) n) 90)))))
  (princ (map 'string #'f m)))

Measured memory_bytes: 17512
#include<stdio.h>

int main(){

	double a, b, c, d, e, f;
	double x, y;

	while( scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF ){

		x = (1 / (a * e - b * d)) * (e * c - b * f);
		y = (1 / (a * e - b * d)) * (a * f - c * d);

		if(x == 0) x = 0; if(y == 0) y = 0;
		printf("%0.3lf %0.3lf\n", x, y);
	}

	return 0;
}

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

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n, vector<int>(26, n));
    for (int i = n-2; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i+1]-'a'] = i+1;
    }
    return res;
}

int main() {
    int N; cin >> N;
    string S = "";
    for (int i = 0; i < N; ++i) {
        string word; cin >> word;
        S += word[0];
    }
    auto next = calcNext(S);
    vector<int> dp(N+1, N);
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        dp[i+1] = min(dp[i+1], dp[i]+1);
        int ni = next[i][S[i]-'a'];
        if (ni >= N) continue;
        dp[ni] = min(dp[ni], dp[i]);
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 16568
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> D(N); rep(i, 0, N) cin >> D[i];
    int M; cin >> M;
    vector<int> T(M); rep(i, 0, M) cin >> T[i];

    map<int, int> mapD, mapT;
    rep(i, 0, N) mapD[D[i]]++;
    rep(i, 0, M) mapT[T[i]]++;

    bool res = true;
    for (auto itr = mapT.begin(); itr != mapT.end(); ++itr) {
        if (mapT[itr->first] > mapD[itr->first]) {
            res = false;
            break;
        }
    }

    cout << (res ? "YES" : "NO") << endl;
}

Measured memory_bytes: 20608
# -*- coding: utf-8 -*-
import sys

n = int(raw_input().split()[0])
a1 = [int(i) for i in raw_input().split()]
a2 = [int(i) for i in raw_input().split()]

maxA = 0
for i in range(1, n + 1):
    # print i, a1[:i], a2[i - 1:], 
    s = sum(a1[:i]) + sum(a2[i - 1:])
    if s > maxA:
        # print '!!!',
        maxA = s
    # print
sys.stdout.write('%d\n' % maxA)
sys.stdout.flush()


Measured memory_bytes: 2568
from bisect import bisect_left

n = int(input())
xyp = [list(map(int, input().split())) for i in range(n)]
inf = 1<<63
tate = [[] for i in range(1<<n)]
yoko = [[] for i in range(1<<n)]
state_ind = [[] for i in range(1<<n)]
for state in range(1<<n):
    tmp_x = [0]
    tmp_y = [0]
    for i in range(n):
        if state & (1<<i):
            tmp_x.append(xyp[i][0])
            tmp_y.append(xyp[i][1])
        else:
            state_ind[state].append(i)
    tmp_x.sort()
    tmp_y.sort()
    x_score = [0]*n
    y_score = [0]*n
    nn = len(tmp_x)
    mm = len(tmp_y)
    for i, (x,y,p) in enumerate(xyp):
        j = bisect_left(tmp_x,x)
        if j == 0:
            x_m = tmp_x[0]-x
        elif j == nn:
            x_m = x-tmp_x[nn-1]
        else:
            x_m = min(x-tmp_x[j-1], tmp_x[j]-x)
        j = bisect_left(tmp_y,y)
        if j == 0:
            y_m = tmp_y[0]-y
        elif j == mm:
            y_m = y-tmp_y[mm-1]
        else:
            y_m = min(y-tmp_y[j-1], tmp_y[j]-y)
        x_score[i] = x_m * p
        y_score[i] = y_m * p
    tate[state] = x_score
    yoko[state] = y_score

ans = [inf]*(1<<n)
for state in range(1<<n):
    j = state
    while j>=0:
        j &= state
        i = state^j
        tmp1 = 0
        for k in state_ind[state]:
            if tate[i][k] < yoko[j][k]:
                tmp1 += tate[i][k]
            else:
                tmp1 += yoko[j][k]
            if tmp1 >= ans[state]:
                break
        if tmp1 < ans[state]:
            ans[state] = tmp1 
        j -= 1

cnt = [0]*(1<<n)
for i in range(1<<(n-1)):
    cnt[2*i] = cnt[i]
    cnt[2*i+1] = cnt[i]+1

ans_k = [inf]*(n+1)
for state in range(1<<n):
    k = cnt[state]
    if ans_k[k] > ans[state]:
        ans_k[k] = ans[state]
print(*ans_k, sep="\n")


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

int main(){
  int a = 0, b = 0, c = 0, d = 0;
  int n[4];
  cin >> n[0] >> n[1] >> n[2] >> n[3];
  for(int i = 0; i < 4; i++){
    if(n[i] == 1) a++;
    else if(n[i] == 9) b++;
    else if(n[i] == 7) c++;
    else if(n[i] == 4) d++;
  }
  if(a == 1 && b == 1 && c == 1 && d == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  int v[60];
  
  cin >> N;
  for(i=0;i<N;i++){
      cin >> v[i];
  }

  sort(v, v + N);
  double sum = (double)(v[0]+v[1])/2.0;

  for(i=2;i<N;i++){
      sum = (sum + (double)v[i])/2.0;
  }

  cout << sum << endl;
  

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

n = int(input())

get = []
for i in range(10):
  npow6 = 6**(i+1)
  npow9 = 9**(i+1)
  if npow6 <= 100000:
    get.append(npow6)
  if npow9 <= 100000:
    get.append(npow9)
  
get = sorted(get)

memo = [-1] * 110000
for i in range(6):
  memo[i] = i
  
def dfs(money):
  if memo[money] != -1:
    return memo[money]
  ret = 110000
  for g in get:
    if g > money:
      continue
    ret0 = dfs(money-g) + 1
    ret = min(ret, ret0)
  memo[money] = ret
  return ret

print(dfs(n))

Measured memory_bytes: 19060
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a == 1 || b == 1) {
    if (a == b) {
      std::cout << "Draw" << "\n";
    } else if (a == 1) {
      std::cout << "Alice" << "\n";
    } else if (b == 1) {
      std::cout << "Bob" << "\n";
    }
  } else if (a == b) {
    std::cout << "Draw" << "\n";
  } else if (a < b) {
    std::cout << "Bob" << "\n";
  } else if (a > b) {
    std::cout << "Alice" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

tab = [] * 64
X_tmp = 1
for i in range(64):
    tab_tmp = 0
    for j, Aj in enumerate(A):
        tab_tmp += ((Aj >> i) & 0b1)
    tab.append(tab_tmp)

X_ans = 0
for i_inv in range(64):
    i = 63 - i_inv
    if X_ans + (1 << i) > K: continue
    elif tab[i] * 2 >= N: continue
    else:
        X_ans += (1 << i)

# print("#", X_ans)

ans = 0
for Ai in A:
    ans += (Ai ^ X_ans)
print(ans)

Measured memory_bytes: 14620
H = int(input())
W = int(input())
N = int(input())
counth = 0
countw = 0
while True:
    if (H-countw) < (W-counth) and countw < W:
        N -= (W-counth)
        countw += 1
    else:
        N -= (H-countw)
        counth += 1
    if N <= 0:
        break
 
 
print(counth+countw)

Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,C=get_i
ans=array(B,0)
x=A
loop do
  if ans[x]==1
      break
  else
      ans[x]=1
  end
  x+=A
  x%=B
end
if ans[C]==1
    puts "YES"
else
    puts "NO"
end

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, x, ans=0;
	ll a[100005];

	cin >> N >> x;
	rep(i,N) cin >> a[i];

	reps(i,1,N) if( a[i] + a[i-1] > x ){
		ll r = a[i] + a[i-1] - x;
		ans += r;
		ll m = min(r, a[i]);
		a[i] -= m;
		r -= m;
		a[i-1] -= r;
	}

	cout << ans << endl;

	return 0;
}

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


typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;
typedef vector<vll> vvll;


#define F first
#define S second
#define pb push_back
#define mp make_pair

// don't edit before this line 



//const ll inf = (ll)1e9 + 7; 



ll n;
vll arr;
pll memo[3001][3001][2];
bool check[3001][3001][2];

pll func(int i,int j,int t){

	if(i==j)
	{
		if(t==0)
			return mp(arr[i],0);
		else
			return mp(0,arr[i]);
	}
	
	if(check[i][j][t])
		return memo[i][j][t];
	

	check[i][j][t]=true;
	if(t==0)
	{
		auto xx = func(i+1,j,1-t);
		auto yy = func(i,j-1,1-t);
		xx.first+=arr[i];
		yy.first+=arr[j];
		//cout<<xx.F<<" "<<xx.S<<" " <<yy.F<<" "<<yy.S<<"\n";
		if(xx.first > yy.first )
			return memo[i][j][t]=xx;
		else
			return memo[i][j][t]=yy;
	}
	else
	{

		auto xx = func(i+1,j,1-t);
		auto yy = func(i,j-1,1-t);
		xx.second+=arr[i];
		yy.second+=arr[j];
		//cout<<xx.F<<" "<<xx.S<<" " <<yy.F<<" "<<yy.S<<"\n";
		if(xx.second > yy.second)
			return memo[i][j][t]=xx;
		else
			return memo[i][j][t]=yy;
	}
	
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n;
	arr.resize(n);

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

	for(int i=0;i<3001;i++)
		for(int j=0;j<3001;j++){
			check[i][j][0]=false;
			check[i][j][1]=false;
		}
	auto xx = func(0,n-1,0);
	cout<<xx.F-xx.S<<"\n";
	
	return 0;
}


Measured memory_bytes: 299520
#include<bits/stdc++.h>
using namespace std ;
#define Fors(n) for(int i=1;i<=n;i++)
#define For(n) for(i=0;i<n;i++)
#define ll unsigned long long
#define vint(s) vector<int> s
#define pb(x)  push_back(x)
#define mpair(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll x=0,y=0,n=0,i=0;

int main(){
    IOS;
     cin >> n;
    ll a[n];
    double s = 0,ans = 1;
    For(n){
    	cin >> a[i];
    	ans *= a[i];
    }
    for (i=0;i<n;i++){
    	s += (ans / double(a[i]));
    }
    ans /= s;
    printf("%0.5f",ans);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

A = [int(i) for i in input().split()]
A = np.array(A)

min_amari = min(A)
while 0==0:
  amari = A%min_amari
  amari = amari[amari!=0]
  if len(amari)==0:
    print(min_amari)
    break
  else:
    min_amari = min(amari)



Measured memory_bytes: 23124
#include<stdio.h>
#define MAX 5001

int max(int a,int b){
 if(a >b)return a;
 return b;
}


int f(int a[],int n){
 int t=a[0]; int s=a[0];
 for(int k=1;k<n;k++){
     t=max(t+a[k],a[k]);
     s=max(s,t);
 }
 return s;
}

int main(){
 int n;
 int a[MAX];

 while(1){

       scanf("%d",&n);
       if(n==0)break;

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

       printf("%d\n",f(a,n));

 }

return 0;
}


Measured memory_bytes: 1972
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    a.clear();a.reserve(n);

    fo(i,n)
    {
        cin>>in;
        cnt^=in&1;
    }

    cout<<(cnt?"NO":"YES")<<endl;

}   aryanc403();
    return 0;
}

Measured memory_bytes: 384
S = input()

A = 0
for b in range(pow(2,len(S)-1)):
    ans = 0
    sub = int(S[0])
    for s in S[1:]:
        if b%2==1:
            ans += sub
            sub = int(s)
        else:
            sub *= 10
            sub += int(s)
        b //= 2
    ans += sub
    A += ans
    
print(A)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string s1,s2;cin>>s1>>s2;
  for(int i=0;i<n;++i){
    cout<<s1[i]<<s2[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	map<string,vector<int> > m;
	map<string,vector<int> >::iterator it;
	vector<int>::iterator itv;
	string s;int a;
	while(cin>>s){
		cin>>a;
		m[s].push_back(a);
	}
	for(it=m.begin();it!=m.end();it++){
		cout<<it->first<<endl;
		sort(it->second.begin(),it->second.end());
		for(itv=it->second.begin();itv!=it->second.end() - 1;itv++)cout << *itv << ' ';
		cout << *itv << endl;
	}
}

Measured memory_bytes: 1244
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll D,N,T[200],A[200],B[200],C[200];
ll dp[200][200];//day: i   clothes: j  maximum C
int main()
{
	scanf("%lld%lld",&D,&N);
	for(ll i=0;i<D;i++){
		scanf("%lld",&T[i]);
	}
	for(ll i=0;i<N;i++){
		scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
	}
	for(ll i=0;i<N;i++){
		if(T[0]<A[i]||B[i]<T[0]) dp[0][i]=-1;
	}
	for(ll i=1;i<D;i++){
		for(ll j=0;j<N;j++){
			if(T[i]<A[j]||B[j]<T[i]) dp[i][j]=-1;
			else{
				for(ll k=0;k<N;k++){
					if(dp[i-1][k]>=0) dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(C[j]-C[k]));
				}
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<N;i++) ans=max(ans,dp[D-1][i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3516
/*
Author- Aasav Badera
Time- Sun Mar 22 17:56:09 2020
*/
#include<bits/stdc++.h> 
#define ll                 long long                            
#define pb                 push_back                                                     
#define s                  second
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define rep(i, a, b)         for(ll  i=a;i<b;i++)
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define f                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define mp                 make_pair
#define yes                cout << "YES" << endl;
#define no                 cout << "NO" << endl;
#define inf                1e18L+1
#define endl               '\n' 
using namespace std;
#define N  300005
ll cnt[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
        ll n;
        cin >> n;
        ll a[n];
        rep(i, 0, n)
        cin >> a[i];
        rep(i, 0 , n+100)
        	cnt[i] = 0;
        si s;
        rep(i, 0, n)
        {
        	cnt[a[i]]++;
        	s.insert(a[i]);
        }
        vi v(all(s));
        ll ans = 0;
        for(auto itr:v)
        {
        	ans += ((cnt[itr])*(cnt[itr]-1))/2;
        }

        rep(i, 0, n)
        {
        	ans -= (cnt[a[i]]*(cnt[a[i]]-1))/2;
        	ans += ((cnt[a[i]]-1)*(cnt[a[i]]-2))/2;
        	cout << ans << endl;
        	ans -= ((cnt[a[i]]-1)*(cnt[a[i]]-2))/2;
        	ans += (cnt[a[i]]*(cnt[a[i]]-1))/2;

        }
    }
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){

  for(int n,q;cin>>n>>q,n;){
    vector<pair<string, pair<int, int >>> era;

    for(int i=0;i<n;++i){
      string a;int b,c;
      cin>>a>>b>>c;
      era.push_back(make_pair(a,make_pair(c-b,c)));
    }

    for(int i=0;i<q;++i){
      int query;
      cin>>query;

      for(int j=0;j<n;++j){
        if(era[j].second.first<query&&query<=era[j].second.second){
          cout << era[j].first << " " << query-era[j].second.first << endl;
          break;
        }

        if(j==n-1) cout << "Unknown" << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1284
n = int(input())
t = list(int(i) for i in input().split())
m = int(input())
p = []
x = []
ans = sum(t)
for i in range(m):
  tmp1,tmp2 = (int(i) for i in input().split())
  p.append(tmp1)
  x.append(tmp2)
  print(ans-t[tmp1-1]+tmp2)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;


int main() {
  int n;
  cin >> n;
  vector<long long int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  bool odd = (x[0] + y[0]) % 2 ? true : false;

  for (int i = 0; i < n; i++) {
    if (odd && (x[i] + y[i]) % 2 == 0) {
      cout << -1;
      return 0;
    }
    if (!odd && (x[i] + y[i]) % 2) {
      cout << -1;
      return 0;
    }
  }


  vector<long long int> d(31, 1);
  for (int i = 0; i < d.size(); i++) {
    d[i] = 1 << i;
  }
  if (!odd) d.insert(d.begin(), 1);
  cout << d.size() << endl;
  for (int i = 0; i < d.size(); i++) cout << d[i] << ' ';
  cout << endl;
  for (int i = 0; i < n; i++) {
    long long int px = 0, py = 0;
    string s;
    for (int j = d.size() - 1; j >= 0; j--) {
      long long int ydiff = y[i] - py;
      long long int xdiff = x[i] - px;
      if (abs(xdiff) > abs(ydiff)) {
	if (xdiff < 0) {
	  s = "L" + s;
	  px -= d[j];
	}
	else {
	  s = "R" + s;
	  px += d[j];
	}
      }
      else {
	if (ydiff < 0) {
	  s = "D" + s;
	  py -= d[j];
	}
	else {
	  s = "U" + s;
	  py += d[j];
	}
      }
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P);
int solve();

int main(void){
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i=0;i<n;i++){
		scanf("%d",&T[i]);
	}
	llong ans=solve();
	printf("%d\n",ans);
	return 0;
}



int check(llong P){
	int i=0;
	for(int j=0;j<k;j++)
	{
		llong s=0;
		while(s+T[i]<=P)
		{
			s +=T[i];
			i++;
			if(i==n){
				return n;
			}
		}
	}
	return i;
}

int solve(){
	llong left=0;
	llong right=100000*10000;
	llong mid;
	while(right-left>1)
	{
		mid=(right+left)/2;
		int v=check(mid);
		if(v>=n){
			right=mid;
		}
		else{
			left = mid;
		}
	}
	return right;
}





Measured memory_bytes: 2576
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,i;
	scanf("%d",&n);
	double a[n];
	for(i=0;i<n;i++)
    scanf("%lf",&a[i]);
    sort(a,a+n);
    for(i=1;i<n;i++)
    {
    	a[i]=(a[i]+a[i-1])/2;
	}
	printf("%f",a[n-1]);
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
int H[N] = {};
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> H[i];
    int u, v;
    while (m--) {
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int val = 1;
        for (const int &v : G[i])
            if (H[i] <= H[v]) {
                val = 0;
                break;
            }
        ans += val;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    // 0: r, 1: s, 2: p
    // r: a, s: b, p: c
    unsigned long long res = 0;
    vector<char> play{'z'};
    char t;
    for(int i=1;i<=n;i++){
        cin >> t;
        if(t == 'r'){
             if(i <= k){
                 res += p;
                 play.push_back('p');
             } else {
                 if(play[i - k] == 'p'){
                     play.push_back('a');
                 } else {
                     res += p;
                     play.push_back('p');
                 }
             }
        }
        else if(t == 's'){
            if(i <= k){
                 res += r;
                 play.push_back('r');
             } else {
                 if(play[i - k] == 'r'){
                     play.push_back('b');
                 } else {
                     res += r;
                     play.push_back('r');
                 }
             }
        }
        else {
            if(i <= k){
                 res += s;
                 play.push_back('s');
             } else {
                 if(play[i - k] == 's'){
                     play.push_back('c');
                 } else {
                     res += s;
                     play.push_back('s');
                 }
             }
        }
    }
    cout << res << endl;


}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct edge{
    double p;//点
    double w;//辺の重み*-1
};
struct circle{
  double x;
  double y;
  double r;
};
vector<vector<edge>> graph(100000);
vector<double> res(100000);
double v,e,r;//vは頂点,eは辺,rは始点
void dijkstra(){
  for(int i = 0;i < v;i++)res[i] = pow(10,18);
    res[r] = 0;
    priority_queue<pair<double,double> > que;//重み、頂点
    que.push(make_pair(0,r));
    while(!que.empty()){
        edge now;
        now.p = que.top().second;
        now.w = que.top().first * -1;
        que.pop();
        if(res[now.p] < now.w)continue;
        for(int i = 0;i < graph[now.p].size();i++){
            if(res[graph[now.p][i].p] > now.w + graph[now.p][i].w){
                res[graph[now.p][i].p] = now.w + graph[now.p][i].w;
                que.push(make_pair(res[graph[now.p][i].p] * -1,graph[now.p][i].p));
            }
        }
      //cout << que.size() << " " << now.p << " " << now.w << endl;
    }
}
int main(){
  vector<circle> pos;
  double sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  circle s,t;
  s = {sx,sy,0};
  t = {tx,ty,0};
  pos.push_back(s);
  pos.push_back(t);
  double n = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    double nowx,nowy,nowr;
    cin >> nowx >> nowy >> nowr;
    circle now = {nowx,nowy,nowr};
    pos.push_back(now);
  }
  for(double i = 0;i < n + 1;i++){
    for(double j = i + 1;j < n + 2;j++){
      double cost = sqrt(pow(pos[i].x - pos[j].x,2) + pow(pos[i].y - pos[j].y,2)) - (pos[i].r + pos[j].r);
      if(cost < 0)cost = 0;
      edge memoi = {j,cost};
      edge memoj = {i,cost};
      graph[i].push_back(memoi);
      graph[j].push_back(memoj);
    }
  }
  r = 0;
  v = n + 2;
  e = (n + 2) * (n + 1) / 2;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < graph[i].size();j++){
      //cout << i << " " << graph[i][j].p << " " << graph[i][j].w << endl;
    }
  }
  dijkstra();
  cout << fixed << setprecision(20) << (double)res[1] << endl;
}

Measured memory_bytes: 25072
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if b < a:
        a,b = b,a
    if a <= c <= b:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = input()
    a = list(set(list(s)))
    k = II()-1
    for i in a:
        if s[k] != i:
            s = s.replace(i, "*")
    print(s)
    return

#C
def C():
    n = II()
    s = S()
    s.append(0)
    ans = 0
    for k in range(n):
        if s[k] == 0:
            break
        if s[k] == "#" and s[k + 1] == ".":
            ans += 1
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39280
/*
 * kadai3_3
 * kamecha
 */
#include<stdio.h>

int main(void){
    int num, base;
    scanf("%d %d", &num, &base);
    /*
     * 何桁かを求めれば良いので何回割れるかを求めればOK
     */
    int ans = 0;
    while(num > 0){
        num /= base;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

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

    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    
//    for (int i = 0; i < N; i++)
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    //out
    cout << d.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll  long long 
const ll INF=1LL<<60;
const ll MOD=1000000007;
const int MAX = 5000000;
long long moto[MAX], gyaku[MAX], inv[MAX];
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
void ncr_shokika() {
    moto[0] = moto[1] = 1;
    gyaku[0] = gyaku[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        moto[i] = moto[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        gyaku[i] = gyaku[i - 1] * inv[i] % MOD;
    }
}
long long ncr(int n, int r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return moto[n] * (gyaku[r] * gyaku[n - r] % MOD) % MOD;
}
int main(){
    ll a,b=1,c=2,d=1;cin>>a;
    rep(i,a){
        b*=10;
        b%=MOD;
    }
    rep(i,a){
        c*=9;
        c%=MOD;
    }
    rep(i,a){
        d*=8;
        d%=MOD;
    }
        b+=d;
    b%=MOD;
    b-=c;
    if(b<0)while(b<0)b+=MOD;
    cout<<b;
}

Measured memory_bytes: 3616
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> T(N),A(N);
	vector<int> L(N,0),H(N,INF);
	int MAX = 0;
	for(int i=0;i<N;++i){
		cin >> T[i];
		if( T[i] > MAX ){
			L[i] = T[i];
			H[i] = T[i];
			MAX = T[i];
		}else{
			H[i] = T[i];//最大値は同じ
			L[i] = 1;
		}
	}
	
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	MAX = 0;
	for(int i=N-1;i>=0;--i){//逆から
		if( A[i] > MAX ){
			if( L[i] <= A[i] && A[i] <= H[i] ){
				L[i] = A[i];
				H[i] = A[i];
				MAX = A[i];
			}else{
				//範囲外
				cout << 0 << endl;return;
			}
		}else{
			//[1,MAX]
			if( MAX < L[i] ){
				cout << 0 << endl;return;
			}else{
				L[i] = max(1,L[i]);
				H[i] = min(MAX,H[i]);
			}
		}
	}
	LL ans = 1;
	for(int i=0;i<N;++i){
		LL E,W;
		E = L[i];
		W = H[i];
		ans = (ans * (W-E+1)) % MOD;
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x, t; cin >> x >> t;
    if(t>=x) cout << 0 << endl;
    else cout << x-t << endl;
}

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

int main()
{
 int k,n,i;
  cin>>k;
  string s;
  cin>>s;
   n=s.size();
  if(k>=n)cout<<s;
  else
  {
   for(i=0;i<k;i++)
     cout<<s[i];
    cout<<"...";
  }
}


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

int main(void){
    int N,K,res=1;
    cin>>N>>K;
    rep(i,N){
        if(res*2<res+K)res*=2;
        else res+=K;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
# ABC 085
N, Y = [int(x) for x in input().split()]
#print(N,Y)#
Y //= 1000
c1m = Y // 10
c5c = Y // 5
c1c = Y
#print(c1m, c5c, c1c)
found = False
for i in range(c1m+1):
    for j in range(c5c+1):
        k = N - i - j
        #print(i,j,k)#
        if k>=0 and k<=c1c and i*10 + j*5 + k == Y:
            found = True
            break
    if found: break
if not found:
    i,j,k = -1,-1,-1
print('%d %d %d' % (i,j,k))


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int i,j,a[1000000];
  scanf("%d",&a[0]);
  for(i=1;;i++){
    if(a[i-1]%2)a[i]=3*a[i-1]+1;
    else a[i]=a[i-1]/2;
    for(j=0;j<i;j++)if(a[i]==a[j]){
      printf("%d",i+1);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>




const int N=1e5+10;
ll n,x,d,res,a[N];




void solve()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		d=a[i-1]+a[i]-x;
		if(d>0)
		{
			res+=d;
			if(a[i]>=d)
			{
				a[i]-=d;
				d=0;
			}
			else
			{
				d-=a[i];
				a[i]=0;
			}
			a[i-1]-=d;
		}
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::cout << (S.substr(0, 4) == "YAKI" ? "Yes" : "No") << std::endl;
  return 0;
}

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

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int[] num=sc.readIntL();
		int[] a=new int[]{num[0],num[1]};
		int[] b=new int[]{num[2],num[3]};
		
		int da=0;
		int db=0;
		da=a[0]-b[0];
		db=a[1]-b[1];
		//System.out.println(da);
		
		int[] c=new int[]{b[0]+db,b[1]-da};
		//System.out.println(c[0]);
		int[] d=new int[]{c[0]+da,c[1]+db};
		
		System.out.printf("%d %d %d %d\n",c[0],c[1],d[0],d[1]);
		
		//disp(num);
	}
	
	static void solve(){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			int i=sc.nextInt();
			return i;
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;

	vector<int> a(n);
	vector<int> b(m);


	REP(i, n) cin >> a[i];

	REP(i, m) cin >> b[i];

	sort(ALL(a));
	sort(ALL(b));

	if (a[n-1] < b[0]){
		if (x < b[0] && b[0] <= y){
			cout << "No War" << endl;
			return 0;
		}
	}

	cout << "War" << endl;

}


Measured memory_bytes: 256
#include "iostream"
#include "math.h"


int main()
{
	double x1, x2, y1, y2, result;
	std::cin >> x1 >> y1 >> x2 >> y2;
	x1 *= 1.0000000;
	x2 *= 1.0000000;
	y1 *= 1.0000000;
	y2 *= 1.0000000;
	x1 = x1 - x2;
	y1 = y1 - y2;
	result = hypot(x1, y1);
	std::cout << std::fixed << result << std::endl;
    return 0;
}

Measured memory_bytes: 3288