akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	ll H, W;
	cin >> H >> W;

	ll ans = 1LL << 60;
	for(int loop = 0; loop < 2; loop++){
		for(int i = 1; i < H; i++){
			ll h = H - i;
			ll h1 = h / 2, h2 = h - h1;
			ll s1 = i * W, s2 = h1 * W, s3 = h2 * W;
			//cerr << "s1 : " << s1 << ", s2 : " << s2 << ", s3 : " << s3 << endl;
			ans = min(ans, max({ s1, s2, s3 }) - min({ s1, s2, s3 }));
			ll w1 = W / 2, w2 = W - w1;
			s1 = i * W, s2 = h * w1, s3 = h * w2;
			ans = min(ans, max({ s1, s2, s3 }) - min({ s1, s2, s3 }));
			//cerr << "s1 : " << s1 << ", s2 : " << s2 << ", s3 : " << s3 << endl;
		}
		swap(H, W);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int partition(int*, int, int);

int main(){
  int n, i, k;
  scanf("%d", &n);
  int A[n];
  for(i = 0 ; i < n ; i++) scanf("%d", &A[i]);
  k = partition(A, 0, n-1);
  for(i = 0 ; i < n ; i++){
    if(i == n-1)printf("%d\n", A[i]);
    else if(i == k)printf("[%d] ", A[i]);
    else printf("%d ", A[i]);
  }
}

int partition(int* A, int p, int r){
  int x = A[r], temp;
  int j, i = p - 1;
  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] =A[r];
  A[r] = temp;
  return i+1;
}



Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> >g;
vector<int> V;

void dfs(int a) {
	V[a] = 1;
	for (int i : g[a]) {
		if(V[i] == 0){
			dfs(i);
		}
	}


}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	g.resize(N);
	V.resize(N, 0);
	vector<int> C(N, 0);
	int res = 0;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b; a--; b--;
		C[a]++; C[b]++;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < N; i++) {
		if (C[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 0; i < N; i++) {
		if (C[i] >= 6) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	int t = 0;
	for (int i = 0; i < N; i++) {
		if (C[i] >= 4) {
			t++;
			if (t == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	if (t == 2) {


		for (int i = 0; i < N; i++) {
			if (C[i] >= 4) {
				for (int j = 0; j < N; j++) {
					V[j] = 0;
				}

				V[i] = 1;

				dfs(g[i][0]);
				for (int j = 0; j < 4; j++) {
					if (V[g[i][j]] == 0) {
						cout << "Yes" << endl;
						return 0;
					}
				}

			}
		}


	}




	cout << "No" << endl;
}

Measured memory_bytes: 8832
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int num,i,line[1000];
    double sum,sum1;
    for(;sum=0.0,sum1=0.0,scanf("%d",&num),num;){
        for(i=0;i<num;sum+=line[i],i++)
            scanf("%d",&line[i]);
        sum/=num;
        for(i=0;i<num;i++)
            sum1+=pow((line[i]-sum),2);
        sum1/=num;
        printf("%f\n",sqrt(sum1));
    }
    return 0;
}


Measured memory_bytes: 2052
import Data.List                                                                                                                                                            

checker :: Int -> Int -> Int -> Bool
checker a b c 
  | a <= b && ((elemIndex c [a..b]) /= Nothing) = True
  | otherwise = False

main = do
  [a, b, c] <- map read . words <$> getLine
  if checker a b c 
    then putStrLn "Yes"
    else putStrLn "No"

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		int start = 0;
		int end = 0;
		for (int i = 0; i < m; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
			if (i == 0) {
				start = l[i];
				end = r[i];
			} else {
				if (l[i] > start) {
					start = l[i];
				}
				if (r[i] < end) {
					end = r[i];
				}
			}
		}
		if (start > end) {
			System.out.println(0);
		} else {
			System.out.println(end - start + 1);
		}
	}
}


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

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> substr;
    int j=1;
    while (1) {
        if (j > fmin(5, s.size())) break;
        for (int i=0; i<s.size()+1-j; i++){
            substr.insert(s.substr(i, j));
        }
        j += 1;
    }
    vector<string> ans(substr.begin(), substr.end());
    cout << ans[k-1] << endl;
    return 0;
}

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

vector<pair<pair <string,int>,int>> p;
int main() {
  int N;
  cin >> N;

  for (int i =0;i<N;i++){
    string a;
    int b;
    cin>>a>>b;
    p.push_back(make_pair(make_pair(a,-b),i+1));
  }
  
  sort(p.begin(),p.end());
  
  for(int i=0;i<N;i++){
    string a;
    int b;
    cout<<p.at(i).second<<endl;
  }
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

int dp[100005];

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int& x:a){
		cin>>x;
	}
	
	dp[0] = 0;
	for(int i = 1; i <= k; i++){
		dp[i] = 0;
		for(int x:a){
			if(i >= x && dp[i-x] == 0){
				dp[i] = 1;
				break;
			}
		}
	}
	
	if(dp[k] == 1)
		cout<<"First";
	else
		cout<<"Second";
	
}

