akhauriyash/Code-Regression huggingface dataset:
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 200000;
int N;
ll A[MAX_N+1];

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

  for (int i = 0; i < N; ++i) A[i] -= i+1;

  sort(A, A+N);

  ll lb = A[0], ub = A[N-1], mid;
  while (ub-lb>1) {
    mid = (lb+ub)/2;
    ll dif = 0;
    for (int i = 0; i < N; ++i) {
      dif += abs(A[i]-mid) - abs(A[i]-(mid-1));
    }
    if (dif > 0) ub = mid;
    else lb = mid;
  }

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += abs(A[i]-lb);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
A,B, C= list(map(int,input().split()))
K = int(input())

for i in range((K)):
    if(A>=B):
        B=B*2
    elif(B>=C):
        C=C*2
    else:
        break
        
    
if (C>B >A):
     print('Yes')
else:
     print('No')

Measured memory_bytes: 9044
// 8-11.cpp : 螳壻ケ画而蛻カ蜿ー蠎皮畑遞句コ冗噪蜈・蜿」轤ケ縲?//

#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
 using namespace std;
 struct island
 {
	 int v,t;
 };
 struct island a[1000];
 bool cmp(struct island a,struct island b)
 {
	 return a.t<b.t;
 }
int main()
{

	int n;
	while(cin>>n && n!=0)
	{
		for(int i=1;i<=n;i++)
			cin>>a[i].v>>a[i].t;
		sort(a+1,a+n+1,cmp);
		int f=1;
		long long sum=0;
		for(int i=1;i<=n;i++)
		{
			sum+=a[i].v;
			if(sum>a[i].t) f=0;
		}
		if(f==1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define maxn 100009
#define mk make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> P;
multiset<int>st[maxn];
map<P,int>mp;
map<P,int>::iterator it;
multiset<int>::iterator jt;
int fa[maxn],sz[maxn];
queue<P>q;
vector<int>vec[maxn];
int find(int x){if(fa[x]!=x) fa[x]=find(fa[x]);return fa[x];}
int main(){
  int n,x,y;
  scanf("%d",&n);
  for(int i=1;i<n;i++){
    scanf("%d%d",&x,&y);
    st[x].insert(y),st[y].insert(x);
    mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
  }
  for(int i=1;i<n;i++){
    scanf("%d%d",&x,&y);
    st[x].insert(y),st[y].insert(x);
    mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
  }
  for(it=mp.begin();it!=mp.end();it++)
    if(it->se==2) q.push(it->fi);
  for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1,vec[i].pb(i);
  for(int T=1;T<n;T++){
  tp:
    if(q.empty()) puts("NO"),exit(0);
    P u=q.front();q.pop();
    mp.erase(u);
    int x=find(u.fi),y=find(u.se);
    if(x==y) goto tp;
    if(sz[x]>sz[y]) swap(x,y);
    for(jt=st[x].begin();jt!=st[x].end();jt++){
      int k=find(*jt);if(k==y) continue;
      st[y].insert(k),st[k].insert(y),mp[mk(y,k)]+=1,mp[mk(k,y)]+=1;
      if(mp[mk(y,k)]==2) q.push(mk(y,k));
      if(mp[mk(k,y)]==2) q.push(mk(k,y));
    }
    fa[x]=y,sz[y]+=sz[x];
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 121984
#include<bits/stdc++.h>
using namespace std;
#define rg register 
#define ll long long
inline ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
int n,k;
ll a[200000];
ll s[200000];
ll ss[200000];
ll sum;
ll maxx;
int main()
{
	n=read();
	k=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		s[i]=s[i-1]+a[i];
		if(a[i]>0)//用来保存区间外面的正数 
		{
			ss[i]=ss[i-1]+a[i];
		}
		else
		{
			ss[i]=ss[i-1];
		}
	}
	for(rg int i=1;i<=n-k+1;++i)
	{
		sum=0;
		ll j=i+k-1;//右端点 
		if(s[j]-s[i-1]>=0)
		{
			sum+=s[j]-s[i-1];
		}
		sum+=(ss[n]-ss[j]);//统计区间外正数 
		sum+=(ss[i-1]-ss[0]);
		maxx=max(maxx,sum);	
	}
	cout<< maxx;
}

Measured memory_bytes: 3584
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)

N=int(input())
A=[int(i) for i in input().split()]
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])
Z=[gcd(X[i],Y[i]) for i in range(N)]
print(max(Z))

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

int main(){
    int m,f,l;
    int score;
    while(true){
        cin >> m >> f >> l;
        score=m+f;
        if(m==-1 && f==-1 && l==-1){
            break;
        }
        else if(m==-1 || f==-1){
            cout << "F" << endl;
        }
        else{
            if(score>=80){
                cout << "A" << endl;
            }
            else if(score>=65 && score<80){
                cout << "B" << endl;
            }
            else if(score>=50 && score<65){
                cout << "C" << endl;
            }
            else if(score>=30 && score<50){
                if(l>=50){
                    cout << "C" << endl;
                }
                else{
                    cout << "D" << endl;
                }
            }
            else if(score<30){
                cout << "F" << endl;
            }
        }
    }
}


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

int main(){
    int N;
    double ans = 0.0, A;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        ans += 1.0/A;
    }
    ans = 1.0 / ans;
    cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc054/tasks/abc054_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

bool match(int x, int y, vector<string> &a, vector<string> &b)
{
  int n = a.size();
  int m = b.size();
  FOR(i, x, x + m)
  {
    FOR(j, y, y + m)
    {
      if (a[i][j] != b[i - x][j - y])
        return false;
    }
  }
  return true;
}

string search(vector<string> &a, vector<string> &b)
{
  int n = a.size();
  int m = b.size();

  REP(i, n - m + 1)
  {
    REP(j, n - m + 1)
    {
      if (match(i, j, a, b))
        return "Yes";
    }
  }
  return "No";
}

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, m;
  string ai, bi, r;
  vector<string> a, b;

  cin >> n >> m;

  REP(i, n)
  {
    cin >> ai;
    a.push_back(ai);
  }

  REP(i, m)
  {
    cin >> bi;
    b.push_back(bi);
  }

  cout << search(a, b) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main(){
  int N,T;
  int A[100000];
  cin >> N >> T;
  Rep(i,N)cin >> A[i];
  int maxv = -1;
  int maxc = -1;
  for(int i = N - 1;i >= 0;i--){
    maxv = max(maxv,A[i]);
    maxc = max(maxc,maxv - A[i]);
  }
  maxv = -1;
  int cnt = 0;
  for(int i = N - 1;i >= 0;i--){
    maxv = max(maxv,A[i]);
    if(maxc == maxv - A[i])cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
//少し考えると、「ある数kで操作をした直後に、k以上の数で操作をしているとき、その2つの操作の順序を入れ替えることができる」とわかる
//また、当然「同じ数で続けて操作することはない」ので、これらを合わせて「選ぶ数の列は狭義単調減少」とわかる
//つまり、選ぶ数の集合として{1,...,50}の部分集合を決めれば良い
//コストが2ベキなので、上から順に考えると「ある数を使わなくてすむなら、それ未満の数はどれだけ使っても良い」
//よって、上から順に使わなくてもよいかどうかをチェックすれば良い
//1回の判定にO(N^3)、N個の数を判定するので全体でO(N^4)

#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define bit(n,m)(((n)>>(m))&1)

ll ans=(1LL<<51)-2;
int dfs(int a,int b){
	if(a<b)return 0;
	if(a==b)return 1;
	//使える数だけを使ってaからbにできるか
	rep(k,1,a+1)if(bit(ans,k)&&dfs(a%k,b))return 1;
	return 0;
}

int a[60],b[60];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,0,n)scanf("%d",b+i);
	
	rep(i,0,n)if(!dfs(a[i],b[i])){
		puts("-1");
		return 0;
	}
	
	for(int k=50;k>0;k--){
		int flag=0;
		ans&=~(1LL<<k);//kを消してみる
		rep(i,0,n)if(!dfs(a[i],b[i]))flag=1;
		if(flag)ans|=1LL<<k;//だめなら追加しなおす
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static final long MOD = 1000000007;
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int H = sc.nextInt();
			final int W = sc.nextInt();
			
			final boolean[][] can_enter = new boolean[H][W];
			
			for(int i = 0; i < H; i++) {
				final char[] chs = sc.next().toCharArray();
				
				for(int j = 0; j < W; j++) {
					can_enter[i][j] = chs[j] == '.'; 
				}
			}
			
			long[][] DP = new long[H][W];
			DP[0][0] = 1;
			
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					
					if(i != 0 && can_enter[i - 1][j]) { 
						DP[i][j] += DP[i - 1][j];
						DP[i][j] %= MOD;
					}
					if(j != 0 && can_enter[i][j - 1]) {
						DP[i][j] += DP[i][j - 1];
						DP[i][j] %= MOD;
					}
				}
			}
			
			System.out.println(DP[H - 1][W - 1]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 37176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		while(true){
			c -= b;
			if(c <= 0) {
				System.out.println("Yes");
				return;
			}
			a -= d;
			if(a <= 0) {
				System.out.println("No");
				return;
			}
		}



	}
}

