akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


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

        string s;
        cin >> s;
        int n=s.size();
        int i,j,k;
        int m=(n-1)/2;
        int p=(n+3)/2;

        string a=s;
        int w=0;
        reverse(a.begin(),a.end());
        if(a==s)w++;
        a="";
        for(i=0; i<m; i++)a+=s[i];
        string b=a;
        reverse(b.begin(),b.end());
        if(b==a)w++;

        a="";
        for(i=p-1; i<n; i++)a+=s[i];
         b=a;
        reverse(b.begin(),b.end());
        if(b==a)w++;
        
        if(w==3)cout << "Yes" << '\n';
        else cout << "No";
        

}

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

int main(void) {
    int N,K;
    cin >> N >> K;

    int ans[N+1];

    for(int i=0; i<N+1; i++){
      ans[i] = 0; //すぬけ君に番号を振り、持っているお菓子の数をカウント
    }

    for(int i=0; i<K; i++){
      int d;
      cin >> d;
      int A[d];
      for(int j=0; j<d; j++){ //該当のお菓子を持っている人数
        cin >> A[j];  //該当のお菓子を持っている すぬけ君の番号を取得
        ans[A[j]]++;  //取得した番号の配列にカウントアップする
      }
    }
    int cnt =0;
    for(int i=1; i<N+1; i++){
      if(ans[i]==0) //お菓子を何も持っていない場合、すぬけ君をカウントする
        cnt++;
     }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())

candies1 = list(map(int, input().split()))
candies2 = list(map(int, input().split()))
num = 0

for i in range(N):
    tmp = 0
    tmp += sum(candies1[:i+1])
    tmp += sum(candies2[i:N])
    if  num < tmp:
        num = tmp

print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define N 100005

using namespace std;

int n;
int val[N], func[N], nex[N];
long long sum[N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}

