akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 2044
  Title:Lying about Your Age
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define min(x,y) (((x)<(y))?(x):(y))

int a,c,saba;
char b[9];
int radix;

int dec2M(char *s,int rad,int num)
{
  int d,pos,i;

  memset(s,0,9);
  pos=0;
  while(1)
    {
      d = num % rad;
      if(d > 9)
	return(0);
      s[0]=d+'0';
      num /= rad;
      if(num==0)
	break;
      for(i=pos+2;i>0;i--)
	s[i]=s[i-1];
      pos++;
    }
  return(-1); // -1: '0~9' only
              // 0:  include 'a'~
}
int M2dec(char *s,int rad)
{
  int i,ret,n;

  ret=0;
  while(1)
    {
      n = (*s-'0');
      if(n >= rad)
	return(-1);
      ret+=n;
      s++;
      if(!*s)
	break;
      ret*=rad;
    }
  return(ret);
}

int cal_radix(int num,char *s)
{
  int i,limit,val;

  if(strlen(s)==1 && num == (s[0]-'0'))
    return(16);
  if(strlen(s)>2)
    limit=10;
  else
    limit=16;
  for(i=2;i<=16;i++)
    {
      val=M2dec(s,i);

      if(val==num)
	return(i);
      if(val>num)
	break;
    }
  return(-1);
}


