akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
 
 
template< typename Data, typename T >
struct ReRooting {
 
  struct Node {
    Int to, rev;
    Data data;
  };
 
  using F1 = function< T(T, T) >;
  using F2 = function< T(T, Int, Int, Data) >; // ret, src, to, data
 
  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< Int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;
 
  ReRooting(Int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}
 
  void add_edge(Int u, Int v, const Data &d) {
    g[u].emplace_back((Node) {v, (Int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (Int) g[u].size() - 1, d});
  }
 
  T dfs(Int idx, Int par) {
    while(lptr[idx] != par && lptr[idx] < (Int)g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }
 
  vector< T > solve() {
    for(Int i = 0; i < (Int)g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (Int) g[i].size() - 1;
    }
    vector< T > ret;
    for(Int i = 0; i < (Int)g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};
 
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  auto f1=[m](Int a,Int b){return a*b%m;};
  auto f2=[m](Int res,Int a,Int b,Int d){return (res+1)%m;};
  ReRooting<Int, Int> G(n,f1,f2,1);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y,1);
  }
  auto ans=G.solve();
  for(Int x:ans) cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 39796
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}
ll mo = 1000000000+7;
ll powmod (int n,int k){
    ll res = 1;
    for(int i = 0; i < k ; i++){
        res = res * n %mo;
    }
    return res;
}
int main(){
    ll s,mod = 1000000007;
    cin >> s;
    vector<int> vec(s+1);
    ll x = 0;
    vec[0] = 1;
    for(int i = 1;i<=s;i++){
        if(i-3 >= 0){
            x += vec[i-3];
            x %= mod;
        }
        vec[i] = x;
    }
    cout << vec[s]%mod <<endl;
}





Measured memory_bytes: 3616
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e6+5;

int32_t main(){
   
   speed_cubing
   
   int n;
   cin>>n;

   map<string,int> m;

   for(int i=0;i<n;i++){
      string s;
      cin>>s;
      m[s]++;
   }

   cout<<"AC x "<<m["AC"]<<endl;
   cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
   cout<<"RE x "<<m["RE"]<<endl;

   return 0;
}

Measured memory_bytes: 3668
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],sum[100005],temp[100005];
long long cnt,num;
void merge_sort(int l,int r)
{
	if(l>=r) return;
	int mid=(l+r)/2;
	merge_sort(l,mid);
	merge_sort(mid+1,r);
	int i=l,j=mid+1,k=l;
	while(i<=mid&&j<=r)
	{
		if(sum[i]<=sum[j]) temp[k++]=sum[i++];
		else cnt+=mid-i+1,temp[k++]=sum[j++];
	}
	while(i<=mid) temp[k++]=sum[i++];
	while(j<=r) temp[k++]=sum[j++];
	for(i=l;i<=r;i++) sum[i]=temp[i];
}
bool check(int x)
{
	sum[0]=cnt=0;
	for(int i=1;i<=n;i++) sum[i]=a[i]<=x?-1:1;
	for(int i=1;i<=n;i++) sum[i]+=sum[i-1];
	merge_sort(0,n);
	return cnt>=num/2+1;
}
int main()
{
	int l=INT_MAX,r=INT_MIN;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),l=min(l,a[i]),r=max(r,a[i]),num+=i;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 1408
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n;
  cin >> n;
  vll a(n),b(n),c(n);
  vll p(n,0),q(n+1,0);

  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];

  vsort(a);
  vsort(b);
  vsort(c);

  ll j = 0;
  ll k = 0;

  ll ans = 0;

  rep(i,n)
  {
    for(; j < n; ++j)
    {
      if(b[i] < c[j])
        break;
    }

    p[i] = n - j;
  }

  for(ll i = 0;i < n; ++i)
  {
    q[n-i-1] = q[n-i] + p[n-i-1];
  }

  j = 0;
  rep(i,n)
  {
    for(;j < n; ++j)
    {
      if(a[i] < b[j])
        break;
    }
    ans += q[j];
  }



  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 4224
n = int(input())
l = list(map(int,input().split()))

dp = [float('inf')]*n

dp[0] = 0
dp[1] = abs(l[0]-l[1])

for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(l[i]-l[i-2]), dp[i-1]+abs(l[i]-l[i-1]))