Measured memory_bytes: 4000
#include <iostream>
using namespace std;
int N, M, X, cnt;
int main() {
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int pos;
		cin >> pos;
		if (pos < X) cnt++;
	}
	cout << (cnt < M - cnt ? cnt : M - cnt) << "\n";
	return 0;
}

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, k, q, A[MAX];

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

	cin>>n>>k>>q;
	for(int i=1,x; i<=q; i++) cin>>x, A[x]++;
	for(int i=1; i<=n; i++){
		A[i] += k-q;
		cout<<(A[i]<=0 ? "No" : "Yes")<<'\n';
	}

	return 0;
}


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

namespace ABC168A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            N = N % 10;

            string ans = "hon";
            if (N == 0 || N == 1 || N == 6 || N == 8) ans = "pon";
            else if (N == 3) ans = "bon";

            Console.WriteLine(ans);

            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

int main() {
	int xx1 = 0, xx2 = 0, yy1 = 0, yy2 = 0;
	int W, H, N;
	int x, y, a;

	cin >> W >> H >> N;
	xx2 = W;
	yy2 = H;
	for (int i = 0; i < N; ++i) {
		cin >> x >> y >> a;
		if (a == 1) {
			xx1 = max(xx1,x);
		} else if (a == 2) {
			xx2 = min(xx2,x);
		} else if (a == 3) {
			yy1 = max(yy1,y);
		} else if (a == 4) {
			yy2 = min(yy2,y);
		}
	}
	int dx=max(0,xx2-xx1);
	int dy=max(0,yy2-yy1);

	cout << dx*dy<< endl;
}


Measured memory_bytes: 256
N=input()
cnt=int(input())
L=len(N)
dp=[[[0]*(cnt+1) for j in range(2)] for i in range(L+1)]
dp[0][0][0]=1
for i in range(L):
    for j in range(2):
        for k in range(cnt+1):
            D=int(N[i])
            for d in range(10 if j else D+1):
                K=k+int(d!=0)
                if K>cnt:
                    continue
                dp[i+1][int(j or d<D)][K]+=dp[i][j][k]
