akhauriyash/Code-Regression huggingface dataset:
fun main(args:Array<String>){
    val str = readLine()!!
    var flag = false
    if(str[0]==str[1]){
        if(str[2]==str[3])flag=true
    }else if(str[0]==str[2]){
        if(str[1]==str[3])flag=true
    }else if(str[0]==str[3]){
        if(str[1]==str[2])flag=true
    }else if(str[1] ==str[2]){
        if(str[0]==str[3])flag=true
    }else if(str[1]==str[3]){
        if(str[2]==str[0])flag=true
    }else if(str[2]==str[3]){
        if(str[0]==str[1])flag=true
    }
    if(str[0]==str[1]&&str[1]==str[2]&&str[2]==str[3])flag=false
    if(flag){
        println("Yes")
    }else{
        println("No")
    }
}

Measured memory_bytes: 31448
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)

class FordFulkerson:
    def __init__(self,n):
        self.visited=[False]*n
        self.G=[[0]*n for _ in range(n)]
        self.n=n
    def add_edge(self,fr,to,cap):
        self.G[fr][to]=cap
    def dfs(self,start,goal,f):
        if start==goal:
            return f
        self.visited[start]=True
        for i in range(self.n):
            if i==start:
                continue
            if (not self.visited[i]) and self.G[start][i]>0:
                d=self.dfs(i,goal,min(f,self.G[start][i]))
                if d>0:
                    self.G[start][i]-=d
                    self.G[i][start]+=d
                    return d
        return 0
    def maxflow(self,source,sink):
        flow=0
        while True:
            self.visited=[False]*self.n
            f=self.dfs(source,sink,float('inf'))
            if f==0:
                break
            flow+=f
        return flow

def BipartiteMatching(Pairs,a,b):
    solver=FordFulkerson(a+b+2)
    for x,y in Pairs:
        solver.add_edge(x+1,a+y+1,1)
    for x in range(a):
        solver.add_edge(0,x+1,1)
    for y in range(b):
        solver.add_edge(a+y+1,a+b+1,1)
    return solver.maxflow(0,a+b+1)

n=int(input())
R=[list(map(int,input().split())) for _ in range(n)]
B=[list(map(int,input().split())) for _ in range(n)]
Pairs=[]
for i in range(n):
    for j in range(n):
        if R[i][0]<B[j][0] and R[i][1]<B[j][1]:
            Pairs.append((i,j))