int next_age(int num,int radix)
{
  int i=radix,prev_val,val;
  char prev_s[9],s[9];

  dec2M(prev_s,i,num-1);
  sscanf(prev_s,"%d",&prev_val);

  for(i=16;i>1;i--)
    {
      if(dec2M(s,i,num))
	{
	  sscanf(s,"%d",&val);
	  if(val >= prev_val)
	    return(i);
	}

    }
}
main()
{
  int ret,i;
  char result[9];
  
  while(scanf("%d %s %d",&a,&b[0],&c) && (a!=-1||c!=-1))
    {
      radix=cal_radix(a,b);
      if(radix==-1)
	{
	  printf("-1\n");
	  continue;
	}
      for(i=a+1;i<=c;i++)
	{
	  radix=next_age(i,radix);
	  //dec2M(result,radix,i);
	  //printf("%d %d %s\n",i,radix,result);
	}
      dec2M(result,radix,c);
      printf("%s\n",result);
    }
  
  return(0);
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <string>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

class Dice{
public:
    Dice(int o_u,int o_s,int o_e,int o_w,int o_n,int o_d);
    ~Dice();
    int dice_south();
    int dice_north();
    int dice_east();
    int dice_west();
    int get_up();

  private:
    int up, south, east, west, north, down;


};

Dice::Dice(int o_u,int o_s,int o_e,int o_w,int o_n,int o_d){
    up = o_u;
    south = o_s;
    east = o_e;
    west = o_w;
    north = o_n;
    down = o_d;
}

Dice::~Dice(){}

int Dice::dice_north(){
    int tmp;
    tmp = north;
    north = up;
    up = south;
    south = down;
    down = tmp;
    return up;
}

int Dice::dice_south(){
    int tmp;
    tmp = south;
    south = up;
    up = north;
    north = down;
    down = tmp;
    return up;
}

int Dice::dice_east(){
    int tmp;
    tmp = east;
    east = up;
    up = west;
    west = down;
    down = tmp;
    return up;
}

int Dice::dice_west(){
    int tmp;
    tmp = west;
    west = up;
    up = east;
    east = down;
    down = tmp;
    return up;
}

int Dice::get_up(){
    return up;
}


int main(){

    vector<int> v(6);
    REP(i,6){cin >> v[i];}

    unique_ptr<Dice> d(new Dice(v[0],v[1],v[2],v[3],v[4],v[5]));

    char tmp;
    while(cin>>tmp){
        if(tmp == 'S'){
            d->dice_south();
        }else if(tmp == 'W'){
            d->dice_west();
        }else if(tmp == 'E'){
            d->dice_east();
        }else if(tmp == 'N'){
            d->dice_north();
        }
    }

    cout << d->get_up() << endl;

    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define int long long int
using namespace std;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int> (3,0));
    for(int i=0;i<n;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    for(int i=1;i<n;i++)
    {
        v[i][0]=v[i][0]+max(v[i-1][1],v[i-1][2]);
        v[i][1]=v[i][1]+max(v[i-1][0],v[i-1][2]);
        v[i][2]=v[i][2]+max(v[i-1][1],v[i-1][0]);
    }
    cout<<max(v[n-1][0],max(v[n-1][1],v[n-1][2]));
}

int32_t main()
{
    solve();
}

Measured memory_bytes: 5760
import sys
input = sys.stdin.readline

inf = float('inf')

# 一点更新　区間取得　1-indexed
class SegmentTree:
    def __init__(self, n):
        tmp = 1
        while tmp < n:
            tmp <<= 1
        # self.N : 完全二分木の葉の数(N以上の最小の2べき)
        self.N = tmp
        # 2*self.N - 1 : 完全二分木のノード数
        # 1-indexedで管理するので１つ余分に設ける
        self.Data = [(inf, -1) for _ in range(2*self.N)]

    # k (0-indexed)
    def update(self, k, x):
        #　インデックスを補正
        k += self.N
        # 指定ノードを更新
        self.Data[k] = (x, k-self.N)
        # kを含む区間ノードを更新していく
        while k > 1:
            k >>= 1
            self.Data[k] = min([self.Data[2*k], self.Data[2*k+1]])

    # [l, r) (0-indexed)
    def query(self, l, r):
        #　インデックスを補正
        l += self.N
        r += self.N
        # 返り値を初期化
        res = (inf, -1)
        while l < r:
            # 右側なら右側を更新 右上に行く
            # 左側なら更新しない　上に行く
            if l & 1:
                res = min([res, self. Data[l]])
                l += 1
            # 右側なら左側を更新　上に行く
            # 左側なら更新しない 上に行く
            if r & 1:
                r -= 1
                res = min([res, self.Data[r]])
            l >>= 1; r >>= 1
        return res

    def value(self, k):
        k += self.N
        return self.Data[k]

N, M = map(int,input().split())
S = input()

ST = SegmentTree(N+1)
ST.update(0, 0)
memo = [-1] * (N+1)

for i in range(1, N+1):
    l = max(i-M, 0)
    r = i
    if S[i] == "0":
        d, j = ST.query(l, r)
        if d != inf:
            ST.update(i, d+1)
            memo[i] = j

if ST.value(N)[0] == inf:
    print(-1)
    exit()

ans = []
now = N
while now != 0:
    pre = memo[now]
    ans.append(now-pre)
    now = pre

print(*ans[::-1])

Measured memory_bytes: 26084
#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si second
#define fi first
#define show_(x) cerr<<"-> "<<#x<<endl;F(x){cerr<<it<<" ";}cout<<endl;
#define show(x) cerr<<#x<<"-> "<<x<<endl;
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("F:\\inout\\input.txt", "r", stdin); freopen("F:\\inout\\output.txt", "w", stdout);
using namespace std;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------
 int t[100000];


signed main(){
	//FILEIO
	//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[n];
	int u=0;
	int uu=0;
	int sum=0;
	f(n){
		cin>>a[i];
		sum+=a[i];
		if(a[i]>0){
			u=1;
		}
		if(a[i]<=0){
			uu=1;
		}
	}
	if(u==1 && uu==0){
		int mi=1000000000000000;
		int in=-1;
		f(n){
			if(a[i]<mi){
				mi=a[i];
				in=i;
			}
		}
		cout<<sum-2*a[in]<<endl;
		int in1=-1;
		f(n){
			if(a[i]>0 && i!=in){
				in1=i;
			}
		}
		int cur=a[in];
		f(n){
			if(i==in || i==in1){
				continue;
			}
			cout<<cur<<" "<<a[i]<<endl;
			cur-=a[i];
		}
		cout<<a[in1]<<" "<<cur<<endl;

	}
	else if(u==0 && uu==1){
		int mx=-100000000000000;
		int in=-1;
		f(n){
			if(a[i]>mx){
				mx=a[i];
				in=i;
			}
		}
		int cur=a[in];
		cout<<-1*sum+2*a[in]<<endl;
		f(n){
			if(i==in){
				continue;
			}
			cout<<cur<<" "<<a[i]<<endl;
			cur-=a[i];
		}
	}
	else{
		int in=-1;
		int in1=-1;
		int sum1=0;
		f(n){
			if(a[i]<=0){
				in=i;
			}
			sum1+=abs(a[i]);
		}
		cout<<sum1<<endl;
		f(n){
			if(a[i]>0){
				in1=i;
			}
		}
		int cur=a[in];
		int cur1=a[in1];
		f(n){
			if(i==in || i==in1){
				continue;
			}
			if(a[i]<=0){
				cout<<cur1<<" "<<a[i]<<endl;
				cur1-=a[i];
			}
			else{
				cout<<cur<<" "<<a[i]<<endl;
				cur-=a[i];
			}
		}
		cout<<cur1<<" "<<cur<<endl;
	}

	

	
	
	






	return 0;
}



Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, double> pdd;

map<pii, int> amtDP;
ll dp[10];
ll ndp[10];
void solve() {
  int h, w, k;
  cin >> h >> w >> k;
  int totalInc = 0;
  {
    vector<pii> v;
    for(int i = 2; i <= w; i++) {
      v.push_back({i-1, i});
    }
    for(int mask = 0; mask < (1 << v.size()); mask++) {
      set<int> seen;
      bool good = true;
      for(int i = 0; i < v.size(); i++) {
        if((mask&(1<<i)) == 0) continue;
        if(seen.count(v[i].first) || seen.count(v[i].second)) good = false;
        seen.insert(v[i].first);
        seen.insert(v[i].second);
      }
      if(!good) continue;
      totalInc++;
      for(int i = 0; i < v.size(); i++) {
        if(mask&(1<<i)) amtDP[v[i]]++;
      }
    }
  }
  dp[1] = 1;
  while(h--) {
    memset(ndp, 0, sizeof(ndp));
    for(int i = 1; i <= w; i++) {
      int scale = totalInc;
      pii key = {i-1, i};
      scale -= amtDP[key];
      ndp[i-1] += amtDP[key] * dp[i];
      key = {i, i+1};
      scale -= amtDP[key];
      ndp[i+1] += amtDP[key] * dp[i];
      ndp[i] += scale * dp[i];
    }
    for(int i = 1; i <= w; i++) ndp[i] %= 1000000007;
    memcpy(dp, ndp, sizeof(dp));
  }
  cout << dp[k] << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(){
	for(int i=0;i<5;i++)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			cout<<i+1<<endl;
			break;
		}
	}
}
int main()
{
	solve();
}