print(dp[-1][0][-1]+dp[-1][1][-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    map<string,ll> st;
    for(int i=0;i<n;i++){
	sort(s[i].begin(),s[i].end());
	st[s[i]]++;
    }
    ll res = 0;
    for(auto it:st){
	ll v = it.second;
	res += v*(v-1)/2;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 18176
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int main() {
    abdelrahman010
    int x , y , z;
    cin >> x >> y >> z;
    swap(x , y);
    swap(x , z);
    cout << x << " " << y << " " << z;
    return 0;
}


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

int main(void){
	int N;
	string S;
	cin >> N;
	cin >> S;

	int ret = 0;
	int cn = 0;
	for (int i = 0; i < S.length(); i++){
		if (S[i] == 'I'){ cn++; }
		else { cn--; }
		ret = max(ret, cn);
	}

	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>

using namespace std;

int main(){
	int n;
	int a;
	int count = 0;
	int ans = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		while (1){
			if (a % 2 == 0)count++;
			else break;
			a = a / 2;
		}
		ans += count;
		count = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, cnt;

bool chk(int p) {
	bool v[9]={};
	for(; p; p/=10) v[p%10] = 1;
	return v[3] & v[5] & v[7];
}

void f(int p, int q) {
	if(p<=n && chk(p)) cnt++;
	if(q>0) {
		f(p*10+3, q-1);
		f(p*10+5, q-1);
		f(p*10+7, q-1);
	}
}

int main() {
	int i, k;
	cin>>n;
	for(i=n, k=0; i; i/=10, k++);
	f(0, k);
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long [201000];
        for(int i =0; i < N; i++) A[i] = sc.nextLong();
        long humidai = 0;
        for(int i = 0; i < N - 1; i++){
          if(A[i] > A[i + 1]){
            humidai += (A[i] - A[i +1]);
            A[i+1] = A[i];
          }
        }
      System.out.println(humidai);
    } 
}

Measured memory_bytes: 51532
#include <stdio.h>

#define N 100000
 
int arr[N];
 void sw(int *x, int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
void part(int P, int R){
  int x = arr[R];
  int i = P - 1, j;
  for(j = P;j < R;j++){
    if(arr[j] <= x){
      i++;
      sw(&arr[i], &arr[j]);
    }
  }
  sw(&arr[i+1], &arr[R]);
  for(j = P;j <= R;j++){
    if(j != P) printf(" ");
    if(j == i+1) printf("[%d]", arr[j]);
    else printf("%d", arr[j]);
  }
  printf("\n");
}
 
int  main(int argc,char *argv[]){
  int n, i;
  scanf("%d", &n);
  for(i = 0;i < n;i++) scanf("%d", &arr[i]);
  part(0, n-1);

  return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//











int main(){
        int n;
        cin >> n;
        Int ret = 1;
        for(int i = 2; i <= n; i++){
                bool flg = true;
                for(int j = 2; j * j <= i; j++){
                        if(i%j == 0) flg = false;
                }
                if(flg){
                        int ord = 0;
                        int v = n;
                        while(v){
                                ord += v/i;
                                v /= i;
                        }
                        ret = ret * (ord+1) % mod;
                }
        }

        cout << ret << endl;
        return 0;
}

























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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	char c;
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
	    ANS("vowel");
	}else{
	    ANS("consonant");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<bitset<10>> F(N);
  for(bitset<10> &i:F)
    for(int j=0;j<10;j++){
      int k;
      cin>>k;
      i[j]=k;
    }
  vector<vector<int>> P(N,vector<int>(11));
  for(vector<int> &i:P)
    for(int &j:i)
      cin>>j;
  int k=-1000000000;
  for(int tmp=1;tmp<(1<<10);tmp++){
    bitset<10> S(tmp);
    int j=0;
    for(int i=0;i<N;i++)
      j+=P[i][(S&F[i]).count()];
    k=max(k,j);
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=998244353;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct Edge{
    int ver;
    int wei;
    Edge(int v,int w) : ver(v),wei(w) {}
};

using WGraph = vector<vector<Edge>>;

int main(){
    int n;
    cin >> n;
    WGraph G(n);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    int Q,k;
    cin >> Q >> k;
    k--;
    queue<int> q;
    vl dis(n,-1);
    dis[k] = 0;
    q.push(k);
    while(q.size()){
        int v = q.front();
        q.pop();

        for(auto to : G[v]){
            if(dis[to.ver]!=-1) continue;
            dis[to.ver] = dis[v] + to.wei;
            q.push(to.ver);
        }
    }


    while(Q--){
        int x,y;
        cin >> x >> y;x--;y--;
        cout << dis[x] + dis[y] << endl;
    }
}

Measured memory_bytes: 8820
info = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0), ".": (-1, -1)}

while True:
    H, W = map(int, input().split())
    if H == 0:
        break
    tiles = [input() for _ in range(H)]
    i = j = 0
    for _ in range(H*W):
        a, b = info[tiles[i][j]]
        if a == b == -1:
            print(j, i)
            break
        i += a
        j += b
    else:
        print("LOOP")



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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    if (x == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == n-1) {
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    int h, w; cin >> h >> w;
    vector<int> alp(26,0);
    rep(i,h*w){
        char c; cin >> c;
        if (c == 'a') alp[0]++;
        else if (c == 'b') alp[1]++;
        else if (c == 'c') alp[2]++;
        else if (c == 'd') alp[3]++;
        else if (c == 'e') alp[4]++;
        else if (c == 'f') alp[5]++;
        else if (c == 'g') alp[6]++;
        else if (c == 'h') alp[7]++;
        else if (c == 'i') alp[8]++;
        else if (c == 'j') alp[9]++;
        else if (c == 'k') alp[10]++;
        else if (c == 'l') alp[11]++;
        else if (c == 'm') alp[12]++;
        else if (c == 'n') alp[13]++;
        else if (c == 'o') alp[14]++;
        else if (c == 'p') alp[15]++;
        else if (c == 'q') alp[16]++;
        else if (c == 'r') alp[17]++;
        else if (c == 's') alp[18]++;
        else if (c == 't') alp[19]++;
        else if (c == 'u') alp[20]++;
        else if (c == 'v') alp[21]++;
        else if (c == 'w') alp[22]++;
        else if (c == 'x') alp[23]++;
        else if (c == 'y') alp[24]++;
        else if (c == 'z') alp[25]++;
    }
    sort(alp.begin(), alp.end());
    bool t = true;
    if (t){
        int hh = h / 2;
        int ww = w / 2;
        int sm = 0;
        int c;
        rep(i,26){
            if (alp[i] >= 4){
                c = alp[i] / 4;
                sm += c;
                alp[i] -= c * 4;
            }
            if (sm >= hh * ww){
                alp[i] += (sm - hh * ww) * 4;
                break;
            }
        }
        if (sm < hh * ww) cout << "No" << endl;
        else{
            int hhh = w % 2 * h / 2;
            int www = h % 2 * w / 2;
            sm = 0;
            rep(i,26){
                if (alp[i] >= 2){
                    c = alp[i] / 2;
                    sm += c;
                    alp[i] -= c * 2;
                }
                if (sm >= hhh + www){
                    alp[i] += (sm - hhh - www) * 2;
                    break;
                }
            }
            if (sm < hhh + www) cout << "No" << endl;
            else cout << "Yes" << endl;
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()

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

	long N;
	cin >> N;

	unordered_map<string, long> s;

	bool f = false;
	string tmp;
	for(long i = 0; i < N; i++) {
		cin >> tmp;
		sort(all(tmp));
		if (s.count(tmp) == 0) {
			s[tmp] = 1;
		} else {
			f = true;
			s[tmp]++;
		}
	}

	if (!f) {
		cout << 0 << endl;
		return 0;
	}

	long cnt = 0;
	for(auto& a : s) {
		if (a.second != 1) {
			if (a.second % 2 == 1)
				cnt += ((a.second-1) / 2) * a.second;
			else
				cnt += a.second / 2 * (a.second + 1) - a.second;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 10660
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> 

using namespace std;

long long a[100100];

int main()
{
	long long n,sum = 0;
	scanf("%lld",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	long long t = n * (n + 1) / 2;
	if(sum % t)printf("NO\n");
	else{
		sum = sum / t;
		for(int i = 2;i <= n;i++)
			if(sum + a[i - 1] - a[i] < 0 || (sum + a[i - 1] - a[i]) % n)
			{
				printf("NO\n");
				return 0;
			}
		if(sum + a[n] - a[1] < 0 || (sum + a[n] - a[1]) % n)
		{
			printf("NO\n");
			return 0;
		}
		printf("YES\n");
	}
}

Measured memory_bytes: 896
use std::io::*;
use std::str::*;

fn solve(s: String) -> u32 {
    let mut prev = ' ';
    let mut result = 0;
    for c in s.chars() {
        if c != prev {
            result += 1;
        }
        prev = c;
    }

    result - 1
}

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;
    let s: String = read(s).unwrap();

    println!("{}", solve(s));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=998244353,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;


int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      A[k]%=MAX;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2])%MAX;
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return MAXL;if(a<=l&&r<=b)return (Mi[k]+A[k])%MAX;
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return (min(left,right)+A[k])%MAX;
  }
};

StarrySkyTree t;

void Main() {
  ll n,m;
  cin >> n >> m;
  t.init();
  P a[m];
  rep(i,m) cin >> a[i].F >> a[i].S;
  t.add(0,1,1);
  rep(i,n) {
    rep(j,m) {
      ll x=t.getMin(i,i+1);
      t.add(min(n,i+a[j].F),min(n,i+a[j].S)+1,x);
    }
  }
  pr(t.getMin(n-1,n));

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 12372
K = []
n = int(input())
num = 2*n
card = [i for i in range(1,num+1)]
m = int(input())
for i in range(m):
    K.append(int(input()))

for k in K:
    new_card = []
    if k == 0:
        A = card[:n]
        B = card[n:num]
        for i in range(n):
            new_card.append(A[i])
            new_card.append(B[i])
    else:
        A = card[:k]
        B = card[k:num+1]
        new_card = B+A
    card = new_card
for i in card:
    print(i)

Measured memory_bytes: 7796
def main():
    N = int(input())
    S = input()
    mod = pow(10, 9) + 7
    d = dict()
    for c in S:
        d[c] = d.get(c, 0) + 1
    ans = 1
    for c in d:
        ans *= (d[c]+1)
        ans %= mod
    return (ans - 1) % mod


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 39408
//it's wa time
//what are numbers
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<pl,ll> tl;
vvi g;
vi so;
ll dod(int u, int p, int d) {
	ll res = 0;
	if(so[u]) {res += d;}
	for(int i=0;i<g[u].size();i++) {
		int v = g[u][i];
		if(v == p) {continue;}
		res += dod(v,u,d+1);
	}
	return res;
}
ll sob(vector<tl>& w) {
	if(w.size() == 0) {return 0;}
	sort(w.begin(),w.end());
	ll ma = w.back().first.first;
	ll su = 0;
	for(int i=0;i<w.size()-1;i++) {
		ll par = w[i].first.first&1;
		ll mr = min((w[i].first.second-par)/2,(ma-par)/2);
		ll mv = mr*2+par;
		su += mv;
	}
	if(ma > su) {return ma-su;}
	return (su+ma)&1;
}
tl rod(int u, int p) {
	tl res = {{0,0},0};
	if(so[u]) {
		res.second++;
	}
	vector<tl> go;
	for(int i=0;i<g[u].size();i++) {
		int v = g[u][i];
		if(v == p) {continue;}
		tl ro = rod(v,u);
		ro.first.first += ro.second;
		ro.first.second += ro.second;

		res.second += ro.second;
		res.first.second += ro.first.second;
		go.push_back(ro);
	}
	res.first.first = sob(go);
	return res;
}
ll proc(int u) {
	ll su = 0;
	for(int i=0;i<g[u].size();i++) {
		ll val = dod(g[u][i],u,1);
		su += val;
	}
	vector<tl> go;
	for(int i=0;i<g[u].size();i++) {
		int v = g[u][i];
		tl ro = rod(v,u);
		ro.first.first += ro.second;
		ro.first.second += ro.second;
		go.push_back(ro);
	}
	if(sob(go) != 0) {
		return -1;
	}
	return su/2;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i=0;i<n;i++) {
		so.push_back(s[i]-'0');
	}
	g.assign(n,vi());
	for(int i=1;i<n;i++) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bool pop = false;
	ll ma = 1e18;
	for(int i=0;i<n;i++) {
		ll val = proc(i);
		if(val != -1) {
			ma = min(ma,val);
			pop = true;
		}
	}
	if(pop) {
		cout << ma << '\n';
	} else {
		cout << -1 << '\n';
	}
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, l;

int main(){
	cin >> n >> m >> l;
	if(l!=m){
		if(n==m){
			cout << l << endl;
		}
		if(n==l){
			cout << m << endl;
		}
	}else{
		
	cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));
$A = array_values(array_unique($A));
$cnt = count($A);
$ans = $A[0];
for ($i = 1; $i < $cnt; $i++) {
    $ans = gcd($ans, $A[$i]);
    if ($ans === 1) break;
}
echo $ans;


Measured memory_bytes: 21040
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s: chars,
    }
    if s[0] != 'A' {
        println!("WA");
        return;
    }
    if s.iter()
        .skip(2)
        .rev()
        .skip(1)
        .filter(|c| **c == 'C')
        .count()
        != 1
    {
        println!("WA");
        return;
    }
    if s.iter()
        .filter(|c| match **c {
            'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N'
            | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' => true,
            _ => false,
        })
        .count()
        != 2
    {
        println!("WA");
        return;
    }
    println!("AC");
}


Measured memory_bytes: 4352
N = int(input())
happy = [[int(n) for n in input().split()] for _ in range(N)]
dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if not j == k:
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + happy[i][k])

print(max(dp[N]))


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

    long long ans1 = 0;
    long long ans2 = 0;
    long long sum1 = 0; // 偶>0, 奇<0
    long long sum2 = 0; // 偶<0, 奇>0

    for (int i=0; i<n; i++) {
        sum1 += a[i];
        sum2 += a[i];
        if (i%2 == 0) {
            if (sum1 > 0) {
            } else {
                ans1 += abs(sum1) + 1;
                sum1 = 1;
            }
            if (sum2 < 0) {
            } else {
                ans2 += abs(sum2) + 1;
                sum2 = -1;
            }
        } else {
            if (sum1 < 0) {
            } else {
                ans1 += abs(sum1) + 1;
                sum1 = -1;
            }
            if (sum2 > 0) {
            } else {
                ans2 += abs(sum2) + 1;
                sum2 = 1;
            }
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
C=[]
S=[]
F=[]
for i in range(n-1):
	c,s,f=map(int, input().split())
	C.append(c)
	S.append(s)
	F.append(f)

def d(x,t): #駅x時間ｔで移動するのにかかる時間
	if S[x]>=t:
		return C[x]+S[x]-t
	else:
		if (t-S[x])%F[x]==0:
			return C[x]
		else:
			return C[x]+F[x]-(t-S[x])%F[x]

for i in range(n-1):
	x=i
	ans=0
	for j in range(x,n-1):
		ans+=d(j,ans)
		x=+1
	print(ans)
print(0)


Measured memory_bytes: 9192
x=[int(input()) for _ in range(5)]
res=0
mx,mi=10,-1
for i in range(5):
    if 0<x[i]%10<mx:
        mx=x[i]%10
        mi=i
#print(mx,mi)
if mx==10:
    print(sum(x))
else:
    res=0
    for i in range(5):
        if i!=mi:
            res+=(-(-x[i]//10)*10)
    res+=x[mi]
    print(res)

Measured memory_bytes: 38384
#!/usr/bin/env python3
n, m = map(int, input().split())
ac = 0
wa = 0
tmp = {}
d = set()
for _ in range(m):
    p, s = map(str, input().split())
    if p not in tmp:
        tmp[p] = 0
    if p not in d and s == "AC":
        d.add(p)
        ac += 1
        if p in tmp:
            wa += tmp[p]
    if p not in d and s == "WA":
        tmp[p] += 1
print(ac, wa)


Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, d,ans;
    cin >>n >> d;
    ans =n/(2*d+1);
    if(n%(2*d+1) == 0){
        cout << ans;
    }
    else{
        cout<< ans + 1;
    }
}


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

using namespace std;

int main(){
	int a,b;
	char s;
	
	cin>>a>>s>>b;
	
	if(s=='+'){
		cout<<a+b<<endl;
		}
	else{
		cout<<a-b<<endl;
		}
	}

Measured memory_bytes: 256
import java.util.*;

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

        int th = sum / (4 * m);
        if (sum % (4 * m) != 0) th++;
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= th) count++;
        }

        if (count >= m ){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

double distance(P<double,double> a,P<double,double> b) {
	return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second,2));
}
int main()
{
	int a, b;
	std::cin >> a >> b;
	int k;
	float kd;
	k = (a + b) % 2 == 0 ? (a + b) / 2 : -1;
	if (k ==-1) {
		cout << "IMPOSSIBLE";
	}
	else {
		cout << k;
	}
    return 0;
}

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

#define int long long

#define REP(i, a) for(int i = 0; i < (a); i++)

using namespace std;

signed main()
{
    cout << fixed << setprecision(10);

    int n; cin >> n;
    vector<int> a(n); REP(i, n) cin >> a[i];
    int sum = 0; REP(i, n) sum += a[i];
    cout << *min_element(a.begin(), a.end()) << " " << *max_element(a.begin(), a.end()) << " " << sum << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	map<int, int> mp;
	for(int i = 1; i <= n; i++){
		int x; cin>>x; mp[x]++;
		if(mp[x] == 3)mp[x] -= 2;
	}
	int ans = mp.size();
	int cnt = 0;
	for(auto x : mp){
		if(x.second == 2)cnt++;
	}
	ans -= (cnt&1);
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 4992
N, M = map(int, input().split())
ans = {i:0 for i in range(N+1)}
pn = {i:0 for i in range(N+1)}
ans_num = 0
pn_num = 0

for i in range(M):
    p_tmp, S_tmp = input().split()
    p_tmp = int(p_tmp)
    
    if ans[p_tmp] == 0 and S_tmp == "AC":
        ans[p_tmp] = 1
        ans_num += 1
        pn_num += pn[p_tmp]
        
    elif ans[p_tmp] != 1 and S_tmp == "WA":
        pn[p_tmp] = pn[p_tmp] + 1
        
print(ans_num, pn_num)

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

int main ()
{
	int a[100000], n, i, count = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
		cin >> a[i];
	for (i = 1; i <= n; i++)
	{
		
		if (a[i] == i)
		{
			count++;
			if (i == n)
				swap(a[i], a[i-1]);
			else
				swap(a[i], a[i+1]);
		}
	}
	cout << count;
}

Measured memory_bytes: 640
#include <stdio.h>
#define DEBUG
int main(void){
	int n;
	scanf("%d", &n);
	long a[n];
	for(int i = 0; i < n; i++){
		scanf("%ld", &a[i]);
	}
	long sum = 0;
	for(int i = 0; i < n; i++){
		sum += a[i];
	}
	long min = sum - 2 * a[0];
	long snuke =	a[0], arai = sum - a[0];
	if(min < 0){
		min = -min;
	}
	for(int i = 1; i <= n-2; i++){//a[i]から上をすぬけが取る
		long div;
		snuke += a[i];
		arai -= a[i];
		div = snuke - arai;
		if(div < 0){
			div = -div;
		}
		if(div < min){
			min = div;
		}
	}
	printf("%ld\n", min);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define N 110
#define INF_MAX 0x3f3f3f3f
int p[N];
int m[N][N];
int n;
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d %d", &p[i], &p[i+1]);
    for(int i = 0; i < n; i++) m[i][i] = 0;
    for(int len = 2; len <= n; len++){
        for(int i = 1; i <= n-len+1; i++){
            int j = i+len-1;
            m[i][j] = INF_MAX;
            for(int k = i; k < j; k++){
                int temp = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                m[i][j] = m[i][j] < temp ? m[i][j] :temp;
            }
        }
    }
    printf("%d\n", m[1][n]);
    return 0;
}


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

using namespace std;

int main(){
	int n, m, place[100], i, j, *ans, *jun, judge = 1001, cut2;

	while(1) {
		cin >> n >> m;
		int cut[100] = {0};

		if(n == 0 && m == 0) break;

		ans = new int[m];
		jun = new int[m];
		cut2 = m;
		for(i = 0; i < n; i ++){
			for(j = 0; j < m; j ++){
				cin >> place[j];
				if(place[j] == 1) cut[j] ++;
			}
		}
	
		for(i = 0; i < m; i ++){
			ans[i] = cut[i];
		}

		sort(cut, cut + m);

		for(i = m; i >= 0; i --){
			for(j = 0; j < m; j ++){
				if(cut[i] == ans[j]){
					if(i == 0){
						cout << j + 1 << endl;
						break;
					}
					else{
						cout << j + 1 << " "; 
						ans[j] = 0;
						break;
					}
				}
			}
		}
	}			

	return 0;
}

Measured memory_bytes: 2932
#include<stdio.h>
#include <stdlib.h>
int main(void) {
	int n;
	float v[51];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%f", &v[i]);
	}
	int total = n;
	for (int i = 0; i < total; ++i) {
		for (int j = i + 1; j < total; ++j) {
			if (v[i] > v[j]) {
				float tmp = v[i];
				v[i] = v[j];
				v[j] = tmp;
			}
		}
	}
	/*for (int i = 0; i < n; i++) {
		printf("%f ", v[i]);
	}:*/
	for (int i = 1; i < n; i++) {
		v[i] = (v[i] + v[i - 1]) / 2;
		//printf("%f",v[i]);
	}
	printf("%f", v[n - 1]);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>a>>b;
    if(b==1)
    {
        cout<<0<<endl;
    }
    else if(b<=a)
    {
        cout<<1<<endl;
    }
    else
    {
        b -= a;
        a--;
        cout<<ceil((double)b/a)+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
 long long  int n,k,t;
  cin>>n>>k>>t;
  if(n%k==0)
  {
    cout<<(n/k)*t<<endl;
  }
  else{
    cout<<((n/k)+1)*t<<endl;
  }
}



Measured memory_bytes: 3596
input_N = gets.chomp.to_i
input_K = gets.chomp.to_i
input_x = gets.chomp.split.map!(&:to_i)
sum = 0

(1..input_N).each{ |i|
  sum += [input_x[i-1]*2,((input_K-input_x[i-1])*2).abs].min
  }
puts sum

Measured memory_bytes: 1788
#include <stdio.h>
#define N 100

int main(){
    int M[N][N]={0};
    int n,k,u,v,i,j;
    scanf("%d",&n);
   
   
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    
    
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            printf("%d%s",M[i][j],j==n-1?"":" ");
        }
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2112
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int a;
    string s;

    scan(a);
    scan(s);

    writeln(a >= 3200 ? s : "red");
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - ABD
https://abc099.contest.atcoder.jp/tasks/abc099_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    n = int(input())
    if n < 1000:
        print('ABC')
    else:
        print('ABD')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
int longest_palindrome_prefix(const string &s)
{
    string kmprev = s;
        std::reverse(kmprev.begin(), kmprev.end());
        string kmp = s + "#" + kmprev;

        vector<int> lps(kmp.size(), 0);   // lps[i] = longest suffix length for substring kmp[0..i] where the suffix == prefix
        for (int i = 1; i < (int)lps.size(); ++i)
        {
            int prev_idx = lps[i - 1];

            while (prev_idx > 0 && kmp[i] != kmp[prev_idx])
            {
                prev_idx = lps[prev_idx - 1];
            }

            lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
        }

        // after KMP's LPS preprocessing, the last index of the LPS array will contain the longest palindrome prefix' length!
        return lps[lps.size() - 1];

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll ans1,ans2;
    ans1=n*(n-1);
    ans1/=2;
    ans2=m*(m-1);
    ans2/=2;
    cout<<ans1+ans2;
}


Measured memory_bytes: 256