print(BipartiteMatching(Pairs,n,n))

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    int ans,tmp;
    public void input(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        ans = a;
        if(a > b){
            ans--;
        }
        sc.close();
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 21840
#include<stdio.h>
int main()
{
    long long h,a,b,n,N;
    int c;
    while(~scanf("%lld",&N))
    {
        c=0;
        for(h=1; h<=3500; h++)
        {
            for(n=1; n<=3500; n++)
            {
                a=N*h*n;
                b=4*h*n-N*n-h*N;
                if(a>0&&b>0&&a%b==0)
                {
                    printf("%lld %lld %lld\n",h,n,a/b);
                    c++;
                    break;
                }
            }
            if(c!=0) break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
A = [[0]*W for i in range(H)]
B = [[0]*W for i in range(H)]
for i in range(H):
  inf = [int(c) for c in input().split()]
  for j in range(W):
    A[i][j] = inf[j]

for i in range(H):
  inf = [int(c) for c in input().split()]
  for j in range(W):
    B[i][j] = inf[j]

X = (H+W)*80
dp = [[0]*W for i in range(H)]
d = abs(A[0][0]-B[0][0])
dp[0][0] = 1<<(X+d)

for i in range(H):
  for j in range(W):
    if i==0 and j==0:
      continue
    d = abs(A[i][j]-B[i][j])
    if i!=0:
      dp[i][j] |= dp[i-1][j]>>d
      dp[i][j] |= dp[i-1][j]<<d
    if j!=0:
      dp[i][j] |= dp[i][j-1]>>d
      dp[i][j] |= dp[i][j-1]<<d

s = bin(dp[-1][-1])[2:]
l = len(s)-1
ans = float('inf')
for i in range(l,-1,-1):
  if s[i]=='1':
    m = abs(l-i-X)
    if m<ans:
      ans = m
print(ans)

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<bool> tricked(n,true);
	rep(i,k){
		int d;
		cin>>d;
		rep(j,d){
			int a;
			cin>>a;
			tricked[a-1]=false;
		}
	}
	int ans=0;
	rep(i,n){
		if(tricked[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int   par1[200010];
int  rank1[200010];

int   par2[200010];
int  rank2[200010];

void init (int n){
  for(int t=1;t<=n;t++){
    par1[t]=t;
    rank1[t]=0;
  }
}
int  find (int x){
  if(par1[x]==x){
    return x;
  }else{
    return par1[x]=find(par1[x]);
  }
}
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rank1[x]<rank1[y]){
    par1[x]=y;
  }else{
    par1[y]=x;
    if(rank1[x]==rank1[y])rank1[x]++;
  }
}
bool same(int x, int y){
  return find(x)==find(y);
}

void init2(int n){
  for(int t=1;t<=n;t++){
    par2[t]=t;
    rank2[t]=0;
  }
}
int  find2(int x){
  if(par2[x]==x){
    return x;
  }else{
    return par2[x]=find2(par2[x]);
  }
}
void unite2(int x, int y){
  x=find2(x);
  y=find2(y);
  if(x==y)return;

  if(rank2[x]<rank2[y]){
    par2[x]=y;
  }else{
    par2[y]=x;
    if(rank2[x]==rank2[y])rank2[x]++;
  }
}
bool same2 (int x, int y){
  return find2(x)==find2(y);
}

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

  init (N);
  init2(N);

  for(int t=1;t<=K;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    unite(a,b);

  }
  for(int t=1;t<=L;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    unite2(a,b);
  }

  vector <P>v;
  P p[200010];

  for(int t=1;t<=N;t++){
    p[t]=P(find(t),find2(t));
    v.push_back(p[t]);
  }

  sort(v.begin(),v.end());

  for(int t=1;t<=N;t++){
    int temp=upper_bound(v.begin(),v.end(),p[t])-lower_bound(v.begin(),v.end(),p[t]);
    printf("%d ",temp);
  }

  printf("\n");
  return 0;
}


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

int main(){

	long long n;
	cin >> n;
  
  	if ( n == 2 ){
      cout << 1 << endl;
      return 0;
    }else if ( n == 3 ){
      cout << 2 << endl;
      return 0;
    }

	long long a;

	a = sqrt(n);

	if ( a * a == n ){
		cout << (a-1) + (a-1) << endl;
	}else{
		for ( long long i = a; i >= 1; i--){
			if ( n % i == 0 ){
				cout << (n / i -1) + (i-1) << endl;
                return 0;
			}
		}
	}

	return 0;

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

int main(){
	int n,k; cin >> n >>k;
	int arr[n+1] ={};
	rep(i,n) cin >> arr[i+1];

	vector<ll> dp(n+1,INT_MAX);
	dp[2] = abs(arr[2] - arr[1]);
    dp[1] = 0;
    dp[0] = 0;
    
    ll cur;
	
	for(int i=3;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(i-j > 0){
				cur = dp[i-j] + abs(arr[i] - arr[i-j]);
				self_min(dp[i],cur);
			}
			    
		}
	}

	cout << dp[n] << endl;
	return 0;
}




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

#define int long long
const int INF = 1e15;
typedef pair<int, int> P;

struct Edge {
	int to, cost;
};

int n;
vector<Edge> G[801];
int ss;

int dfs(int v, int p) {
	//if ( ss == 3 ) cout << v << " " << p << endl;
	bool flg = false;
	for ( Edge e : G[v] ) {
		int to = e.to, cost = e.cost;		
		if ( to == p ) continue;
		if ( G[to].size() >= 2 ) flg = true;
	}

	if ( !flg ) return 0;
	
	int ret = 0;	
	for ( Edge e : G[v] ) {
		int to = e.to, cost = e.cost;
		if ( to == p ) continue;
		if ( G[to].size() == 1 ) continue;
		ret += dfs(to, v)+cost;		
	}

	return ret;
}

int calc(int s) {
	ss = s;
	int ret = 0;
	int ma = 0;
	for ( Edge e : G[s] ) {
		int to = e.to, cost = e.cost;
		if ( G[to].size() == 1 ) continue;
		int tmp = dfs(to, s)+cost;
		//if ( s == 7 ) cout << tmp << endl;
		ma = max(ma, tmp);
		ret += tmp*2;
	}

	queue<P> q;
	vector<int> d(n, -1);
	q.push(P(s, 0));
	while ( !q.empty() ) {
		P p = q.front(); q.pop();
		int v = p.first, c = p.second;

		if ( d[v] >= 0 ) continue;
		if ( G[v].size() == 1 ) continue;

		d[v] = c;

		for ( Edge e : G[v] ) {
			int to = e.to, cost = e.cost;
			if ( G[to].size() == 1 ) continue;
			q.push(P(to, c+cost));
		}
	}

	ma = 0;
	for ( int i = 0; i < n; i++ ) ma = max(ma, d[i]);

	//if ( s == 3 ) cout << ma << endl;

	return ret-ma;
}

signed main() {
	
	while ( cin >> n, n ) {
		for ( int i = 0; i < 801; i++ ) G[i].clear();
		int sum = 0;

		{		
			vector<int> p(n);
			for ( int i = 0; i < n-1; i++ ) cin >> p[i], p[i]--;
			for ( int i = 1; i < n; i++ ) {
				int d;
				cin >> d;
				sum += d;
				G[i].push_back(Edge{p[i-1], d});
				G[p[i-1]].push_back(Edge{i, d});
			}
		}

		//for ( int i = 0; i < n; i++ ) cout << G[i].size() << endl;

		int ans = INF;
		int id = 0;
		for ( int i = 0; i < n; i++ ) {
			//if ( ans > calc(i) ) id = i;
			ans = min(ans, calc(i));
		}

		//cout << id << endl;
		cout << ans+sum << endl;
	}	
	return 0;
}



Measured memory_bytes: 3308
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		String[] a = new String[h];
		for (int i = 0; i < h; i++) {
			a[i] = in.next();
		}

		boolean[] row = new boolean[h];
		Arrays.fill(row, false);
		boolean[] col = new boolean[w];
		Arrays.fill(col, false);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i].charAt(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]) {
						System.out.print(a[i].charAt(j));
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 26388
# -*- coding: utf-8 -*-
def print_rec(now_moji, tsugi, nokori):
    if nokori == 0:
        print(now_moji)
    else:
        for i in range(tsugi + 1):
            tsugi_moji = now_moji + chr(i + 97)
            if i == tsugi:
                print_rec(tsugi_moji, tsugi + 1, nokori - 1)
            else:
                print_rec(tsugi_moji, tsugi, nokori - 1)


n = int(input())
if n == 1:
    print("a")
else:
    print_rec("a", 1, n - 1)


Measured memory_bytes: 4404
n = input()
s = input().strip()

l = "("
r = ")"

add_right, add_left = 0, 0

for c in s:
    if c == l:
        add_right += 1
    else:
        if add_right:
            add_right -= 1
        else:
            add_left += 1

print(l * add_left + s + r * add_right)

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

int main() {
  int h, w, c = 0;
  scanf("%d %d", &h, &w);
  vector<string> a(h);
  for(int i = 0; i < h; i++) {
    cin >> a[i];
    for(auto x : a[i]) c += x == '#';
  }
  if(c == h + w - 1)
    printf("Possible\n");
  else
    printf("Impossible\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,m,n) for(int i=(m);i<(n);i++)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int n;cin >> n;
  vector<ll>a(n);
  rep(i,n)cin >> a[i];
  ll sum=0;
  rep(i,60){
    ll cnt=0,rui=pow(2,i);
    rep(j,n){
      if(a[j]>>i&1)cnt++;
    }
    cnt=(cnt*(n-cnt))%mod;
    sum+=(cnt*(rui%mod))%mod;
    sum%=mod;
  }
  cout << sum;
}
	  




Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=100100;
const ll MAXK=17;
const ll INF=2e18;
const ll MOD=998244353;

ll A[MAXN];
ll B[MAXN];
ll T[MAXN];
ll F[MAXN];
ll N,a,b;
ll ans;

int main(){
    cin>>N;
    for(int i=0;i<=N;++i)cin>>A[i];
    F[0]=1;
    for (int i=1;i<=N;++i){
        F[i]=F[i-1]*2;
        if(F[i]>1e16)F[i]=1e16;
    }
    for (int i=N-1;i>=0;--i){
        T[i]=T[i+1]+A[i+1];
        T[i]=min(F[i]-A[i],T[i]);
    }
    // for (int i=0;i<=N;++i)cout<<T[i]<<' ';cout<<'\n';
    B[0]=min(1LL,T[0]);
    for (int i=1;i<=N;++i){
        B[i]=2*B[i-1]-A[i];
        B[i]=min(B[i],T[i]);
        ans+=B[i]+A[i];
    }
    if(N==0&&A[N]!=1){
        cout<<-1;
        return 0;
    }
    // for(int i=0;i<=N;++i)cerr<<A[i]<<' '<<B[i]<<'\n';
    if (B[N]<0){
        cout<<-1;return 0;
    }
    for (int i=0;i<N;++i){
        if (B[i]<=0||B[i]>B[i+1]+A[i+1]||B[i]*2<A[i+1]+B[i+1]){
            cout<<-1;
            return 0;
        }
    }
    cout<<ans+1;
}   

Measured memory_bytes: 6800
use std::io::Read;
use std::cmp::Reverse;

fn main() {
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let mut iter = buf.split_whitespace().map(|s| s.parse().unwrap());
  
  let n:usize = iter.next().unwrap() as usize;
  let mut S : Vec<(i64, i64)> = (0 .. n).map(|_|(iter.next().unwrap(), iter.next().unwrap())).collect();
  S.sort_by_key(|(a,b)| Reverse(a + b));
  let dp = S.into_iter().fold((true, 0, 0), |(first, sa, sb), (a,b)|{
    if first {
      (!first, sa + a, sb)
    } else {
      (!first, sa, sb + b)
    }       
  });
  println!("{}", dp.1 - dp.2);
}

Measured memory_bytes: 6064
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def combination(self, n, r):
        if n - r < r:
            return self.combination(n, n - r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def factorial(self, n):
        return self.fact[n]


def main():
    MOD = 10 ** 9 + 7

    N, K = map(int, input().split())
    K = min(K, N)

    calc = Calc(max_value=N * 2, mod=MOD)

    ans = 0
    for v in range(K + 1):  # 空室数
        ans = (ans + calc.combination(N, v) * calc.combination(v + (N - v) - 1, v)) % MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36724
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

#define N 100001

int parent[N];
int visited[N];
ll num[N];
int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}

void init(){
  for (int i = 0; i < N; i++){
    parent[i] = i;
    num[i] = 1;
  }
}

int main(void){
  ll n, m;
  cin >> n >> m;
  
  vector<ll> a(m), b(m);
  for (int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
  }

  ll ans = 0;
  for (int i = 0; i < m; i++){
    init();

    for (int j = 0; j < m; j++){
      if (i != j){
        if (findroot(a[j]) != findroot(b[j]))
          parent[findroot(a[j])] = b[j];
      }
    }
    if (findroot(a[i]) != findroot(b[i]))
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict

n,p = map(int, input().split())
s = input()
t = list(map(int, s))

mod = p

if mod < 10:
    d = {0:0}
    ans = 0
    for i in t:
        nxt = defaultdict(int)
        for key,value in d.items():
            nxt[(key*10 + i)%mod] += value
        nxt[i%mod] += 1
        ans += nxt[0]
        d = nxt
    print(ans)
else:
    cnt = [0]*mod
    f = 1
    ans = 0
    cur = 0
    for i in reversed(range(n)):
        cur += f*t[i]
        cur %= mod
        ans += cnt[cur]
        cnt[cur] += 1
        if cur == 0:
            ans += 1
        f *= 10
        f %= mod
    print(ans)

Measured memory_bytes: 48332
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s;
  cin>>s;

  string t="";
  for(int i=s.size()-1;i>=0;i--){
    t+=s[i];
    if(t=="maerd" || t=="remaerd" || t=="esare" || t=="resare"){
      t="";
    }
  }
  if(t.empty()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
# AOJ 0145 Cards
# Python3 2018.6.18 bal4u
#　動的計画法　（行列の積に類似）

INF = 0x7fffffff

n = int(input())
c = [[INF for j in range(n)] for i in range(n)]
a = [[0 for j in range(2)] for i in range(n)]

for i in range(n): c[i][i] = 0
for i in range(n): a[i][0], a[i][1] = list(map(int, input().split()))

for l in range(1, n):
	for i in range(n-l):
		j = i + l
		for k in range(i, j):
			c[i][j] = min(c[i][j], c[i][k] +a[i][0]*a[k][1]*a[k+1][0]*a[j][1] +c[k+1][j])

print(c[0][n-1])


Measured memory_bytes: 5644
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	A := make([]int, m)
	for i := range A {
		fmt.Scan(&A[i])
	}

	cst := 0
	for i := 0; i < m && A[i] < x; i++ {
		cst++
	}

	ans := cst
	cst = 0
	for i := m - 1; i >= 0 && A[i] > x; i-- {
		cst++
	}
	ans = min(ans, cst)

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const D EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> PII;

struct  P {
	int x, y;
	P() {}
	P(int x_, int y_) : x(x_), y(y_) {}
};

/** Problem1018 : Cheating on ICPC **/
int main()
{
	int N;
	while (cin>>N) {
		vector<int> times;
		rep(i, N) {
			int a; cin>>a;
			times.push_back(a);
		}
		sort(times.begin(), times.end());
		int ans=0, sum=0;
		rep(i, N) {
			sum+=times[i];
			ans+=sum;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1220
S = gets.chomp.split('')
N = S.length

MOD = 10**9 + 7

a = 0
ab = 0
abc = 0
pattern = 1

(1..N).each do |i|
  str = S[i-1]
  if str == 'A'
    a += pattern
  elsif str == 'B'
    ab += a
  elsif str == 'C'
    abc += ab
  elsif str == '?'
    abc = abc * 3 + ab
    ab = ab * 3 + a
    a = a * 3 + pattern
    pattern *= 3
  end
  a %= MOD
  ab %= MOD
  abc %= MOD
  pattern %= MOD
end

puts abc % MOD

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
const lld OO = 1e16 , AKA = 1e5 + 5;
int SD(){int x; scanf("%d" , &x); return x;}
lld SLL(){lld x; scanf("%lld" , &x); return x;}
lld mem[101][AKA] , N , C , W[AKA] ,P[AKA];
void init()
{
    for(int i = 0 ; i < 101 ; ++i)
        memset(mem , -1 , sizeof mem);
}
lld knapsack(int i = N - 1 , int rem = C)
{
    if(rem < 0)
        return -OO;
    if(i < 0)
        return 0;
    lld &ret = mem[i][rem];
    if(~ret)
        return ret;
    return ret = max(knapsack(i - 1 , rem - W[i]) + P[i] , knapsack(i - 1 , rem));
}
int main()
{
    init();
    N = SLL() , C = SLL();
    for(int i = 0 ; i < N ; ++i)
        W[i] = SLL() , P[i] = SLL();
    printf("%lld" , knapsack());
}


Measured memory_bytes: 79232
import java.util.*;
class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt();
        String S = sc.next();
        int i=0,j=S.length()-1,c=0;
        while(i<j){
            if(S.charAt(i)=='W'){
                while(i<j){
                    if(S.charAt(j)=='R'){
                        c++;
                        j--;
                        i++;
                        break;
                    }
                    else{
                        j--;
                    }
                }
            }else{
                i++;
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 40320
s = input()
v = [0 for i in range(len(s))]
r,l = 0,0
vis = [False for i in range(len(s))]

for i in range(len(s)):
  if vis[i]:
    continue
  vis[i] = True
  if s[i] == 'L':
    x = i-1
    y = i
    r,l = 0,0
    while x >= 0 and s[x] == 'R':
      r += 1
      x -= 1
    while y <= len(s)-1 and s[y] == 'L':
      vis[y] = True
      l += 1
      y += 1
    v[i-1] = l//2+(r-r//2)
    v[i] = (l-l//2)+r//2
print (*v)

Measured memory_bytes: 11616
N=gets.to_i
    $as=N.times.map{gets.split.map{|e|e.to_i-1}}
    $queue=Array.new
    def push_queue(i)
      op=$as[i][0]
      return if op.nil?
      opop=$as[op][0]
      return if i!=opop
      $queue << [i,op]
      return
    end
     
    day=0
     
    N.times do |i|
      push_queue(i)
    end
     
    until $queue.empty?
      day+=1
      queue_cur=$queue.clone
      $queue=Array.new
      until queue_cur.empty?
        a,b=queue_cur.shift
        if $as[a][0]==b && $as[b][0]==a
          $as[a].shift
          $as[b].shift
          push_queue(a)
          push_queue(b)
        end
      end
    end
    puts $as.all?{|es|es.empty?} ? day : -1


Measured memory_bytes: 11644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
const ll mod = 1e9+7;
// __uint128_t

//このSegmentTreeは最小値を扱う仕様になっている
struct SegmentTree {
private:
    ll n;
    vector<ll> node;
    ll INF = 1e18;
public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<ll> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        ll sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(ll x, ll val) {
        // x番目をvalに変える
        // 最下段のノードにアクセスする
        x += (n - 1);

        // 最下段のノードを更新したら、あとは親に上って更新していく
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    ll get_X(ll x){
        x += (n - 1);
        return node[x];
    }
    
    // 要求区間 [a, b) 中の要素の最小値を答える
    // k := 自分がいるノードのインデックス
    // 対象区間は [l, r) にあたる

    ll get_min(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if(r < 0) r = n;

        // 要求区間と対象区間が交わらない -> 適当に返す
        if(r <= a || b <= l) return INF;

        // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
        if(a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        ll vl = get_min(a, b, 2*k+1, l, (l+r)/2);
        ll vr = get_min(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }

};

int main(){
    ll N, M; cin >> N >> M;
    vector<pair<pair<ll, ll>, ll>> V(M); 
    for(int i = 0; i < M; i++){
        ll l, r, c; cin >> l >> r >> c;
        V[i] = {{l, r}, c};
    }
    sort(V.begin(), V.end());
    vector<ll> DP(N+1, INF);
    SegmentTree tree(DP);
    for(int i = 0; i < M; i++){
        auto p = V[i];
        ll l = p.first.first, r = p.first.second, c = p.second;
        if(l == 1) tree.update(r, c);
        else{
            ll Min = tree.get_min(l, r);
            tree.update(r, min(tree.get_X(r), Min+c));
        }
    }
    if(tree.get_X(N) == INF) cout << -1 << endl;
    else cout << tree.get_X(N) << endl;
}

Measured memory_bytes: 6144
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b;
    cin >> a >> b;
    cout << (a == b ? "Draw" : ((a+11)%13 > (b+11)%13 ? "Alice" : "Bob")) << "\n";
    
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

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

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;


 
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) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}

LL powm(LL x, LL y,LL m) {
    if (y==0) return 1;
    if (y==1) return x%m;
    if (y&1) return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m) {
    return powm(x,m-2,m);
}

int add(int var1, int var2) {
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}


int mul(int var1, int var2) {
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

LL INF=1e9;

void solve() {
    string s;
    read(s);

    if (s== string(3,'R')) {
        cout << 3 << nl;
        return;
    }

    if (s == string(3,'S')) {
        cout << 0 << nl;
        return;
    }

    if ( (s[0] == 'R' and s[1] == 'R') or (s[1] == 'R' and s[2] == 'R')) {
        cout << 2 << nl;
        return;
    }
    cout << 1 << nl;
}

int main() {
    fast;
        solve();
}


Measured memory_bytes: 3528
n = int(input())
stations = []
for i in range(n-1):
    stations.append(list(map(int, input().split())))

ans = [0]
time_matrix = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(i+1):
        if i < n-1:
            if time_matrix[i][j] % stations[i][2] == 0:
                waiting = 0
            else:
                waiting = stations[i][2] - (time_matrix[i][j] % stations[i][2])
            time_matrix[i+1][j] = max(time_matrix[i][j] + stations[i][0] + waiting, stations[i][0] + stations[i][1])

for i in range(n):
    print(time_matrix[n-1][i])


Measured memory_bytes: 15040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	b := make([]int, n)
	wa := 0
	ac := 0
	for i := 0; i < m; i++ {
		p := iScan() - 1
		s := Scan()
		if b[p] <= 0 {
			if s == "AC" {
				ac++
				wa += b[p] * -1
				b[p] = 1
			} else {
				b[p]--
			}
		}
	}
	fmt.Println(ac, wa)
}


Measured memory_bytes: 3132
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int i;
    int val;
    rep(i,n){
    	cin>>val;
    }
    n--;
    val=n/(k-1);
    if(n%(k-1))
    	val++;
    cout<<val<<endl;
    return 0;  
    
}



Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
L = []
R = []
for _ in range(M):
  l, r = [int(x) for x in input().split()]
  L.append(l)
  R.append(r)

ans = min(R) - max(L) + 1
print(ans if ans >= 0 else 0)

Measured memory_bytes: 11020
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

bool dfs(string& s, int cur, int obj) {
  if(cur >= s.size()) return false;
  if(s[cur] == '#') return false;
  if(cur == obj) return true;

  return dfs(s, cur + 1, obj) || dfs(s, cur + 2, obj);
}

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

  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  --a; --b; --c; --d;
  string s; cin >> s;

  if(c > d) {
    // b->c 間で3つ空白がなければaはbを追い越せない
    int maxw = 0;
    int wcnt = 0;
    for(int i = b - 1; i <= d + 1; ++i) {
      if(s[i] == '.') {
        ++wcnt;
        chmax(maxw, wcnt);
      } else {
        wcnt = 0;
      }
    }
    if(maxw < 3) {
      cout << "No" << endl;
      return 0;
    }
  }

  bool ans1 = dfs(s, b, d);
  bool ans2 = dfs(s, a, c);
  if(ans1 && ans2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 2384
package main

import "fmt"

const mod = 1000000007

var (
	n, k int
	c    [][]int
)

func initCmb() {
	max := n - k + 1
	if v := k - 1; v > max {
		max = v
	}

	c = make([][]int, max+1)
	for i := 0; i <= max; i++ {
		c[i] = make([]int, i+1)
		c[i][0], c[i][len(c[i])-1] = 1, 1
		for j := 1; j < len(c[i])-1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod
		}
	}
}

func cmb(a, b int) int {
	if b > a {
		return 0
	}
	return c[a][b]
}

func main() {
	fmt.Scan(&n, &k)

	initCmb()
	for i := 1; i <= k; i++ {
		fmt.Println(cmb(n-k+1, i) * cmb(k-1, i-1) % mod)
	}
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
	int a,b;cin>>a>>b;
	int cnt=0;
	for(int i=a;i<=b;i++){
		string s=to_string(i),t=s;
		reverse(t.begin(),t.end());
		if(s==t)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

ll about(ll n){
    
  int ans = 1;

  for (int i = 2; i <= sqrt(n); i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    ans *= (cnt + 1);
    if (n == 1) break;
  }
  if (n != 1) ans *= 2;

  return ans;
}



signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N;
    cin >> N;
    ll c=1;
    ll count=1;
    ll i =0;
    ll a =0; 

    FOR(i,c,N-2){
        
        a = about(N-i);

        count = count + a;

    }

    
    cout << count << endl;
    
}

Measured memory_bytes: 3680
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N , K;
vector<int> V[100010];
int P[100010];
int w[100010][2];
bool b[100010];
const int INF = -123456789;

bool dfs(int r , int e){
	b[e] = 1;
	if(r >= 0 && P[e] >= 0){
		if((w[e][0] + P[e]) % 2 == 1 || (P[e] < w[e][0] || w[e][1] < P[e])) return 0;
		w[e][0] = w[e][1] = P[e];
		return dfs(-1 , e);
	}
	repv(int,it,V[e]){
		if(b[*it]) continue;
		w[*it][0] = w[e][0] - 1;
		w[*it][1] = w[e][1] + 1;
		if(!dfs(e,*it)) return 0;
		w[e][0] = max(w[e][0] , w[*it][0] - 1);
		w[e][1] = min(w[e][1] , w[*it][1] + 1);
		if(w[e][0] > w[e][1]) return 0;
	}
	return 1;
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N){
		int x , y;
		scanf("%d%d" , &x , &y);
		V[x].PB(y);
		V[y].PB(x);
	}
	fill(P , P + N + 1 , INF);
	scanf("%d" , &K);
	int r = 0;
	repp(i,0,K){
		int x , y;
		scanf("%d%d" , &x , &y);
		P[x] = y;
		if(i == 0 || P[r] < y) r = x;
	}
	w[r][0] = w[r][1] = P[r];
	if(!dfs(-1,r)){
		printf("No\n");
		return 0;
	}
	queue<int> Q;
	Q.push(r);
	fill(b , b + N + 1 , 0);
	b[r] = 1;
	while(!Q.empty()){
		int x = Q.front(); Q.pop();
		repv(int,it,V[x]){
			if(b[*it]) continue;
			Q.push(*it);
			b[*it] = 1;
			if(P[*it] == INF){
				if(P[x] - 1 < w[*it][0]){
					P[*it] = P[x] + 1;
				} else {
					P[*it] = P[x] - 1;
				}
			}
		}
	}
	printf("Yes\n");
	repp(i,1,N+1){
		printf("%d\n" , P[i]);
	}
	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int d,n;

int main(){
	cin>>d>>n;
	if(n==100) n++;
	int ans=1;
	rep(i,d){
		ans*=100;
	}
	ans*=n;
	cout<<ans<<endl;
	return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    i32 top_is_B = 0, AB = 0, tail_is_A = 0, topB_tailA = 0;
    string s;
    rep(i,n) {
        cin >> s;
        if(s[0] == 'B' && s[s.size()-1] == 'A') ++topB_tailA;
        else if(s[0] == 'B') ++top_is_B;
        else if(s[s.size()-1] == 'A') ++tail_is_A;
        for(int i = 0; i < s.size()-1; ++i) if(s[i]=='A' && s[i+1] == 'B') ++AB;
    }

    i32 p;
    if(topB_tailA > 0) {
        if(top_is_B==0 && tail_is_A==0) {
            p = topB_tailA-1;
        }
        else if(top_is_B==0 || tail_is_A==0) {
            p = topB_tailA;
        }
        else {
            p = topB_tailA+1 + min(top_is_B-1, tail_is_A-1);
        }
    }
    else {
        p = min(top_is_B, tail_is_A);
    }
    i32 ans = p + AB;
    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int flag = 0;
      if((a+b)%2==0){
        flag = 1;
      }
		// 出力
      if(flag==0){
		System.out.println((a+b+1)/2);
	}else{
        System.out.println((a+b)/2);
      }
      }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main()
{
  char a[200];
  int K;
  
  scanf("%d",&K);
  scanf("%s",a);
  
  int i=0;
  while(a[i]!=0)
    i++;
  if(i<=K)
    printf("%s",a);
  else
  {
    for(int j=0;j<K;j++)
      printf("%c",a[j]);
    printf("...");
  }
  }

Measured memory_bytes: 1720
N=int(input())
ALL=[]
for i in range(N):
  A=int(input())
  XY=[]
  for k in range(A):
    x,y=map(int,input().split())
    XY+=[[x,y]]
  ALL+=[XY]
ans=0  
for i in range(2**N):
  people=[-1]*N
  anssub=0
  for k in range(N):
    if ((i >> k) & 1):
      if people[k]==0 or people[k]==-2:
        people[k]=-2        
      else:
        people[k]=1
      anssub+=1
      for t in ALL[k]:
        if people[t[0]-1]!=t[1] and people[t[0]-1]!=-1:
          people[t[0]-1]=-2
        else:
          people[t[0]-1]=t[1]
    else:
      if people[k]==1 or people[k]==-2:
        people[k]=-2
      else:
        people[k]=0  
  if not -2 in people:
    ans=max(ans,anssub)
print(ans)            

Measured memory_bytes: 3188
#include <math.h>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];
  vector<vector<double>> t(N + 1, vector<double>(N + 1, 0.0));

  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      if (j > i) break;

      if (i == 1) {
        if (j == 0)
          t[i][j] = 1 - p[i - 1];
        else if (i == 1 && j == 1)
          t[i][j] = p[i - 1];
      } else if (j == 0)
        t[i][j] = t[i - 1][j] * (1 - p[i - 1]);
      else {
        t[i][j] = t[i - 1][j - 1] * p[i - 1] + t[i - 1][j] * (1 - p[i - 1]);
      }
    }
  }
  int k = N / 2 + 1;
  double ans = 0.0;
  for (int i = k; i <= N; ++i) {
    ans += t[N][i];
  }
  cout << setprecision(10) << ans;
}


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

using namespace std;

int main(void){
  int n,m;
  cin>>n>>m;
  vector<vector<int> > t(n,vector<int>(n,1<<22));
  int a,b,c,d;
  char dm;
  for(int i = 0 ; i < m ; i ++){
    cin>>a>>dm>>b>>dm>>c>>dm>>d;
    a--,b--;
    t[a][b] = c;
    t[b][a] = d; 
  }
  
  int x1,x2,y1,y2;
  cin>>x1>>dm>>x2>>dm>>y1>>dm>>y2;
  for(int i = 0 ; i < n ; i ++) 
    t[i][i] = 0;
  for(int k = 0 ; k < n ; k ++)
  for(int i = 0 ; i < n ; i ++)
  for(int j = 0 ; j < n ; j ++)
    t[i][j] = min(t[i][j] , t[i][k] + t[k][j]);
  
  int s = t[--x1][--x2];
  int r = t[x2][x1];
  cout<< y1 - (y2 + s + r) <<endl;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<int> S(N);
    vector<int> T(M);
    rep(i,0,N)cin >> S[i];
    rep(i,0,M)cin >> T[i];
    vector<int> vec[100010];
    rep(i,0,N){
        if(vec[S[i]].size() != 0)continue;
        rep(j,0,M){
            if(S[i] == T[j])vec[S[i]].push_back(j+1);
        }
    }

    /*
    cout << endl;
    rep(i,0,N){
        rep(j,0,vec[S[i]].size())cout << vec[S[i]][j] << " ";cout << endl;
    }
    */
    ll dp[N+1][M+1] = {};
    dp[0][0] = 1;
    rep(i,0,N){
        rep(j,0,M+1){
            dp[i+1][j] += dp[i][j];
        }
        vector<ll> accum(M+2);
        rep(j,0,M+1){
            accum[j+1] = (accum[j] + dp[i][j]) % MOD;
        }
        for(auto j:vec[S[i]]){
            ll cnt = 0;
            /*
            rep(k,0,j){
                cnt += dp[i][k];
            }
            */
           
            dp[i+1][j] += accum[j];
            dp[i+1][j] %= MOD;
        }
    }
    ll ans = 0;
    rep(i,0,M+1){
        ans += dp[N][i];
        ans %= MOD;
    }
    /*
    rep(i,0,N+1)rep(j,0,M+1){
        cout << dp[i][j] << " \n"[j==M];
    }
    */
    cout << ans << endl;
}

Measured memory_bytes: 33920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
 
int main(){
  int n;
  cin>>n;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  
  rep(i,n) --a[i];
  
  int ans = 0;
  
  rep(i,n){
    ans += b[a[i]];
    if(a[i]+1 == a[i+1]) ans += c[a[i]];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 302;
const ll mod = 998244353;
int a[M][M];
ll power(ll a,ll b)
{
	ll val=1;
	while(b)
	{
		if(b%2)
			val=(val*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return val;
}
int findRank(int n,int m)
{
	for(int i=0;i<m;i++)
	{
		int id = i;
		for(int j=i;j<n;j++)
			if(a[j][i] == 1)
				id = j;
		for(int j=0;j<m;j++)
			swap(a[i][j], a[id][j]);
		for(int j=0;j<n;j++)
		{
			if(a[j][i]==0 || i == j)
				continue;
			for(int k=0;k<m;k++)
				a[j][k] ^= a[i][k];
		}
	}
	int rank = 0;
	for(int i=0;i<n;i++)
	{
		bool flag = 0;
		for(int j=0;j<m;j++)
			if(a[i][j])
				flag = 1;
		if(flag)
			rank++;
	}
	return rank;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	int r = findRank(n,m);
	ll v = power(2,m-1);
	ll x = (power(2,n) - power(2,n-r)+mod)%mod;
	ll ans = (v*x)%mod;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3968