Measured memory_bytes: 3648
#include<cstdio>

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

using namespace std;

// dp[i][j] := ( i 組のカードがあり、そのうち j 種類の(片方の)場所がわかっている状態でのミスマッチ回数の期待値 )
double dp[501][501];
double dfs(int i,int j){
	if(i==0) return 0;

	if(dp[i][j]!=-1) return dp[i][j];

	// 一枚目を、まだ中身がわかっていない 2*i-j 枚の中から選ぶ
	// 確率 p=j/(2*i-j) で場所が知れているカードと同じ絵柄を引き当てる
	// このとき、二枚目を引いて確実に絵柄を揃えられる
	double res1=0;
	if(j>0) res1+=dfs(i-1,j-1);

	// 確率 1-p で場所が知れていないカードを引き当てる
	// 二枚目を引いたとき
	// - 一枚目と同じ絵柄だった
	// - すでに場所が知れているカードと同じ絵柄だった
	// - まだ場所が知れていないカードだった
	// の三通りが起こりうる
	double res2=0;
	if(i>j){
		res2+=1.0/(2*i-j-1)*dfs(i-1,j);
		if(j> 0 ) res2+=1.0*j/(2*i-j-1)*(dfs(i-1,j)+1);
		if(i>j+1) res2+=1.0*(2*i-2*j-2)/(2*i-j-1)*(dfs(i,j+2)+1);
	}

	double p=1.0*j/(2*i-j);
	return dp[i][j]=p*res1+(1-p)*res2;
}

