akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

struct node
{
	int key;
	node* lc, * rc, * p;
};

node* root = 0;

void insert(int x)
{
	node* pre = root;        //设当前节点为根，以根为起点
	node* temp = pre;        //用来保存当前节点的临时指针

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = 0;
	in->rc = 0;
	in->p = 0;

	while (pre != 0)        //找到将要插入的节点的父节点(当前节点)
	{
		temp = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}
	pre = temp;

	if (pre == 0)           //插入
		root = in;
	else
	{
		if (in->key < pre->key)
			pre->lc = in;
		else
			pre->rc = in;
		in->p = pre;
	}
}

node* Findlater(node* f)
{
	if (f->rc != 0)
	{
		f = f->rc;
		while (f->lc != 0)
			f = f->lc;

		return f;
	}
	else
	{
		while (true)
		{
			if (f->p->key > f->key)
				return f->p;
			else
				f = f->p;
		}
	}
}

void Delete(int de)
{
	node* find = root;             
	node* De;              //将要删除的节点
	node* c;               //De的子节点  

	while (find != 0)
	{
		if (de < find->key)
			find = find->lc;
		else if (de > find->key)
			find = find->rc;
		else
		{
			if (find->lc == 0 || find->rc == 0)           //确认将要删除的节点
				De = find;
			else
				De = Findlater(find);

			if (De != find)
				find->key = De->key;

			if (De->lc != 0)                      //确认De的子节点
				c = De->lc;
			else
				c = De->rc;

			if (c != 0)
				c->p = De->p;

			if (De->p == 0)
				root = c;
			else
			{
				if (De == De->p->lc)
					De->p->lc = c;
				else
					De->p->rc = c;
			}
			
			break;
		}
	}
}

bool Find(int f)
{
	bool fin = false;

	node* pre = root;
	while (pre != 0)
	{
		if (f < pre->key)
			pre = pre->lc;
		else if (f > pre->key)
			pre = pre->rc;
		else
		{
			fin = true;
			break;
		}

	}

	return fin;
}

void Inorder(node* r)
{
	if (r->lc != 0)
		Inorder(r->lc);

	cout << " " << r->key;
	
	if (r->rc != 0)
		Inorder(r->rc);
}

