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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}

//main------------------------------------------------------------------------------------------

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

    int n, k; cin >> n >> k;

    int ans = 1;

    rep(i,0,n){
        ans = min(ans + k, ans * 2);
    }
    print(ans);

 




}

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

using namespace std;

const int MOD = 1e9 + 7;

char s[5005];
long long dp[5005][5005];

void add(long long &x, long long y) {
	x = (x + y) % MOD;
}

int main() {
	int n;
	scanf("%d%s", &n, s + 1);
	
	int l = strlen(s + 1);
	
	dp[0][0] = 1LL;
	
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j + 1 <= l) add(dp[i][j], 2LL * dp[i - 1][j + 1]);
			else add(dp[i][j], dp[i - 1][j + 1]);
			
			if (j <= l) {
				if (j == 0) add(dp[i][j], dp[i - 1][j]);
				else add(dp[i][j], dp[i - 1][j - 1]);
			}
			else {
				add(dp[i][j], 2LL * dp[i - 1][j - 1]);
			}
		}
	}
	
	printf("%lld\n", dp[n][l]);
}


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

int N, M;
vector<int> G[100009];
long long dp[100009];

void dfs1(int v, int p) {
    dp[v] = 1;
    for(int u : G[v]) {
        if(u != p) {
            dfs1(u, v);
            dp[v] *= dp[u] + 1;
            dp[v] %= M;
        }
    }
}

void dfs2(int v, int p, long long dp_p) {
    int n = G[v].size();
    // 積を累積しておく配列
    vector<long long> mul1(n), mul2(n);
    for(int i = 0; i < n; i++) {
        int u = G[v][i];
        if(u == p) {
            mul1[i] = mul2[i] = (dp_p + 1) % M;
            dp[v] *= dp_p + 1;
            dp[v] %= M;
        } else
            mul1[i] = mul2[i] = (dp[u] + 1) % M;
    }
    for(int i = 0; i + 1 < n; i++) {
        mul1[i + 1] *= mul1[i];
        mul1[i + 1] %= M;
    }
    for(int i = n - 1; i - 1 >= 0; i--) {
        mul2[i - 1] *= mul2[i];
        mul2[i - 1] %= M;
    }

    for(int i = 0; i < n; i++) {
        int u = G[v][i];
        if(u != p) {
            long long a = (i ? mul1[i - 1] : 1);
            long long b = (i + 1 < n ? mul2[i + 1] : 1);
            dfs2(u, v, a * b % M);
        }
    }
}

int main() {
    cin >> N >> M;
    for(int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dfs1(0, -1);
    dfs2(0, -1, 1);

    for(int i = 0; i < N; i++)
        cout << dp[i] << endl;
}

Measured memory_bytes: 18816
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
using ll = long long;
using db = long double;
const int N = 1 << 17, MOD = 1e9 + 7;

int main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);cin.tie(0);
#endif // ONLINE_JUDGE

  	int n, k;
  	cin >> n >> k;

  	if((n-1) * (n-2) / 2 < k)cout << -1 << '\n';
  	else {
  		std::vector<pair<int, int>> e;
  		for(int i = 2; i <= n; i++)
  			e.push_back({1, i});
  		int cur = (n - 1) * (n - 2) / 2;

  		for(int i = 2; i <= n; i++)
  			for(int j = i + 1; j <= n && cur > k; j++){
  				e.push_back({i, j});
  				cur--;
  			}
  		cout << e.size() << '\n';
  		for(auto x : e)
  			cout << x.first << ' ' << x.second << '\n';
  	}

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int N, H; scanf("%d%d", &N, &H);

  int max_a = 0;
  priority_queue<int> q;
  rep(i, N) {
    int a, b; scanf("%d%d", &a, &b);
    q.push(b);
    max_a = max(max_a, a);
  }
  int ans = 0;
  while (!q.empty()) {
    int p = q.top(); q.pop();
    if (p < max_a)
      break;
    H -= p;
    ++ans;
    if (H <= 0)
      break;
  }
  if (H > 0)
    printf("%d\n", ans + (H + max_a-1) / max_a);
  else
    printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 892