int main(){
	rep(i,501) rep(j,501) dp[i][j]=-1;
	for(int n;scanf("%d",&n),n;) printf("%.9f\n",dfs(n/2,0));
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long int a,b,c,d,i,j;
    while(~scanf("%lld %lld %lld %lld",&a,&b,&c,&d))
    {
      if(a>=b)
      {
          i=(a-b)*d+b*c;
          printf("%lld\n",i);
      }
      if(a<b)
      {
          i=a*c;
          printf("%lld\n",i);
      }
    }


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  d = N % 10; c = (N / 10) % 10 ; b = (N / 100) % 10, a = (N / 1000);
  if (b == c && ((a == b) || (c == d))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		long ans = modPow(10, n);

		ans -= modPow(9, n);

		if (ans < 0){
			ans += 1000000007;
		}

		ans -= modPow(9, n);

		if (ans < 0){
			ans += 1000000007;
		}

		ans += modPow(8, n);

		ans %= 1000000007;

		System.out.println(ans);;
	}

	public static long modPow (long base, long pow ){

		long ret = base;

		for (int i=0; i<pow-1; i++){

			ret *= base;
			ret %= 1000000007;

		}
		return ret;
	}
}

Measured memory_bytes: 35660
numStrings = int(input())

headlines = []

for i in range(numStrings):
	headlines.append(input())

commons = []

for letter in headlines[0]:
	isShared = True
	for word in headlines:
		if letter not in word:
			isShared = False
			break

	if isShared:
		commons.append(letter)
		for w in range(numStrings):
			headlines[w] = headlines[w][:headlines[w].index(letter)] + headlines[w][headlines[w].index(letter)+1:]

print("".join(sorted(commons)))

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

int main()
{
    ll h;
    cin >> h;
    int keta = 0;
    while (1) {
        h /= 2;
        keta++;
        if (h == 0) break;
    }
    ll ans = pow(2, keta) - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
typedef pair<int,int> pie;
int main() {
	int d,t,s;
	cin >> d >> t >> s;
	ll dist = t*s;
	if(d <= dist) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
}


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

ll int maxcustom(ll int a, ll int b)
{
	if(a>=b)
		return a;
	else
		return b;
}

ll int mincustom(ll int a, ll int b)
{
	if(a<=b)
		return a;
	else
		return b;
}

int main(void)
{
	ll int n, cost=0;
	cin >>n;
	ll int h[n];
	for(int i=0; i<n; i++)
		cin>>h[i];

	long long int dp[n];
	for(int i=0; i<n; i++)
		dp[i]=0;

	dp[1]=abs(h[1]-h[0]);

	for(ll int i=2; i<n; i++)
		 dp[i]=min( dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]) );
	

	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/
char a[100][100];
char b[100][100];
int main() {
    int n,m;
    re(a,0);
    re(b,0);

    s(n) s(m) gc;
    for( int i = 1; i <= n; i ++){
        for(int j = 1; j <= n; j ++){
            a[i][j] = gc;
        }
        gc;
    }

    for( int i = 1; i <= m; i ++){
        for(int j = 1; j <=m; j ++){
            b[i][j] = gc;
        }
        gc;
    }
    for(int i = 1; i <= n-m+1; i ++){
        for(int j = 1; j <= n-m+1; j ++){
            for(int k = 1; k <= m; k ++){
                for(int l = 1; l <= m ;l ++){
                    if(a[i+k-1][j+l-1] != b[k][l]){
                        goto l;
                    }
                }
            }
            puts("Yes");
            return 0;
            l:0;
        }
    }
    puts("No");


    return 0;
}



 //1 1 1 1 2 2 2 3 3 5 6 6 8 8 11


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int N = scn.nextInt();

			int ret = 0;
			int index = 1;
			for (int i = 0; i < N; i++) {
				int tmp = scn.nextInt();
				if (tmp == index) {
					index++;
				} else {
					ret++;
				}
			}
			if (index == 1) {
				System.out.println(-1);
			} else {
				System.out.println(ret);
			}
		}
	}
}


Measured memory_bytes: 63816
<?php

fscanf(STDIN, '%s', $b);

switch ($b) {
    case 'A':
        echo 'T';
        break;
    case 'T':
        echo 'A';
        break;
    case 'C':
        echo 'G';
        break;
    case 'G':
        echo 'C';
        break;
}

echo PHP_EOL;


Measured memory_bytes: 16072
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int a, b; cin >> a >> b; a--; b--;
	cout << (b + a - 1) / a << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ff(i, x, n, k) for(int i=x;i<n;i+=k)
#define rf(i, x, n, k) for(int i=n-1;i>=x;i+=k)
#define ef(i, x, n, k) for(int i=x;i<=n;i+=k)
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int MOD = 1e9+7;
const ll INF = pow(10, 18)+5;