void Preorder(node * r)
{
	cout << " " << r->key;

	if (r->lc != 0)
		Preorder(r->lc);
	if (r->rc != 0)
		Preorder(r->rc);
}

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

	int n, x;
	string p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p;

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else if (p == "find")
		{
			cin >> x;
			if (Find(x))
				cout << "yes\n";
			else
				cout << "no\n";
		}
		else if (p == "delete")
		{
			cin >> x;
			Delete(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 21896
#include<cstdio>
#include<cmath>
int main()
{
	int a,b,len=0;
	scanf("%d %d",&a,&b);
	if(b>9&&b<100) len=100;
	else if(b==100) len=1000;
	else len=10;
	a=a*len+b;
	if(int(sqrt(a))==sqrt(a)) printf("Yes\n");
		else printf("No\n");
}

Measured memory_bytes: 128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def len_cycle(edge, start=0):
    stack = [start]
    cnt = 0
    pop, push = stack.pop, stack.append
    while stack:
        cnt+=1
        from_ = pop()
        for to in edge[from_]:
            push(to)
            if to == start:
                return cnt
    return 0
def main():
    N=I()
    A=LI()
    B=LI()

    A_with_index = [(a,i) for i,a in enumerate(A)]
    B_with_index = [(b,i) for i,b in enumerate(B)]
    A_with_index.sort()
    B_with_index.sort()

    for i,(a,_) in enumerate(A_with_index):
        b = B_with_index[i][0]
        if a>b:
            print("No")
            return

    B_dict = {}
    for j,(b,i) in enumerate(B_with_index):
        B_dict[j] = i

    edge = [[]for _ in range(N)]
    for i,(a,from_) in enumerate(A_with_index):
        to = B_dict[i]
        edge[from_] += to,

    cycle = len_cycle(edge)
    if cycle != N:
        print("Yes")
        return 
    for i in range(N-1):
        a = A_with_index[i+1][0]
        b = B_with_index[i][0]
        if a<=b:#辺を組み替えてサイクルを2つに分割できる
            print("Yes")
            return
    print("No")




if __name__ == '__main__':
    main()

Measured memory_bytes: 53076
import sys
sys.setrecursionlimit(10**7)

h,w = map(int,input().split())
sij = [input() for i in range(h)]

dp = [[10**18 for i in range(w)] for j in range(h)]

dp[0][0] = 0

for i in range(w-1):
    if sij[0][i+1] != sij[0][i]:
        dp[0][i+1] = dp[0][i]+1
    else:
        dp[0][i+1] = dp[0][i]
        
for i in range(h-1):
    if sij[i+1][0] != sij[i][0]:
        dp[i+1][0] = dp[i][0]+1
    else:
        dp[i+1][0] = dp[i][0]

for i in range(1,h):
    for j in range(1,w):
        #print(i,j)
        if sij[i-1][j] != sij[i][j]:
            sita = dp[i-1][j]+1
        else:
            sita = dp[i-1][j]
        if sij[i][j-1] != sij[i][j]:
            yoko = dp[i][j-1]+1
        else:
            yoko = dp[i][j-1]
        #print(i,j,sita,yoko)
        dp[i][j] = min(sita,yoko)

add = 0
#print(dp)

if sij[0][0] == '#':
    add = 1
"""
if dp[h-1][w-1] == 1:
    print(1)
else:
    print(dp[h-1][w-1]//2+add)
""" 
if dp[h-1][w-1] % 2 == 1:
    print(dp[h-1][w-1]//2+1)
else:
    print(dp[h-1][w-1]//2+add)

Measured memory_bytes: 3188
#
# 優先度つきキュー + ダイクストラ
# ダイクストラなので負の辺は不可
#
class PriorityQueue
  def initialize
    @q = []
    @h = {}
  end

  # push obj unless already contained
  def push_ex(obj, cost)
    return if @h.key?(obj)
    i = (0...@q.size).bsearch{|i| @q[i][1] > cost} || @q.size
    @q.insert(i, [obj, cost])
    @h[obj] = true
  end

  def pop
    return nil if @q.empty?
    obj = @q.shift[0]
    @h.delete(obj)
    return obj
  end

  # ある点からすべての点への距離を求める
  # - Node number starts from 1
  def self.dijkstra_all(edges, start)
    best = Array.new(edges.size+1){ Float::INFINITY }
    best[start] = 0
    q = PriorityQueue.new
    q.push_ex(start, 0)
    while (a = q.pop)
      edges[a].each do |b, cost|
        new_cost = best[a] + cost
        if new_cost < best[b]
          best[b] = new_cost
          q.push_ex(b, new_cost)
        end
      end
    end
    return best
  end
end

N = gets.to_i
EDGES = Hash.new{|h, k| h[k] = [] }
(N-1).times{ a,b,c = gets.split.map(&:to_i); EDGES[a] << [b, c]; EDGES[b] << [a, c] }
Q, K, *rest = $stdin.read.split.map(&:to_i)
QUERIES = rest.each_slice(2).to_a

dists = PriorityQueue.dijkstra_all(EDGES, K)

QUERIES.each do |x, y|
  p dists[x] + dists[y]
end


Measured memory_bytes: 77944
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a[55], b[55];
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	int ans = 0;
	int j, k;
	int x;
	int v[55];
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
			v[j] = 0;
		v[0] =1;
		for (j = 0; j < m; j++)
		{
			for (k = 0; k < m; k++)
			{
				if (i != k)
				{
					if (v[a[k]] > 0)
						v[b[k]] = 1;
					if (v[b[k]] > 0)
						v[a[k]] = 1;
				}
			}
		}
		x = 0;
		for (j = 0; j < n; j++)
			if (v[j] == 0)
				x++;
		if (x > 0)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

n = int(input())
s = [list(input()) for _ in range(n)]


for i in range(n):
    s[i].sort()
    s[i] = "".join(s[i])

c = Counter(s)

ans = 0

for v in c.values():
    ans += v * (v - 1) // 2
print(ans)


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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]/*最後の列を見ている*/) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


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

// int H = 3;
// int W = 3;
// int A = 1;
// int B = 1;

int H, W, A, B;
int result[1000][1000]; // 0
int col_nums[1000];
int row_nums[1000];

int main() {
    cin >> H >> W >> A >> B;

    rep(i, H) {
        rep(j, W) {
            if (i < B && j < A) {
                cout << 0;
            } else if (i >= B && j >= A) {
                cout << 0;
            } else {
                cout << 1;
            }
        }
        printf("\n");
    }
}

Measured memory_bytes: 1280
import itertools
N,M,X=map(int,input().split())
C=[0 for i in range(N)]
A=[[0 for j in range(M)]for i in range(N)]
for i in range(N):
    line=list(map(int,input().split()))
    C[i]=line[0]
    for j in range(M):
        A[i][j]=line[j+1]

ans=sum(C)+1
for seq in itertools.product(range(2),repeat=N):
    R=[0 for i in range(M)]
    cost=0
    for i in range(N):
        if seq[i]==0:
            continue
        cost+=C[i]
        for j in range(M):
            R[j]+=A[i][j]
    if min(R)>=X:
        ans=min(ans,cost)
if ans==sum(C)+1:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 74484
def solve():
    from sys import stdin
    f_i = stdin
    
    T1, T2 = map(int, f_i.readline().split())
    A1, A2 = map(int, f_i.readline().split())
    B1, B2 = map(int, f_i.readline().split())
    
    P = (A1 - B1) * T1
    Q = (A2 - B2) * T2
    
    if P < 0:
        P *= -1
        Q *= -1
    
    cycle = P + Q
    if cycle > 0:
        return 0
    elif cycle == 0:
        return 'infinity'
    else:
        S, T = divmod(P, -cycle)
        if T == 0:
            return 2 * S
        else:
            return 2 * S + 1

print(solve())

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

int main(){
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1){
                    cout << "#";
                }
                else{
                    if(j==0||j==W-1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


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


int main()
{
    long long n;
    const unsigned int m= 1000000007;
    cin>>n;
    ll sum=0,ans=0;
    ll arr[n];
    for( ll i=0;i<n;i++)
       {
           cin>>arr[i];
        arr[i]=arr[i];
        sum=sum+arr[i];
       }
    for(ll i=0;i<n;i++)
    {
        int s=(sum-arr[i])%m;
        ans = (ans + (s*arr[i]))%m;
        sum=sum-arr[i];

    }
    cout<<ans%m;


}



Measured memory_bytes: 5180
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

vector<P> p;
ll N, M;

P root(ll a){
  ll atmp = a;
  ll cnt = 0;
  while(atmp!=p[atmp].second){
    atmp = p[atmp].second;
    cnt++;
  }
  p[a].second = atmp;
  return P(cnt, atmp);
}

void con(ll a, ll b){
  P tmpa = root(a);
  P tmpb = root(b);
  if(tmpa.first>tmpb.second){
    swap(tmpa, tmpb);
  }
  p[tmpa.second].second = tmpb.second;
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> M;
  p.resize(N);
  rep(i, N){
    cin >> p[i].first;
    p[i].first--;
    p[i].second = i;
  }

  rep(i, M){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    con(a, b);
  }
  
  map<ll, set<ll>> mp;
  rep(i, N){
    P piroot=root(p[i].second);
    mp[piroot.second].insert(i);
  }
  
  ll ans = 0;
  rep(i, N){
    P piroot=root(p[i].second);
    if(mp[piroot.second].count(p[i].first)>0)ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
int main(){
  int x, y;
  cin >> x >> y;
  if(x == 1) x = 14;
  if(y == 1) y = 14;
  if(x == y)puts("Draw");
  else puts(x > y ? "Alice" : "Bob" );





  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;
    int max = 0;

    for(int i = 0 ; i < n ; ++i){
      int l = sc.nextInt();
      sum += l;
      max = Math.max(max,l);
    }
    
    if(max < sum-max){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 35776
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

int N, M;
char C;
char chairs[102];

void PutA(){
	for(int i = 1; i <= N; i++){
		if(chairs[i] == '#'){
			chairs[i] = 'A';
			return;
		}
	}
}

void PutB(){
	for(int i = N; i >= 1; i--){
		if(chairs[i+1] != 'A' && chairs[i] == '#' && chairs[i-1] != 'A'){
			chairs[i] = 'B';
			return;
		}
	}
	for(int i = 1; i <= N; i++){
		if(chairs[i] == '#'){
			chairs[i] = 'B';
			return;
		}
	}
}

void PutC(){
	for(int i = 1; i <= N; i++){
		if(chairs[i] != '#'){
			if(chairs[i+1] == '#'){
				chairs[i+1] = 'C';
				return;
			}
			if(chairs[i-1] == '#'){
				chairs[i-1] = 'C';
				return;
			}
		}
	}
	if(N&1) chairs[ (N+1)/2 ] = 'C';
	chairs[N/2 + 1] = 'C';
}

void PutD(){
	int l[102], r[102];
	l[0] = INT_MAX/2; r[N+1] = INT_MAX/2;
	for(int i = 1; i <= N; i++) l[i] = (chairs[i] == '#') ? l[i-1] + 1 : 0;
	for(int i = N; i >= 1; i--) r[i] = (chairs[i] == '#') ? r[i+1] + 1 : 0;

	int ma_idx, ma_d = -1;
	for(int i = 1; i <= N; i++){
		int d = min(l[i], r[i]);
		if(d >= INT_MAX/2) d = INT_MAX;
		if(ma_d < d){
			ma_idx = i; ma_d = d;
		}
	}
	chairs[ma_idx] = 'D';
}

int main(){
	void (*put[4])() = {PutA, PutB, PutC, PutD};

	while(cin >> N >> M, N || M){
		fill_n(chairs, N+2, '#');
		chairs[0] = chairs[N+1] = '.';
		for(int i = 0; i < M; i++){
			cin >> C;
			put[C - 'A']();
			//for(int i = 1; i <= N; i++) printf("%c", chairs[i]); puts("");
		}
		for(int i = 1; i <= N; i++) printf("%c", chairs[i]); puts("");
	}
	return 0;
}

Measured memory_bytes: 1128
n,a,b=map(int,input().split())
ans=[];L=[a]*b;x=a*b-n;ct=1
if a+b>n+1 or x<0:print(-1);exit()
for i in range(b-1,0,-1):
 y=min(a-1,x);L[i]-=y;x-=y
for i in L:
 l=[]
 for j in range(i):
  l+=[str(ct)];ct+=1
 ans+=[' '.join(l)]
print(*reversed(ans))

Measured memory_bytes: 82508
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,K; cin>>N>>K;
    ll ans=0;
    while(N){
        N/=K;
        ++ans;
    }
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char *str1;
    str1 = (char *)malloc(sizeof(char) * 100);
    scanf("%s", str1);
    int center = 0;
    int L = strlen(str1);
    int count = 0;
    if(L%2==0){
        for(int i=0;i<L/2;i++){
            if(str1[i]!=str1[L-i-1]){
                count++;
            }
        }
    }else{
        int center = (L-1)/2;
        for(int i=0;i<center;i++){
            if(str1[i]!=str1[L-i-1]){
                count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}

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

int main(){
	ll n, W, w[105], v[105],dp[100005];
	cin >> n >> W;
	for( int i = 0 ; i < 100005 ; i++ )
		dp[i] = 1000000000000;
	for( int i = 0 ; i < n ; i++ )
		cin >> w[i] >> v[i];
	dp[0] = 0;
	for( int i = 0 ; i < n ; i++ )
		for( int j = 100000 - v[i] ; j > -1 ; j-- )
			dp[j+v[i]] = min(dp[j]+w[i], dp[j+v[i]]);
	for( int j = 100000 ; j > -1 ; j-- )
		if( dp[j] <= W ){
			cout << j << endl;
			break;
		}
	return(0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    unsigned long long ans = 0;
    int a[n];
    int now[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
        now[i] = 0;
    }

    now[0] = a[0];
    for(int i=1; i<n; i++){
        
        if(now[i-1] > a[i]){
            ans += now[i-1] - a[i];
            now[i] = (now[i-1] - a[i]) + a[i];
        }else{
            now[i] = a[i];
        }
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5148
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
 
#define OPTIMIZE ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define In inline
#define Re register
#define db double
#define ll long long
const int M=1e5+5;

int read(){
	int x=0,y=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') y=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*y;
}

int main(){
	int k=read(),x=read();
	for(int i=x-k+1;i<=x+k-1;i++){
		printf("%d ",i);
	}
}

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

int main()
{
	int N, P[100005],ans = 0;

	cin >> N;

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

	for (int i = 0; i < N; i++) {
		if (P[i] == i + 1) {
			if (i == N - 1) {
				swap(P[i], P[i - 1]);
				ans++;
			}
			else {
				swap(P[i], P[i + 1]);
				ans++;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long x = sc.nextLong(); long y = sc.nextLong();
        if (Math.max(x, y) -  Math.min(x, y) <= 1) {
            out.println("Brown");
        } else {
            out.println("Alice");
        }
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32756
#include <stdio.h>

int main()
{
	int N, x;
	scanf("%d %d", &N, &x);
	if (x == 1 || x == N * 2 - 1) {
		printf("No\n");
		fflush(stdout);
		return 0;
	} else if (N == 2) {
		printf("Yes\n1\n2\n3\n");
		fflush(stdout);
		return 0;
	}
	
	int i, j, ans[200001] = {}, flag[200001] = {};
	ans[N-1] = x - 1;
	ans[N] = x;
	ans[N+1] = x + 1;
	flag[x-1] = 1;
	flag[x] = 1;
	flag[x+1] = 1;
	if (x <= N) {
		ans[N+2] = x + 2;
		flag[x+2] = 1;
	} else {
		ans[N-2] = x - 2;
		flag[x-2] = 1;
	}
	for (i = 1, j = 1; i <= N * 2 - 1; i++) {
		if (ans[i] != 0) continue;
		for (; flag[j] == 1; j++);
		ans[i] = j++;
	}
	
	printf("Yes\n");
	for (i = 1; i <= N * 2 - 1; i++) printf("%d\n", ans[i]);	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3272
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut N: usize = sc.read();
    let mut S: String = sc.read();
    let K: usize = sc.read();
    let k = S.chars().nth(K - 1).unwrap();
    let mut ans = String::new();
    for i in 0..N {
        let c = S.chars().nth(i).unwrap();
        if c != k {
            ans.push('*');
        } else {
            ans.push(c);
        }
    }    
    println!("{}", ans);
}

Measured memory_bytes: 2156
def judge(a):
    global flg
    if a % 4 == 0 or a % 7 == 0:
        flg = 1

N = int(input())
flg = 0
judge(N)

while N > 7:
    N -= 7
    judge(N)

if flg == 1:
    print("Yes")
else:
    print("No")


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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  if (P >= Q && P >= R) cout << Q+R << endl;
  else if (Q >= R && Q >= P) cout << R+P << endl;
  else if (R >= Q && R >= P) cout << Q+P << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	int N;
	cin >> N;
	map<int,bool> mp;
	int cnt = 0,beda = 0;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		if(!mp[a]) {
			cnt++;
		}
		else{
			beda++;
		}
		mp[a] = 1;
	}
	beda = beda % 2;
	cout << cnt - beda << "\n";
}




Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

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

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    long long int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int cnt=1;int m=a.at(0);
    for(int i=0;i<n-1;i++){
        m=min(m,a.at(i+1));
        if(m>=a.at(i+1)){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    

    return 0;
} //カモンAC

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int a[15][15];

signed main(){
	int N,D;
	cin>>N>>D;
	REP(i,N){
		REP(j,D){
			cin>>a[i][j];
		}
	}
	int cnt = 0;
	REP(i,N){
		FOR(j,i+1,N){
			int sum = 0;
			REP(k,D){
				sum += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int idist = sqrt(sum);
			double ddist = (double)sqrt(sum);
			if(idist==ddist)cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  int x, a, ans;
	cin >> x >> a;
	if(x<a) ans = 0;
	else ans = 10;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char s[1024];
	char e[1024];
	int c = 0;
	int i;
	if (scanf("%1023s", s) != 1) return 1;
	for (i = 0; s[i] != '\0'; i++) {
		switch (s[i]) {
			case '0':
				e[c++] = '0';
				break;
			case '1':
				e[c++] = '1';
				break;
			case 'B':
				if (c > 0) c--;
				break;
		}
	}
	e[c] = '\0';
	puts(e);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int len,que,num;
    int vis[100005];
    memset(vis,0,sizeof(vis));
    cin>>len>>que;
    string fin;
    getchar();
    getline(cin,fin);
        num=0;
    for(int j=1; j<len; j++)
    {
        if(fin[j-1]=='A'&&fin[j]=='C')
        {
            num++;
        }
        vis[j]=num;
    }
    for(int i=0; i<que; i++)
    {
        int a,b;
        cin>>a>>b;

        cout<<vis[b-1]-vis[a-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s;cin>>s;
	ll cnt=0;
	ll ans=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='W')cnt++;
		if(s[i]=='B')ans+=cnt;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc147/tasks/abc147_d
n = int(input())
nums = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

ans = 0
one = [0] * 61
zero = [0] * 61

for i in range(61):
    for num in nums:
        if (num >> i) & 1:
            one[i] += 1
        else:
            zero[i] += 1
ans = 0
for k in range(61):
    ans = (ans + (one[k] * zero[k] * (1 << k))) % mod
print(ans % mod)

Measured memory_bytes: 125624
from itertools import *
N,M,Q=map(int,input().split())
a=[0 for i in range(Q)]
b=[0 for i in range(Q)]
c=[0 for i in range(Q)]
d=[0 for i in range(Q)]
for i in range(Q):
  a[i],b[i],c[i],d[i] = map(int,input().split())
  b[i] -= 1
  a[i] -= 1
ans = 0
for pat in combinations_with_replacement(range(M),N):
  count = 0
  for i in range(Q):
    if pat[b[i]]-pat[a[i]] == c[i]:
      count += d[i]
  ans=max(ans, count)
print(ans)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n;
  str s;
  cin >> n >> s;
  vll Ep(n), Wp(n);
  for (ll i = 1; i < n; i++) {
    Wp[i] = Wp[i-1];
    if (s[i-1] == 'W') Wp[i]++;
    Ep[n-1-i] = Ep[n-i];
    if (s[n-i] == 'E') Ep[n-1-i]++;
  }
  
  for (ll i = 0; i < n; i++) {
    ll x = Ep[i] + Wp[i];
    if (INF > x) INF = x;
  }
  
  cout << INF << endl;
}

Measured memory_bytes: 5380
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll a, b, c, d;std::cin >> a >> b >> c >> d;
  if(a>=d||c>=b) std::cout << 0 << '\n';
  else std::cout << min(d, b) - max(a, c) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];

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

  for (int i = 1; i <= n; i++) {
    m[i][i] = 0;
  }
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for(int k = i; k <= j - 1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}


Measured memory_bytes: 3136
# include <bits/stdc++.h>
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
 
const int xn = 3e3 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ll mod = 1e9 + 7;
const int base = 257;

int n, q, a[xn], dp[2][xn][xn], ans, qq;
ll inv = power(2, mod - 2, mod);

int main(){
    InTheNameOfGod;
    
    cin >> n >> q;
    for (int i = 1; i <= n; ++ i) cin >> a[i];
    for (int i = 1; i <= n; ++ i){
    	for (int j = i + 1; j <= n; ++ j){
    		if (a[i] < a[j]) dp[0][i][j] = 1;
    		else if (a[i] != a[j]) dp[1][i][j] = 1;
		}
	}
	qq = q;
	while (qq --){
		int x, y;
		cin >> x >> y;
		if (y < x) swap(x, y);
		for (int i = 1; i < x; ++ i){
			dp[0][i][x] = dp[0][i][y] = ll((dp[0][i][x] + dp[0][i][y]) % mod) * inv % mod;
			dp[1][i][x] = dp[1][i][y] = ll((dp[1][i][x] + dp[1][i][y]) % mod) * inv % mod;
		}
		for (int i = y + 1; i <= n; ++ i){
			dp[0][x][i] = dp[0][y][i] = ll((dp[0][x][i] + dp[0][y][i]) % mod) * inv % mod;
			dp[1][x][i] = dp[1][y][i] = ll((dp[1][x][i] + dp[1][y][i]) % mod) * inv % mod;
		}
		for (int i = x + 1; i < y; ++ i){
			dp[0][x][i] = dp[1][i][y] = ll((dp[0][x][i] + dp[1][i][y]) % mod) * inv % mod;
			dp[1][x][i] = dp[0][i][y] = ll((dp[1][x][i] + dp[0][i][y]) % mod) * inv % mod;
		}
		dp[0][x][y] = dp[1][x][y] = ll((dp[0][x][y] + dp[1][x][y]) % mod) * inv % mod;
	}
	for (int i = 1; i <= n; ++ i) for (int j = i + 1; j <= n; ++ j) ans = (ans + dp[1][i][j]) % mod;
	for (int i = 0; i < q; ++ i) ans = ans * 2 % mod;
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 58756
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	boolean J = true;
	  	int i,j;
	  	
	  	while(J) {
	  		
		  	int  h = scanner.nextInt();			//入力
		  	int  w = scanner.nextInt();
		  	
		  	if( h == 0 && w == 0 )
		  		break;
	  		
		  	for(i = 1; i <= h ; i ++){
		  		for(j = 1; j <= w ; j++){
		  			if(j == w) 
		  				System.out.println("#");
		  			else	
		  				System.out.print("#");
		  		}
		  	}
		  	System.out.print("\n");
		  	
  		}
        scanner.close();
  }
}


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

int main(){
  int n;
  cin >> n;
  int count = 0;
  rep(i,n/2+1){
    if(i != n-i) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_h

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define em emplace_back
#define test ll t;cin>>t;while(t--)
#define M 1000000007
#define input ll x;cin >> x
ll dp[1001][1001];
char grid[1001][1001];
ll solve(ll h, ll w, ll y, ll x);
ll power(ll a, ll b)
{
	ll res = 1;
	a = a % M;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % M;
			b--;
		}
		a = (a * a) % M;
		b >>= 1;
	}
	return res;
}
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
	ll h,w;
	cin >> h >> w;
	memset(dp, -1, sizeof(dp));
	for (size_t i = 1; i <= h; i++)
	{
		for (size_t j = 1; j <= w; j++)
		{
			cin >> grid[i][j];
		}
	}
	ll ans = solve(h, w, 1, 1);
	cout << ans << endl;
}

ll solve(ll h, ll w, ll y, ll x){
	if(grid[y][x]=='#'){
		return dp[y][x] = 0;
	}
	if (y > h || x > w)
	{
		return 0;
	}
	if(y==h&&x==w){
		return dp[y][x] = 1 % M;
	}
	if(dp[y][x]!=-1)
		return dp[y][x];
	ll right = solve(h, w, y, x + 1) % M;
	ll down = solve(h, w, y+1, x) % M;
	return dp[y][x] = (right + down) % M;
}

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  int N;
  cin>>N;
  vector<ll> vec(N);
  rep0(i,N){cin>>vec[i];}
  rep0(k,N){if(k<N-1){cout<<vec[k]<<" ";}else{cout<<vec[k]<<endl;}}
  rep1(i,N-1){
      int v=vec[i];
      int j=i-1;
      while(j>=0&&vec[j]>v){
          
          vec[j+1]=vec[j];
          j--;
          vec[j+1]=v;
      }
      rep0(k,N){if(k<N-1){cout<<vec[k]<<" ";}else{cout<<vec[k]<<endl;}}
  }
}



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

#define mp          make_pair
#define pb          push_back
#define ff          first
#define ss          second
#define ii          pair<int,int>
#define mod         (int)1e9+7
#define inf         1e18
#define max_v       200005

typedef long long int lli;
typedef long double ld;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int n;
int A[100005],B[100005],C[100005];
int dp[100005][3];

int func()
{
    for(int i=1;i<=n;i++)               //initialization
    {
        for(int j=1;j<=3;j++)
        {
            if(i==1)
            {
                if(j==1)
                    dp[i][j]=A[i];
                else if(j==2)
                    dp[i][j]=B[i];
                else
                    dp[i][j]=C[i];
            }
        }
    }

    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        {
            for(int k=1;k<=3;k++)
            {
                if(j==k)
                    continue;
                if(j==1)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i]);
                else if(j==2)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+B[i]);
                else
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+C[i]);
            }
        }
    }

    int ans=0;
    ans=max(ans,dp[n][1]);
    ans=max(ans,dp[n][2]);
    ans=max(ans,dp[n][3]);

    return ans;
}

void solve() 
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i]>>B[i]>>C[i];
    }
    cout<<func()<<endl;
}

int main()
{
    fio

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
 
    int t;
    t=1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    string s;
    cin >> s;
    vector<char> v;

    rep(i, s.length()) {
        if (s[i] == '0') v.push_back('0');
        else if (s[i] == '1') v.push_back('1');
        else {
            if (!v.empty()) v.pop_back();
        }
    }

    rep(i, v.size()) cout << v[i];
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
vector<int> g[100005];
void fun(int x,int y,int n){
	cout<<x<<" "<<y<<endl;
	cout<<x<<" "<<n-y+1<<endl;
	cout<<n-x+1<<" "<<y<<endl;
	cout<<n-x+1<<" "<<n-y+1<<endl;
}
int main(){
	int n;cin>>n;
	int y=n/2;
	int x=2*y*(y-1);
	if(n%2)
	cout<<x+n-1<<endl;
	else cout<<x<<endl;
	if(n%2){
		for(int i=1;i<=n-1;i++)cout<<i<<" "<<n<<endl;
		n=n-1;
	}
		for(int i=1;i<=n/2;i++){
			for(int j=i+1;j<=n/2;j++){
				fun(i,j,n);
			}
		}
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int mem[5];
int result;

int main()
{
	int a, b;
	int i, j;
	int two = 0, notTwo = 0;
	for (i = 0; i < 3; i++)
	{
		cin >> a >> b;
		
		mem[a]++;
		mem[b]++;

	}
	for (i = 1; i < 5; i++)
	{
		if (mem[i] == 2)
			two++;
		else
			notTwo++;
	}
	if (two == 2 && notTwo == 2)
		cout << "YES\n";
	else
		cout << "NO\n";


	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b;
  float t; cin >> a >> b >> t;
  cout << (b*int((t+0.5)/a));
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
signed main() {
	int n, a[100], m = 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		m += a[i];
	}
	m /= n;
	for (int i = m; i >= 0; i--) {
		int cnt = 0;
		rep(j, n) {
			cnt += a[j];
			cnt -= i;
			if (cnt < 0)goto ioi;
		}
		cout << i << endl;
		return 0;
	ioi:;
	}
}


Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static int permu[][];

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

		int n = Integer.parseInt(br.readLine());
		permu = new int[(int) Math.pow(2, n)][n];

		int said[][] = new int[n][n];

		for (int i = 0; i < n; i++)
			Arrays.fill(said[i], -1);

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(br.readLine());
			for (int j = 0; j < a; j++) {
				String str[] = br.readLine().split(" ");
				int x = Integer.parseInt(str[0]) - 1;
				int y = Integer.parseInt(str[1]);
				said[i][x] = y;
			}
		}

		for (int i = 0; i < Math.pow(2, n); i++) {
			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) != 0) {
					permu[i][j] = 1;
				} else {
					permu[i][j] = 0;
				}
				// System.out.print(permu[i][j]);
			}
			// System.out.print("\n");
		}

		int max = 0;

		for (int i = 0; i < Math.pow(2, n); i++) {
			int ans = 0;
			boolean flag = false;

			for (int j = 0; j < n; j++) {
				if (permu[i][j] == 1) {
					for (int k = 0; k < n; k++) {
						if (said[j][k] == 0) {
							if (permu[i][k] != 0) {
								flag = true;
								break;
							}
						} else if (said[j][k] == 1) {
							if (permu[i][k] != 1) {
								flag = true;
								break;
							}
						}
					}
					ans++;
				}
				if (flag) {
					break;
				}
			}
			if (flag) {
				continue;
			}
			max = Math.max(max, ans);
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 23380
n, k = [int(i) for i in input().split()]

divList = [0 for i in range(k)]
for i in range(1, n+1):
    divList[i % k] += 1

# print(divList)

count = 0
for i in range(k):
    if (i*2) % k == 0:
        count += divList[i] ** 3
print(count)

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n, w;
    cin>>n>>w;
    vector<long long> weights(n), values(n);
    for(long long i=0;i<n;i++){
        cin>>weights[i]>>values[i];
    }

    vector<vector<long long>> dp(n+1, vector<long long>(w+1));

    for(long long i=1;i<n+1;i++){
        for(long long j=1;j<w+1;j++){
            // building dp[i][j]
            dp[i][j]=dp[i-1][j];
            if(j-weights[i-1]>=0)
                dp[i][j]=max(dp[i-1][j-weights[i-1]]+values[i-1], dp[i][j]);
        }
    }

    cout<<dp[n][w]<<endl;

}

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

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

    string S;
    cin >> S;

    vector<char> v;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'B') {
            if (v.size() == 0) continue;
            else v.pop_back();
        } else v.push_back(S[i]);
    }

    for (int i = 0; i < v.size(); ++i) {
        cout << v[i];
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n,k;
int a[300010];
int ans;
int max_a;
int min(int a,int b){
	return a<b ? a:b;
}
int max(int a,int b){
	return a>b?a:b;
}
struct seg{
	int tree[2000010],lim;
	void init(int n){
		for(lim=1; lim<=n; lim<<=1);
		for(int i = 0;i<2*lim;i++){
			tree[i] = 0;
		}
	}
	void add(int x,int v){
		x+=lim;
		tree[x] = v;
		while(x>1){
			x >>= 1;
			tree[x] = max(tree[2*x],tree[2*x+1]);
		}
	}
	int query(int s,int e){
		s+=lim;
		e+=lim;
		int ret = 0;
		while(s<e){
			if(s%2==1) ret = max(ret, tree[s++]);
			if(e%2==0) ret = max(ret, tree[e--]);
			s >>= 1;
			e >>= 1;
		}
		if(s==e) ret = max(ret,tree[s]);
		return ret;
	}
}seg;
int main(){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		max_a = max_a > a[i] ? max_a : a[i];
	}
	seg.init(max_a);
	for(int i=n-1;i>=0;i--){
		int t = seg.query(max(0,a[i]-k),min(max_a,a[i]+k))+1;
		ans = max(ans,t);
		seg.add(a[i],t);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 7008
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long a, long long b){
    LL m = min(a,b);
    LL t = max(a,b);
    REP(i, t){
        cout<<m;
    }
    cout<<endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256