akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  int N,K;
  cin>>N>>K;
  
  double ans=0;
  
  
  for(int i=1;i<=N;i++){
    double res=1.0/N;
    int j=i;
    while(j<K){
      j*=2;
      res/=2;
    }
    ans+=res;
  }
  
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 2000 + 10;
int n, m, a[MAXN][MAXN];
char S[MAXN];

const int MOD = (int) 1e9 + 7;
int H[2][MAXN][MAXN];
int E[MAXN];

int LCP[MAXN];
int L[MAXN];
int R[MAXN];

int getHash(int v, int col, int i, int j) {
	return (H[v][j][col] - (LL) H[v][i - 1][col] * E[j - i + 1] + (LL) MOD * MOD) % MOD;
}

int computeLCP(int i, int j, int x, int y) {
	int l = 1, r = i, f = 0;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (getHash(x, j - 1, i - mid + 1, i) == getHash(y, j, i - mid + 1, i)) {
			f = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	return f;
}

int Compute(int i) {
	for (int j = 2; j <= m; ++j) LCP[j] = computeLCP(i, j, a[i][j - 1], a[i][j]);
	for (int j = 1; j <= m; ++j) {
		L[j] = j;
		while (1 < L[j] && LCP[L[j] - 1] >= LCP[j]) L[j] = L[L[j] - 1];
	}
	for (int j = m; j >= 1; --j) {
		R[j] = j;
		while (R[j] < m && LCP[R[j] + 1] >= LCP[j]) R[j] = R[R[j] + 1];
	}
	int ans = i;
	for (int j = 1; j <= m; ++j)
		ans = max(ans, LCP[j] * (R[j] - L[j] + 2));
	return ans;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", S + 1);
		for (int j = 1; j <= m; ++j) a[i][j] = (S[j] == '#') ? 1 : 0;
	}
	// return 0;

	E[0] = 1;
	for (int i = 1; i <= n; ++i) E[i] = E[i - 1] * 31ll % MOD;
	for (int j = 1; j <= m; ++j) for (int i = 1; i <= n; ++i) {
		for (int v = 0; v < 2; ++v) {
			int val = a[i][j] ^ v;
			H[v][i][j] = (H[v][i - 1][j] * 31ll + val) % MOD;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) ans = max(ans, Compute(i));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    string s;
    ll x,y;
    cin >> s >> x >> y;
    map<ll,ll> LX, LY;
    LX[0] = 1;
    LY[0] = 1;
    vector<ll> v,h;
    ll N = s.size();
    ll cnt = 0;
    bool st = 0;
    bool init = 1;
    rep(i,N){
        map<ll,ll> tm;
        if(s[i] == 'T'){
            if(st==0){
                for(auto&e:LX){
                    tm[e.fi+cnt] = 1;
                    if(init)continue;
                    tm[e.fi-cnt] = 1;
                }
                LX = tm;
                h.push_back(cnt);
                init = 0;
            }else{
                for(auto&e:LY){
                    tm[e.fi+cnt] = 1;
                    tm[e.fi-cnt] = 1;
                }
                LY = tm;
                v.push_back(cnt);
            }
            st = !st;
            cnt = 0;
        }else{
            cnt++;
        }
    }
    //cout << N << endl;
    //cout << cnt << endl;
    if(cnt > 0){
        map<ll,ll> tm;
        if(st==0){
            for(auto&e:LX){
                tm[e.fi+cnt] = 1;
                if(init)continue;
                tm[e.fi-cnt] = 1;
            }
            LX = tm;
            h.push_back(cnt);
        }else{
            for(auto&e:LY){
                tm[e.fi+cnt] = 1;
                tm[e.fi-cnt] = 1;
            }
            LY = tm;
            v.push_back(cnt);
        }
    }
    if(LX[x]&&LY[y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

const int N=1e5+10;

int n;
int A[N],B[N];


int main()
{
	cin>>n;
	long long S=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&A[i]);
		A[i]*=2;
		if(i&1) S+=A[i];else S-=A[i];
	}
	B[1]=S/2;
	for(int i=1;i<n;i++) B[i+1]=A[i]-B[i];
	for(int i=1;i<=n;i++) printf("%d ",B[i]);
}

Measured memory_bytes: 2048
class Dice():
    
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.d1=d1
        self.d2=d2
        self.d3=d3
        self.d4=d4
        self.d5=d5
        self.d6=d6
    
    def roll(self,c):
        if c=='N':
            self.d1,self.d5,self.d6,self.d2=self.d2,self.d1,self.d5,self.d6
        elif c=='S':
            self.d1,self.d5,self.d6,self.d2=self.d5,self.d6,self.d2,self.d1
        elif c=='E':
            self.d1,self.d3,self.d6,self.d4=self.d4,self.d1,self.d3,self.d6
        else:
            self.d1,self.d3,self.d6,self.d4=self.d3,self.d6,self.d4,self.d1
    
a,b,c,d,e,f=map(int,input().split())
D=Dice(a,b,c,d,e,f)
order=input()
for c in order:
    D.roll(c)
print(D.d1)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
int a,b,c,d,n,m,x,k,h,w,sum,mi,ma;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int l[101];

int main(void){
    cin>>n>>x;
    rep(i,n){
        cin>>l[i];
        d+=l[i];
        if(d<=x)sum++;
    }
    p(sum+1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void move(int *dice, char c) {
  dice[0]=dice[1];
  if (c=='N') {
    dice[1]=dice[2];
    dice[2]=dice[6];
    dice[6]=dice[5];
    dice[5]=dice[0];
  } else if (c=='E') {
    dice[1]=dice[4];
    dice[4]=dice[6];
    dice[6]=dice[3];
    dice[3]=dice[0];
  } else if (c=='W') {
    dice[1]=dice[3];
    dice[3]=dice[6];
    dice[6]=dice[4];
    dice[4]=dice[0];
  } else if (c=='S') {
    dice[1]=dice[5];
    dice[5]=dice[6];
    dice[6]=dice[2];
    dice[2]=dice[0];
  }
}

int main() {
  int dice[7]={0};
  scanf("%d %d %d %d %d %d", &dice[1], &dice[2], &dice[3], &dice[4], &dice[5], &dice[6]);

  char c;
  while (scanf("%c", &c)!=EOF) {
    move(dice, c);
  }

  printf("%d\n", dice[1]);
  return 0;
}


Measured memory_bytes: 2108
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let mut a_s: Vec<i64> = vec![];
    let mut b_s: Vec<i64> = vec![];
    for _ in 0..(n + 1) {
        a_s.push(read());
    }
    for _ in 0..n {
        b_s.push(read());
    }
    let mut next_remain = a_s[0];
    let mut sum = 0;
    for (i, b) in b_s.into_iter().enumerate() {
        let now_remain = next_remain.clone();
        // ai 残存
        if b <= now_remain {
            sum += b;
            next_remain = a_s[i + 1];
            continue;
        }
        // ai 全滅
        sum += now_remain;
        let hero_remain = b - now_remain;

        // next全滅
        if a_s[i + 1] <= hero_remain {
            sum += a_s[i + 1];
            next_remain = 0;
            continue;
        }

        sum += hero_remain;
        next_remain = a_s[i + 1] - hero_remain;
    }
    println!("{}", sum);
    return;
}


Measured memory_bytes: 6396
package main

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

func main() {
	N := nextInt64()
	K := nextInt64()

	c := mint(0)

	for i := mint(K); i <= mint(N+1); i++ {
		min := i.mul(i - 1).div(2)     // 0 + 1 + 2 + 3 + ... + i - 1
		max := mint(N).mul(i).sub(min) // N + (N - 1) + ... + (N - (i - 1))
		c = c.add(max).add(1).sub(min)
	}

	fmt.Println(c)
}

type mint int64

var mod = mint(1e9 + 7)

// add は a + bを返します
func (a mint) add(b mint) mint {
	return (a + b) % mod
}

// sub は a - bを返します
func (a mint) sub(b mint) mint {
	return (a - b + mod) % mod
}

// mul は a * bを返します
func (a mint) mul(b mint) mint {
	return (a * (b % mod)) % mod
}

// div は a/bを返します
func (a mint) div(b mint) mint {
	return a.mul(b.inv())
}

// inv は aの逆元を返します
func (a mint) inv() mint {
	// 拡張ユークリッドの互除法
	b := mod
	u := mint(1)
	v := mint(0)
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	return (u + mod) % mod
}

// pow は a ^ bを返します
func (a mint) pow(b mint) mint {
	ans := mint(1)

	for b != 0 {
		if b&1 == 1 {
			ans = ans.mul(a)
		}
		a = a.mul(a)
		b = b >> 1
	}
	return ans
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1808
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}

string s,t="AKIHABARA",q="KIHBR";
bool ck(string a, string b){
	if(SZ(a)>SZ(b))return 0;
	for(int i=0,j=0;i<SZ(a);i++){
		while(j<SZ(b)&&a[i]!=b[j])j++;
		if(j>=SZ(b))return 0;j++;
	}
	return 1;
}
int main() {
	cin>>s;bool ok=ck(s,t)&&ck(q,s);
	printf("%s\n",ok?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int A, B;
  std::cin >> A >> B;

  for(int C=0;C<4;C++)
    {
      if( (A*B*C)%2 == 1)
	{
	  std::cout << "Yes" << std::endl;
	  return 0;
	}
    }
  std::cout << "No" << std::endl;  
  return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.begin(), a.end());
	int p = n / 2 - 1;
	cout << a[p + 1] - a[p] << endl;
	// a.resize(unqiue(a.begin))
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

struct card{
	char m;
	ll num;
};

void merge(vector<card>&b , int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right -mid;
	vector<card> L(n1);
	vector<card> R(n2);
	rep(i, n1){
		L.at(i) = b.at(left+i);
	}
	rep(i, n2){
		R.at(i) = b.at(mid+i);
	}
	card x;
	x.num = 1e18;
	L.push_back(x);
	R.push_back(x);
	int i = 0;
	int j = 0;
	for(int k = left; k <right; k++){
		if(L.at(i).num <= R .at(j).num){
			b.at(k) = L.at(i);
			i++;
		}else{
			b.at(k) = R.at(j);
			j++;
		}
	}
}

void mergesort(vector<card>&b , int left,int right){
	if(left +1 >= right) return;
	int mid = (left + right)/2;
	mergesort(b, left, mid);
	mergesort(b, mid, right);
	merge(b, left, mid, right);
}

int partition(vector<card>&a, int p, int r){
	int i = p-1;
	for(int j = p; j<r; j++){
		if(a.at(j).num <= a.at(r).num){
			i++;
			card x = a.at(i);
			a.at(i) = a.at(j);
			a.at(j) = x;
		}
	}
	card x = a.at(i+1);
	a.at(i+1) = a.at(r);
	a.at(r) = x;
	return i+1;
}

void quicksort(vector<card>&a, int p, int r){
	if(p < r){
		int q = partition(a, p, r);
		quicksort(a, p, q-1);
		quicksort(a, q+1, r);
	}
}

int main(){
	int n;
	cin >> n;
	vector<card> a(n);
	vector<card> b(n);
	rep(i,n){
		char s;
		ll num;
		cin >> s >> num;
		a.at(i).m = s;
		a.at(i).num = num;
		b.at(i).m = s;
		b.at(i).num = num;
	}
	quicksort(a, 0, n-1);
	mergesort(b, 0, n);
	bool judge = true;
	rep(i, n){
		if(a.at(i).m != b.at(i).m){
			judge = false;
		}
	}
	if(judge){
		cout <<"Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	rep(i, n){
		cout << a.at(i).m << " " << a.at(i).num << endl;;
	}
}



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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (2000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main() {
    string s;
    cin >> s;

    map<char,int> mp;
    for(int i=0; i<s.length(); i++){
        mp[s[i]]++;
    }
    if(mp.size()==2){
        for(auto it:mp){
            if(it.second!=2) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())

ans = N*N*N

print(ans)


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
using int64 = long long;
using vint = vector<int>;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, init, n) for (int i = (init); i < (n); ++i)
#define RepLong(i, n) for (int64 i = 0; i < (n); ++i)
#define InitRepLong(i, init, n) for (int64 i = (init); i < (n); ++i)
#define RepItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)


int64 extGCD(int64 a, int64 b, int64& x, int64& y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	int64 g = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return g;
}

int main()
{
	int x, y;
	cin >> x >> y;
	constexpr int mod = 1e9 + 7;

	if ((x + y) % 3 != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	int n = (x + y) / 3;
	int dx = x > y ? x - y : y - x;
	// r - (n - r) = dx
	// 2r = dx + n > 0
	if (dx > n || (dx - n) % 2 != 0)
	{
		cout << 0 << endl;
		return 0;
	}
	int r = (dx + n) / 2;

	// ans = nCr
	// x ≡ a ^ (-1)  (mod p)
	// ax - py = 1
	if (r > n / 2)
	{
		r = n - r;
	}
	vector<int64> invA(r + 1);
	RepLong(i, r)
	{
		int64 x, y;
		extGCD(i + 1, mod, x, y);
		invA[i] = x >= 0 ? x : x + mod;
	}
	int64 dividend = 1L;
	int64 divisor = 1L;
	int64 ans = 1L;
	RepLong(i, r)
	{
		ans = ans * (n - i) % mod * invA[i] % mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define int ll

const int N = 1e5+100;

int a[N];

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin >> n;
	for(int i=0 ; i<n ; i++)
		cin >> a[i];
	reverse(a, a+n);
	int l=2, r=2;
	for(int i=0 ; i<n ; i++){
		if(r<a[i]){
			cout << "-1\n";
			return 0;
		}
		l += (l%a[i] == 0 ? 0 : a[i] - (l%a[i]));
		if(l>r){
			cout << "-1\n";
			return 0;
		}
		r = (r/a[i])*a[i] + a[i]-1;
	}
	cout << l << " " << r << "\n";
 	return 0;
}
















Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int par[100005],r[100005],size[100005];

void init(int n){
  int i;
  for (i-0;i<n;i++){
    par[i]=i;
    r[i]=size[i]=1;
  }
}

int root(int a){
  if (par[a]==a) return a;
  return par[a]=root(par[a]);
}

void unite(int a,int b){
  a=root(a);
  b=root(b);
  if (a==b) return;
  if (r[a]>r[b]){
    par[b]=a;
    r[a]++;
    size[a]+=size[b];
  }else{
    par[a]=b;
    r[b]++;
    size[b]+=size[a];
  }
}


int main(void){
  int n,m,k,i,a,b,fr[100005]={};
  vector<int> bl[100005];
  
  cin >> n >> m >> k;
  
  init(n);
  for (i=0;i<m;i++){
    cin >> a >> b;
    unite(a-1,b-1);
    fr[a-1]++;
    fr[b-1]++;
  }
  for (i=0;i<k;i++){
    cin >> a >> b;
    bl[a-1].push_back(b-1);
    bl[b-1].push_back(a-1);
  }
  
  for (i=0;i<n;i++){
    int bc=0;
    for (int j=0;j<bl[i].size();j++){
      if (root(i)==root(bl[i][j])) bc++;
    }
    cout << size[root(i)]-fr[i]-bc-1 << ' ';
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size(), ans = 0;
  for (int i = 0; i <= (n-1)/2; i++) {
    if (s[i] != s[n-i-1]) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if (T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout <<"[";
  for(i=0,c=T[u].l;c != NIL;i++, c =T[c].r){
    if(i) cout << ", ";
    cout << c;
  }

  cout << "]" << endl;
}

void rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin >> v >> d;
    for(j=0;j<d;j++){
      cin >> c;
      if(j==0)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL)r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}



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


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

    int A, B, C, D;
    A = nyuryoku / 1000;
    B = (nyuryoku - A*1000) / 100;
    C = (nyuryoku - A * 1000 - B * 100) / 10;
    D = nyuryoku % 10;

    if (A + B + C + D == 7)
    {
        cout << A << "+" << B << "+" << C << "+" << D << "=" << 7;
        return 0;
    }
    
    if (A + B + C - D == 7)
    {
        cout << A << "+" << B << "+" << C << "-" << D << "=" << 7;
        return 0;
    }

    if (A + B - C + D == 7)
    {
        cout << A << "+" << B << "-" << C << "+" << D << "=" << 7;
        return 0;
    }

    if (A + B - C - D == 7)
    {
        cout << A << "+" << B << "-" << C << "-" << D << "=" << 7;
        return 0;
    }

    if (A - B + C + D == 7)
    {
        cout << A << "-" << B << "+" << C << "+" << D << "=" << 7;
        return 0;
    }

    if (A - B + C - D == 7)
    {
        cout << A << "-" << B << "+" << C << "-" << D << "=" << 7;
        return 0;
    }

    if (A - B - C + D == 7)
    {
        cout << A << "-" << B << "-" << C << "+" << D << "=" << 7;
        return 0;
    }

    if (A - B - C - D == 7)
    {
        cout << A << "-" << B << "-" << C << "-" << D << "=" << 7;
        return 0;
    }

    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s;
  int N;
  cin >> N >> s;
  for(int i = 0 ; i < s.length() ; i++){
    s[i] += N;
    if('Z' < s[i])
      s[i] -= 'Z' - 'A' + 1;
  }

  cout << s << endl;
  
  return 0;
}


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

int main() {
  long long N, A, B, X=0;
  cin >> N >> A >> B;
  X = N/(A+B) * A;
  if (N%(A+B) >= A) {
    X += A;
  }
  else {
    X += N%(A+B);
  }
  cout << X << endl;
}

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

int main(){
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> p(a); rep(i,a) cin >> p[i];
	vector<ll> q(b); rep(i,b) cin >> q[i];
	vector<ll> r(c); rep(i,c) cin >> r[i];
	sort(p.begin(),p.end(),greater<ll>());
	sort(q.begin(),q.end(),greater<ll>());
	sort(r.begin(),r.end(),greater<ll>());
	vector<ll> temp;
	rep(i,min(x,a)) temp.push_back(p[i]);
	rep(i,min(y,b)) temp.push_back(q[i]);
	rep(i,c) temp.push_back(r[i]);
	sort(temp.begin(),temp.end(),greater<ll>());
	
	ll ans = 0;
	rep(i,x+y){
		ans += temp[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8560
N,A,B=map(int,input().split())
p=0
q=0
if (B-A)%2==0:
  print((B-A)//2)
else:
  if (N-B)>(A-1):
    print(((B-A)+(A-1)*2)//2+1)
  else:
    print(((B-A)+(N-B)*2)//2+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> g[8];
bitset<8> vis;
int n, m;

ll dfs(int u, int cnt) {
    if (cnt == n) return 1;
    vis[u] = true;
    ll ans = 0;
    for (auto &v : g[u]) {
        if (!vis[v]) {
            ans += dfs(v, cnt+1);
            vis[v] = false;
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int u, v;
    cin >> n >> m;
    fore(i,0,m) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    cout << dfs(0, 1) << endl;
}


Measured memory_bytes: 256
var line, res, i, h, w, j, cover, body;

line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
line.length = line.lastIndexOf('0 0');
for (i in line) line[i] = line[i].split(' ').map(Number);

res = [];
for (i in line) {
	h = line[i][0];
	w = line[i][1];
	cover = repeat("#", w);
	body = "#" + repeat(".", w - 2) + "#";
	res.push(cover);
	for (j = h - 3; j >= 0; j--) res.push(body);
	res.push(cover);
	res.push("");
}

console.log(res.join("\n"));

function repeat(str, n) {
	var binary, res, powstr, i, len;
	binary = n.toString(2);
	len = binary.length;
	res = "";
	powstr = str;
	for (i = len - 1; i > 0; i--) {
		if (binary[i] === '1') res = res + powstr;
		powstr = powstr + powstr;
	}
	return res + powstr;
}

Measured memory_bytes: 15548
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=410,Mod=1e9+7;
int a[N],b[N],n,sum[N][N],c,dp[N][N];
int val(int i,int Q){
	return (sum[Q][b[i]]-sum[Q][a[i]-1]+Mod)%Mod;
}
int qpow(int a,int b){
	int ret=1;
	while(b){
		if(b&1)ret=1ll*ret*a%Mod;b>>=1;
		a=1ll*a*a%Mod;
	}
	return ret;
}
signed main(){
	n=gi();c=gi();
	for(int i=1;i<=n;i++)a[i]=gi();for(int i=1;i<=n;i++)b[i]=gi();
	for(int i=0;i<=c;i++)
		for(int j=1;j<=400;j++)
			sum[i][j]=(sum[i][j-1]+qpow(j,i))%Mod;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				dp[i][j]=(dp[i][j]+1ll*dp[i-1][k]*val(i,j-k)%Mod)%Mod;
	printf("%lld\n",dp[n][c]);
	return 0;
}

Measured memory_bytes: 2816
s = input()
q = int(input())
rev = 0
head = []
tail = []
is_rev = False

for _ in range(q):
    qq = input().split()
    t = int(qq[0])
    if t == 1:
        rev += 1
        is_rev = not is_rev
    else:
        f = int(qq[1])
        c = qq[2]
        if f == 1:
            if is_rev:
                tail.append(c)
            else:
                head.append(c)
        else:
            if is_rev:
                head.append(c)
            else:
                tail.append(c)

if is_rev:
    ls = list(reversed(tail))
    ls.extend(reversed(s))
    ls.extend(head)
else:
    ls = list(reversed(head))
    ls.extend(s)
    ls.extend(tail)
print(''.join(ls))


Measured memory_bytes: 8052
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: i32 = read();
	let m: i32 = read();
	let mut v = Vec::new();
	for _ in 0..n { v.push(0); }
	let mut p: usize;
	let mut s: String;
	let mut ac_sum: i32 = 0;
	let mut wa_sum: i32 = 0;
	for _ in 0..m {
		p = read();
		s = read();
		if v[p-1] != -1 {
			if s.ends_with("AC") {
				wa_sum += v[p-1];
				v[p-1] = -1;
				ac_sum += 1;
			} else {
				v[p-1] += 1;
			}
		}
	}
	println!("{} {}", ac_sum, wa_sum);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
N = int(input())
A = [] * N
B = [] * N
C = [] * N
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

past_a = -1
happiness = 0

for a in A:
    happiness += B[a-1]
    if a == past_a + 1:
        happiness += C[a - 2]
    past_a = a

print(happiness)


Measured memory_bytes: 3064
n = int(input())

heads = list(map(float, input().split()))

dp = []

for i in range(n+1):
    temp = []
    for j in range(n+1):
        temp.append(0.0)
    
    dp.append(temp)

dp[0][0] = 1.0

for i in range(1, n+1):
    for j in range(0, n+1):
        dp[i][j] = dp[i-1][j] * (1-heads[i-1]) + dp[i-1][j-1] * heads[i-1]


ans = 0
for i in range((n+1)//2, n+1):
    ans += dp[n][i]

print(ans)

Measured memory_bytes: 147292
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	bool posible=false;
	int data[x+1];
	//data[0]=4*x;
	for(int i=0;i<=x;i++){
		data[i]=(4*(x-i)+(i*2));
	}
	for(int i=0;i<x+1;i++){
		if(data[i]==y)
		posible=true;
	}
	if(posible){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3572
#include<stdio.h>
int main()
{
	long int hgt( long int);
	long int N;
	scanf("%ld",&N);
	printf("%lld\n",hgt(N));
	

}
long int hgt(long int N)
{
	long long h=0;
	long int arr[N];
	for(int i=0;i<N;i++)
		scanf("%ld",&arr[i]);
	for(int i=0; i<=N-2;i++)
	{
		if(arr[i+1]<arr[i])
		{
			h+=(arr[i]-arr[i+1]);
			arr[i+1]=arr[i];
		}
	}
	return h;
	
}

Measured memory_bytes: 3260
#include<stdio.h>
int main(){


int height[15];
int i,j,z;

for(i=0;i<10;i++){

    scanf("%d",&height[i]);

}

   for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){

        if(height[i]<height[j]){

            z=height[i];
            height[i]=height[j];
            height[j]=z;
        }
    }
}

for(i=0;i<3;i++){

    printf("%d\n",height[i]);
}


return 0;
}



Measured memory_bytes: 2040
#include<stdio.h>

int main() {
  int n, sum = 0;
  scanf("%d", &n);
  int v[n], c[n];
  for(int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  
  for(int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  
  for(int i = 0; i < n; i++) {
    if(v[i] - c[i] > 0) {
      sum += v[i] - c[i];
    }
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize, m: usize,
        s_point_list: [(i32, i32); n],
        c_point_list: [(i32, i32); m],
    }
    for s_point in s_point_list {
        let (i, _) =
            c_point_list
            .iter()
            .enumerate()
            .min_by(|&(_, &(x1, y1)), &(_, &(x2, y2))| {
                let m1 = (x1 - s_point.0).abs() + (y1 - s_point.1).abs();
                let m2 = (x2 - s_point.0).abs() + (y2 - s_point.1).abs();
                m1.cmp(&m2)
            }).unwrap();
        println!("{}", i + 1);
    }
}


Measured memory_bytes: 4352
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}

template<typename T, int Begin, int End>
T & OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}

template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

int N, K;
int main() {
	cin >> N >> K;
	int p = K;
	REP(i, 1, N) {
		p *= (K - 1);
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vi a(m),b(m),c(m);
	vvi d(n,vi(n,INF));
	REP(i,m){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--, b[i]--;
		d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
	}
	
	REP(k,n)REP(i,n)REP(j,n){
		chmin(d[i][j],d[i][k]+d[k][j]);
	}
	
	int ans=0;
	REP(i,m){
		if(c[i]>d[a[i]][b[i]]) ans++;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int N, K;

  std::cin >> N >> K;

  int const MaxPairs = (N-2)*(N-1)/2;
  int Differ = MaxPairs - K;

  if (Differ < 0) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::cout << (N-1 + Differ) << '\n';

  for (int u=1; u<N; u++) {
    std::cout << u << ' ' << N << '\n';
  }

  for (int u=1; u<N-1; u++) {
    for (int v=u+1; v<N; v++) {
      if (Differ == 0) return 0;

      std::cout << u << ' ' << v << '\n';
      Differ--;
    }
  }
}


Measured memory_bytes: 256
/*************************************
 * @contest:      ABC149.
 * @user_name:    hkxadpall.
 * @time:         2019-12-29.
 * @language:     C++.
 * @upload_place: AtCoder.
*************************************/ 

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

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

int X;
bool np[100006];
int pt[100006], top = 0;

void s()
{
    for (int i = 2; i <= 100003; i++) {
        if (!np[i]) pt[top++] = i;
        for (int j = i + i; j <= 100003; j += i) np[j] = 1; 
    }
}

int main()
{
    X = read<int>();
    s();
    int pos = *lower_bound(pt, pt + top, X);
    write(pos);
    return 0;
}

Measured memory_bytes: 384
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int p,q,r;
	cin >> p >> q >> r;
	int ans = min(p + q, p + r);
	ans = min(ans, q + r);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int D,N;
    cin >> D >> N;
    if(D==0)
    {
        if(!(N==100))
        {cout << N << endl;
        return 0;}
        else
        {
            cout << 101 <<endl;
            return 0;
        }
    }
    if(D==1)
    {  
        if(N==100)
        {
            cout << 10100<< endl;
            return 0;
        }
        cout << N*100 << endl;
        return 0;
    }
        if(N==100)
        {
            cout << 1010000 << endl;
            return 0;
        }
        cout << N*10000 << endl;
}


Measured memory_bytes: 3536
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 15;
const int MM = 1000000007;

const int DEBUG = 0;

ll N;

bool check(ll x){
	printf("? %lld\n", x);
	fflush(stdout);
	char buf[10];
	if(DEBUG){
		char P[20], Q[20];
		sprintf(P, "%lld", x);
		sprintf(Q, "%lld", N);
		if( ((string)P <= (string)Q) ^ (x <= N)) return false;
		return true;
	}
	scanf("%s", buf); return buf[0] == 'Y';
}

int main()
{
	if(DEBUG) scanf("%lld", &N);
	ll s = 1e11, e = 1e12, m;
	while(s <= e){
		m = (s+e) / 2;
		if( check(m) ) e = m-1;
		else s = m+1;
	}swap(s, e);
	while(e%10 == 0){
		if( !check(e+1) ){
			printf("! %lld\n", e*10);
			fflush(stdout);
			return 0;
		}
		e /= 10;
	}
	if( e%10 == 9 ){
		if(check(e*10-1)) printf("! %lld\n", e*10);
		else printf("! %lld\n", e);
	}
	else{
		if(!check(e+1))printf("! %lld\n", e*10);
		else printf("! %lld\n", e);
	}
	fflush(stdout);
}


Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>

int main(void){

    int i,n,k;

    scanf("%d %d",&n,&k);

    char s[n];

    scanf("%s",s);

    s[k-1]=s[k-1]+32;

    printf("%s\n",s);

    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long int
#define vec vector<int>
#define inf 1e18
using namespace std;
vector<int> adj[100001];
int vis[100001];
void dfs(int node)
{
  vis[node]=1;
  for(int ch: adj[node])
  {
    if(!vis[ch])
        dfs(ch);
  }
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    int n,m,i;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
      int u,v;
      cin>>u>>v;
      adj[u].pb(v);
      adj[v].pb(u);
    }
    int c=0;
    for(i=1;i<=n;i++)
    {
      if(!vis[i])
            dfs(i),c++;
    }
    cout<<c-1;
  }
}


Measured memory_bytes: 11080
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
ans, Bi, Asum, Bsum = 0, M, 0, sum(B)
for Ai in range(N + 1):
    Asum += A[Ai]
    while Asum + Bsum > K and Bi > 0:
        Bsum -= B[Bi]
        Bi -= 1
    if Asum + Bsum <= K:
        ans = max(ans, Ai + Bi)
print(ans)


Measured memory_bytes: 120348
using System;

namespace Hoge
{
    class Hoge
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');

            if (str[1] == "+")
                Console.WriteLine(int.Parse(str[0]) + int.Parse(str[2]));
            else
                Console.WriteLine(int.Parse(str[0]) - int.Parse(str[2]));
        }
    }
}

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

int main(){
  string S;
  cin >> S;
  int count;
  rep(i,S.size()) cout << "x";
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{

    long long int a,b,c,d,i,j,k,l;
    cin>>a>>b;
    int a1[a];
    for(i=0;i<a;i++)
        cin>>a1[i];
    a=a-b;
    b=b-1;

int    ans=ceil((double)a/b);
//<<ans;
    cout<<ans+1;
}
int main()
{
int    k=4;
   // while(k--)
        solve();
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, P; {int[] a = in.ii(); N = a[0]; P = a[1];}
        String S = in.s();
        long ans = 0;
        
        if(P != 2 && P != 5){
            int[] mod = new int[N+1];
            int ten = 1;
            
            for(int i = N-1; i >= 0; i--){
                int n = S.charAt(i) - '0';
                mod[i] = (mod[i+1] + ten * n) % P;
                ten = ten * 10 % P;
            }
            
            int[] count = new int[P];
            for(int i = 0; i <= N; i++){
                count[mod[i]]++;
            }
            
            for(int i = 0; i < count.length; i++){
                ans += (long)(count[i] - 1) * count[i] / 2;
            }        
        } else {
            int tmp = 0;
            for(int i = N-1; i >= 0; i--){
                int n = S.charAt(i) - '0';
                tmp += n % P == 0 ? 1 : 0; 
                ans += tmp;
            }
        }
        
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 27220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int r = sc.nextInt();
		int s = sc.nextInt();
		int p = sc.nextInt();
		String t = sc.next();
		char[] pre = new char[k];
		for(int i = 0; i < k; i++) {
			pre[i] = 'a';
		}
		long ans = 0;
		for(int i = 0; i < n; i++) {
			char te = t.charAt(i);
			if(te != pre[i % k]) {
				if(te == 'r')
					ans += p;
				if(te == 's')
					ans += r;
				if(te == 'p')
					ans += s;
				pre[i % k] = te;
			} else {
				pre[i % k] = 'a';
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 27732
# -*- coding: utf-8 -*-
import heapq
import math


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign


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

my_heap = Heapq(a_list, True)

for i in range(m):
    value = my_heap.pop()
    value = value / 2
    my_heap.push(value)

ret = 0
for i in range(n):
    ret += math.floor(my_heap.pop())

print(ret)


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

int main(void)
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		count += (r-l+1);
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i,j,t,x,n=10;
  int data[10];

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

  for(i=0;i<10;i++){
    for(j=n-1;i<j;j--){
      if (data[j]>data[j-1]){
        t=data[j];
        data[j]=data[j-1];
        data[j-1]=t;
      }
    }
  }


  for(i=0;i<3;i++){
    printf("%d\n",data[i]);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#define INF 10000000000000000
typedef long long ll;
std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	ret.push_back(n);
	return ret;
}

int main()
{
	ll N;
	std::cin >> N;
	ll min;
	std::vector<ll> r = enum_div(N);
	min=INF;
	std::sort(r.begin(),r.end());//昇順ソート
	/*
	for(ll i=0;i<r.size();i++){
		printf("%lld\n",r[i]);
	}
	*/
	for(ll i=1;i<r.size();i++){
			if(min>r[i-1]+r[r.size()-i]-2){
				min=r[i-1]+r[r.size()-i]-2;
		}
	}
	printf("%lld",min);
	return 0;
}


Measured memory_bytes: 384
m,d = map(int,input().split())

count = 0

for i in range(1,m+1):
    for j in range(1,d+1):
        if j >= 22:
            one = int(str(j)[1])
            ten = int(str(j)[0])
            if one >= 2 and ten >= 2:
                if one * ten == i:
                    count += 1
                    
print(count)

Measured memory_bytes: 3068