int main()
{
	fast_cin();
	int n,m;
	cin>>n>>m;
	int arr[110000];
	bool done[110000];
	memset(arr,0,sizeof(arr));
	memset(done,false,sizeof(done));
	for(int i=0;i<m;i++){
		string verdict;
		int ques;
		cin>>ques>>verdict;
		if(verdict=="AC") done[ques]=true;
		if(verdict=="WA" && done[ques]==false) arr[ques]++;
	}
	int ans1=0;
	int ans2=0;
	for(int i=0;i<110000;i++){
		if(done[i]==true){
			ans1++;
			ans2+=arr[i];
		}
	}
	cout<<ans1<<" "<<ans2<<"\n";
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

int N;
vector<int> a;

int Alice = 0;
int Bob = 0;

int main() {

	cin >> N;
	a.resize(N);

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

	sort(a.begin(), a.end(), greater<int>());

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) Alice += a[i];
		else Bob += a[i];
	}

	cout << Alice - Bob << endl;

	return 0;


}

Measured memory_bytes: 256
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0, m, x, y, v;
  set<ll> se[26];
  srand(time(NULL));
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    x = -10000000000000;
    y = -1;
    for (int j = 0; j < 26; j++) {
      if (x < s[i][j] + (i + 1 - *se[j].rbegin()) * c[j]) {
        y = j;
        x = s[i][j] + (i + 1 - *se[j].rbegin()) * c[j];
      }
    }
    t[i] = y;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
  }
  for (int i = 0; i < 26; i++) {
    se[i].insert(d + 1);
  }
  for (int i = 0; i < 15000000; i++) {
    x = i % d + 1;
    y = i % 26;
    v = 0LL;
    v += s[x - 1][y] - s[x - 1][t[x - 1]];
    set<ll>::iterator it = se[t[x - 1]].find(x);
    it--;
    ll z = *se[t[x - 1]].upper_bound(x);
    v -= c[t[x - 1]] * (z - x) * (x - *it);
    it = se[y].lower_bound(x);
    it--;
    v += c[y] * (*se[y].lower_bound(x) - x) * (x - *it);
    if (v > 0LL) {
      ans += v;
      se[t[x - 1]].erase(x);
      t[x - 1] = y;
      se[y].insert(x);
    }
  }
  for (int i = 0; i < d; i++) {
    cout << t[i] + 1 << endl;
  }
}

Measured memory_bytes: 3716
#include <cstdio>
#include <math.h>
using namespace std;

int main ()
{
  int a, b;
  int d, r;
  double f;

  scanf("%d", &a);
  scanf("%d", &b);

  d = a / b;
  r = a % b;
  f = a * 1.0 / b;

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

  return 0;
}

Measured memory_bytes: 2720
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define MAXN 100005
typedef long long LL;
#define int LL
const int mo=1e9+7;
typedef pair<int,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int x,sum[MAXN];
signed main(){
	read(x);int idx=1;sum[1]=1;
	while(sum[idx]-sum[idx-1]<=x)
		idx++,sum[idx]=idx*idx*idx*idx*idx;
	int l=0,r=0;
	while(r<=idx){
		if(sum[r]-sum[l]>x)l++;
		else r++;
		if(sum[r]-sum[l]==x){
			printf("%lld %lld",r,l);
			return 0;
		}
	}
	l=1;r=idx;
	while(r>=0&&l<=idx){
		if(sum[r]+sum[l]>x)r--;
		else l++;
		if(sum[r]+sum[l]==x){
			printf("%lld -%lld",r,l);
			return 0;	
		}
	}
	return 0;
}
/*
a^5-b^5=x
(a-b)(a+b)(a^2+
*/

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cmath>

using namespace std;

typedef long long ll;

int main(void) {
    ll s_num, c_num;
    cin >> s_num >> c_num;
    if ((2 * s_num - c_num) >= 0) {
        cout << min(s_num, c_num / 2) << endl;
    } else {
        cout << s_num + (c_num - 2 * s_num) / 4;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




 
    
void test_case() {

    ll n, k;
    cin>>n>>k;

    ll ans = n%k;

    ans = min(ans, abs(ans-k));

    cout<<ans<<endl;









}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3640
s = input()
yy = int(s[0]+s[1])
mm = int(s[2]+s[3])
if(1<=yy<=12 and 1<=mm<=12):
	print('AMBIGUOUS')
elif(0<=yy<=99 and 1<=mm<=12):
    print('YYMM')
elif(0<=mm<=99 and 1<=yy<=12):
  	print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int x, y;
	
	while (1) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x<y)
			printf("%d %d\n", x, y);
		else
			printf("%d %d\n", y, x);
	}

	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 100000