print(dp[n-1])

Measured memory_bytes: 14108
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int n, x; cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum=0;
    rep(i,n) sum += a[i];
    sort(a.begin(), a.end());
    int ans = n + (x-sum)/a[0];
    cout << ans << endl;

}


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

int main(){
    int k,s; cin>>k>>s;

    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(0<=s-i-j&&s-i-j<=k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef vector<int> Node;
typedef vector<Node> Graph;
typedef pair<int, int> P;
typedef tuple<int, int, int, int> T;
const int INF = 1000000000;

int main(){
    int N, M;
    while(cin >> N >> M) {
        vector<string> s(N);
        REP(i, N) cin >> s[i];

        bool d[100][100] = {};
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            d[a][b] = true;
        }

        vector<P> next[100][10][26];
        REP(i, N) REP(j, s[i].size()) {
            if(j == s[i].size() - 1) {
                REP(k, N) if(d[i][k]) {
                    next[i][j][ s[k][0] - 'a' ].push_back(P(k, 0));
                }
            } else {
                next[i][j][s[i][j+1] - 'a'].push_back(P(i, j+1));
            }
        }

        vector<P> nextr[100][10][26];
        REP(i, N) REP(j, s[i].size()) {
            if(j == 0) {
                REP(k, N) if(d[k][i]) {
                    nextr[i][j][ s[k][s[k].size() - 1] - 'a' ].push_back(P(k, s[k].size() - 1));
                }
            } else {
                nextr[i][j][s[i][j-1] - 'a'].push_back(P(i, j-1));
            }
        }


        int dist[100][10][100][10] = {};
        bool inque[100][10][100][10] = {};
        //REP(i, N) REP(j, s[i].size()) REP(k, N) REP(l, s[k].size()) dist[i][j][k][l] = INF;

        queue<T> que;

        REP(i, N) REP(k, N) {
            if(s[i][0] == s[k][s[k].size() - 1]) {
                que.push(T(i, 0, k, s[k].size() - 1));
                dist[i][0][k][s[k].size() - 1] = 1;
            }
        }

        int ans = 0;
        const int MAX_D = 100000 / 100;
        while(!que.empty()){
            int a, i, b, j;
            tie(a, i, b, j) = que.front();
            que.pop();
            inque[a][i][b][j] = false;

            int cdist = dist[a][i][b][j];

            if(cdist > MAX_D) continue;

            //printf("(%d, %d) (%d, %d) : %d\n", a, i, b, j, cdist);

            if(a == b && i == j) {
                ans = max(ans, 2 * cdist - 1);
            }
            bool exist = false;
            REP(c, 26) for(auto p : next[a][i][c]) if(p.first == b && p.second == j) exist = true;
            if(exist) {
                ans = max(ans, 2 * cdist);
            }

            REP(c, 26) for(auto p : next[a][i][c]) for(auto q : nextr[b][j][c]) {
                int& ndist = dist[p.first][p.second][q.first][q.second];
                bool& inq = inque[p.first][p.second][q.first][q.second];
                if(ndist < cdist + 1) {
                    ndist = cdist + 1;
                    if(!inq) {
                        que.push(T(p.first, p.second, q.first, q.second));
                        inq = true;
                    }
                }
            }
        }
        if(ans >= MAX_D + 1) ans = -1;

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

Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,W;cin>>n>>W;
    ll w[n+1],v[n+1];rep(i,1,n)cin>>w[i]>>v[i];
    ll dp[n+1][n*1000+1];
    dp[0][0]=0;
    rep(i,1,1000*n){
        dp[0][i]=inf;
    }
    rep(i,1,n){
        rep(j,0,n*1000){
            if(j-v[i]<0){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            }
        }
    }
    /*
    rep(i,0,n){
        rep(j,0,n*1000){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    ll ans=0;
    rep(i,0,1000*n){
        if(dp[n][i]<=W){
            ans=i;
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n, t;
  cin >> n >> t;
  ll ans = 0;
  ll bf = 0;
  rep(i, n){
    ll in;
    cin >> in;
    if(bf < in){
      ans += t;
    }else{
      ans += in+t-bf;
    }
    bf = in + t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[211111], t[211111];

int main(void)
{
	int n, i;

	scanf("%d", &n);
	for (i = 2; i <= n; i++)
	{
		scanf("%d", &a[i]);
		t[a[i]]++;
	}

	for (i = 1; i < n; i++)
		printf("%d\n", t[i]);
	printf("0");
	return 0;
}

Measured memory_bytes: 3248
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int pre_max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int max = Arrays.stream(arr).max().getAsInt();
        boolean max_double = Arrays.stream(arr).filter(i -> i==max).count() > 1;
        if(max_double) {
            for (int i = 0; i < n; i++) {
                System.out.println(max);
            }
            return;
        }
        for (int i = 0; i < n; i++) {
            if(arr[i] == max) continue;
            if(arr[i] > pre_max) {
                pre_max = arr[i];
            }
        }
        for (int i = 0; i < n; i++) {
            if(arr[i] == max) {
                System.out.println(pre_max);
            } else {
                System.out.println(max);
            }
        }
    }
}

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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll s,w;
        cin >> s >>w;
        if(w>=s)
            cout << "unsafe" << endl;
        else
            cout << "safe" << endl;
    }
}


Measured memory_bytes: 3656
fun main(args: Array<String>) {
    for(i in 3..1){
        println(i)
    }
    val(n,m,x,y)= readLine()!!.split(" ").map{it.toInt()}
    val rx= readLine()!!.split(" ").map{it.toInt()}.max()!!
    val ly= readLine()!!.split(" ").map{it.toInt()}.min()!!
    for(pos in rx+1..ly){
        if((x+1..y).contains(pos)){
            println("No War")
            return
        }
    }
    println("War")
}

Measured memory_bytes: 37740
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int K, A, B, i, tmpK = 0, t = 0;
  unused = scanf("%d", &K);
  unused = scanf("%d %d", &A, &B);

  i=1;
  while(tmpK <= 1000){
    tmpK = i*K;
    if(A <= tmpK && tmpK <= B) t = 1;
    i++;
  }
  if(t==1) printf("OK");
  else printf("NG");
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
int main(){
  int N;
  int v;
  int i;
  int j;
  int count;
  int x;
  int A[10000];

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf(" %d",&A[i]);
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i == N - 1) break;
    printf(" ");
  }
  printf("\n");
  
  for(i = 1;i<N;i++){
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j+1] = v;
    
    for(x = 0;x<N;x++){
	printf("%d",A[x]);
	if(x == N-1) break;
	printf(" ");
    }
      printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();

            int hug = 0;

            for (int i = 0; i < S.Length / 2; i++) {
                if (S[i] != S[S.Length - 1 - i]) {
                    hug++;
                }
            }

            Console.WriteLine(hug);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N, C;
  cin >> N >> C;
  bool on_off[C][100000];
  for(int i=0; i<C; i++)
    for(int j=0; j<100000; j++)
      on_off[i][j] = false;
  for(int i=0; i<N; i++){
    int s, t, c;
    cin >> s >> t >> c;
    for(int j=s-1; j<t; j++){
      on_off[c-1][j] = true;
    }
  }
  int ret = 0;
  for(int i=0; i<100000; i++){
    int tmp = 0;
    for(int j=0; j<C; j++){
      if(on_off[j][i])
        tmp++;
    }
    ret = max(ret, tmp);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3200
import numpy as np
import sys
k = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[k-1])

Measured memory_bytes: 21776
l,r=map(int, input().split())
if l//673 != r//673 and l//3 != r//3:
  print(0)
else:
  ans=2019**2
  for i in range(l,r):
    for j in range(i+1,r+1):
      if (i*j)%2019 < ans:
        ans = (i*j)%2019
  print(ans)

Measured memory_bytes: 9108
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int a, b, c; cin >> a >> b >> c;
    int cnt[110] = {};
    cnt[a]++; cnt[b]++; cnt[c]++;
    int ans = 0;
    rep(i,0,101) {
        if(cnt[i] != 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var abcd = IO.ReadSplitInt;
            int ans = Min(abcd[1], abcd[3]) - Max(abcd[0], abcd[2]);
            if (ans < 0) ans = 0;
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

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

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

    int count = 0;

    if (s[0] == 'o'){
        ++count;
    }
    if (s[1] == 'o'){
        ++count;
    }
    if (s[2] == 'o'){
        ++count;
    }
    cout << 700 + count * 100 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(void) {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

    cout << (n-1+k-2) / (k-1) << endl;

}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  static long x;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    x = sc.nextLong();

    if(x <= 6){
      System.out.println(1);
      return;
    }

    if(x <= 11){
      System.out.println(2);
      return;
    }

    long s;
    if(x % 11 == 0){
      s = (x / 11) * 2;
    }
    else if(x % 11 <= 6){
      s = (x / 11) * 2 + 1;
    }
    else{
      s = (x / 11) * 2 + 2;
    }

    System.out.println(s);
  }
}


Measured memory_bytes: 23508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int main(){
  int A=0,B=0,i;

  rep(i,4){
    int t;
    scanf("%d",&t);
    A += t;
  }
  rep(i,4){
    int t;
    scanf("%d",&t);
    B += t;
  }

  cout << max(A,B) << endl;

  return 0;
}

Measured memory_bytes: 0
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String s = buf.readLine();
        int x = Integer.parseInt(s);
        int res = x * x * x;
        System.out.println(res);
    }
}

Measured memory_bytes: 24172
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,x=0,y;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c,d=0,e=0,f=0,g=1,h=0;
    cin >>a>>b>>c;
    if(a+b+c>=22) cout <<"bust\n";
    else cout <<"win\n";
    return (0);
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
    char a[200001], b[200001];
    int s=0, i=0;
 
    scanf("%s",a);
    scanf("%s",b);
 
    while(a[i]!='\0'){
        if(a[i] != b[i]){
            a[i] = b[i];
            s++;
        }
        i++;
    }
    printf("%d",s);
  
    return 0;
}

Measured memory_bytes: 2120
s = input()

if len(s) < 5:
    print("NO")
    exit()

for i in range(0, 9, 2):
    if i == 8 and len(s) <= 8:
        s = s[:i] + "A" + s[i:]
    elif i != 2:
        if s[i] != "A":
            s = s[:i] + "A" + s[i:]
if s == "AKIHABARA":
    print("YES")
else:
    print("NO")

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

int n;
map<int, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++mp[a];
  }
  
  vector<long> v;
  for (auto p : mp) {
    v.push_back(p.second);
  }
  
  const long m = v.size();
  sort(v.begin(), v.end());
  vector<long> p(m + 1);
  partial_sum(v.begin(), v.end(), p.begin() + 1);

  vector<long> xs;
  for (int i = 0; i < m; ++i) {
    long ya = p[i];
    long yb = p[i + 1];
    xs.push_back(i - ya / (yb - ya));
  }

  for (int i = 1; i <= n; ++i) {
    long x = m - i;
    long ans;
    if (x < 0) {
      ans = 0;  
    } else {
      long k = upper_bound(xs.begin(), xs.end(), x) - xs.begin();
      ans = p[k] / (k - x);
    }
    cout << ans << endl;
  }
}


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

using namespace std;
#define PI 3.14159265359

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}



int main(){
    int i,r;
    //入力
    cin>>r;
    //処理
    //出力
    cout<<2*r*PI;
}

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


int main() {
	
	int s;
	cin >> s;
	const int N = 1000000;
	vector<int> a(N);
	a.at(0) = s;
	set<int> t;
	t.insert(s);
	for(int i=1; i<N; i++){
		if(a.at(i-1)%2==0) a.at(i) = a.at(i-1) / 2;
		else a.at(i) = 3*a.at(i-1) +1;
		if( t.count( a.at(i) ) ) {
			cout << i+1 << endl;
			break;
		}
		t.insert(a.at(i));
	}
		
	
	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>

int main()
{
	char buf[256];

	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		while ( !( strstr(buf, "the") != NULL || strstr(buf, "this") != NULL || strstr(buf, "that") != NULL ) ) {
			int i;
			for (i = 0; i < strlen(buf); i++) {
				if ( !isalpha(buf[i]) ) {
					// do nothing;
				} else if (buf[i] == 'z') {
					buf[i] = 'a';
				} else {
					buf[i]++;
				}
			}
		}
		printf("%s", buf);
	}
	return 0;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;

const int MOD = 1000000007;
const int INF = 1000000000;

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

int main(){
    string s, t; cin >> s >> t;
    VS ans;
    REP(i, SZ(s) - SZ(t) + 1){
        bool okay = true;
        REP(j, SZ(t)){
            if((s[i+j] != t[j]) && (s[i+j] != '?')) okay = false;
        }
        if(!okay) continue;
        string a = s;
        REP(j, SZ(s)){
            if(i <= j && j < i + SZ(t)) a[j] = t[j-i];
            else if(a[j] == '?') a[j] = 'a';
        }
        ans.PB(a);
    }
    if(!SZ(ans)){
        cout << "UNRESTORABLE\n"; return 0;
    }
    SORT(ans);
    cout << ans[0] << "\n";
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    string S;
    set<string> gacha;

    for (int i = 0; i < N; i++) {
        cin >> S;
        gacha.insert(S);
    }
    cout << gacha.size() << endl;
    return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define reQv(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
    IOS;
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    for(ll i=k; i<=n+1; i++){
            ll x=i*(2*n-i+1);
            x/=2;
            ll y=(i*(i-1));
            y/=2;
            ll temp=(x-y+1);
            ans+=(temp);
            ans%=mod;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <set>

using namespace std;

int main()
{
	// 入力
	int s;
	cin >> s;
	set<int> a;
	
	int answer = 0;
	int n = s;
	// 重複の値が出たら抜ける
	while (a.count(n) == 0)
	{	
		a.insert(n);
		// 偶数
		if (n % 2 == 0)
		{
			n = n / 2;
		}
		// 奇数
		else {
			n = 3 * n + 1;
		}
	}
	
	answer = a.size() + 1;
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
        cin>>b[i];
    rev(b);
    ll p=0,q=0;
    while(p<n && a[p]!=b[p])
        p++;
    while(p<n && q<n && a[p]==b[p])
    {
        while(q<n && (a[q]==a[p] || b[q]==a[p]))
            q++;
        if(q==n)
        {
            cout<<"No";
            return 0;  
        }
        swap(b[p],b[q]);
        p++;
    }
    cout<<"Yes\n";
    for(auto i:b)
        cout<<i<<' ';
    subt;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  int N2 = N * 2;
  vector<pair<PLL,int>> xs(N);
  vector<PLL> a(N2);
  REP(i,N){
	cin >> xs[i].FF;
	if(xs[i].FF.FF > xs[i].FF.SS)
	  swap(xs[i].FF.FF, xs[i].FF.SS);
	xs[i].SS = i;
	
	a[i*2] = MP(xs[i].FF.FF, i);
	a[i*2+1] = MP(xs[i].FF.SS, i);
  }
  SORT(a);
  SORT(xs);
  LL ans = 1e18;

  {
	LL mn = a.front().FF;
	LL mx = a.back().FF;
	REP(i,N){
	  if(a.front().SS != xs[i].SS)
		maxi(mn, xs[i].FF.FF);
	  if(a.back().SS != xs[i].SS)
		mini(mx, xs[i].FF.SS);
	}

	LL d1 = mn - a.front().FF;
	LL d2 = a.back().FF - mx;
	mini(ans, d1*d2);
  }
  if(a.front().SS != a.back().SS){
	LL d = a.back().FF - a.front().FF;
	multiset<LL> mt;
	REP(i,N){
	  if(a.front().SS == xs[i].SS){
		mt.insert(xs[i].FF.SS);
	  }
	  else{
		mt.insert(xs[i].FF.FF);
	  }
	}
	mini(ans, (*mt.rbegin() - *begin(mt)) * d);
	REP(i,N){
	  if(a.front().SS != xs[i].SS && a.back().SS != xs[i].SS){
		mt.erase(mt.find(xs[i].FF.FF));
		mt.insert(xs[i].FF.SS);
		mini(ans, (*mt.rbegin() - *begin(mt)) * d);
	  }
	}
  }
  
  cout << ans << endl;

  return 0;
}


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

 int main() {
   // 入力


  //おもり 1 W1 おもり2 W2 .... おもりN  Wn
  //T=5    S1 <T5   S2>T5  sum s1 vs sum s2 abs(s1-s2)=?

   int N;
   cin >> N;

   int i=0;
   int W[N]={0};

   for(i;i<N;i++){
     cin >> W[i];
     if(100<W[i]&&W[i]<1){
       return 1;
     }
   }

   int tmp=0;
   int sum[2]={0};
   int ans[N]={0};


   //3              123
   //1~N 0~N-1の配列要素 T(配列の番号は0スタート)
   int T;
   for(T=0;T<N;T++){
     sum[0]=0;
     sum[1]=0;
     for(i=0;i<N;i++){

       if(i<=T){
         sum[0]+=W[i];
       }
       else{
         sum[1]+=W[i];
       }
     }

     //cout << "sum0="<<sum[0]<<"\n";
     //cout << "sum1="<<sum[1]<<"\n";
     ans[T]=abs(sum[0]-sum[1]);
     //cout << "ans="<<ans[T]<<"\n";
   }
   sort(ans,ans+N);
   cout << ans[0];






 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pair<pii,pair<int,pii> >, null_type, less<pair<pii,pair<int,pii> > >, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
	fast;
	int n;cin>>n;
	int *arr=new int[n];
	int ans=0;
	for(int i=0;i<n;i++)
		cin>>arr[i];

	for(int i=0;i<n;i++)
	{
		if(i%2==0 and arr[i]&1)
			ans++;
	}

	cout<<ans;
}

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

int A[1001][1000];
int indices[1001];
bool changed[1001];
int done[1000];

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

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N - 1; ++j) {
            cin >> A[i][j];
        }
    }

    for (int i = 1; i <= N; ++i) {
        indices[i] = 1;
        changed[i] = true;
    }

    for (int day = 1; ; ++day) {
        bool is_complete = true;
        int index = 0;

        for (int i = 1; i <= N; ++i) {
            if (indices[i] >= N || !changed[i]) continue;

            is_complete = false;
            
            int another = A[i][indices[i]];
            
            if ((i < another || !changed[another]) && A[another][indices[another]] == i) {
                done[index++] = i;
                done[index++] = another;
            }
        }

        if (is_complete) {
            cout << (day - 1) << endl;
            return 0;
        }

        if (index == 0) {
            cout << -1 << endl;
            return 0;
        }

        for (int i = 1; i <= N; ++i) {
            changed[i] = false;
        }

        for (int i = 0; i < index; ++i) {
            ++indices[done[i]];
            changed[done[i]] = true;
        }
    }

    return 0;
}


Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    def f(cnd):
        for i in range(1, N):
            if S[i] == 'o' and cnd[i] == 'S':
                cnd.append(cnd[i-1])
            elif S[i] == 'o' and cnd[i] == 'W':
                cnd.append('S' if cnd[i-1] == 'W' else 'W')
            elif S[i] == 'x' and cnd[i] == 'S':
                cnd.append('S' if cnd[i-1] == 'W' else 'W')
            elif S[i] == 'x' and cnd[i] == 'W':
                cnd.append(cnd[i-1])

        cnd.pop()
        for i in range(N):
            if cnd[i] == 'S' and S[i] == 'o':
                if cnd[(i+1) % N] != cnd[i-1]:
                    return None
            elif cnd[i] == 'S' and S[i] == 'x':
                if cnd[(i+1) % N] == cnd[i-1]:
                    return None
            elif cnd[i] == 'W' and S[i] == 'o':
                if cnd[(i+1) % N] == cnd[i-1]:
                    return None
            elif cnd[i] == 'W' and S[i] == 'x':
                if cnd[(i+1) % N] != cnd[i-1]:
                    return None
        return ''.join(cnd)
    # SS
    ans = f(['S', 'S'])
    if ans:
        return ans

    # SW
    ans = f(['S', 'W'])
    if ans:
        return ans

    # WS
    ans = f(['W', 'S'])
    if ans:
        return ans

    # WW
    ans = f(['W', 'W'])
    if ans:
        return ans

    return -1


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


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

int main(){
	int a,b;
	cin >> a >> b;
	if(b == 1){
		cout << 0 << endl;
		return 0;
	}
	int count;
	if((b - 1) % (a - 1)  == 0){
		count = (b - 1) / (a - 1);
	}else{
		count = (b - 1) / (a - 1) + 1;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256