Measured memory_bytes: 27092
A, B, C, K = map(int, input().split())
S = 0
if K - A > 0:
    S += A * 1
    K = K - A
else:
    S += K * 1
    K = 0

if K - B > 0:
    S += B * 0
    K = K - B
else:
    S += K * 0
    K = 0

if K - C > 0:
    S += C * -1
    K = K - C
else:
    S += K * -1
    K = 0

print(S)

Measured memory_bytes: 9168
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

const int64_t INF = 1e+18;

struct edge {
    int from, to;
    int64_t weight;
};

void Bellman_Ford(int s, vector<edge> &es, vector<int64_t> &d) {
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    for (int i = 0; i < d.size() - 1; i++) {
        for (int j = 0; j < es.size(); j++) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.weight) {
                d[e.to] = d[e.from] + e.weight;
            }
        }
    }
    return;
}
void inf_check(vector<edge>es, vector<int64_t> &d, vector<bool> &is_inf) {
    fill(is_inf.begin(), is_inf.end(), false);
    for (int i = 0; i < d.size(); i++) {
        for (int j = 0; j < es.size(); j++) {
            edge e = es[j];
            if (is_inf[e.from]) is_inf[e.to] = true;
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.weight) {
                d[e.to] = d[e.from] + e.weight;
                is_inf[e.to] = true;
            }
        }
    }
}