n, k, q = map(int, input().split())
man = [0] * n
#合計正解数はq
for i in range(q):
    man[int(input()) - 1]+=1

for i in range(n):
    if k - (q - man[i]) >= 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int w,h,n, mode;
    cin>>w>>h>>n;
    int c[4]={0,w,0,h};
    vector<pair<int,int>>x(n);
    for(int i=0;i<n;i++){
            cin>>x[i].first>>x[i].second>>mode;
            switch(mode){
                case 1:c[0]=max(c[0],x[i].first);break;
                case 2:c[1]=min(c[1],x[i].first);break;
                case 3:c[2]=max(c[2],x[i].second);break;
                case 4:c[3]=min(c[3],x[i].second);break;
            }
    }
    int xx=((c[1]-c[0])>0?c[1]-c[0]:0);
    int yy=((c[3]-c[2])>0?c[3]-c[2]:0);
    cout<<xx*yy<<endl;

}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> a(N), b(N), c(M), d(M);
	rep(i, N) cin >> a[i] >> b[i];
	rep(i, M) cin >> c[i] >> d[i];

	for (int i = 0; i < N; i++) {
		ll mi = 1e14;
		ll ans;
		for (int j = 0; j < M; j++) {
			if (mi > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				mi = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j + 1;
			}
		}

		cout << ans << endl;
	}
}

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

int main(void){
    int a, b, c, count;
    
    std::cin >> a >> b >> c;
    
    count = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0 ) count++;
    }
    std::cout << count << std::endl;
}

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

using namespace std;

#define fl(x,n) for(x=0;x<n;x++)
#define I(x) cin>>x
#define O(x) cout<<x<<endl
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define St(name) stack<string>name
#define lld long long int
const int INF = 1e9 + 7; 

int main(){
    fast;
    int n;
    cin>>n;
    int a[n], b[n], c[n];
    for(int i = 0; i<n; i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    int dp[3];
    dp[0] = a[0];
    dp[1] = b[0];
    dp[2] = c[0];
    for(int i = 1; i<n; i++){
    	int dd[3];
    	dd[0] = max(dp[1], dp[2]) + a[i];
    	dd[1] = max(dp[0], dp[2]) + b[i];
    	dd[2] = max(dp[0], dp[1]) + c[i];
    	dp[0] = dd[0];
    	dp[1] = dd[1];
    	dp[2] = dd[2]; 
    }
    cout<<max(dp[0], max(dp[1], dp[2]));
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    for(int i = 0; i <= N; i++) {
        B[i] = 0;
    }
    for(int i = 2; i <= N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        cout << B[i] << endl;
    }
}


Measured memory_bytes: 5196
n = int(input())
a = list(map(int, input().split()))
c = [a[0]]
l = []
h = 1000
for i in range(1, n):
    if a[i - 1] > a[i]:
        l.append(c)
        c = [a[i]]
    else:
        c.append(a[i])
l.append(c)
for i in l:
    cnt = h // i[0]
    h %= i[0]
    h += i[-1] * cnt
print(h)

Measured memory_bytes: 61724
x,a,b=(int(f) for f in input().split())
n = int(input())
i=0
for i in range(n):
    str = input()
    if str == "nobiro":
        x += a
    elif str == "tidime":
        x += b
    elif str == "karero":
        x = 0
    if x < 0:
        x = 0
        
print(x)


Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];
    int count = 0;
    Outer:
      for (int i = 0; i < n; i++) {
        a[i] = stdIn.nextInt();
        if (a[i] < 2) continue;
        if (a[i] == 2) {
          count++;
          continue;
        }
        if (a[i] % 2 == 0) continue;
        for (int j = 3; j <= a[i] / j; j+= 2) {
          if (a[i] % j == 0) continue Outer;
        }
        count++;
      }
    System.out.println(count);
  }
}