#define QUERY_MAX 100000


int main(void) {
    int num, queries;
    get_int2(&num, &queries);
    static char str[NUM_MAX];
    get_str(str, num);

    int i;
    char prev = str[0];
    static char match[NUM_MAX];
    for(i = 1; i < num; i++) {
        if(prev == 'A' && str[i] == 'C') match[i] = 1;
        prev = str[i];
    }

    static int cum[NUM_MAX+1];
    for(i = 1; i <= num; i++) {
        cum[i] = cum[i-1] + match[i-1];
    }

    int q;
    static int ans[QUERY_MAX];
    int aidx = 0;
    for(q = 0; q < queries; q++) {
        int start, end;
        get_int2(&start, &end);
        start--; end--;
        // [start, end)
        end++;
        int res = cum[end] - cum[start];
        if(str[start] == 'C' && match[start]) res-= 1;
        ans[aidx++] = res;
    }

    // presentation
    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
	//const auto s = chrono::system_clock::now();
	
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int sum = 0, ans = 0;
	for (int i = 0; i <= a; ++i)
		for (int j = 0; j <= b; ++j)
			for (int k = 0; k <= c; ++k)
			{
				sum = (500 * i) + (100 * j) + (50 * k);
				ans += (sum == x);
			}

	cout << ans << endl;

	//const auto e = chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(e - s).count() << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    if (N + 1 == K) {
        printf("1\n");
        return 0;
    }
    if (N == K) {
        printf("%d\n", 1 + (N + 1));
        return 0;
    }

    long long result = 1 + (N + 1);
    long long i = 1;
    long long mod = 1000000007;
    long long n = (long long)N;
    while (N - i >= K) {
        long long max = ((i + 1 + n) * (n - i)) / 2;
        long long min = ((0 + n - i - 1) * (n - i)) / 2;
        result += (long long)((max - min) + 1);
        result = result % mod;
        i++;
    }
    printf("%lld\n", result);

    return 0;
}

Measured memory_bytes: 2156
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])
d = int(arr_data[0][3])


mindata = a  if a>c else c
maxdata = b  if b<d else d



print(maxdata-mindata if maxdata>mindata else 0)








Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            inp = inp.OrderBy(x => x).ToArray();
            var inpInc = inp.Select(i => i + 1).ToArray();
            var inpDec = inp.Select(i => i - 1).ToArray();
            var dic = new Dictionary<int, int>();
            for (int i = 0; i < n; i++)
            {
                if (!dic.ContainsKey(inp[i])) dic[inp[i]] = 0;
                dic[inp[i]]++;
                if (!dic.ContainsKey(inpInc[i])) dic[inpInc[i]] = 0;
                dic[inpInc[i]]++;
                if (!dic.ContainsKey(inpDec[i])) dic[inpDec[i]] = 0;
                dic[inpDec[i]]++;
            }
            Console.WriteLine(dic.Values.Max());
        }
    }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  map<int, int> cnt;
  vi a(n); rep(i, n) std::cin >> a[i], cnt[a[i]]++;
  int MAX = 2 * 100'000 + 5;
  vector<ll> fact(MAX); fact[1] = 1; srep(i, 2, MAX) fact[i] = fact[i-1] * i;
  auto comb = [](ll x) {
    if (x < 2) return ll(0);
    return x * (x-1) / 2;
  };
  ll ans = 0;
  for (auto p : cnt) ans += comb(p.se);
  rep(i, n) {
    ll tmp = ans;
    tmp -= comb(cnt[a[i]]);
    tmp += comb(cnt[a[i]]-1);
    std::cout << tmp << "\n";
  }
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
map<lli, lli> prime_factor(lli m) {
  map<lli, lli> data;
  int a = 2;
  while (m >= a * a) {
    if (m % a == 0) {
      data[a]++;
      m /= a;
    } else {
      if (a >= 3)
        a += 2;
      else
        a++;
    }
  }
  if (m != 1)
    data[m]++;
  return data;
}