int main() {
	read(n);
	read(val[1]), func[1] = 1;
	for(int i = 2; i <= n; ++i) {
		func[i] = (getchar() == '+' ? 1 : -1);
		read(val[i]);
//		printf("%d\n", func[i] * val[i]);
	}
	
	nex[n] = n + 1;
	for(int i = n; i > 1; --i) {
		sum[i] = val[i] + sum[i + 1];
		nex[i - 1] = (func[i] == -1 ? i : nex[i]);
	}
	
	long long ans, cur, res;
	ans = -1e18, cur = val[1];
	for(int i = 2; i <= n; ++i) {
		if(func[i] == -1) {
			res = cur - (sum[i] - sum[nex[i]]) + sum[nex[i]];
			if(res > ans) ans = res;
		}
		cur += func[i] * val[i];
	}
	
	if(cur > ans) ans = cur;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
<?php
// Your code here!
$n = trim(fgets(STDIN));
$arr = explode(" ",trim(fgets(STDIN)));
$brick = 0;
$jug = 1;
for($i=0;$i<$n;$i++) {
    if($arr[$i]==$jug) {
        $jug++;
    }else {
        unset($arr[$i]);
        $brick++;
    }
}
if($brick==$n) {
    echo -1;
}else {
   echo $brick; 
}
?>

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int x;
signed main(){
	cin>>x;
	int p=x/100,q=x%100;
	if(p==0){
		puts("0");
		return 0;
	}
	if(q<=p*5){
		puts("1");
	}
	else{
		puts("0");
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<string> t(n);
    for (int i = 0;i < n;++i) cin >> t[i];
    int ans = INT_MAX;
    for (int i = 0;i < n;++i) {
        vector<string> s = t;
        bool ok = true;
        int k = -1;
        int cnt = 0;
        for (int j = 0;j < n;++j) if (s[j][i] == '#') {k = j;break;}
        if (k < 0) {
            for (int j = 0;j < n;++j) {
                for (int l = 0;l < n;++l) if (s[i][j] == '#') {
                    string u = s[i];
                    for (int m = 0;m < n;++m) s[m][i] = u[m];
                    k = j;
                    cnt++;
                    break;
                }
                if (k >= 0) break;
            }
        }
        for (int j = 0;j < n;++j) if (s[i][j] == '.') {
            if (k < 0) {ok = false;break;}
            string u = s[k];
            for (int l = 0;l < n;++l) s[l][j] = u[l];
            cnt++;
        }
        for (int j = 0;j < n;++j) {
            for (int l = 0;l < n;++l) if (s[l][j] == '.') {cnt++;break;}
        }
        if (ok) ans = min(ans,cnt);
    }
    cout << (ans  < INT_MAX ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 952
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;
using Float = double;

template <typename T>
inline std::string to_bin_str(T n, std::size_t digit_num) {
    std::string str;
    while (n > 0) {
        str.push_back('0' + (n & 1));
        n >>= 1;
    }
    str.resize(digit_num, '0');
    std::reverse(str.begin(), str.end());
    return str;
}

vector<int> to_groups(const auto& hbun_bin) {
  int H = hbun_bin.size() + 1;
  auto ret = vector<int>(H+1, 0);
  ret[1] = 0;
  for(int i=2; i<=H; i++) {
    ret[i] = (hbun_bin[i-2] == '0') ? ret[i-1] : ret[i-1]+1;
  }
  return move(ret);
}

int numbit1(const auto& hbun_bin) {
  int pop = 0;
  for(auto&& b : hbun_bin) {
    if (b=='1') {
      pop++;
    }
  }
  return pop;
}

int main() {
  Int H, W, K;
  cin >> H >> W >> K;
  
  auto SS = vector<int>(H*W);
  #define S(i,j)  SS[W*((i)-1) + (j)-1]
  #define SE(SS, i,j)  (SS)[W*((i)-1) + (j)-1]
  for(int i=1; i<=H; i++) {
    string str;
    cin >> str;
    for(int j=1; j<=W; j++) {
      S(i,j) = str[j-1] - '0';
    }
  }

  auto ns = vector<int>(H, 0);
  int min_div = 1 << 30;
  for(int hbun=(1<<(H-1)) - 1; hbun >= 0; --hbun) {
    auto hbun_bin = to_bin_str(hbun, H-1);
    auto group = to_groups(hbun_bin);
	int ngourp = group[H] + 1;
    int ndiv = numbit1(hbun_bin);
    fill(ns.begin(), ns.end(), 0);
    for(int i=1; i<=H; i++) {
      if (S(i,1) == 1) {
        if (++ns[group[i]] > K) {
          goto next1;
        }
      }
    }
    for(int j=2; j<=W; j++) {
      for(int i=1; i<=H; i++) {
        if (S(i,j) == 1) {
          if (++ns[group[i]] > K) {
            ++ndiv;
            if (ndiv >= min_div) {
              goto next1;
            }
            fill(ns.begin(), ns.end(), 0);
            for(int i=1; i<=H; i++) {
              if (S(i,j) == 1) {
                if (++ns[group[i]] > K) {
                  goto next1;
                }
              }
            }
            break;
          }
        }
      }
    }
    min_div = min(ndiv, min_div);
next1: ;    
  }
  cout << min_div << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int r,c;
    cin >> r >> c;
    int array[101][101] = {};
    
    
    for(int i=0;i<r;i++) {
        for(int j=0;j<c;j++) {
            cin >> array[i][j];
            array[i][c] = array[i][c] + array[i][j];
            array[r][j] = array[r][j] + array[i][j];
            array[r][c] = array[r][c] + array[i][j];
        }
    }
    
    for(int i=0;i<r+1;i++) {
        for(int j=0;j<c+1;j++) {
            cout << array[i][j];
            if(j!=c)
            cout << " ";
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{ //freopen ("0-1Knapsack.txt","r",stdin);
int n,w;
cin>>n>>w;
ll a[n+1],b[n+1];
for(int i=1;i<=n;i++)
{ cin>>a[i]>>b[i];
	cout<<endl;
}
ll dp[n+1][w+1];

for(int i=0;i<=n;i++)
{ for(int j=0;j<=w;j++)
  { 
   if(i==0 || j==0)
  	{ dp[i][j]=0;}
  else if(j<a[i]) { dp[i][j]=dp[i-1][j];}
  else 
  { dp[i][j]=max(b[i]+dp[i-1][j-a[i]],dp[i-1][j]);}
  }\
}

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

Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
const int oo = INT_MAX;
int n,w;
int weight[101],val[101];
ll dp[100010];
int main(){
    cin>>n>>w;
    for(int i=0;i<n;i++)
        cin>>weight[i]>>val[i];
    for(int i=1;i<100002;i++)
        dp[i]=oo;
    for(int i = 0; i < n; i++){
        for(int j = 100000; j >= val[i]; j--){
            dp[j]=min(dp[j], dp[j-val[i]] + weight[i]);
        }
    }
    int ans=0;
    for(int i = 100000; i >= 0; i--){
        if(dp[i]!=oo&&dp[i]<=w){
            ans=i;
            break;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3932
N = int(input())

count = [0] * (N + 1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp <= N:
                count[tmp] += 1

for i in range(1, N + 1):
    print(count[i])


Measured memory_bytes: 69044
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		
		String hitachi = "";
		
		for(int i = 1; i <= 5; i++) {
			hitachi += "hi";
			
			if(hitachi.equals(s)) {
				System.out.println("Yes");
				return;
			}
			
		}
		System.out.println("No");
		
		
	}

}


Measured memory_bytes: 22612
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    A, B, C, X, Y = map(int, input().split())
    
    ans = INF
    for c in range(0, max(X, Y) * 2 + 1, 2):
        p = c * C
        p += max(0, A * (X - (c // 2)))
        p += max(0, B * (Y - (c // 2)))
        ans = min(ans, p)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
def unique(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


n = int(input())

point = []
for _ in range(n):
    p = list(map(int, input().split()))
    p.sort()
    point.append(p)

point_uni = unique(point)
ans = len(point) - len(point_uni)
print(ans)



Measured memory_bytes: 5636
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 60;
double x[maxn],y[maxn];
int n;
double solve(double xx,double yy)
{
	double ans=0.0;
	for(int i=1;i<=n;i++)
	ans=max(ans,sqrt((x[i]-xx)*(x[i]-xx)+(y[i]-yy)*(y[i]-yy)));
	return ans;
}
double solve(double xx)
{
	double lb=-1e9,ub=1e9;
	double mid,lmid,rmid;
	double ans=1e17;
	while(ub-lb>1e-8)
	{
		lmid=(lb+ub)/2;
		rmid=(lmid+ub)/2;
		if(solve(xx,lmid) <= solve(xx,rmid)) ub = rmid;
        else lb = lmid;
	}
	return solve(xx,lb);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%lf%lf",&x[i],&y[i]);
	double lb=-1e9,ub=1e9;
	double mid,lmid,rmid;
	double ans=1e17;
	while(ub-lb>1e-8)
	{
		lmid=(lb+ub)/2;
		rmid=(lmid+ub)/2;
		if(solve(lmid) <= solve(rmid)) ub = rmid;
        else lb = lmid;
	}
	printf("%.7lf",solve(lb));
	return 0;
}

Measured memory_bytes: 256
N,K = (int(T) for T in input().split())
D = input().split()
for TN in range(N,100000):
    StrN = str(TN)
    Flag = True
    for TS in StrN:
        if TS in D:
            Flag = False
            break
    if Flag:
        print(TN)
        break

Measured memory_bytes: 9068
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

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

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

    return 0;
}

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

using namespace std;

int main(){
    vector<int> a(3);
    for(int i = 0;i < 3;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < 3;i++){
        cout << a[i];
        if(i != 2){
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3148
import sys
input=sys.stdin.readline
from collections import deque

def main():
    N = int(input())
    Q = [deque(map(int, input().split())) for _ in range(N)]
    games = N*(N-1)//2

    days = 0
    nxt = [i for i in range(N)] # 翌日に対戦相手を更新する選手のリスト
    opp = [0]*N # 選手毎の、次の対戦相手のリスト
    while 1:
        days += 1
        for i in nxt:
            opp[i] = Q[i].popleft() - 1 if Q[i] else -1

        tmp = set() # 次の日の更新のため、試合をした選手をメモ
        for i in nxt:
            if i not in tmp and i == opp[opp[i]]:
#                print("game:", i+1, opp[i]+1, days)
                tmp.add(i)
                tmp.add(opp[i])
                games -= 1
        if games == 0:
            break
        elif not tmp:
            print(-1)
            return
        nxt = tmp
    print(days)

if __name__ == '__main__':
    main()

Measured memory_bytes: 36076
import sys
import numpy as np

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

n = int(input())
a = np.array(readline().split(), dtype=np.int64)
a.sort()
a = a[::-1]
m = -(-n//2)
ans = np.sum(a[:m])*2 - a[0] if n % 2 == 0 else np.sum(a[:m])*2 - a[0] - a[m-1]
print(ans)

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555555555555555555555545555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

template< int mod = 1000000007 >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

// const int mod = 1000000007;
const int mod = 998244353;
using mint = ModInt< mod >;

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

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    mint dp[c+1][d+1]={};
    dp[a][b]=1;
    for(int i=a;i<=c;i++){
        for(int j=b;j<=d;j++){
            if(i+1<=c) dp[i+1][j]+=dp[i][j]*mint(j);
            if(j+1<=d) dp[i][j+1]+=dp[i][j]*mint(i);
            if(i+1<=c && j+1<=d) dp[i+1][j+1]-=dp[i][j]*mint(i)*mint(j);
        }
    }
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 38772
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
#define int ll
int f[444][444],n,a[444],p[444];
int inf=1e18;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int i,j,k;
	for(i=1;i<=n;++i) cin>>a[i],p[i]=p[i-1]+a[i];
	for(i=1;i<=n;++i) for(j=i-1;j;--j){
		f[j][i]=inf;
		for(k=j;k<i;++k) f[j][i]=min(f[j][i],f[j][k]+f[k+1][i]+p[i]-p[j-1]);
	}
	cout<<f[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> x = new ArrayList<Integer>();

		while(sc.hasNextInt()){
			int value = sc.nextInt();
			if(value != 0){
				x.add(value);
			}
			else{
				break;
			}
		}

		for(int i = 0; i < x.size(); i++){
			System.out.println("Case " + (i + 1) + ": " + x.get(i));
		}
	}
}


Measured memory_bytes: 46868
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define vi vector<int>
#define mod 100000007
const int INF=1e9+5;
const int N=1e7+2;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;vector<int> dp(n,INF);vector<int> g;
    fo(i,n){int chap;cin>>chap;
    g.push_back(chap);
        }
           dp[0]=0;
       for(int i=0;i<n;i++){
           for(int j=i+1;j<=(i+2);j++){
               if(j<n){
        dp[j]=min(dp[j],dp[i]+abs(g[j]-g[i]));
               }
    }
}
        cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
using namespace std;
const int MAXN = 300 + 10;
string mat[MAXN], sec[MAXN];
int n;
bool check(int x) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            sec[i][j] = mat[(i+x)%n][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (sec[i][j] != sec[j][i]) return false;
        }
    }
    return true;

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> mat[i];
        sec[i] = mat[i];
    }
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (check(i)) ret += n;
    }
    cout << ret << endl;

    return 0;
}

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

#define M 1000000007
#define FOR(i, s, n) for (ll i = (s); i < (n); ++i)
#define FORALL(i, n) for (ll i = 0; i < (n); ++i)
#define MOD 1000000007
#define ff first
#define ss second
#define pll pair<long long, long long>
#define fast ios_base::sync_with_stdio(false)
#define countbits(x) __builtin_popcount(x)
#define pb(x) push_back((x))
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define print(x) cout << x << endl
#define debug print("reaching\n")
#define mll map<ll,ll>
#define lsb(i) i&(-i)
#define printv(x)            \
    FORALL(i, x.size())      \
    {                        \
        cout << x[i] << ' '; \
    }                        \
    cout << endl            \
;
#define input(v,x)  \
    FORALL(i,n)     \
    {               \
        cin>>v[i];  \
    }               \
;
#define printm(m) \
    for(auto i: m){\
        cout<<i.ff<<' '<<i.ss<<endl;        \
    }\
;
long long pow2(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = ((res%MOD) * (a%MOD))%MOD;
        a = ((a%MOD) * (a%MOD));
        b >>= 1;
    }
    return res;
}

typedef struct Edge{
	int u;
	int v;
	int w;
} edge;

bool com(edge a, edge b){
	return a.w < b.w;
}

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // // freopen("input.txt", "r", stdin);
    // // freopen("output.txt", "w", stdout);
    // #endif

    int t=1;
    // cin>>t;
    ll tot=t;
    while(t--){
    	ll a,b;
    	cin>>a>>b;
    	cout<<a*b<<endl;
    }
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int total = 0;
  for (int i = a; i <= b; i++) {
    int d1, d2, d4, d5;

    d1 = i % 10;
    d2 = (i / 10) % 10;
    d4 = (i / 1000) % 10;
    d5 = (i / 10000) % 10;

    if (d1 == d5 && d2 == d4) {
      total++;
    }
  }

  cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

signed main(){
   vector <int> vec;
    vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<vec.at(K-1);
  
}


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

int main(){
  long long n;
  cin >> n;
  
  long long digit = 0, nine = 0, ans = 0;
  while(n > 9){
    long long now = n % 10;
    if(now == 9) nine++;
    digit++;
    ans += now;
    n /= 10;
  }
  
  ans += n;
  ans = max(ans, n-1+digit*9);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from copy import deepcopy
N = int(input())
a0 = list(map(int, input().split()))

for i in range(N, 0, -1):
    if a0[i - 1] < 0:
        tmp = 0
        b = []
        for j in range(1, 101):
            if i * j - 1 >= N:
                break
            tmp += a0[i * j - 1]
            b.append(i * j - 1)
        if tmp < 0:
            for j in b:
                a0[j] = 0

for k1 in range(N, 0, -1):
    for k2 in range(k1-1, 0, -1):
        a = deepcopy(a0)
        for j in range(1, 101):
            if k1*j-1 >= N:
                break
            a[k1*j-1] = 0
        for j in range(1, 101):
            if k2*j-1 >= N:
                break
            a[k2*j-1] = 0
        for i in range(N, 0, -1):
            if a[i - 1] < 0:
                tmp = 0
                b = []
                for j in range(1, 101):
                    if i * j - 1 >= N:
                        break
                    tmp += a[i * j - 1]
                    b.append(i * j - 1)
                if tmp < 0:
                    for j in b:
                        a[j] = 0

        for i in range(N, 0, -1):
            if a0[i - 1] < 0:
                tmp = 0
                b = []
                for j in range(1, 101):
                    if i * j - 1 >= N:
                        break
                    tmp += a0[i * j - 1]
                    b.append(i * j - 1)
                if tmp < 0:
                    for j in b:
                        a0[j] = 0

        if sum(a) > sum(a0):
            a0 = a

print(sum(a0))


Measured memory_bytes: 52328
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = scan.nextInt();
            if (!map.containsKey(a)) {
                map.put(a, 0);
            }
            int c = map.get(a);
            map.put(a, c+1);
        }
        long answer = 0;
        for(int x : map.keySet()) {
            int c = map.get(x);
            if (x == c) {
                continue;
            }
            if (x < c) {
                answer += c - x;
                continue;
            }
            answer += c;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 62336
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main() {
    const double PI=3.14159265358979323846;
    double r;
    cin >> r;
    p(2.0 * PI *r);
}

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



//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N; string S[N+1];
    cout<< 0 <<endl;
    cin>>S[0];
    S[N]=S[0];
    if(S[0][0]=='V') return;
    ll left=0,right=N;
    rep(i,19){
        ll x=(left+right)/2;
        cout<< x <<"\n";
        cin>>S[x];
        if(S[x][0]=='V') return;
        if((x-left)%2==0 xor (S[left]==S[x])) right=x;
        else left=x;
    }
}
//--START----------------------------------
int main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1620
#include<stdio.h>
int main()
{
	char s[16];
	int a,b,i;
	for(i=0;i<9;i++){
		scanf("%s%d%d",s,&a,&b);
		printf("%s %d %d\n",s,a+b,a*200+b*300);
	}
	return 0;
}

Measured memory_bytes: 2576
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;


int main(int argc, char* argv[]){
 int N,D;
 scanf("%d %d",&N, &D);
 long long X[N];
 long long Y[N];
 for(int i=0;i<N;i++){
	 scanf("%lld %lld", &X[i], &Y[i]);
 }
 int count = 0;
 for(int i=0;i<N;i++){
	 long long kyori = X[i]*X[i] + Y[i]*Y[i];
	 if(kyori<=(long long)D*D){
		 count++;
	 }
 }
 printf("%d", count);



}


Measured memory_bytes: 6876
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;


#define ll long long
#define ld long double
#define mp make_pair
#define what_is(x) cerr << #x << " is " << x << endl;

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


int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(vector<int> s)
{
    int n = s.size();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
    return z;
}

mt19937 rnd(time(0));
/*
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct CHT : multiset<Line, less<>> {
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) { // floored division
        return a /b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
        isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        auto l = *lower_bound(x);
        return l.k * x + l.m;
    }
};
*/


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int h,w, a, b;
    cin>>h>>w>>a>>b;
    for (int i = 0; i<h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ((i < b) ^ (j < a));
        }
        cout<<endl;
    }


}

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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){// limit is 5e6 /// write pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return res;
}

int dp[2100][2100];//dp[i][j]:ボールをi色置き終わってj個0の場所の予約してる状態

signed main(){
  int n,K;cin>>n>>K;
  if(K==1){cout<<1<<endl;return 0;}
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    int col=n-i;
    int res=n*K-i*K-1;
    /*
    for(int j=0;j<=n-i;j++)
      for(int k=0;j+k<=n-i;k++)
        dp[i+1][max(j-1,0LL)+k]+=dp[i][j]*nCk(res-(max(j-1,0LL)+k)-1,K-2)%MOD;
    */
    for(int k=0;k<=n-i;k++)dp[i+1][k]+=dp[i][0]*nCk(res-k-1,K-2)%MOD;
    int now=0;
    for(int A=0;A<=n-i+2;A++){
      (now+=dp[i][A+1])%=MOD;
      (dp[i+1][A]+=nCk(res-A-1,K-2)*now%MOD)%=MOD;
    }
    for(int j=0;j<=2000;j++)(dp[i+1][j]*=col)%=MOD;
  }
  cout<<dp[n][0]<<endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;

    if(n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string s1, s2;
    s1 = s.substr(0, n/2);
    s2 = s.substr(n/2, n/2);

    if(s1 == s2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b,k;
   cin>>a>>b>>k;
   int ta=a;int tk=k;
   a-=min(ta,tk);
   k-=min(ta,tk);
   b-=min(b,k);
   cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG /GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
double cbrt_newton(double a,double x){
  double e;
  do{
    e=(x*x*x-a)/(3.0*x*x);
    x=x-e;

  }while(fabs(e)>1.0e-6);
  return x;
}
int main(){
int n;
cin>>n;
vector<int>vecx(n);
vector<int>vecy(n);
rep(i,n){
  cin>>vecx.at(i);
}
rep(i,n){
  cin>>vecy.at(i);
}
int md=0;
rep(i,n){
  md+=abs(vecx.at(i)-vecy.at(i));
}
cout<<fixed<<setprecision(10);
cout<<md<<endl;
double yd=0;
rep(i,n){
  yd+=pow((vecx.at(i)-vecy.at(i)),2);
}
cout<<sqrt(yd)<<endl;
double yyd = 0;
rep(i,n){
  yyd+=pow(abs((vecx.at(i)-vecy.at(i))),3);
}
//1/3乗をニュートン法で実装
if(yyd==0){
  cout<<yyd<<endl;
}else{
yyd = cbrt_newton(yyd,sqrt(yd));
cout<<yyd<<endl;}
int cd=0;
rep(i,n){
 if(cd<(abs(vecx.at(i)-vecy.at(i)))){
   cd=abs(vecx.at(i)-vecy.at(i));
 }
}
cout<<cd<<endl;
}


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

int main()
{
  string s;
  cin >> s;
  int ans = 700;
  int flag = 0;

  rep(i, 3)
  {
    if (s.at(i) == 'o')
      flag++;
  }
  cout << ans + flag * 100;
}


Measured memory_bytes: 3624
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	cout << (M - 1 + N - 2) / (N -1)<< endl;
}

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

#include <iostream>
#include <vector>
// #include <map>
#include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if (97 <= s[i] and s[i] <= 122) {
			cout << char(s[i] - 32);
			continue;
		}
		if (65 <= s[i] and s[i] <= 90) {
			cout << char(s[i] + 32);
			continue;
		}
			cout << s[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3160
#150E
from functools import lru_cache
import sys
sys.setrecursionlimit(200000)

H,N = map(int, input().split()) #H<=10**4,N<=10**3

AB_dict = dict() #A:Atack power, B:Consumption MP

for i in range(N): #N<=10**3
    A,B = map(int, input().split())
    if A not in AB_dict:
        AB_dict[A] = B
    else:
        if B < AB_dict[A]: #同じ攻撃力なら消費MPが少ない方を優先する
            AB_dict[A] = B

@lru_cache(maxsize=None)
def get_consumption_MP(HP): #HPを削るのに必要なMPを求める関数
    ans = 10**9 + 7
    
    for AB in AB_dict.items():
        A = AB[0]
        B = AB[1]
        
        if A >= HP:
            if B < ans:
                ans = B
        else:
            if B + get_consumption_MP(HP-A) < ans:
                ans = B + get_consumption_MP(HP-A)
                
    return ans
        
print(get_consumption_MP(H))

Measured memory_bytes: 70620
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	long Q;
	long r,l;
	public void solve() {
		Q = nextLong();
		r = 0;
		l = 0;
		for(int i = 0;i < Q;i++){
			long p = nextLong();
			String c = next();
			long n = nextLong();
			
			if(c.equals("(")){
				r += n;
			}else{
				l += n;
			}
			
			if(r == l){
				out.println("Yes");
			}else{
				out.println("No");
			}
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 33432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s;
int cnt[30];

signed main() {
	cin >> s;
	for (int i = 0; i < (int)s.size(); i++)cnt[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)if (!cnt[i]) {
		cout << s + char(i + 'a') << endl;
		return 0;
	}
	for (int i = (int)s.size() - 1; i > 0; i--) {
		if (s[i - 1] < s[i]) {
			char mi = 'z';
			for (int j = i; j < 26; j++)if (s[i - 1] < s[j])mi = min(mi, s[j]);
			for (int j = 0; j < i - 1; j++)cout << s[j];
			cout << mi << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int MX_N = 2005;
const int MX_M = 2005;
const int MX_Q = 2e5+5;

int N, M, Q, G[MX_N][MX_M];

struct node {
    int s, e, m; vector<int> v;
    node *l, *r;
    node(int s, int e): s(s), e(e), m((s+e)/2) {
        if (s != e) l = new node(s,m), r = new node(m+1,e);
    }
    void add(int x, int z) {
        if (s == e) v.push_back(z);
        else if (x <= m) l->add(x,z);
        else r->add(x,z);
    }
    vector<int>& build() {
        if (s != e) {
            auto a = l->build(), b = r->build();
            for (int i = 0, j = 0; i < SZ(a) || j < SZ(b); ) {
                if (i < SZ(a) && (j == SZ(b) || a[i] < b[j])) v.push_back(a[i++]);
                else v.push_back(b[j++]);
            }
        }
        return v;
    }
    int query(int x, int y, int a, int b) {
        if (x > y || a > b) return 0;
        if (s == x && e == y) return lower_bound(ALL(v),b+1)-lower_bound(ALL(v),a);
        if (y <= m) return l->query(x,y,a,b);
        if (x > m) return r->query(x,y,a,b);
        return l->query(x,m,a,b) + r->query(m+1,y,a,b);
    }
} *grid, *vert, *horz;

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

    cin >> N >> M >> Q;
    vert = new node(1,N);
    horz = new node(1,N);
    FOR(i,1,N){
        string S; cin >> S;
        S = '^' + S;
        FOR(j,1,M){
            G[i][j] = S[j]-'0';
            if (G[i][j]) {
                if (i > 0 && G[i-1][j]) vert->add(i,j);
                if (j > 0 && G[i][j-1]) horz->add(i,j);
            }
        }
    }
    vert->build();
    horz->build();
    FOR(i,1,N) FOR(j,1,M) G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1];

    FOR(i,0,Q-1){
        int X1, Y1, X2, Y2;
        cin >> X1 >> Y1 >> X2 >> Y2;
        
        int v = G[X2][Y2] - G[X1-1][Y2] - G[X2][Y1-1] + G[X1-1][Y1-1];
        int e = vert->query(X1+1,X2,Y1,Y2) + horz->query(X1,X2,Y1+1,Y2);

        cout << v-e << '\n';
    }
}



Measured memory_bytes: 197496
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    double s,m;
    char a[8],c[8][8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"},h[17]="0123456789abcdef";
    int d[8][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}},
        w[6],i,j,e,r,g,b;
    while(cin >> a) {
		if (a[0]=='0') break;
		for (i=0;i<6;i++)  for (j=0;j<16;j++) if (a[i+1]==h[j]) w[i]=j;
		s=99999999; r=w[0]*16+w[1]; g=w[2]*16+w[3]; b=w[4]*16+w[5]; 
		for (i=0;i<8;i++) {
		 m=sqrt((r-d[i][0])*(r-d[i][0])+(g-d[i][1])*(g-d[i][1])+(b-d[i][2])*(b-d[i][2]));
		 if (m<s) { s=m; e=i;};
	 }
	 cout << c[e] << endl;
 }	
 return 0;
}

Measured memory_bytes: 1136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n - 1];

		String[] tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(tmpArray[i]);
		}

		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			b[i] = Integer.parseInt(tmpArray[i]);
		}

		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n - 1; i++){
			c[i] = Integer.parseInt(tmpArray[i]);
		}
		int result = 0;

		for(int i = 0; i < n; i++){
			result += b[a[i] - 1];

			if(i >= 1 && a[i] == a[i - 1] + 1){
				result += c[a[i - 1] - 1];
			}
//			System.out.println(result);
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 23124