int main(int argc, const char * argv[]) {
     
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m; cin >> n >> m;
    vector<edge> es(m);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        int64_t c; cin >> c;
        es[i].from = a; es[i].to = b;
        es[i].weight = - c;
    }
    
    vector<int64_t> cost(n);
    Bellman_Ford(0, es, cost);
    
    vector<bool> is_inf(n);
    inf_check(es, cost, is_inf);
    
    if (is_inf[n - 1]) {
        cout << "inf" << endl;
    } else {
        cout << - cost[n - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int K = sc.nextInt();
    char headChar = S.charAt(0);
    char tailChar = S.charAt(S.length()-1);
    char seqChar = headChar;
    char seqLen = 1;
    long ans = 0;
    for (int i = 1; i < S.length(); i++) {
      if (seqChar == S.charAt(i)) {
        seqLen++;
      } else {
        ans += seqLen/2;
        seqLen = 1;
        seqChar = S.charAt(i);
      }
      if (i == S.length()-1) {
        ans += seqLen/2;
      }
    }

    ans *= K;

    if (headChar == tailChar) {
      int headLen = 0;
      for (int i = 0; i < S.length(); i++) {
        if (headChar == S.charAt(i)) {
          headLen++;
        } else {
          break;
        }
      }
      int tailLen = 0;
      for (int i = S.length()-1; i >= 0; i--) {
        if (tailChar == S.charAt(i)) {
          tailLen++;
        } else {
          break;
        }
      }
      if (headLen%2 == 1 && tailLen%2 ==1) {
        if (headLen == tailLen && headLen == S.length()) {
          ans += K/2;
        } else {
          ans += K-1;
        }
      }
    }
    System.out.println(ans);
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

int main()
{
    int h, w;
    cin >> h >> w;
    string c[2*h];
    rep(i, h) cin >> c[i];
    
    rep(i, 2*h) {
        rep(j, w) {
            cout << c[i/2][j];
        }
        cout  << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,t,s;
    scanf("%d%d%d",&a,&b,&t);
    if(a>t)
        printf("0\n");
    else
    {
        for(int i=1; a*i<=t+0.5; i++)
        {
            s=b*i;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int n1,n2,n3;
  scanf("%d",&n1);
  scanf("%d",&n2);
  scanf("%d",&n3);
  if(n1==n2&&n1==n3){
    printf("No");
  }
  else if(n1==n2||n1==n3||n2==n3){
    printf("Yes");
  }
  else {printf("No");}
  return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  int x,y;
  int n;
  P(int x,int y,int n) :x(x),y(y),n(n){}
};
typedef pair<int,int> pii;
int main() {
  int n;
  while(cin>>n,n) {
    int b[2][n+3];
    memset(b,0,sizeof(b));
    REP(j,2) REP(i,n) cin >> b[j][i];

    queue<P> Q;
    REP(i,2) {
      int y = 0;
      if (b[i][0] == 1)
        while (b[i][y+1] == 1)
          y++;
      Q.push(P(i,y,0));
    }
    bool visited[2][n+3];
    memset(visited,0,sizeof(visited));
    int res = -1;
    while(!Q.empty()) {
      P now = Q.front(); Q.pop();

      if (now.y>=n-1) {
        res = now.n;
        break;
      }
      if (visited[now.x][now.y]) continue;
      visited[now.x][now.y] = 1;
      
      //cout << now.x << ". " << now.y <<" " << now.n<<endl;
      
      int nx = now.x^1;
      for (int ny=now.y; ny<=now.y+2; ++ny) {
        int yy = ny;
        if (b[nx][ny] == 0) ;
        else if (b[nx][ny] == 1) {
          while(b[nx][yy+1] == 1)
            yy++;
        } else {
          while(b[nx][yy] == 2)
            yy--;
        }
        //cout << nx << ",, " << yy << endl;
        Q.push(P(nx,yy,now.n+1));
      }
    }
    if (res >= 0)
      cout << res << endl;
    else
      cout << "NA" << endl;
  }
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i * r <= n; i++)
  for (int j = 0; j * g <= n - i * r; j++) {
    if ((n - i * r - j * g) % b == 0) {
      ans++;
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3632
while True:
    data = input().split()
    n,m = int(data[0]),int(data[1])
    if n == 0 and m == 0: break

    tarou_cards = []
    hanako_cards = []
    cards_size = n + m

    total = 0
    t_total = 0
    h_total = 0

    for i in range(0,cards_size):
        point = int(input())
        total += point
        if n >= i+1:
            tarou_cards.append(point)
            t_total += point
        else:
            hanako_cards.append(point)
            h_total += point
    tarou_cards.sort()
    hanako_cards.sort()

    if total%2 != 0:
        print("-1")
        continue
    
    exchangeFlg = False
    target = t_total - total/2
    for t_card in tarou_cards:
        for h_card in hanako_cards:
            diff = t_card - h_card
            if diff == target:
                print("{} {}".format(t_card,h_card))
                exchangeFlg = True
                break
        if exchangeFlg:
            break
    if exchangeFlg != True:
        print("-1")


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, kaunto;
  cin >> a;
  string b;
  cin >> b;
  kaunto = 0;
  for (int i = 0; i < a - 2; i++) {
    if (b.at(i) == 'A' && b.at(i + 1) == 'B' && b.at(i + 2) == 'C') {
      kaunto++;
    }
  }
  cout << kaunto << endl;
}

Measured memory_bytes: 3584
import scala.io.StdIn
import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    println(line.sorted.mkString(" "))
    println(sSort(List(), line, 0))
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={
    if(unsorted.length == 0) n
    else if(unsorted.sorted == unsorted) n
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      if(pos == 0) sSort(sorted :+ unsorted.min, swapped.tail, n)
      else sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 45124
#include<iostream>
using namespace std;
int main(){
	int n,x,flag=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x%2==1)flag=1;
	}
	if(flag==1)cout<<"first"<<endl;
	else cout<<"second"<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;

using int64 = long long;

template <typename T>
struct FenwickTree {
    int n;
    vector<T> dat;

    FenwickTree(vector<T>& d) {
        n = d.size();
        dat.resize(n + 1, 0);
        for (int i = 0; i < n; i++) dat[i + 1] = d[i];
    }

    FenwickTree(int size) {
        n = size;
        dat = vector<T>(n + 1, 0);
    }

    // 0-indexed
    T sum(int i) {
        if (i < 0) return 0;

        i++;
        T res = 0;
        while (i > 0) {
            res += dat[i];
            i -= i & -i;
        }
        return res;
    }

    // [i, j]
    T sum(int i, int j) {
        return sum(j) - sum(i - 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

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

    int N, K;
    cin >> N >> K;

    map<int64, int> b2id;
    b2id[0] = 0;

    vector<int64> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
        b[i] -= K;

        if (i > 0) b[i] += b[i - 1];

        b2id[b[i]] = 0;
    }

    int id = 0;
    for (auto& mp : b2id) mp.second = id++;

    FenwickTree<int64> ft(id);
    ft.add(b2id[0], 1);

    int64 ans = 0;
    for (int i = 0; i < N; i++) {
        ans += ft.sum(b2id[b[i]]);
        ft.add(b2id[b[i]], 1);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ll bans = 0;
	string t = to_string(n);
	for (ll a = 1; a <= n; ++a) {
		string s = to_string(a);
		if (s.back() != '0') {
			if (s.front() == s.back() && (s.back() - '0') <= n)++ans;
			if (10 * (s.back() - '0') + (s.front() - '0') <= n)++ans;
			if (t.size() > 2) {
				if (s.back() < t.front()) {
					string preans;
					for (ll i = 0; i < t.size() - 2; ++i) {
						preans += "1";
					}
					preans += "0";
					ans += stol(preans);
				}
				else if (s.back() == t.front()) {
					string preans;
					for (ll i = 0; i < t.size() - 3; ++i) {
						preans += "1";
					}
					preans += "0";
					ans += stol(preans);
					if (s.front() > t.back()) {
						ans += max(0, stoi(t.substr(1, t.size() - 2)));
					}
					else {
						ans += stol(t.substr(1, t.size() - 2)) + 1;
					}
				}
				else {
					string preans;
					for (ll i = 0; i < t.size() - 3; ++i) {
						preans += "1";
					}
					preans += "0";
					ans += stol(preans);
				}
			}
		}
		//cerr << a << " " << ans - bans << endl;
		bans = ans;
	}
	cout << ans << endl;
}

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

typedef long long lld;
const int NN = 1e3 + 5;
const lld Mo = 1e9 + 7;
int aa[NN][NN];
lld dp[NN][NN];
int nn, mm;
string ss;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
        cin >> nn >> mm;
        for (int ii = 1; ii <= nn; ++ii) {
            cin >> ss;
            for (int jj = 1; jj <= mm; ++jj)
                aa[ii][jj] = ss[jj - 1] == '.' ? 1 : 0;
        }
        dp[1][1] = 1;
        for (int ii = 1; ii <= nn; ++ii)
        for (int jj = 1; jj <= mm; ++jj) {
            if (ii == 1 && jj == 1) continue;
            if (aa[ii - 1][jj] == 1) dp[ii][jj] = (dp[ii][jj] + dp[ii - 1][jj]) % Mo;
            if (aa[ii][jj - 1] == 1) dp[ii][jj] = (dp[ii][jj] + dp[ii][jj - 1]) % Mo;
        }
        cout << (dp[nn][mm] + 1LL * Mo * Mo) % Mo;
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int input[5];

    for (int i = 0; i < 5; i++)
        cin >> input[i];

    sort(input, input + 5, greater<int>());

    cout << input[0] << " " << input[1] << " " << input[2] << " " << input[3];
    cout << " " << input[4] << endl;

    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int N;
int A[200000];

bool judge(int X) {
    stack<pair<int, int>> S;
    for(int i=1; i<N; ++i) {
        if(A[i - 1] >= A[i]) {
            while(S.size() && S.top().first > A[i]) S.pop();
            if(S.size() && S.top().first == A[i]) {
                ++S.top().second;
            } else {
                S.push({A[i], 1});
            }
            while(S.top().second == X) {
                int d = S.top().first;
                if(d == 1) return false;
                S.pop();
                if(S.size() && S.top().first == d - 1) {
                    ++S.top().second;
                } else {
                    S.push({d - 1, 1});
                }
            }
        }
    }
    return true;
}

int main() {
    cin >> N;
    bool flag = true;
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        if(i > 0 && A[i-1] >= A[i]) flag = false;
    }

    if(flag) {
        cout << 1 << endl;
        return 0;
    }

    int l = 1, r = N;
    while(r - l > 1) {
        int m = (l + r) / 2;
        if(judge(m)) r = m;
        else l = m;
    }
    cout << r << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int n, ans;
bool rp[MAX];
vector<pair<int,int> > a;
set<int> f[2][2];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i & 1;
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++) {
		rp[i] = a[i].second ^ (i & 1);
		f[rp[i]][a[i].second].insert(i);
	}
	for(int i = 0; i < n; i++) if(rp[i]) {
		ans++;
		f[1][a[i].second].erase(i);
		int t = !f[1][a[i].second ^ 1].empty();
		int j = *f[t][a[i].second ^ 1].begin();
		rp[j] ^= 1;
		a[j].second ^= 1;
		f[t ^ 1][a[i].second].insert(j);
		f[t][a[i].second ^ 1].erase(j);
	}
	cout << ans;
}


Measured memory_bytes: 5888
<?php
list($people, $type) = explode(' ',trim(fgets(STDIN)));
$input = [];
for ($i = 1; $i <= $type; $i++) {
    $count = trim(fgets(STDIN));
    $A = explode(' ',trim(fgets(STDIN)));
    foreach ($A as $a) {
        $input[$a] = 1;
    }
}
printf("%d", $people-count($input));


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

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

int main() {
  int a ,b ,h ;
  cin >> a >> b >> h ;
  
  cout << (a+b)*h/2;


}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 998244353;

namespace modexp
{
	const int mod = 998244353;

	long long p (long long x, long long y)
	{
		long long ans = 1;
		while(y)
		{
			if(y & 1)
				(ans *= x) %= mod;
			(x *= x) %= mod;
			y /= 2;
		}
		return ans;
	}

	long long inv (long long x)
	{
		return p (x, mod - 2);
	}
}
using modexp::p;
using modexp::inv;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, m, k;
	cin >> n >> m >> k;
	ll c = 1;
	ll ans = 0;
	rep(i,0,min(n-1,k)+1)
	{
		(ans += c * m % h * p(m -1, n - 1 - i) % h) %= h;
		(c *= n - 1 - i) %= h;
		(c *= inv(i + 1)) %= h;
		// cerr << ans << '\n';
	}
	cout << ans;
}


Measured memory_bytes: 3584
S = list(input())
pair = []
cnt = 0
now = S[0]
if len(S) == 2:
  print(1, 1)
  exit()
s, t = 0, 0
for i in range(len(S)-1):
  if now == 'R' and S[i+1] == 'L':
    pair += [[i, i+1]]
    now = 'L'
  if now == 'L' and S[i+1] == 'R':
    pair[-1] += [s, t]
    now = 'R'
    s = t+1
  t += 1


pair[-1] += [s, t]
result = [0]*len(S)
for a, b, s, t in pair:
  p = t - s + 1
  if p % 2 == 0:
    result[a] = p // 2
    result[b] = p // 2
  else:
    a_even = (a-s)//2 + (t-a)//2 + 1
    b_even = p-a_even
    result[a] = a_even
    result[b] = b_even
result = list(map(str, result))
print(" ".join(result))

Measured memory_bytes: 60040
from sys  import stdin,stdout
 
st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")
 
mod=1000000007
INF=float('inf')


 
 
for _ in range(1):
    s=st()
    if s[-1]=='s':
        print(''.join(s)+'es')
    else:
        print(''.join(s)+'s')


Measured memory_bytes: 61508
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
const ll base=1000000007;
ll f[100001];
int n, m;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    f[0]=1;
    FOR(i, 1, 100000) f[i]=(f[i-1]*i)%base;
    cin>>n>>m;
    if(n>m) swap(m, n);
    if(m-n>1){
        cout<<0;
        return 0;
    }
    else if(m-n==1) cout<<(f[m]*f[n])%base;
    else cout<<(f[m]*f[n]*2)%base;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int W[n];
    int mi = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        cin >> W[i];
    }
    for (int T = 0; T < n; T++)
    {
        int S1 = 0, S2 = 0;
        for (int i = 0; i < T; i++)
        {
            S1 += W[i];
        }
        for (int i = T; i < n; i++)
        {
            S2 += W[i];
        }
        mi = min(mi, abs(S1 - S2));
    }
    cout << mi << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> cnt(100005);
    rep(i, n){
        int a;
        cin >> a;
        ++cnt[a];
    }

    int ans = cnt[0] + cnt[1] + cnt[2];

    for(int i = 3; i <= 100004; ++i){
        int sum = cnt[i-2] + cnt[i-1] + cnt[i];
        chmax(ans, sum);
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3732
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
K = int(input())
leng = len(S)
if len(set(S))==1:
    print(K*leng//2)
    exit()
if S[0]!=S[-1] or K==1:
    last = S[0]
    cnt = 0
    for s in S[1:]:
        if s==last:
            cnt += 1
            last = '.'
        else:
            last = s
    print(cnt*K)
else:
    S += ['.']
    cnt = 1
    lis = []
    last = S[0]
    for s in S[1:]:
        if s==last:
            cnt += 1
        else:
            lis.append(cnt)
            last = s
            cnt = 1
    first = lis.pop(0)
    end = lis.pop()
    others = sum([i//2 for i in lis])
    ans = first//2 + others*K + (first+end)//2*(K-1)+end//2
    print(ans)


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

int main(void){
	int N;
  	int flag[4] = {0,0,0,0};
  cin>>N;
	char s;
  int ans = 0;
  for(int i=0;i<N;i++){
    cin>>s;
  	if(s == 'P'){
    	if(flag[0] == 0 ){
          flag[0] = 1;
          ans++;
        }
    }
    if(s == 'W'){
    	if(flag[1] == 0 ){
          flag[1] = 1;
          ans++;
        }
    }
    if(s == 'G'){
    	if(flag[2] == 0 ){
          flag[2] = 1;
          ans++;
     }
    }
     if(s == 'Y'){
    	if(flag[3] == 0 ){
          flag[3] = 1;
          ans++;
          
        }
      }
    
  }
  if(ans == 3)cout<<"Three"<<endl;
  else cout<<"Four"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  string sub = S.substr(0, 4);
  if (sub=="YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=400+5,M=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n,m;
int x[M],y[M];
void input()
{
	n=read<int>(),m=read<int>();
	For(i,1,m)x[i]=read<int>(),y[i]=read<int>();
}
bitset<N>mp[N];
bool die[N];
void work()
{
	For(i,1,n)
	{
		mp[i][i]=1;
		Fordown(j,m,1)
		{
			if(mp[i][x[j]]&&mp[i][y[j]]){die[i]=1;break;}
			else if(mp[i][x[j]])mp[i][y[j]]=1;
			else if(mp[i][y[j]])mp[i][x[j]]=1;
		}
	}
	int ans=0;
	For(i,1,n)if(!die[i])
	{
		For(j,i+1,n)if(!die[j])
		{
			if((mp[i]&mp[j]).none())ans++;//,cerr<<i<<' '<<j<<endl;
		}
	}
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
    int n,b=0;
    scanf("%d",&n);
    int a[100005];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    a[n]=0;
   // int b[100005];
    //memset(b,true,sizeof(b));
    for(int i=0;i<n;)
    {
      if(a[i]==a[i+1])
      {
          i+=2;
          continue;
      }
      b++;
      i++;
    }
    printf("%d",b);
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,ans;
  scanf("%d",&N);
  ans=N%10;
  if(ans==3) printf("bon");
  else if(ans==0 || ans==1 || ans==6 || ans==8) printf("pon");
  else printf("hon");
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> gazo(h);
  vector<string> gazo2(h);
  for (int i = 0; i < h; i++) {
    cin >> gazo.at(i);
    gazo2.at(i) = gazo.at(i);
  }
  
  for (int i = 0; i < h; i++) {
    cout << gazo.at(i) << endl;
    cout << gazo2.at(i) << endl;
  }
}

Measured memory_bytes: 256
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main(){

    input!{
        a: usize,
        b: usize,
    }

    let mut con = 1;
    let mut tap = 0;
    loop{
        if con < b {
            tap += 1;
            con += a-1;
        } else {
            break;
        }
    }
    println!("{}", tap);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[2][101][10001];
int a[101],b[101],c[101];
int main(){
    int n,C,ai,bi;
    cin>>n>>C;
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0][0]=0;
    rep(i,n){
        rep(j,C+1)rep(k,i*100+1){
            if(dp[0][j][k]==-1) continue;
            int t=dp[0][j][k];
            if(j+c[i]<=C){
                int u=max(k+a[i],t+b[i]);
                int l=min(k+a[i],t+b[i]);
                dp[1][j+c[i]][u]=max(dp[1][j+c[i]][u],l);
                u=max(k+b[i],t+a[i]);
                l=min(k+b[i],t+a[i]);
                dp[1][j+c[i]][u]=max(dp[1][j+c[i]][u],l);            
            }
            dp[1][j][k]=max(dp[1][j][k],t);
        }
        swap(dp[0],dp[1]);
        memset(dp[1],-1,sizeof(dp[1]));
    }
    int mx=0;
    rep(i,C+1)rep(j,10001)if(dp[0][i][j]!=-1) mx=max(mx,dp[0][i][j]);
    cout<<mx<<endl;
    return 0;
}


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

int main(){
	int group[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
	int x, y; cin >> x >> y;
	if(group[x - 1] == group[y - 1]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

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

ll n,m,x,y,k,d,i,j,index,flag=0,mini,count=0,result,odd,even,sum=0,temp;
cin>>n;

//string str;
//cin>>str;
//ll a[200005];
//ll b[200005];
//vector<ll> ans;
//set<ll> s;

/*for(i=0;i<n;i++)
{
    cin>>a[i];
}
*/
//sort(a,a+n);
if(n==0) cout<<1<<endl;
else if(n==1) cout<<0<<endl;


    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
 int s,m,h;
 scanf("%d",&s);

 h = s / 3600;
 m = (s - (h * 3600)) / 60;
 s = s - (h * 3600) - (m * 60);

 printf("%d:%d:%d\n",h,m,s);

 return(0);
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 13 14:21:46 2018
ABC048C
@author: maezawa
"""

n, x = list(map(int, input().split()))
a = list(map(int, input().split()))

cnt = 0
pre = 0
for i in a:
    if pre + i <= x:
        pre = i
        continue
    elif x-pre >= 0:
        cnt += i - (x-pre)
        pre = x-pre
    else:
        cnt += pre + i - x
        pre = 0

print(cnt)

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

int main()
{
	int R,G,B,n;
	cin>>R>>G>>B>>n;
	
	int sum=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)		//双重循环 
		{
			int k=n-i*R-j*G; 
			if(k%B==0 && k>=0)
				sum++;
		}
				
	
	cout<<sum<<endl;
	return 0;
}

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

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

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

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

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

    int x;
    cin >> x;

    if (INRANGE(x, 400, 599)) cout << 8 << endl;
    else if (INRANGE(x, 600, 799)) cout << 7 << endl;
    else if (INRANGE(x, 800, 999)) cout << 6 << endl;
    else if (INRANGE(x, 1000, 1199)) cout << 5 << endl;
    else if (INRANGE(x, 1200, 1399)) cout << 4 << endl;
    else if (INRANGE(x, 1400, 1599)) cout << 3 << endl;
    else if (INRANGE(x, 1600, 1799)) cout << 2 << endl;
    else if (INRANGE(x, 1800, 1999)) cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoder.ABC000
{
    class Program
    {
        static void Main()
        {
            string input = Console.ReadLine();
            int i = input.Length;
            while (--i > 0)
            {
                if (!isEvenString(input, i)) continue;
                Console.WriteLine(i);
                return;
            }
        }

        static bool isEvenString(string str, int leng)
        {
            if (leng % 2 != 0) return false;
            string str1 = str.Substring(0, leng / 2);
            string str2 = str.Substring(leng / 2, leng / 2);
            return str1 == str2;
        }
    }
}

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

int main() {
  int N, l[1000], r[1000];
  int res = 0;
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> l[i] >> r[i];
  for(int i = 0; i < N; ++i) {
    res += (r[i] - l[i] + 1);
  }

  cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
robots = [list(map(int, input().split())) for i in range(N)]

robots.sort()
robots_arms = [[r[0] - r[1],r[0], r[0] + r[1]] for r in robots ]#leftarm, x, right arm
left_robot = [-float('inf')]*3
ans = 0
for robot in robots_arms:
    if left_robot[2] <= robot[0]:
        ans += 1
        left_robot = robot
    elif left_robot[2] > robot[2]:
            left_robot = robot
    else:
        left_robot = left_robot
print(ans)

Measured memory_bytes: 41560
from collections import defaultdict

N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
grid=[list(map(int,input().split())) for _ in range(N)]

mod_0=defaultdict(int)
mod_1=defaultdict(int)
mod_2=defaultdict(int)

for i in range(N):
    for j in range(N):
        n=(i+j+2)%3
        if n==0:
            mod_0[grid[i][j]]+=1
        elif n==1:
            mod_1[grid[i][j]]+=1
        else:
            mod_2[grid[i][j]]+=1

ans=float("inf")
for i in range(C):
    for j in range(C):
        if i==j:
            continue
        for k in range(C):
            if k in [i,j]:
                continue

            total=0
            for prev,cnt in mod_0.items():
                total+=D[prev-1][i]*cnt
            for prev,cnt in mod_1.items():
                total+=D[prev-1][j]*cnt
            for prev,cnt in mod_2.items():
                total+=D[prev-1][k]*cnt
            
            ans=min(ans,total)
print(ans)

Measured memory_bytes: 5876
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	long long inf = 1e18;

	int n;
	cin >> n;
	
	vector<int> data(n+1,inf);
	rep(i, n) {
		cin >> data[i];
	}

	vector<long long> dp(n+1, inf);
	dp[0] = 0;

	for (int i = 0; i < n - 1; i++) {
		if (abs(data[i] - data[i + 1]) + dp[i] < dp[i + 1]) {
			dp[i + 1] = abs(data[i] - data[i + 1])+dp[i];
		}
		if (abs(data[i] - data[i + 2] )+ dp[i] < dp[i + 2]) {
			dp[i + 2] = abs(data[i] - data[i + 2]) + dp[i];
		}
	}
	
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4556