akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
 
int H, W;
vector<string> field;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int bfs(int x, int y){
    Graph dist(H, vector<int>(W, -1));
    queue<P> que;
 
    que.push(P(x, y));
    dist[x][y] = 0;
 
    while (que.size()) {
        P p = que.front(); que.pop();
 
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second +dy[i];
 
            if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != '#' && dist[nx][ny] == -1) {
                que.push(P(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }
 
    int depth;
    depth = dist[H - 1][W - 1];
 
    return depth;
}
 
int main() {
    int cnt, white = 0, ans = 0;
    cin >> H >> W;
    field.resize(H);
    for (int i = 0; i < H; i++) cin >> field[i];
    cnt = bfs(0, 0);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '.') white++;
        }
    }
    if (cnt == -1) cout << - 1 << endl;
    else cout << white - cnt - 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
 
bool check(string str){
  int i=0;
  int j=str.size()-1;
  while(i<j){
    if (str[i]!=str[j]){
      return false;
    }
    else{
      i++;
      j--;
    }
  }
  return true;
}
 
int main(){ 
  string str;
  cin >>str;
  string str1=str.substr(0,(str.size()-1)/2);
  string str2=str.substr((str.size()+1)/2,(str.size()-1)/2);
  bool x=check(str1);
  bool y=check(str2);
  bool z=check(str);
  if (x && y && z) cout <<"Yes"<<endl;
  else cout<<"No"<<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 K = sc.nextInt();
		int h[]=new int[N+1];
		int ans= 0;
		for(int i=1;i<=N;i++){
			h[i]=sc.nextInt();
		}
		for(int i=1;i<=N;i++){
			if (h[i]>=K){
				ans=ans+1;
			}
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 51148
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
/*
各bitがKより小さいi,jでA_i,A_jが一番大きいものをdp[K][0],dp[K][1]とする(i,jが入ってる)
答えは当然dp[K][0]+dp[K][1]
dp[K][0]とdp[K][1]の求め方は、Kの立ってるbitを1つ外した数字Lに対してのdp[L][0]とdp[L][1]、A[K]を見ればいいので
40個くらい見ればいいはず
*/
int dp[1234567][3];
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(1234567);
  for(int i=0;i<pow(2,N);i++)cin>>v[i];
  typedef pair<int,int> P;
  set<int> s;
  priority_queue<P> que;
  int mx=0;dp[0][0]=0;
  for(int i=1;i<pow(2,N);i++){
    s.clear();
    for(int j=0;j<N;j++){
      if((i>>j)&1){
        s.insert(dp[i^(1<<j)][0]);
        if((i^(1<<j)))s.insert(dp[i^(1<<j)][1]);
      }
    }
    //cout<<i<<" "<<s.size()<<endl;
    while(que.size())que.pop();//que.clear();
    for(int p:s)que.push(P(v[p],p));
    que.push(P(v[i],i));
    dp[i][0]=que.top().second;que.pop();
    dp[i][1]=que.top().second;que.pop();
    //cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<" "<<v[dp[i][0]]+v[dp[i][1]]<<endl;
    mx=max(mx,v[dp[i][0]]+v[dp[i][1]]);
    cout<<mx<<endl;
  }
}


Measured memory_bytes: 20864
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

int main(){
    int r;

    std::cin >> r;

    std::cout << 3.0*r*r << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[31];

int main (void){
a[0]=1;
a[1]=1;
a[2]=2;
for(int i=3; i<=30;i++)
     a[i]=a[i-1]+a[i-2]+a[i-3];
int n;
while(cin >> n,n|0){
    int ans=a[n]/3650;
    if(a[n]%3650)
         ans++;
    cout << ans << endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>

class Dice {
public:
    int num[6];
    void move (char cmd) {
        if (cmd == 'N') north();
        if (cmd == 'S') south();
        if (cmd == 'E') east();
        if (cmd == 'W') west();
    }
    void north () {
        std::swap(num[0], num[1]);
        std::swap(num[1], num[5]);
        std::swap(num[5], num[4]);
    }
    void south () {
        std::swap(num[0], num[4]);
        std::swap(num[4], num[5]);
        std::swap(num[5], num[1]);
    }
    void east () {
        std::swap(num[0], num[3]);
        std::swap(num[3], num[5]);
        std::swap(num[5], num[2]);
    }
    void west () {
        std::swap(num[0], num[2]);
        std::swap(num[2], num[5]);
        std::swap(num[5], num[3]);
    }
};

int main() {
    Dice dice;
    for (int i=0;i<6;++i)
        std::cin >> dice.num[i];
    std::string cmd;
    std::cin >> cmd;
    for (int i=0;i<(int)cmd.size();++i)
        dice.move(cmd[i]);
    std::cout << dice.num[0] << std::endl;
    
    return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		Dice dice = new Dice(input());
		int q = Integer.parseInt(input());

		for (int i = 0; i < q; i++) {

			dice.setRight(input());
			System.out.println(dice.getRight());

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

class Dice {

	private int top;
	private int front;
	private int right;
	private int left;
	private int back;
	private int bottom;

	public Dice(String num) {

		String[] partsNum = num.split(" ");

		top = Integer.parseInt(partsNum[0]);
		front = Integer.parseInt(partsNum[1]);
		right = Integer.parseInt(partsNum[2]);
		left = Integer.parseInt(partsNum[3]);
		back = Integer.parseInt(partsNum[4]);
		bottom = Integer.parseInt(partsNum[5]);

	}

	public void setRight(String num) {

		String[] numList = num.split(" ");

		for (int i = 0; i < 7; i++) {

			if (i == 4) {

				this.roll("E");

			}

			if (Integer.parseInt(numList[1]) == this.front) {

				break;

			} else {

				this.roll("N");

			}
		}

		while (true) {

			if (Integer.parseInt(numList[0]) == this.top) {

				break;

			} else {

				this.roll("W");

			}
		}
	}

	public int getRight() {

		return this.right;

	}

	public void roll(String direction) {

		int temp;

		for (int i = 0; i < direction.length(); i++) {

			switch (direction.charAt(i)) {

			case 'E':

				temp = top;
				top = left;
				left = bottom;
				bottom = right;
				right = temp;
				break;

			case 'N':

				temp = top;
				top = front;
				front = bottom;
				bottom = back;
				back = temp;
				break;

			case 'S':

				temp = top;
				top = back;
				back = bottom;
				bottom = front;
				front = temp;
				break;

			case 'W':

				temp = top;
				top = right;
				right = bottom;
				bottom = left;
				left = temp;
				break;

			}
		}
	}

	public int getTop() {

		return top;

	}
}

Measured memory_bytes: 26192
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    first = s[:3]
    second = s[1:]

    if len(set(first)) == 1 or len(set(second)) == 1:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main(){
  int n , k , ans = 0;
  cin >> n >> k;
  vector<int> p(n , 0);
  for (int i = 0; i < n ; i ++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  for (int i = 0 ; i < k ; i ++) {
    ans += p[i];
  }
  cout << ans << endl;
}

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

int N, W;
int VALUE[110], WEIGHT[110];

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

    int dp[110][10010] = {0};
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= WEIGHT[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - WEIGHT[i]] + VALUE[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7408
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }


    val dp = IntArray(n + 1) {0}

    dp[0] = 1
    dp[1] = 1

    for (i in 0 until m) {
        dp[readLine()!!.toInt()] = -1
    }

    var ans = 0
    val modVal = 1e9.toInt() + 7
    for (i in 2..n){

        if(dp[i] == -1) continue

        if(dp[i-1] == -1 && dp[i-2] == -1) {
            println(0)
            return
        }

        if(dp[i-1] != -1) {
            dp[i] = (dp[i] + dp[i-1]) % modVal
        }

        if(dp[i-2] != -1) {
            dp[i] = (dp[i] +  dp[i-2]) % modVal
        }
    }

    println(dp[n])
}

Measured memory_bytes: 41436
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,ans,a[10005][10005],s[10005],v[10005];
int main(){
	in(n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++)in(a[i][j]);
        s[i]=1;
    }
    while(1){
        bool flag=0,ok=0;
        for(int i=1;i<=n;i++){
            if(s[i]!=n){
                flag=1;
                break;
            }
        }
        if(flag==0){
            printf("%d\n",ans);
            return 0;
        }
        memset(v,0,sizeof(v));
        ans++;
        for(int i=1;i<=n;i++){
            if(v[i]||s[i]==n)continue;
            int l=a[i][s[i]];
            int r=a[l][s[l]];
            if(!v[i]&&!v[l]&&r==i){
                ok=1;
                s[i]++;
                s[l]++;
                v[i]=v[l]=1;
            }
        }
        if(ok==0){
            puts("-1");
            return 0;
        }
    }
	return 0;
}


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

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

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

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int n, m;
vector<T> edge(2010);
vector<bool> negative(1010);
vector<ll> dis(1010, INF);

ll shortest_path(){
    dis[0]=0;
    for(int i=0; i<n-1; i++){
        for(int j=0; j<m; j++){
            int crt_v, nxt_v;
            ll cost;
            tie(crt_v, nxt_v, cost)=edge[j];
            //cout << crt_v << " " << nxt_v << " " << cost << endl;

            if(dis[crt_v] != INF && dis[nxt_v] > dis[crt_v] + cost){
                dis[nxt_v] = dis[crt_v] + cost;
            }
        }
    }
    return -dis[n-1];
}

void find_negative_loop(){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            int crt_v, nxt_v;
            ll cost;
            tie(crt_v, nxt_v, cost)=edge[j];
            //cout << crt_v << " " << nxt_v << " " << cost << endl;

            if(dis[crt_v] != INF && dis[nxt_v] > dis[crt_v] + cost){
                dis[nxt_v] = dis[crt_v] + cost;
                negative[nxt_v]=true;
            }

            if(negative[crt_v]){
                negative[nxt_v]=true;
            }
        }
    }
}

int main(){
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b;
        ll c; 
        cin>>a>>b>>c;
        a--, b--;
        edge[i]=T(a, b, -c);
    }

    ll ans=shortest_path();
    find_negative_loop();

    if(negative[n-1]){
        cout << "inf" << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n;
	cin >> n;
	map<string,int> m;

	rep(i,n){
		string s;
		cin >> s;
		m[s]++;
	}
	int maxi = -1;
	for(auto& x:m)chmax(maxi,x.se);
	vector<string> ans;
	for(auto& x:m)if(x.se == maxi)cout << x.fi << endl;


	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc155.contest.atcoder.jp/tasks/abc155_c

Measured memory_bytes: 19128
#include <iostream>
#include <numeric>

inline int gcd(int a, int b){
  if(b<a) std::swap(a, b);
  int r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];
bool use[1000001];

int main(){
  int n = read();
  int num = read();
  int o = 0, g = num;
  if(num==1) o=1;
  int ex = (n-1)/8;
  cnt[num] = 1;

  for(int i=0;i<ex;i++){
    int num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;
  }

  for(int i=0;i<(n-1)%8;i++){
    int num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;
  }

  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }
  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    if(use[i]) continue;
    int S = 0;
    for(int j=i;j<=1000000;j+=i) {
      use[j] = 1;
      S += cnt[j];
    }
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


Measured memory_bytes: 8520
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=22,M=1<<15;
int i,j,k,n,m,ch,ff,nn,nm,Sum,Ans,x,y,v;
int f[M][N],a[N][N],sum[1<<15];
void R(int &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void R(ll &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int max(const int &x,const int &y) {
	if (x<y) return y;
	return x;
}
int main() {
	memset(f,-1,sizeof f);
	Ans=-1;
	R(n);R(m);
	for (i=1;i<=m;i++) {
		R(x);R(y);R(v);
		a[x][y]=a[y][x]=v;
		Sum+=v;
	}
	nn=1<<n;
	for (i=0;i<nn;i++)
		for (j=1;j<=n;j++) if (i&1<<j-1)
			for (k=j+1;k<=n;k++) if (i&1<<k-1) sum[i]+=a[j][k];
	f[1][1]=0;
	for (i=1;i<nn;i+=2)
		for (j=1;j<=n;j++) if (f[i][j]!=-1) {
			if (j==n) Ans=max(Ans,f[i][j]);
			for (k=1;k<=n;k++) if (!(i&1<<k-1) && a[j][k]) f[i|1<<k-1][k]=max(f[i|1<<k-1][k],f[i][j]+a[j][k]);
			for (k=(i+1)|i;k<nn;k=(k+1)|i) f[k][j]=max(f[k][j],f[i][j]+sum[(k^i)|1<<j-1]);
		}
	printf("%d\n",Sum-Ans);
}

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

const int MOD = 1e9 + 7;
int add(int x, int y) { return (x += y) < MOD ? x : x - MOD; }
int sub(int x, int y) { return (x -= y) >= 00 ? x : x + MOD; }
int mul(int x, int y) { return 1LL * x * y % MOD; }
int pwr(int x, int p) {
  if (p <= 0) return 1;
  if (p % 2) return mul(x, pwr(x, p - 1));
  return pwr(mul(x, x), p / 2);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), c0(n);
  vector<int> dp1(1 << 20);
  vector<int> dp2(1 << 20, 1);
  vector<int> sol(1 << 20);
  vector<int> last(1 << 20);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) {
      a[i] ^= a[i - 1];
      c0[i] += c0[i - 1];
    }
    if (a[i]) {
      dp2[a[i]] = add(dp2[a[i]], mul(dp1[a[i]], c0[i] - c0[last[a[i]]]));
      dp1[a[i]] = add(dp1[a[i]], dp2[a[i]]);
      sol[a[i]] = dp2[a[i]];
      last[a[i]] = i;
    } else {
      c0[i] += 1;
    }
  }
  dp1[0] = pwr(2, c0[n - 1] - 1);
  if (a[n - 1]) {
    cout << sol[a[n - 1]] << '\n';
  } else {
    cout << accumulate(dp1.begin(), dp1.end(), 0, add) << '\n';
  }
}


Measured memory_bytes: 22780
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

  string T = S;
  rep(i, N) {
    rep(j, max(T.size(), (size_t)1) - 1) {
      if (T[j] == '(' && T[j + 1] == ')') {
        T.erase(T.begin() + j, T.begin() + j + 2);
        continue;
      }
    }
  }

  int cnt_l = 0, cnt_r = 0;
  if (T.size() != 0) {
    rep(i, T.size()) {
      if (T[i] == ')')
        cnt_r++;
      else
        cnt_l++;
    }
  }

  reverse(all(S));
  rep(i, cnt_r) {
    S.pb('(');
  }

  reverse(all(S));
  rep(i, cnt_l) {
    S.pb(')');
  }

  cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 255050

ll n,m,k;
ll a[N],x[N];
int mv[80][N];

main(){
    n=in();
    rep(i,n)x[i]=in();
    m=in();
    k=lin();
    rep(i,m)a[i]=in();
    rep(i,n-1)mv[0][i]=i;
    rep(i,m)swap(mv[0][a[i]-1],mv[0][a[i]-2]);
    rep(i,63){
        rep(j,n-1){
            mv[i+1][j]=mv[i][mv[i][j]];
        }
    }
    /*
    rep(i,3){
        rep(j,n)cout<<mv[i][j]<<" ";
        cout<<endl;
    }
    */
    vec now(n),temp(n);
    rep(i,n-1)now[i]=i;
    rep(i,63){
        if(k&(1ll<<i)){
            rep(j,n-1){
                temp[j]=now[mv[i][j]];
                /*printf("mv[i][j]=%d now[mv[i][j]]=%d\n",mv[i][j],now[mv[i][j]]);
                */
            }
            /*cout<<"now="<<i<<endl;
            rep(ii,n-1)cout<<temp[i]<<" ";
            cout<<endl;
            */
            now=temp;        
        }
    }
    /*
    rep(i,n-1)cout<<now[i]<<" ";
    cout<<endl;
    */
    vec d(n);
    rep(i,n-1)d[i]=x[i+1]-x[i];
    /*
    rep(i,n-1)cout<<d[i]<<" ";
    */
    cout<<x[0]<<endl;
    rep(i,n-1){
        x[i+1]=x[i]+d[now[i]];
        cout<<x[i+1]<<endl;
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  if(b==1) cout<<0<<endl;
  else if(b<=a) cout<<1<<endl;
  else{
    b-=a;
    cout<<(b+a-2)/(a-1)+1<<endl;
  }
}

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

int main() {
	int N = 0, Q = 0;
	int K = 0;
	cin >> N >> K >> Q;

	vector<int> A(N, K);
	vector<int> Stacks(N, 0);

	for(int i = 1; i <= Q; i++) {
		int answerer = 0;
		cin >> answerer;
		Stacks[answerer - 1] += 1;
	}

	for(int i = 0; i < N; i++) {
		A[i] = K - (Q - Stacks[i]);
 	  cout << ((A[i] > 0) ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define RG register
#define ll long long
#define For(i, f, t) for (RG int i = f; i <= t; i++)

ll K;

int main()
{
	scanf("%lld", &K);
	printf("%d\n", 50);
	For (i, 1, K % 50) printf("%lld ", 50 + K / 50);
	For (i, 1, 50 - (K % 50)) printf("%lld ", 49 + K / 50 - K % 50);
	puts("");
	return 0;
}

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

int main() {
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	c1 *= 1; c5 *= 5; c10 *= 10;
	c50 *= 50; c100 *= 100; c500 *= 500;
	if (c1 + c5 + c10 + c50 + c100 + c500 >= 1000) cout << "1" << endl;
	else cout << "0" << endl;
	return 0;
}


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


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main()
{
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    for (size_t i = 0; i < m ; i++)
    {
        int a,b;
        cin >> a >> b ;
        a--;
        b--;
        uf.unite(a,b);
    }
    map<int,long long> mp;
    for (size_t i = 0; i < n; i++)
    {
        mp[uf.root(i)]++;
    }
    cout << mp.size() - 1 << endl;
}

Measured memory_bytes: 8936
MOD = 10 ** 9 + 7


def power_expo(x, y):
    """Returns x^y.

    <https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6>

    結局, 組み込み関数の `pow()` のほうが速そう. 第3引数でmodもできる.
    """
    if y == 0:
        return 1
    elif y % 2 == 0:
        return power_expo(x, y // 2) ** 2 % MOD
    else:
        return power_expo(x, y // 2) ** 2 * x % MOD


def main():
    x, y = [int(x) for x in input().split()]
    if (x + y) % 3 != 0:
        return 0
    summ = (x + y) // 3     # d + r
    diff = x - y  # d - r
    if summ % 2 != diff % 2:
        return 0
    d = (summ + diff) // 2  # Down
    r = (summ - diff) // 2  # Right
    if d < 0 or r < 0:
        return 0
    chosen = min(d, r)

    patterns = 1

    for i, j in zip(range(summ - chosen + 1, summ + 1), range(1, summ + 1)):
        patterns = patterns % MOD * i % MOD * pow(j, MOD - 2, MOD) % MOD

    return patterns


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

# やはり難しい，再び解説。割り算のときは mod 10^9+7 が厄介。
# とりあえず，割る方は 10^9+5 乗して掛ければいいらしい。


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string D,ans="";
	int i=0,cnt=0;
	cin>>D;
	while(i+8<=D.size()){
		int aiduny[6]={0};
		for(int j=i;j<i+8;j++){
			if(D[j]=='A')aiduny[0]++;
			else if(D[j]=='I')aiduny[1]++;
			else if(D[j]=='D')aiduny[2]++;
			else if(D[j]=='U')aiduny[3]++;
			else if(D[j]=='N')aiduny[4]++;
			else if(D[j]=='Y')aiduny[5]++;
		}
		if(aiduny[0]==2 && aiduny[1] && aiduny[2] && aiduny[3] && aiduny[4]==2 && aiduny[5]){
			ans=ans+D.substr(cnt,i-cnt)+"AIZUNYAN";
			i+=8;
			cnt=i;
		}else{
			i++;
		}
	}
	ans+=D.substr(cnt);
	cout<<ans<<endl;
	return 0;
}

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

double calc(double t, int A, int B, int C){
    double pi = 3.14159265358979323;
    return A*t + B*sin(C*t*pi);
}

int main() {

    string S;
    cin >> S;
    vector<long> remains(13, 0), new_remain(13, 0);
    char c;
    int number;
    int D = 1000000000 + 7;
    c = S.at(0);
    if(c=='?'){
        for(int i=0;i<10;i++){
            remains.at(i)++;
        }
    }else{
        remains.at(c-'0')++;
    }
    for(int i=1;i<S.size();i++){
        c = S.at(i);
        if(c == '?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++) {
                    new_remain.at((j * 10 + k) % 13) += remains.at(j);
                }
            }
        }else{
            number = c - '0';
            for(int j=0;j<13;j++){
                new_remain.at((j*10+number)%13) += remains.at(j);
            }
        }
        for(int j=0;j<13;j++){
            remains.at(j) = new_remain.at(j) % D;
            new_remain.at(j) = 0;
        }
    }
    cout << remains.at(5) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
lli maxSubArraySum(lli a[], lli size)
{
    lli max_so_far = INT_MIN, max_ending_here = 0;

    for (lli i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
int main()
{


    fast;
    lli n;
    cin>>n;
    lli a[n][2];
    double x=0,y=0;
    for(lli i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
        x+=a[i][0],y+=a[i][1];
    }
    double X=x/n,Y=y/n;
    //cout<<X<<" "<<Y<<"\n";
    double m=0.999;
    double p=0.01;
    lli f;
    double dist=0;
    for(lli i=1;i<=30000;i++)
    {
        f=0;
        dist=((X-a[0][0])*(X-a[0][0])+(Y-a[0][1])*(Y-a[0][1]));
        for(lli j=1;j<n;j++)
        {
            if(((X-a[j][0])*(X-a[j][0])+(Y-a[j][1])*(Y-a[j][1]))>dist)
            {
                dist=((X-a[j][0])*(X-a[j][0])+(Y-a[j][1])*(Y-a[j][1]));
                f=j;
            }
        }
        X+=(a[f][0]-X)*p;
        Y+=(a[f][1]-Y)*p;
        p*=m;
    }

    cout<<fixed<<setprecision(9)<<sqrt((X-a[f][0])*(X-a[f][0])+(Y-a[f][1])*(Y-a[f][1]));


    return 0;

}


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

using namespace std;

#define int long long
#define rep(i,a,n) for(int i = a; i<n; i++)
#define per(i,a,n) for(int i = n-1; i>=a; i--)

int max(int a,int b){return a>b ? a:b;}
int min(int a,int b){return a<b ? a:b;}


const int INF = 1e9+7;

int n;

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

  cin>>n;
  int m = sqrt(10+n);
  vector<int> out(n+1,0);
  int ctr = 0;
  rep(x,1,m+1)
    rep(y,1,m+1)
      rep(z,1,m+1)
        if(x*x + y*y + z*z +x*y+y*z+z*x <= n){
          out[x*x + y*y + z*z +x*y+y*z+z*x]++;
        }
  rep(i,1,n+1)cout<<out[i]<<"\n";




}


Measured memory_bytes: 3596
num = []

for _ in range(5) :
    num.append(int(input()))

k = int(input())
ans = True

for i in range(5) :
    for l in range(i + 1, 5) :
        if num[l] - num[i] > k :
            ans = False

if ans :
    print('Yay!')
else :
    print(':(')


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

L = sum(A)

sum_1 = 0

for i in range(N):
    sum_1 += A[i]
    if sum_1 >= L / 2:
        break

sum_2 = 0

for i in reversed(range(N)):
    sum_2 += A[i]
    if sum_2 >= L / 2:
        break

print(min(2 * sum_1 - L, 2 * sum_2 - L))


Measured memory_bytes: 26764
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
D = 1000000007
n, m = map(int, input().split())
a = [0] * (10**5 + 1)
for i in range(m):
    a[int(input())] += 1

# 初期値
s = [0] * (n + 1)
s[0] = 1
if (a[1] == 1):
    s[1] = 0
else:
    s[1] = 1

# 暫定結果を格納する配列


def calc(n):
    if(a[n] == 1):
        return 0
    else:
        return (s[n - 1] + s[n - 2]) % D


def solver(n):
    for i in range(2, n + 1):
        s[i] = calc(i)


solver(n)
print(s[n])


Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define MAX 100010
using namespace std;
int P[MAX];
int main() {
  int N; cin >> N;
  REP(i,1,N+1)
    cin >> P[i];
  int ans = 0;
  REP(i,1,N+1) {
    if (i != P[i]) {
      continue;
    } else {
      int tmp1 = P[i];
      int tmp2 = P[i+1];
      P[i]   = tmp2;
      P[i+1] = tmp1;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long

int sumofdigits(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

void PrintMap(std::map<int, int>& m) {
  for (auto iter: m) {
    std::cout << iter.first << " => " << iter.second << "\n";
  }
}

signed main() {
  int a, b, c, x, y;
  std::cin >> a >> b >> c >> x >> y;
  
  int total = 0;
  if (2 * c < a + b) {
    if (x < y) {
      total += x * (2 * c);
      if (b < 2 * c) {
        total += (y - x) * b;
      } else {
        total += (y - x) * (2 * c);
      }
    } else {
      total += y * (2 * c);
      if (a < 2 * c) {
        total += (x - y) * a;
      } else {
        total += (x - y) * (2 * c);
      }
    }
  } else {
    total = a * x + b * y;
  }
  
  std::cout << total << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
string a,b,c;
int d,e;
map<int,int>mp;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>d;
	for(int i=0;i<d;i++){
		cin>>e;
		mp[e]++;
		if(mp[e]==2){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ara[300005];
struct data{
    ll r;
    ll val;
};
data ss[300009];
ll bs(ll l,ll h,ll val)
{
    while(l<=h)
    {
//        cout<<l<<" "<<h<<endl;
        ll mid=(l+h)/2;
        if(val<=ara[mid])
        {
            h=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return h;
}
bool comp(data p,data q)
{
    return p.val>q.val;
}
int main()
{
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++)cin>>ara[i];
    for(ll i=1;i<=m;i++)
    {
        cin>>ss[i].r>>ss[i].val;
    }
    ll pos=1;
    long long sum=0;
    sort(ara+1,ara+n+1);
    sort(ss+1,ss+m+1,comp);
//    for(ll i=0;i<n;i++)cout<<ara[i]<<" ";cout<<endl;
    for(ll i=1;i<=m;i++)
    {
        ll temp=bs(pos,min(pos+ss[i].r-1,n),ss[i].val)+1;
        sum+=(temp-pos)*ss[i].val;
//        cout<<"sum = "<<sum<<" pos = "<<temp<<endl;
        if(pos>=temp)break;
        pos=temp;
        if(pos>n)break;
    }
    for(ll i=pos;i<=n;i++)
    {
        sum+=ara[i];
    }
    cout<<sum<<endl;
}


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

int main() {
  int X;
  cin >> X;
  int z = 360;
  for(int i=0; i<360; i++){
    if(z%X == 0){
      cout << z/X << endl;
      return 0;
    }
    else{
      z += 360;
    }
  }
}


Measured memory_bytes: 3612
//Bingo

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int A[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    bool b[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            b[i][j] = false;
        }
    }

    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (A[j][k] == tmp) {
                    b[j][k] = true;
                }
            }
        }
    }


    /*
    for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
            cout << b[j][k] << " ";
        }
        cout << endl;
    }
    */

    for (int i = 0; i < 3; i++) {
        bool tmp = true;
        bool tmp2 = true;
        for (int j = 0; j < 3; j++) {
            tmp = tmp && b[i][j];
            tmp2 = tmp2 && b[j][i];
        }
        if (tmp || tmp2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    bool tmp = true;;
    bool tmp2 = true;
    for (int i = 0; i < 3; i++) {
        tmp = tmp && b[i][i];
        tmp2 = tmp2 && b[i][2-i];
    }
    if (tmp || tmp2) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

int partition(int A[], int p, int r);

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

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


Measured memory_bytes: 3480
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int K, N, r=0, tmp, m=-1;
    cin >> K >> N;

    int a[N];
    cin >> a[0];
    r = a[0];
    for(int i=1; i<N; i++){
        cin >> tmp;
        a[i] = tmp - r;
        r += a[i];
        m = max(m, a[i]);
    }
    a[0] += K-r;
    m = max(m, a[0]);

    cout << K-m << endl;
    // REP(i, N){
    //     cout << a[i] << endl;
    // }

    return 0;
}



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

#define ll long long

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

  ll A, B, n;
  cin >> A >> B >> n;
  ll r = min(B - 1, n);
  cout << (ll)A * r / B << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int k,x;
  cin >> k >> x;
  string ans;
  if(k*500>=x){
	ans = "Yes";
  }else{
	ans = "No";
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int K;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.K = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        //NをK進数に変換する
        String num = Integer.toString(N, K);
        answer = num.length();
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35788
#include <iostream>
#include <cstring>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>
 

using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e5 + 5;
int n = 0;
 
ll largest(ll a, ll b){
	return (a<b)?b:a;
}
ll smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}
 
int main(){
	cin >> n;
	vector<tuple<int,int,int> > d;
	int a,b,c;
	for(int i = 0; i < n; ++i){
		cin >> a >> b >> c;
		d.push_back(make_tuple(a, b, c)); 
	}
	sort(d.begin(), d.end());
    int t = 0, x = 0, y = 0, k = 1;
    int i = 0;
    while(i != n){
        a = get<0>(d[i]);
        b = get<1>(d[i]);
        c = get<2>(d[i]);
        y = abs(y - c);
        x = abs(x - b);
        t = a - t;
        if((x + y + t) & 1){
            cout << "No" << endl;
            return 0;
        }
        if(x + y > t){
            cout << "No" << endl;
            return 0;
        }
        x = b;
		y = c;
		t = a;
        ++i;
        
    }
    cout << "Yes" << endl;
    
    
 
    return 0;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;

int main()
{
    string s,t;
    cin>>s>>t;
    vector<char> shiftS(26,' ');// tのアルファベットはsのどのアルファベットに対応する？
    vector<char> shiftT(26,' ');// 逆
    string res="Yes";
    ll length=s.size();
    for(ll i=0;i<length;i++)
    {
        ll numS=s[i]-'a';
        ll numT=t[i]-'a';
        if(shiftS[numS]!=t[i] && shiftS[numS]!=' ')
        {
            res="No";break;
        }
        if(shiftT[numT]!=s[i] && shiftT[numT]!=' ')
        {
            res="No";break;
        }
        shiftS[numS]=t[i];
        shiftT[numT]=s[i];
    }
    cout<<res;
}

Measured memory_bytes: 3864
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;


ll dp[100001];
vector<Pa> to[100001];
Pa questions[100000];
int main() {
	cin >> N;
	rep(i, N+1) {
		dp[i] = MAX;
	}
	rep(i, N - 1) {
		cin >> A >> B >> C;
		to[A].push_back(Pa(B, C));
		to[B].push_back(Pa(A, C));
	}
	cin >> Q >> K;
	rep(i, Q) {
		cin >> A >> B;
		questions[i] = Pa(A, B);
	}

	dp[K] = 0;
	queue<int> que;
	que.push(K);
	while (!que.empty()) {
		int curr = que.front(); que.pop();
		rep(i, to[curr].size()) {
			if (dp[to[curr][i].first] == MAX) {
				que.push(to[curr][i].first);
				dp[to[curr][i].first] = dp[curr] + to[curr][i].second;
			}
		}
	}

	rep(i, Q) {
		cout << dp[questions[i].first] + dp[questions[i].second] << endl;
	}
}

Measured memory_bytes: 11520
Q = int(input())
def prime_table(n):
  P = [1] * (n + 1)
  P[0] = 0
  P[1] = 0
  for i in range(2, n + 1):
    if P[i]:
      for j in range(2 * i, n + 1, i):
        P[j] = 0
  return P
primes = prime_table(10 ** 5)
Like2017 = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
  if i % 2:
    Like2017[i] = primes[i] * primes[(i + 1) // 2]
  Like2017[i] += Like2017[i - 1]
for i in range(Q):
  l, r = map(int, input().split())
  print(Like2017[r] - Like2017[l - 1])

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (count(s.begin(),s.end(), s[i]) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b, c;
	vector<ll> v;

	cin >> a >> b >> c;

	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end());

	cout << v[0] + v[1] << endl;
}

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


int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double time = (60*h+m);
  double wa = (time*PI/360);
  double wb = (time*PI/30);
  double w = (wb - wa);
  
 
  double ans = (sqrt(a*a + b*b - 2 * a * b * cos(w)));
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

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

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


int main(){
    int a,b;
    cin>>a>>b;
    int m = (a+b)/2;
    if( abs(a-m) == abs(b-m) )cout<<m<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


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

    int co=0;
    for(int i=0;i<s.size()/2;i++){
        if(s.at(i)!=s.at(s.size()-1-i)){
            co++;
        }
        
    }
    
    cout<<co;
}


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

lint n, m, k;
lint mod = 998244353;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

int main() {
    cin >> n >> m >> k;
    combination_mod comb(n, mod);
    lint ans = 0;
    for (int i = 0; i <= k; i++) {
        lint add = comb.query(n - 1, i);
        add = (add * m) % mod;
        add = (add * pow_mod(m - 1, n - i - 1, mod)) % mod;
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7932
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    auto f = [&](vector<ll> &a){
        ll sum = 0;
        rep(i,n)sum += a[i] / n;
        ll c;
        rep(i,n){
            c = a[i] / n;
            a[i] -= c * n;
            a[i] += sum - c;
        }
        ans += sum;
        return sum != 0;
    };
    ll cnt = 0;
    while(f(a)){cnt++;};
    debug(cnt);
    cout << ans << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
x = 0
X = B%(A-1)
Y = B//(A-1)

if B == 1:
  print(0)
elif A ==2:
  print(B-1)
elif A >= B:
  print(1)
elif X <= 1:
  print(Y)
else:
  print(Y + 1)
  

Measured memory_bytes: 2940