Measured memory_bytes: 41044
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=(1<<20)+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int n,f1[N],f2[N],z1[N],z2[N],an[N];
vector<int> e1[N],e2[N],ee[N];
bool vs[N];
int d1(int x)
{
    int nn=e1[x].size(),an=!z1[x]?x:0;
    for(int i=0;i<nn;++i)
    {
	int y=e1[x][i],w=d1(y);
	if(!an||!w) an|=w;
	else
	{
	    ee[an].push_back(w),ee[w].push_back(an);
	    an=0;
	}
    }
    return an;
}
int d2(int x)
{
    int nn=e2[x].size(),an=!z2[x]?x:0;
    for(int i=0;i<nn;++i)
    {
	int y=e2[x][i],w=d2(y);
	if(!an||!w) an|=w;
	else
	{
	    ee[an].push_back(w),ee[w].push_back(an);
	    an=0;
	}
    }
    return an;
}

int main()
{
    n=rd();
    for(int i=1;i<=n;++i)
    {
	f1[i]=rd();
	if(~f1[i]) e1[f1[i]].push_back(i),z1[f1[i]]^=1;
    }
    for(int i=1;i<=n;++i)
    {
	f2[i]=rd();
	if(~f2[i]) e2[f2[i]].push_back(i),z2[f2[i]]^=1;
    }
    for(int i=1;i<=n;++i)
	if(z1[i]^z2[i]){puts("IMPOSSIBLE");return 0;}
    puts("POSSIBLE");
    for(int i=1;i<=n;++i)
	if(f1[i]<0){d1(i);break;}
    for(int i=1;i<=n;++i)
	if(f2[i]<0){d2(i);break;}
    queue<int> q;
    for(int i=1;i<=n;++i)
	if(!z1[i]&&!vs[i])
	{
	    an[i]=-1,vs[i]=1,q.push(i);
	    while(!q.empty())
	    {
		int x=q.front();
		q.pop();
		int nn=ee[x].size();
		for(int j=0;j<nn;++j)
		{
		    int y=ee[x][j];
		    if(!vs[y]) vs[y]=1,an[y]=-an[x],q.push(y);
		}
	    }
	}
    for(int i=1;i<=n;++i) printf("%d ",an[i]);
    return 0;
}
 


Measured memory_bytes: 90368
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


print(len(S()) * 'x')

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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int dma = 0;
map<P, int> col;

void dfs(int now, int prev, int prevcol, const vvi &tr) {
  int id = 0;
  REP(i, SZ(tr[now])) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    if(id == prevcol) {
      id++;
      id %= dma;
    }
    col[{min(now, nxt), max(now, nxt)}] = id;
    dfs(nxt, now, id, tr);
    id++;
    id %= dma;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vvi tr(n);
  vi d(n);
  vector<P> e(n-1);
  REP(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    if(a > b) swap(a, b);
    e[i] = {a, b};
    tr[a].push_back(b);
    tr[b].push_back(a);
    d[a]++;
    d[b]++;
  }

  REP(i, n) {
    chmax(dma, d[i]);
  }

  dfs(0, -1, -1, tr);

  cout << dma << endl;
  REP(i, n-1) {
    cout << col[e[i]] + 1 << endl;
  }
}