void solve(long long N) {
  int cnt = 0;
  auto s = prime_factor(N);
  for (auto ss : s) {
    int p = ss.second;
    for (int i = 1; i <= p; i++) {
      p -= i;
      cnt++;
    }
  }
  cout << cnt << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3696
import sys
import itertools
from math import ceil

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    D, G = in_nn()
    p = [0] * D
    c = [0] * D
    for i in range(D):
        a, b = in_nn()
        p[i] = a
        c[i] = b

    comb = itertools.product([0, 1], repeat=D)
    ans = 10**9 + 7

    for com in comb:
        score = 0
        prob = 0
        for i, x in enumerate(com):
            if x == 1:
                prob += p[i]
                score += c[i] + p[i] * 100 * (i + 1)

        for i in range(D - 1, -1, -1):
            if score >= G:
                break
            if com[i] == 0:
                pt = ceil((G - score) / (100 * (i + 1)))
                pt = min(pt, p[i] - 1)
                score += pt * 100 * (i + 1)
                prob += pt

        if score >= G:
            ans = min(ans, prob)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9352
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#############################################
n=int(input())
if is_power(n,10):
    print(10)
else:
    n=str(n)
    n=list(n)
    n=list(map(int,n))
    print(sum(n))
  



Measured memory_bytes: 6992
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair

using namespace std;

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch=getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch=getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

int a,p;

int main(){
	a = read<int>();
	p = read<int>();
	printf("%d\n",(a * 3 + p)/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int a, b, x;
    cin >> a >> b >> x;

    if(x <= a*a*b/2){
        double s = (double) a*b/2;
        double t = (double) x/s;
        // cout << atan2((double)b, t) /M_PI * 180 << endl;
        printf("%.10f", atan2((double)b, t) /M_PI * 180);
        return 0;
    }else{
        int y = a*a*b-x;
        double s = (double) a*a/2;
        double t = (double) y/s;
        // cout << atan2(t, (double)a) /M_PI * 180 << endl;
        printf("%.10f", atan2(t, (double)a) /M_PI * 180);
        return 0;
    }
}

Measured memory_bytes: 256
class BFS():
    def __init__(self, H, W, maze):
        self.H = H
        self.W = W
        self.maze = maze
        self.distance = [[0 for i in range(self.W)] for j in range(self.H)]
        self.sx = 0
        self.sy = 0
        self.gx = W-1
        self.gy = H-1

    def bfs(self):
        queue = []
        queue.insert(0, (self.sx, self.sy))

        self.distance[self.sx][self.sy] = 0

        while len(queue):
            x, y = queue.pop()

            if x == self.gx and y == self.gy:
                break

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                if (0 <= nx and nx < self.W and 0 <= ny and ny < self.H and self.maze[ny][nx] != '#' and self.distance[ny][nx] == 0):
                    queue.insert(0, (nx, ny))
                    self.distance[ny][nx] = self.distance[y][x] + 1
        return self.distance[self.gy][self.gx]

H, W = list(map(int, input().split()))
sw=[list(input()) for _ in range(H)]

bfs=BFS(H, W, sw)
distance=bfs.bfs()

init_white=0
for i in range(H):
    init_white+=sw[i].count('.')
print(init_white-(distance+1) if distance!=0 else -1)


Measured memory_bytes: 3188
d,g = map(int,input().split())
p = [0]*(d+1)
c = [0]*(d+1)
for i in range(1,d+1):
  p[i],c[i] = map(int,input().split())
m = sum(p)
for x in range(2**d-1):
  b = str(format(x, '010b'))
  s = 0
  y = 0
  for i in range(1,d+1):
    if b[-i] == "1":
      s += 100*i*p[i]+c[i]
      y += p[i]
    else:
      a = i
  if g <= s:
    m = min(m,y)
  elif g <= s+100*a*p[a]:
    m = min(m,y+(g-s+100*(a-1))//(100*a))
print(m)


Measured memory_bytes: 3064
def main():
    n = int(input())
    s = input()
    l, r, c = 0, 0, 0
    for a in s:
        if a == '(':
            c += 1
        else:
            if c:
                c -= 1
            else:
                l += 1
    r = c
    print("("*l + s + ")"*r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9084
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void solve(int test, istream &in) {
    int a, b;
    in >> a >> b;
    printf("%d", a * b);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
	//FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
	//FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }
	return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double l;
  cin>>l;
  cout<<fixed<<setprecision(10); //after the decimal point
  cout<<pow(l/3,3)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int lli;

typedef class BIT{
public:
  //区間が[1, n]
  BIT(lli n){bit.resize(n + 2, 0);};
  lli sum(lli i){
    int s = 0;
    while(i > 0){
      s += bit[i];
      i -= i&-i;
    }
    return s;
  }
  void add(lli i, lli x){
    while(i <= bit.size()){
      bit[i] += x;
      i += i&-i;
    }
  }
private:
  vector<lli> bit;
}BIT;

int main(){
  lli n, k, ans = 0;
  std::cin >> n >> k;
  vector<lli> a(n), accm(n + 1, 0);
  vector<lli> pos;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    a[i] -= k;
    accm[i + 1] = a[i];
  }
  for (int i = 1; i <= n; i++) accm[i] += accm[i - 1];
  for (int i = 0; i <= n; i++) pos.push_back(accm[i]);
  sort(pos.begin(), pos.end());
  pos.erase(unique(pos.begin(), pos.end()), pos.end());
  for (int i = 0; i <= n; i++)
    accm[i] = lower_bound(pos.begin(), pos.end(), accm[i]) - pos.begin() + 1;
  BIT bit(n);
  for (int i = 0; i <= n; i++) {
    ans += bit.sum(accm[i]);
    bit.add(accm[i], 1);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 7152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll u = a+b;
    ll m = n%u;

    ll ans = a*(n/u) + min(a, m);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_sort = np.sort(A)
A_1 = A_sort[n-1]
A_2 = A_sort[n-2]


for i in range(n):
    if A[i] != A_1:
        print(A_1)
    else:
        print(A_2)

Measured memory_bytes: 21732
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

double calc (int x[100], int y[100],int n,double p){
    if(p != INFINITY){
        double d = 0;
        double D;
        for(int i = 0 ; i < n ; i++){
            d += pow(abs(x[i] - y[i]) ,p);
        }
        D = pow(d , 1/p); 
        return D;
    }
    else{
        double D;
        D = abs(x[0] - y[0]);
        for(int i = 0 ; i < n ; i++){
            if(D < abs(x[i] - y[i])){
                D = abs(x[i] - y[i]);
            }        
        }
        return D;
    }
}

int main(){
    int n;
    cin >> n;
    int x[100] = {0};
    int y[100] = {0};
    for(int i = 0 ; i < n ; i++){
        cin >> x[i];
    }
    for(int i = 0 ; i < n ; i++){
        cin >> y[i];
    } 
    cout << fixed << setprecision(6) << calc(x, y, n, 1) << endl;
    cout << fixed << setprecision(6) << calc(x, y, n, 2) << endl;
    cout << fixed << setprecision(6) << calc(x, y, n, 3) << endl;
    cout << fixed << setprecision(6) << calc(x, y, n, INFINITY) << endl;
}



Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double c = 2 * x / (a * b);
  if ( c > 0 && c <= a){
    cout << setprecision(10) << atan((a * b * b) /(2 * x) ) * (180.0/pi)<< endl;
  } else {
    double c = 2 * (b - x / (a * a));
    cout << setprecision(10) << atan(c/a) * (180.0/pi) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, s;
	cin>>n>>s;
	vector<ll> a(n);
	rep(i, n) cin>>a[i];
	vector<int> res; res.reserve(n);
	rep(i, n-1){
		if(a[i]+a[i+1]>=s){
			res.push_back(i+1);
			break;
		}
	}
	if(res.empty()){
		cout<<"Impossible"<<endl;
		return 0;
	}
	for(int i = res[0]+1; i < n; i++) res.push_back(i);
	for(int i = res[0]-1; i >= 1; i--) res.push_back(i);
	reverse(res.begin(), res.end());
	cout<<"Possible"<<endl;
	rep(i, n-1) cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
double reabs(double in){
    if(in<0){
        return (-1)*in;
    }else{
        return in;
    }
}

int main(){
    string S[3];
    FOR(i,3){
        cin>>S[i];
    }
    
    char s1=S[0][0];
    char s2=S[1][1];
    char s3=S[2][2];
    string ans="";
    ans+=s1;
    ans+=s2;
    ans+=s3;

    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256