Measured memory_bytes: 15232
#include<iostream>
using namespace std;
int main(){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r ;

  if(x>W||y>H||x<0||y<0){
    cout<<"No"<<endl;
  }else if(x+r>W||x-r<0||y+r>H||y-r<0){
    cout <<"No"<<endl;
  }else{
    cout <<"Yes"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3136
N,T = map(int, input().split())
e = [[int(i) for i in input().split()] for i in range(N)]
minc=1001
for v in e:
	if v[0]<minc and v[1]<=T:
		minc = v[0]
if minc == 1001:
	print("TLE")
else:
	print(minc)

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

#define ll long long
#define endl "\n";

int main(void)
{
    int x,a;
    cin >> x >> a;
    if(x < a)
        cout << 0 << "\n";
    else
        cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 256
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [N]} = io:fread("", "~d"),
    As = [XX || XX <- lists:map(fun(_) ->
                                        {ok, [X]} = io:fread("", "~d"),
                                        X
                                end,
                                lists:seq(1, N))],
    Ans = lists:foldl(fun(X, Acc) ->
                              Max = lists:max(lists:map(fun(Each) ->
                                                                abs(X - Each)
                                                        end,
                                                        As)),
                              max(Max, Acc)
                      end,
                      0,
                      As),
    io:format("~p~n", [Ans]),
    halt().


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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct data{
    int x,y,z;
    data(int x,int y,int z):x(x),y(y),z(z){}
    bool operator<(const data &d)const{
        if(x!=d.x)return x<d.x;
        if(y!=d.y)return y<d.y;
        return z<d.z;
    }
};

int N;
int x,y,z,xx,yy,zz;

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

map<data,int>dist;
inline void add(data &d,data &nd,queue<data>&que){
    if(dist.find(nd)==dist.end()){
        dist[nd]=dist[d]+1;
        que.push(nd);
    }
}

signed main(){
    cin>>N;
    cin>>x>>y>>z>>xx>>yy>>zz;

    data start(x,y,z);
    dist[start]=0;
    queue<data>que;
    que.push(start);

    rep(i,6){
        start.x+=dx[i];start.y+=dy[i];start.z+=dz[i];
        if(start.x>=0&&start.x<N&&start.y>=0&&start.y<N&&start.z>=0&&start.z<N){
            dist[start]=1;
            que.push(start);
        }
        start.x-=dx[i];start.y-=dy[i];start.z-=dz[i];
    }
    while(que.size()){
        data d=que.front();que.pop();
        data nd=d;

        if(d.x!=xx){
            nd=d;
            nd.y=d.z;
            nd.z=N-1-d.y;
            add(d,nd,que);

            nd=d;
            nd.y=N-1-d.z;
            nd.z=d.y;
            add(d,nd,que);
        }

        if(d.y!=yy){
            nd=d;
            nd.x=d.z;
            nd.z=N-1-d.x;
            add(d,nd,que);

            nd=d;
            nd.z=d.x;
            nd.x=N-1-d.z;
            add(d,nd,que);
        }
        if(d.z!=zz){
            nd=d;
            nd.x=d.y;
            nd.y=N-1-d.x;
            add(d,nd,que);

            nd=d;
            nd.y=d.x;
            nd.x=N-1-d.y;
            add(d,nd,que);
        }
    }

    int mi=1001001001;
    each(it,dist){
        data d=it->fi;
        int cost=abs(d.x-xx)+abs(d.y-yy)+abs(d.z-zz);
        chmin(mi,cost+it->se);
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 1232
import itertools
import numpy as np

n, m, x = map(int, input().split())

num = [i for i in range(n)]

book_list = []
for i in range(n):
  book_list.append(list(map(int, input().split())))


correct = []
for k in range(1, n+1):

  for v in itertools.combinations(num, k):
    test = [] #組み合わせを作る
    for j in v:
      test.append(book_list[j])
      sum_test = np.sum(test, axis = 0) #組みあわせの合計
      cnt = 0
      for i in range(1, m+1):
        if sum_test[i] >= x:
          cnt += 1
      if cnt == m:
        correct.append(sum_test[0]) #正解を入れる
        
if sum(correct) > 0:
  print(min(correct))
    
else:
  print('-1')


Measured memory_bytes: 27676
#include<bits/stdc++.h>
using namespace std;
bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];
void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}
void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}
int main()
{
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]==1?1:0;
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	bool yy=dp[ty][8000+y]==1?1:0;
	if(xx&&yy) cout<<"Yes";
	else cout<<"No";
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int ans  = 0;
  for(int i=0; i<4; i++){
    char c;
    cin >> c;
    if(c=='+') ans++;
    else ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
ex5_4
tomatokan
*/
#include<stdio.h>

int get_len_atgc(char *ptr){//ptrから始まる最長のatgc文字列の長さを返す
    int count=0;
    while(*ptr=='A'||*ptr=='T'||*ptr=='G'||*ptr=='C'){
        count++;
        ptr++;
    }
    return count;
}

int main(void){
    char msg[12], *ptr_msg;
    int len_atgc=0;
    int len_longest=0;//最長のatgc文字列の長さ
    fgets(msg,12,stdin);//入力の読み取り
    ptr_msg=msg;
    while(*ptr_msg!='\n'&&*ptr_msg!='\0'){
        len_atgc=get_len_atgc(ptr_msg);
        if(len_longest<len_atgc){
            len_longest=len_atgc;
        }
        ptr_msg+=(1+len_atgc);
        //直前にチェックしたatgc文字列の末尾の次の文字まで移動
    }
    printf("%d\n",len_longest);
    
    return 0;
}

Measured memory_bytes: 1600
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
  i=list(bin(i))[::-1]
  t=list(s)
  for j in range(len(i)-1,-1,-1):
    if i[j]=='1':
      t.insert(j+1,'+')
  t=''.join(t)
  ans+=eval(t)
print(ans)

Measured memory_bytes: 38768
/*
 * atcoder/dp_3rd/m.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* Mod */
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

const int MAX_N = 110;
const int MAX_K = 100100;
ll N, K;
vector<ll> A;

/*
 * dp[i][k] := i番目までの子にk個配る場合の数
 * dp[0][0] = 1
 * dp[i][k] = dp[i-1][k-a] for a in A_i if k-a>=0
 * dp[N-1][K] := 最終状態。この状態への遷移を考える。
 * N-1では[0: A[N-1]]の範囲を選択肢として配る事ができたはず。
 * dp[N-1][K] <- dp[N-2][K] １個の配らない
 * dp[N-1][K] <- dp[N-2][K-1] 1つ配る
 *            ...
 * dp[N-1][K] <- dp[N-2][K-A[N-1]] A[N-1]つ配る
 * dp[0] の場合は？ k = [0: A[0]]の範囲が1 それ以外は0
 *
 */
mint dp[MAX_N][MAX_K] = {0};

mint acc[MAX_K] = {0};

void input() {
  cin >> N >> K;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

void solve() {
  for (int i=0; i<N; i++) {
    if (i==0) {
      for (int a=0; a<=A[i]; a++) dp[i][a] = 1;
      continue;
    }

    acc[0] = 0;
    for (int k=0; k<=K; k++) {
      acc[k+1] = acc[k] + dp[i-1][k];
    }

    for (int k=0; k<=K; k++) {
      dp[i][k] += acc[k+1] - acc[max(0LL, k-A[i])];
    }
  }
  cout << dp[N-1][K] << endl;
}

void dump() {
  for (int k=0; k<=K; k++) {
    for (int i=0; i<N; i++) {
      cout << dp[i][k] << " ";
    }
    cout << endl;
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  // dump();
  return 0;
}


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

using namespace std;

const int oo = 1e9;

int n, m, k;
int xBegin, yBegin, xEnd, yEnd;
vector<vector<bool>> a;
vector<vector<int>> L;
vector<vector<pair<int, int>>> Pre[4];
queue<pair<int, int>> q;

void Update(int x, int y)
{
    Pre[0][x][y] = make_pair(x - 1, y);
    Pre[1][x][y] = make_pair(x, y + 1);
    Pre[2][x][y] = make_pair(x + 1, y);
    Pre[3][x][y] = make_pair(x, y - 1);
}

pair<int, int> Find(int type, pair<int, int> u)
{
    if (u.first < 0 || u.first >= n || u.second < 0 || u.second >= m)
    {
        return u;
    }
    if (Pre[type][u.first][u.second] != u)
    {
        Pre[type][u.first][u.second] = Find(type, Pre[type][u.first][u.second]);
    }
    return Pre[type][u.first][u.second];
}

void BFS()
{
    L[xBegin][yBegin] = 0;
    q.push(make_pair(xBegin, yBegin));
    Update(xBegin, yBegin);
    while (!q.empty())
    {
        int x = q.front().first, y = q.front().second;
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            int tx = x, ty = y;
            while (true)
            {
                pair<int, int> t = Find(i, make_pair(tx, ty));
                tx = t.first, ty = t.second;
                if (tx < 0 || tx >= n || ty < 0 || ty >= m || !a[tx][ty] || abs(tx - x) + abs(ty - y) > k)
                {
                    break;
                }
                if (L[tx][ty] == oo)
                {
                    L[tx][ty] = L[x][y] + 1;
                    q.push(make_pair(tx, ty));
                    Update(tx, ty);
                }
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    a.resize(n);
    L.resize(n);
    for (int i = 0; i < n; i++)
    {
        a[i].resize(m);
        L[i].assign(m, oo);
    }
    for (int t = 0; t < 4; t++)
    {
        Pre[t].resize(n);
        for (int i = 0; i < n; i++)
        {
            Pre[t][i].resize(m);
        }
    }
    cin >> xBegin >> yBegin >> xEnd >> yEnd;
    xBegin--;
    yBegin--;
    xEnd--;
    yEnd--;
    char ch;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> ch;
            a[i][j] = (ch == '.');
            for (int t = 0; t < 4; t++)
            {
                Pre[t][i][j] = make_pair(i, j);
            }
        }
    }
    BFS();
    cout << (L[xEnd][yEnd] == oo ? -1 : L[xEnd][yEnd]);
    return 0;
}

Measured memory_bytes: 39952
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
    const row = readRows(1)[0];
    immutable n = row.to!long;
    auto s = row.map!(c => c - '0').sum;
    writefln((n % s == 0) ? "Yes" : "No");
}

Measured memory_bytes: 256
n,p=io.read("*n","*n","*l")
s=io.read()

combination=0
if p==2 or p==5 then
    for i=1,n do
        x=tonumber(s:sub(i,i))
        if x%p==0 then
            combination=combination+i
        end
    end
else
    t={}
    for i=1,p do
        t[i]=0
    end
    t[1]=1
    digit=1
    smod=0
    for i=n,1,-1 do
        x=tonumber(s:sub(i,i))
        smod=(smod+x*digit)%p
        combination=combination+t[smod+1]
        t[smod+1]=t[smod+1]+1
        digit=(digit*10)%p
    end
end
print(combination)

Measured memory_bytes: 760
def main():
    n,k=map(int,input().split())
    h = list(map(int,input().split()))

    h.sort()
    if k >= n:
        print(0)
        return
    for i in range(1,k+1):
        h.pop(-1)
    print(sum(h))
if __name__=='__main__':
    main()


Measured memory_bytes: 87636
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  int a, b, c;
  std::string s, t;

  cin >> a >> b;

  if (a <= b) {
    cout << a << endl;
  }
  else {
    cout << a - 1 << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n];
    long long count[n];
    for(long long i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
        count[i]=-1;
    }
    long long now = 0;
    count[0]=0;
    for(long long i=0;i<k;i++){
        //cout << i << endl;
        now=a[now];
        if(count[now]==-1){
            count[now]=i+1;
        }else{
            long long tmp = (k-count[now])/((i+1)-count[now]);
            if(tmp==0){
                count[now]=i+1;
            }else{
                count[now]+=tmp*((i+1)-count[now]);
                i=count[now]-1;
            }
        }

        /*
        for(int j=0;j<n;j++){
            cout << count[j] << " ";
        }
        cout << endl;
        */
        
    }
    cout << now+1 << endl;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<ll,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;
string s;
stack<char> st;

int main(){
	cin >> n >> s; string w=s;
	REP(i,0,n){
		if(!st.empty() and st.top()=='(' and s[i]==')') st.pop();
		else st.push(s[i]);
	}
	
	while(!st.empty()){
		auto p=st.top(); st.pop();
		
		if(p=='(') w=w+')';
		else w="("+w;
	}
	
	cout << w << endl;
	return 0;
}



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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;read(a);return a;}   // iota(all(v),0); genrate(all(v),nxt);

// no change 
const ll MOD = 1e9+7;  
int mx = 1e6+1;
void Titan(){
	int w,a,b;
	read(w,a,b);
	int i = max(a,b) - (min(a,b) + w) ;
	if(i<0)cout << 0;
	else cout << i;



}

	

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int n,r;cin>>n>>r;
    if(10<=n) cout<<r<<endl;
    else cout<<r+(100*(10-n))<<endl;
    


    return 0;
}

Measured memory_bytes: 3600
#include <iostream>

int main(void)
{
	int H, W;
	while (true) 
	{
		std::cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				std::cout << '#';
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll euclidean_gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main() {
  int n;
  cin >> n;
  vector<ll> l(n+1);
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i < n+1; ++i){
    l[i] = l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		
		int ans = 0;
		while(X <= Y) {
			ans++;
			X *= 2;
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 22864
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <math.h>
#include <map>
#include <set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

/** In set, multiset ,map etc the concept of index
    does not exist. */

/*

Bring me back to the time
When we were free, just you and I
Now I can feel the pressure building
The battle for us to survive

[Pre-Chorus]
You're an addiction
The only drug I'll ever need
Like a prescription
I crave you to breathe

[Chorus]
You're an addiction
The only drug I'll ever need
You're an addiction
The only drug I'll ever need

[Drop]
(You're an addiction)
(The only drug I'll ever need)

[Verse 2]
Bring me back to the time
When we would make it 'cross the line
Now I can feel the end is nearing
The time for us has arrived

[Pre-Chorus]
You're an addiction
The only drug I'll ever need
Like a prescription
I crave you to breathe

*/

/*

When I saw you I would lose control
Made me feel like there was no tomorrow
Should've told you that you're beautiful
But the days pass and now it's so long ago

Did you make it?
Did you break free?
Did you manage to be who you wanna be?
Maybe somewhere you think about me too

I wonder where are you now
~

*/


using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/** find_by_order(int k) -> iterator to kth largest element
    order_of_key(int e)  -> position of element with
    value 'e' ie. number of elements strictly less than e */

int mod=1000000007;

int powmod(int64_t a,int64_t b){
int64_t ans=1;while(b>0){if(b&1){b--;ans=(ans*a)%mod;}
else{a=(a*a)%mod;b=b>>1;}}return ans;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cout<<fixed;
    ///learn from your mistakes
    ///read the question properly
    ///initialize variables s'il vous plait
    int64_t k, a, b;
    cin>>k>>a>>b;
    int64_t ct = 1;
    if(a-1<k){
        ct = a;
        k-=a-1;
        if(a<b){
            if(b-a==1){
                ct += k;
                cout<<ct;
                return 0;
            }
            ct += (b-a)*(k/2);
            if(k%2==1){
                ct++;
            }
            cout<<ct;
        }
        else{
            cout<<ct+k;
        }
    }
    else if(a-1 == k){
        cout<<a;
    }
    else{
        cout<<1+k;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

set<int> edge[100050];
lint ans=1;
int N,K;
int depth[100050];
void DFS(int x,int deep){
  int count=0;
  while(!edge[x].empty()){
    int y=*edge[x].begin();
    edge[x].erase(y);
    edge[y].erase(x);
    ans=(ans*(K-min(2,deep)-count))%MOD;
    count++;
    if(ans==0) return;
    DFS(y,deep+1);
  }
  return;
}

int main(void){
  cin >> N >> K;
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--,b--;
    edge[a].insert(b);
    edge[b].insert(a);
  }
  ans*=K;
  DFS(0,1);
  cout << ans << endl;
}

Measured memory_bytes: 16000
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int B[] = new int[M];
    int A[][] = new int[N][M];
    int answer =0;
    for(int i=0;i<M;i++){
      B[i]=sc.nextInt();
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        A[i][j]=sc.nextInt();
      }
    }
    
    for(int i=0;i<N;i++){
      int sum=0;
      for(int j=0;j<M;j++){
        sum = sum+A[i][j]*B[j];
      }
      if(sum+C>0){
        answer=answer+1;
      }
    }
    System.out.println(answer);
      
      
      
      
      
      
    
    
  }
  

  
}

Measured memory_bytes: 22996
H,W=map(int,input().split())
S=[[] for i in range(H+2)]
S[0]=list("_"*(W+2))
S[H+1]=list("_"*(W+2))
for i in range(H):
  S[i+1]=list("_"+str(input())+"_")
for i in range(1,H+1):
  for j in range(1,W+1):
    if S[i][j]!="#":
      bomb=0
      for h in [-1,0,1]:
        for w in [-1,0,1]:    
          if S[i+h][j+w]=="#": bomb+=1
      S[i][j]=bomb
        
for i in range(H+2):
  print(''.join(map(str, S[i])).replace("_",""))

Measured memory_bytes: 3064
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()

  l=0
  r=n-1

  print(0)
  _ans=S()
  if _ans=='Vacant':
    return
  l_ans=_ans

  print(n-1)
  _ans=S()
  if _ans=='Vacant':
    return
  r_ans=_ans

  while True:
    x=(l+r)//2
    print(x)

    ans=S()
    if ans=='Vacant':
      return

    if (x-l)%2==0:
      if l_ans==ans:
        l=x
      else:
        r=x
    else:
      if l_ans!=ans:
        l=x
        l_ans=ans
      else:
        r=x
        r_ans=ans

main()
# print(main())


Measured memory_bytes: 10564
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  string n;
  while (cin >> n) {
    cout << (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3] ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,t=0;
	cin>>a>>b>>c;
	if(a==b)
		t+=10;
	if(b==c)
		t+=100;
	if(a==c)
		t+=1000;
	switch(t)
	{
		case 10:cout<<"Yes";break;
		case 100:cout<<"Yes";break;
		case 1000:cout<<"Yes";break;
		default:cout<<"No";break;		
	}
	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;

fn scan() -> i64 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let n = it.next().unwrap();
    n
}

fn main() {
    let mut r: Vec<i64> = Vec::new();

    let n: i64 = scan();
    for _ in 0..n {
        let v = scan();
        r.push(v);
    }
    
    let mut maxv: i64 = std::i64::MIN;
    let mut minv: i64 = r[0];
    
    for _i in 1..n {
        let i = _i as usize;
        if maxv < r[i] - minv {
            maxv = r[i] - minv;
        }
        if minv > r[i] {
            minv = r[i];
        }
    }
    
    println!("{}", maxv);
}


Measured memory_bytes: 6980
// !Start && !End 
//  0 se divide

// { Tu jab paida hua tha na tabhi ye code likh diya tha --Ranvijay }

#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(ll a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

//                                                      DSU 
// vector<int> parent, rank;
// void make_set(int v) { parent[v] = v; rank[v] = 0;}
// int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]);}
// void union_sets(int a, int b) { a = find_set(a);  b = find_set(b); if (a != b) { if (rank[a] < rank[b]) swap(a, b); parent[b] = a; if (rank[a] == rank[b]) rank[a]++; }}

//                                                     LCA by Binary Lifting      l=ceil(log2(n)) dfs(root,root)
// ll dp[200005][21] ; ve(ll) tin(200005), tout(200005); ll tim = 0 , l;
// void dfs(int n , int par ){  tin[n] = ++tim; dp[n][0] = par; f(i,1,l+1) dp[n][i] = dp[dp[n][i-1]][i-1];
//    foto(x,tr[n]) if(x==par) continue; else dfs(x , n);        tout[n] = ++tim;  }
// bool is_ancestor(ll u , ll v) { return tin[u]<=tin[v] && tout[u]>=tout[v] ;}1
// ll lca(ll u , ll v){ if(is_ancestor(u,v)) return u ; if(is_ancestor(v,u)) return v;
//    for(int j = l ; j>=0 ; j--) if(!is_ancestor(dp[u][j] , v)) u = dp[u][j];    return dp[u][0];}


// 														MAIN
int32_t main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    reads(s) reads(t)
    if(t.length() != s.length() + 1) {cout<<"No";return 0 ;}
    f(i,0,s.length()) if(s[i]!=t[i]) {cout<<"No";return 0 ;}
    cout<<"Yes";
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 3644
import java.math.*;
import java.util.*;

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

    int[] n = new int[N + 1];
    for (int i = 0; i < N; i++) n[A[i]]++;

    long sum = 0;
    long[] c = new long[N + 1];
    for (int i = 0; i < N + 1; i++)
      if (1 < n[i]) {
        c[i] = combination(n[i], 2);
        sum += c[i];
      }

    for (int i = 0; i < N; i++) {
      int a = A[i];
      long na = n[a];
      long ans = sum - c[a];
      if (2L < na) {
        ans += c[a] * (na- 2) / na;
      }
      System.out.println(ans);
    }
  }

  private static long combination(int n, int k) {
    int closer = Integer.min(n - k, k);
    long result = 1;
    for (int i = 1; i <= closer; i++)
      result = result * (n - closer + i) / i;
    return result;
  }
}

Measured memory_bytes: 94964