akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

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

signed main(){
    int h, w, k;
    cin >> h >> w >> k;
    string a[h];
    rep(i,h){
        cin >> a[i];
    }
    int sy,sx;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == 'S'){
                sy = i;
                sx = j;
            }
        }
    }
    int dist[h][w];
    fill(dist[0], dist[h], INF);
    queue<P> que;
    que.emplace(sy, sx);
    dist[sy][sx] = 0;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        rep(i,4){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if(dist[ny][nx] != INF || a[ny][nx] == '#') continue;
            que.emplace(ny, nx);
            dist[ny][nx] = dist[p.first][p.second] + 1;
        }
    }
    int ans = INF;
    rep(i,h){
        rep(j,w){
            if(dist[i][j] <= k){
                ans = min(ans, 1 + min({(i + k - 1) / k, ((h - 1) - i + k - 1) / k, (j + k - 1) / k, ((w - 1) - j + k - 1) / k}));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const long long N = 10e9+7;
int fil, col;
char arr [1001][1001];
long long formas [1001][1001];

long long f(int fi, int co)
{
    long long dev;
    if(formas[fi][co] != -1)
        dev= formas[fi][co];

    else
    {if(fi==0 && co==0)
    {
        formas[0][0] = 1;
        dev= 1;
    }
    else if( (fi==0 || arr[fi-1][co]=='#') && (co==0 || arr[fi][co-1]=='#'))
    {
        //cout<<"HEY"<<endl;
        formas[fi][co] = 0;
        dev= formas[fi][co];
    }

    else if(fi-1 >= 0 && arr[fi-1][co]!='#')
    {
        if(co-1 >= 0 && arr[fi][co-1]!='#')
        {
            formas[fi][co] = f(fi-1, co) + f(fi, co-1);
            dev= formas[fi][co];
        }
        else
        {
            formas[fi][co] = f(fi-1, co);
            dev= formas[fi][co];
        }
    }
    else
    {
        formas[fi][co] = f(fi, co-1);
        dev= formas[fi][co];
    }
    }
    if(dev >= 1000000007)
        return dev%1000000007;
    else
        return dev;
}

int main()
{
    cin>>fil>>col;
    for(int i = 0; i < fil; i++)
    {
        for(int j = 0; j < col; j++)
        {
            cin>>arr[i][j];
        }
    }
    memset(formas, -1, sizeof formas);
    long long res = f(fil-1, col-1);
   // if (res >= N)
    cout<<res<<endl;
    //cout<<res%(N)<<endl;
    //else
     //   cout<<res<<endl;
    
    /*for(int i = 0; i < fil; i++)
    {
        for(int j = 0; j < col; j++)
        {
            cout<<formas[i][j]<<" ";
        }
        cout<<endl;
    }*/
}

Measured memory_bytes: 12088
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

int K, S;

int main(void) {
    int ans = 0;
    cin >> K >> S;
    REP(i, K + 1) REP(j, K + 1) {
        if (S - i - j < 0) continue;
        if (S - i - j > K) continue;
        ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	unsigned long long debt = 100000;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		debt *= 1.05;
		const int mod = debt % 1000;
		if (mod != 0) {
			debt -= mod - 1000;
		}
	}
	cout << debt << endl;

	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N, X;
    cin >> N >> X;
    vi req(N);
    for (int i = 0; i < N; i++)
        cin >> req[i];

    sort(all(req));

    int sat = 0;
    for (int v : req) {
        if (v <= X) {
            X -= v;
            sat++;
        }
    }

    if (sat == N) {
        cout << sat - (X > 0) << endl;
    } else {
        cout << sat << endl;
    }

    return 0;
}



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

using namespace std;

int main() {
	int a, b, c, d ,e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if (k >= e - a) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}


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

int main() {
	int H1,M1,H2,M2,K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	
	int ans = 60 - M1 + (H2 - H1 - 1)*60 + M2;
	
	ans = ans - K;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3624
def count_pop(y):
  count = 0
  while y != 0:
    if y & 1 == 1:count+=1
    y = y >> 1
  return count
  
def main():
  N = int(input())
  X = input()
  X_val=int(X,2)
  X_pc=X.count('1')
  x_mod_pc_x_plus_1 = X_val % (X_pc + 1)
  x_mod_pc_x_minus_1 = X_val % max(X_pc - 1, 1)
  for i in range(N):
    if X[i] == '1':
      pc = X_pc - 1
      if pc == 0:
        print(0)
        continue
      val = (x_mod_pc_x_minus_1 - pow(2, N-i-1, pc)) % pc
    else:     
      pc = X_pc + 1
      val = (x_mod_pc_x_plus_1 + pow(2, N-i-1, pc)) % pc
    ans = 1   
    while val > 0:
      val %= bin(val).count('1')
      ans += 1
    print(ans)
  pass       
if __name__=='__main__':
  main()



Measured memory_bytes: 9440
/*
https://qiita.com/ofutonfuton/items/550c984f08e39a189ca6#d%E5%95%8F%E9%A1%8C
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

struct UnionFind{
vi par;
UnionFind(int N) : par(N){
   rep(i,N)par[i]=i;
}

int root (int x){
   if(par[x]==x)return x;
   return par[x]=root(par[x]);
}

void unite(int x,int y){
int rx=root(x);
int ry=root(y);
if(rx==ry)return;
par[rx]=ry;
}

bool same(int x,int y){
   int rx=root(x);
   int ry=root(y);
return rx==ry;
}
};

int main(){
    int N,M;
    cin>>N>>M;
    vi p(N);
    rep(i,N)cin>>p[i];

    UnionFind tree(N);
    rep(i,M){
        int x,y;
        cin>>x>>y;
        tree.unite(x-1,y-1);
    }

    int cnt=0;
    rep(i,N){
        if(tree.same(i,p[i]-1)){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
map<pair<int,int>,int> mp;
int dy[9] = {0,1,1,0,-1,-1,-1,0,1};
int dx[9] = {0,0,1,1,1,0,-1,-1,-1};
vector<ll> ans(10);

int main(){
  ll h, w, n;
  cin >> h >> w >> n;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    for (int j = 0; j < 9; j++) {
      mp[make_pair(a + dx[j], b + dy[j])]++;
    }
  }
  ans[0] = (h - 2) * (w - 2);
  for (auto p : mp) {
    if (p.first.first >= 2 && p.first.first <= h - 1
        && p.first.second >= 2 && p.first.second <= w - 1) {
          ans[p.second]++;
          ans[0]--;
        }
  }
  for (int i = 0; i <= 9; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56448
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const ll inf = (1LL<<31)-1;
const long long MOD = 1000000007;



int main() {
    int n;
    cin >> n;
    int ans=0;
    rep(i, n) {
        int a;
        cin >> a;
        if (i % 2 == 0)if (a %2== 1)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3092
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();
            var s = a[0] * 10 + a[1] + a[2];

            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cmath>
using namespace std;
long long a[1005],b[1005];
int n,m,cnt;
long long x,y;
char s[45];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if((a[i]+b[i])&1) cnt++;
		else cnt--;
	}
	if(abs(cnt)!=n){
		cout<<-1;
		return 0;
	}
	m=31+(cnt<0);
	cout<<m<<endl;
	for(int i=0;i<=30;i++){
		cout<<(1<<i)<<" ";
	}
	if(cnt<0) cout<<1;
	cout<<endl;
	for(int i=1;i<=n;i++){
		int x=a[i],y=b[i];
		if(cnt<0) s[31]='R',x--;
		int flag=0;
		for(int j=30;j>=0;j--){
			if(abs(x)<abs(y)) swap(x,y),flag^=1;
			if(x>0) x-=(1<<j),s[j]=flag?'U':'R';
			else x+=(1<<j),s[j]=flag?'D':'L';
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>

using namespace std;
vector<int> edge[200000];
int d[2][200000];
int INF = 1e9;

int opposite = 0;
int max_dist = 0;

void f(int index,int x){
  int dx = d[index][x];
  if(dx > max_dist){
    opposite = x;
    max_dist = dx;
  }
  int s = edge[x].size();
  for(int i=0;i<s;i++){
    int y = edge[x][i];
    if(d[index][y] == INF){
      d[index][y] = dx+1;
      f(index,y);
    }    
  }
  return;
}

int main(){
  for(int i=0;i<2;i++){
    for(int j=0;j<2e5;j++){
      d[i][j] = INF;
    }
  }
  int N;
  cin >> N;
  if (N == 1){
    cout << "First" << endl;
    return 0;
  }
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
  }
  d[0][0] = 0;
  f(0,0);
  d[1][opposite] = 0;
  f(1,opposite);
  string answer = (max_dist%3 != 1 ? "First" : "Second");
  cout << answer << endl;  
}

Measured memory_bytes: 25216
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;
struct call{
	int n;
	ll l;
	call *next;
	call *end;
	call(int n=0,ll l=0,call *next=NULL,call *end=NULL):n(n),l(l),next(next),end(end) {}
};
call g[100010];
ll ls[100010]={0};
void create(int a,int b,ll c)
{
	if(g[a].n == 0)
	{
		g[a].n = b;
		g[a].l = c;
		g[a].end = &g[a];
		return ;
	}
	g[a].end->next = (call*)malloc(sizeof(call));
	g[a].end = g[a].end->next;
	g[a].end->n = b;
	g[a].end->l = c;
	g[a].end->next = NULL;
}
void find(int k,int u)
{
	call *no;
	no = &g[k];
	while(no != NULL)
	{
		if(no->n != u)
		{
			ll l;
			ls[no->n] = ls[k]+no->l;
			find(no->n,k);
		}
		no = no->next;
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int t;
	for(t=1;t<n;t++)
	{
		int a,b;
		ll c;
		scanf("%d%d%lld",&a,&b,&c);
		create(a,b,c);
		create(b,a,c);
	}
	int q,k;
	scanf("%d%d",&q,&k);
	find(k,0);
	while(q--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%lld\n",ls[a]+ls[b]);
	}
	return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << 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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() { // 子供たちはRLの場所に集まる
	string s;
	cin >> s;
	int n = s.size();
	V ans(n, 0);
	int k = 0;
	int g = 0;
	bool e = true;
	rep(i, n - 1) {
		if (s[i] == 'L') continue;
		if (e) g++;
		else k++;
		e ^= true;
		if (s[i] == 'R' && s[i + 1] == 'L') {
			ans[i] += g;
			ans[i + 1] += k;
			g = 0; k = 0;
			e = true;
			i++;
		}
	}
	e = true;
	g = 0; k = 0;
	for (int i = n - 1; i >= 1; i--) {
		if (s[i] == 'R') continue;
		if (e) g++;
		else k++;
		e ^= true;
		if (s[i] == 'L' && s[i - 1] == 'R') {
			ans[i] += g;
			ans[i - 1] += k;
			g = 0; k = 0;
			e = true;
			i--;
		}
	}
	rep(i, n) cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 1024
//42
#include<iostream>

using namespace std;

int main(){
  for(int w,h;cin>>w>>h,w|h;){
    int g[102][102][2][2]={{{{}}}};
    g[0][1][0][1]=g[1][0][1][1]=1;
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	for(int d=0;d<2;d++){
	  for(int v=0;v<2;v++){
	    if(v==0){
	      static int dy[]={0,1};
	      static int dx[]={1,0};
	      (g[y+dy[d]][x+dx[d]][d][1]+=g[y][x][d][v])%=100000;
	    }else{
	      (g[y+1][x][1][d==1]+=g[y][x][d][v])%=100000;
	      (g[y][x+1][0][d==0]+=g[y][x][d][v])%=100000;
	    }
	  }
	}
      }
    }
    int ans=0;
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
	ans+=g[h-1][w-1][i][j];
      }
    }
    cout<<ans%100000<<endl;
  }
  return 0;
}
  

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

int main(){
    int n;
    cin >> n;
    bool Just_N=false;
    for(int i=0;i<=n/4;i++){
        for(int j=0;j<=n/7;j++){
            if(4*i+7*j==n){
                Just_N=true;
                break;
            }
        }
    }
    if(Just_N)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ar[1000005];
int main()
{
    ll n,mod,div,i,sum=0,a,x,y;
    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    vector<char>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum+=a;
        //mp[a]++;
        ar[a]++;
    }
    cin>>mod;
    for(i=0;i<mod;i++)
    {
        cin>>x>>y;
        if(ar[x]>0)
        {
            //it=mp[x].second;
            div=ar[x];
            sum=sum-x*div;
            //mp.erase(x);
            ar[x]=0;
            //mp.insert({y,it});
            ar[y]+=div;
            sum=sum+div*y;
        }
        cout<<sum<<endl;
    }
    mp.clear();
    return 0;
}


Measured memory_bytes: 4352
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#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;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;
ll n ,x , t;
void solve(){
	string s ;
	cin>> s ;
	ll ans=0;
	for(ll i=0;i<s.length() ; i++){
		ans += (s[i]-'0');
	}
	if(ans%9)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll N,T,l,r,ans=0;
	cin >> N >> T;
	ll imos[T+4]={};
	FOR(i,0,N){
		cin >> l >> r;
		imos[l]++;
		imos[r]--;
	}
	ans = imos[0];
	FOR(i,1,T+2){
		imos[i] += imos[i-1];
		ans = max(ans,imos[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3928
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    long cnt = 0;
    for(int i = 0;i < n;i++)a[i]=sc.nextLong();
    for(int i = 0;i < n;i++)b[i]=sc.nextLong();
    for(int i = 0;i < n;i++){
      if(b[i]-a[i]>=0)cnt+=(b[i]-a[i])/2;
      else cnt+=b[i]-a[i];
    }
    if(cnt>=0)System.out.println("Yes");
    else System.out.println("No");
  }
}

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

class ProblemDeadline
{
    public:
        long long process;  //処理に必要な時間
        long long deadline; //締め切り時刻

        ProblemDeadline(long long processTime, long long deadlineTime)
        {
            process = processTime;
            deadline = deadlineTime;
        };

        bool operator<(const ProblemDeadline &another) const
        {
            return deadline < another.deadline;
        };
};

int main(int argc, char *argv[])
{
    int n;
    int ans;
    std::vector<ProblemDeadline> deadline;

    std::cin >> n;

    deadline.reserve(n);

    for (int i = 0; i < n; i++) {
        long long a, b;
        std::cin >> a >> b;
        deadline.push_back(ProblemDeadline(a, b));
    }

    std::sort(deadline.begin(), deadline.end());

    long long time = 0;
    for (int i = 0; i < n; i++) {
        time += deadline[i].process;
        if (deadline[i].deadline < time) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;


int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b)cout << 0 << endl;
	else {
		if (n == 1 && b > a) {
			cout << 0 << endl;
		}
		else {
			cout << (n - 2)*(b - a) + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll A, P ;
    cin >> A >> P;
    cout <<( A*3 + P)/2 << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main() {
    int x,tx,f=0;
    cin>>x;
    tx=x;
    for(int i=0; i<=8; i++) {
        f += tx%10;
        tx /= 10;
    }
    if(x%f == 0) {
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }
}

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

using namespace std;

char ToLower(char ch){
    return tolower(ch);
} 

char ToUpper(char ch){
    return toupper(ch);
}

int main(){
    
    string W;
    string sentence="";
    int count=0;

    cin >> W;
    while(true){
        cin >> sentence;
        if(sentence=="END_OF_TEXT"){
            break;
        }
        string tr_W(W);
        string tr_sentence(sentence);
        transform(tr_W.begin(), tr_W.end(), tr_W.begin(), ToLower);
        transform(tr_sentence.begin(), tr_sentence.end(), tr_sentence.begin(), ToLower);
        if(tr_W==tr_sentence){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}




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

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

signed main() {

    string s;
    cin >> s;
    int cnt_a = 0, cnt_b = 0;
    for ( int i = 0; i < s.size(); i++ ) {
        if ( s[i]-'0' != (i&1) ) cnt_a++;
        if ( s[i]-'0' == (i&1) ) cnt_b++;
    }
    cout << min ( cnt_a, cnt_b ) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int main()
{
	int n,s,i,j,cnt,a[4],b,x,y,flg;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		flg=0;
		cnt=0;
		while(1){
			if(n==6174){
					printf("%d\n",cnt);
					break;
				}
			a[0]=n/1000;
			n%=1000;
			a[1]=n/100;
			n%=100;
			a[2]=n/10;
			a[3]=n%10;
			//printf("%d %d %d %d\n",a[0],a[1],a[2],a[3]);
			if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0){
				flg=1;
				break;
			}
			else if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]){
				printf("NA\n");
				break;
			}
			for(i=0;i<4-1;i++){
				for(j=i+1;j<4;j++){
					if(a[i]<a[j]){
						b=a[i];
						a[i]=a[j];
						a[j]=b;
					}
				}
			}
			y=a[0]*1000+a[1]*100+a[2]*10+a[3];
			x=a[3]*1000+a[2]*100+a[1]*10+a[0];
			n=y-x;
			//printf("x=%d y=%d n=%d\n",x,y,n);
			cnt++;
		}
		if(flg==1){
			break;
		}
	}
	return 0;
}
	


Measured memory_bytes: 2736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int T = in.nextInt();
			int X = in.nextInt();
			out.println((double)T / (double)X);
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
//#define f first
#define s second
#define int long long
#define vi vector<int>
#define pi pair<int,int>
const int mod = (int)1e9+7;
const int N = (int)1e5+7;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin >> t;
    int c = 1;
    while(t--)
    {
      int n,k;
      cin >> n;
      vector<int>v(n+1,0);
      for(int i=1;i<=n;i++)
      {
          int x;cin >> x;
          v[x]=i;
      }
     for(auto c:v){
         if(c)
            cout<<c<<" ";
     }
     
    }  
 
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, ans=0;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
  REP(i,N-1) cin >> C[i];
  REP(i,N) {
    ans+=B[A[i]-1];
    if(i>0) {
      if(A[i]==A[i-1]+1) {
        ans+=C[A[i]-2];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int flag[200010];
int main() {
  long long n, k;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> a[i];
  
  int pos = 1, cnt = 0;
  while(k) {
    pos = a[pos];
    k--;
    cnt++;
    if(flag[pos]) k %= (cnt-flag[pos]);
    else flag[pos] = cnt;
  }
  cout << pos << "\n";
}


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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int tmp = j - i;
      tmp = min(tmp, abs(i - X) + abs(j - Y) + 1);
      ans.at(tmp)++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << ans.at(i) << "\n";
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin>>s){
    int i=0,j=s.length()-1;
    for(;s[i]!='A';i++);
    for(;s[j]!='Z';j--);
    cout<<j-i+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3352
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int y1 = A-B;

    int nokori = C - y1;

    cout<<max(0,nokori)<<endl;
  
    return 0 ;
}

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

int main() {
  int m = 3;
  vector<vector<int>> a(m, vector<int>(m));
  rep(i, m) rep(j, m) cin >> a[i][j];
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];

  vector<vector<bool>> aa(m, vector<bool>(m));
  rep(i, n) {
    int tmp = b[i];
    rep(j, m) {
      rep(k, m) {
        if (a[j][k] == tmp) {
          aa[j][k] = true;
        }
      }
    }
  }

  int result = false;
  if (aa[0][0] && aa[1][0] && aa[2][0]) {
    result = true;
  } else if (aa[0][1] && aa[1][1] && aa[2][1]) {
    result = true;
  } else if (aa[0][2] && aa[1][2] && aa[2][2]) {
    result = true;
  } else if (aa[0][0] && aa[0][1] && aa[0][2]) {
    result = true;
  } else if (aa[1][0] && aa[1][1] && aa[1][2]) {
    result = true;
  } else if (aa[2][0] && aa[2][1] && aa[2][2]) {
    result = true;
  } else if (aa[0][0] && aa[1][1] && aa[2][2]) {
    result = true;
  } else if (aa[2][0] && aa[1][1] && aa[0][2]) {
    result = true;
  }
  cout << (result ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
 
int main()
{
	map<string,int> anko;
	int n; cin>>n;
	rep(i,n){
		string s; cin>>s;
		anko[s]++;
	}
	
	int max=0;
	for(auto x:anko){
		int a=x.second;
		if(a>max) max=a;
	}
	for(auto x:anko) if(x.second==max) cout<<x.first<<endl;
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int MAXN=200500;
ll ft[MAXN+1]; // for more dimensions, make ft multi-dimensional
void upd(int i0, ll v){ // add v to i0th element (0-based)
	// add extra fors for more dimensions
	for(int i=i0+1;i<=MAXN;i+=i&-i)ft[i]=max(ft[i],v);
}
ll get(int i0){
	ll r=0;
	for(int i=i0;i;i-=i&-i)r=max(r,ft[i]);
	return r;
}
int n;
ll h[MAXN],a[MAXN];
int main(){FIN;
	cin>>n;
	fore(i,0,n)cin>>h[i];
	fore(j,0,n)cin>>a[j];
	fore(i,0,n){
		ll r=get(h[i])+a[i];
		upd(h[i],r);
	}
	cout<<get(MAXN-1)<<"\n";
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		long l=Long.parseLong(scan.next());
		long r=Long.parseLong(scan.next());
		
		if (r-l>=2018) {
			System.out.print(0);
		}else {
			long min=2019;
			for (long i = l;i<r;++i) {
				for (long k=i+1;k<=r;++k) {
					min=Math.min(min, (i*k)%2019);
				}
			}
			System.out.print(min);
		}

}
}
//end

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define MAX 1000005

ll ar[1000];
int main()
{
 //O_O ;
   ll t,ans=INT_MAX,temp3;
   cin>>t;
   for(ll i=0;i<t;i++) cin>>ar[i];
  for(ll j=1;j<=100;j++)
  {
       temp3=0;
    for(ll i=0;i<t;i++){

      ll temp2= (j-ar[i])*(j-ar[i]);
       temp3+=temp2;

  }
  ans=min(ans,temp3);

  }
  cout<<ans<<nn;
    return 0;
}


Measured memory_bytes: 256
import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
#include <iostream>
 
using namespace std;
 
int main()
{
    int  n, a, b, c, d, a1, a2;
    cin >> n >> a >> b >> c >> d;
    a1 = b * ((n / a) + 1);
    if (n%a == 0)
    {
        a1 -= b;
    }
    a2 = d * ((n / c) + 1);
    if (n%c == 0)
    {
        a2 -= d;
    }
    if (a1 < a2)
    {
        cout << a1 << endl;
    }
    else
        cout << a2 << endl;
         
    return 0;
}


Measured memory_bytes: 3108
package main

import "fmt"

func chessBord(h int, w int) {
	for i := 0; i < h; i++ {
		tmp := ""
		for j := 0; j < w; j++ {
			if i % 2 == 0 {
				if j % 2 == 0 {
					tmp += "#"
				} else {
					tmp += "."
				}
			} else {
				if j % 2 == 0 {
					tmp += "."
				} else {
					tmp += "#"
				}
			}
		}
		fmt.Println(tmp)
	}
}

func main() {
	var H, W int
	var ans[10000][2] int
	var n int

	for n = 0; n != -1; n++ {
		fmt.Scan(&H, &W)

		if H == 0 && W == 0 {
			break
		}
		ans[n][0] = H
		ans[n][1] = W
	}

	for i := 0; i < n; i++ {
		chessBord(ans[i][0], ans[i][1])
		fmt.Println("")
	}
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

ll v[1000006];
ll u[1000006];
int n;
ll k;

ll f(ll x) {
	ll cur = k;
	for(int i = 0; i < n; i++) {
		if(v[i]*u[i] > x) {
			ll l = 0, r = v[i];
			while(l < r) {
				ll m = (l+r)/2;
				if((v[i] - m)*u[i] <= x) r = m;
				else l = m+1;
			}
			if(cur < r) return false;
			cur -= r;
		}
	}

	return true;
}

int main() {
	scanf("%d%lld", &n, &k);

	for(int i = 0; i < n; i++)
		scanf("%lld", &v[i]);

	for(int i = 0; i < n; i++)
		scanf("%lld", &u[i]);

	sort(v, v+n);
	sort(u, u+n, [&](const ll &a, const ll &b) {
		return a > b;
	});

	ll l = 0, r = 2e18;

	while(l < r) {
		ll m = (l+r)/2;

		if(f(m)) r = m;
		else l = m+1;
	}

	printf("%lld\n", l);

    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
using namespace std;
int main()
{
  int N,M;
  cin>>M>>N;
  int max=0;
  for(int i=0;i<M;i++){
    int sum=0;
    for(int j=0;j<N;j++){
      int t;
      cin>>t;
      sum+=t;
    }
    if(max<sum)max=sum;
  }
  cout<<max<<endl;
}

Measured memory_bytes: 0
#include <cstdio>

using namespace std;

long long gcd(long long x, long long y)
{
    if (y == 0) return x;
    
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    return x / gcd(x, y) * y;
}
 
int main() {
	long long a, b;
	
	while (scanf("%lld %lld", &a, &b) != EOF) {
	    printf("%lld %lld\n", gcd(a, b), lcm(a, b));
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

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

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

        bool isprime(int n)
        {
            for(int i=2;i*i<=n;i++)
                if(n%i==0)
                    return false;
            return true;
        }

        bool comp(pair<int,int> a, pair<int,int> b)
        {
            return b.ff < a.ff ;
        }

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }



    	int main()  
    	{

    		#ifndef ONLINE_JUDGE
    		freopen("input.txt","r", stdin);
    		freopen("output.txt", "w", stdout);
    		#endif
    		
    		int t=1;
    		//cin>>t;
    		
    		while(t--)
    		{
                ll x;
                cin>>x;
                ll p=100;
                double r=0.01;

                for(int t=1;;t++)
                {
                    ll si = (ll)p*r;
                    p=p+si;
                    if(p>=x)
                    {
                        cout<<t;
                        break;
                    }
                }   
            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    memset(B, 0, sizeof(B));
    vector<pll> v;
    vector<ll> index;
    v.push_back(pll(0, 0));
    index.push_back(0);
    ll n = 0;
    REP(i, N)
    {
        if (A[i] > n)
        {
            v.push_back(pll(A[i], 1));
            index.push_back(i);
            n = A[i];
            continue;
        }
        ll ok = v.size() - 1, ng = 0;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (A[i] <= v[mid].first)
                ok = mid;
            else
                ng = mid;
        }

        B[index[ok]] += A[i] - v[ok - 1].first;
        v[ok - 1].second++;
    }

    for (int i = v.size() - 1; i > 0; --i)
    {
        B[index[i]] += (v[i].first - v[i - 1].first) * v[i].second;
        v[i - 1].second += v[i].second;
    }

    REP(i, N)
    {
        cout << B[i] << endl;
    }
    return 0;
}

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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int pos=0;
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
        if(arr[i]==1) pos=i;
    }
    cout<<(n-1+k-2)/(k-1);
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


Measured memory_bytes: 3984
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
ll q[200010];
int main()
{
    int i, j, k;
    int n, t, m;
    int h , w;
    cin >> n;
    for(i = 1; i <= n; i++) {
        ll x;
        cin >> x;
        a[x]++;
        q[i] = x;
    }
    ll ans = 0;
    for(i = 1; i <= 200010; i++) {
        if(a[i] >= 2) {
            ans += a[i]*(a[i]-1)/2;
        }
    }
    for(i = 1; i <= n; i++) {
        ll ot = ans;
        if(a[q[i]] >= 2) {
            ot -= a[q[i]]*(a[q[i]]-1)/2-(a[q[i]]-1)*(a[q[i]]-2)/2;
        }
        printf("%lld\n", ot);
    }
    return 0;
}


Measured memory_bytes: 4736
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0 0")) {
				StringTokenizer st = new StringTokenizer(buf);
				int N = Integer.parseInt(st.nextToken());
				int K = Integer.parseInt(st.nextToken());
				st = new StringTokenizer(br.readLine());
				int type[] = new int[K];
				boolean able = true;
				for (int i=0;i<K;i++) {
					type[i] = Integer.parseInt(st.nextToken());
				}
				for (int i=0;i<N;i++) {
					st = new StringTokenizer(br.readLine());
					for (int j=0;j<K;j++) {
						type[j] -= Integer.parseInt(st.nextToken());
						if (type[j]<0) {
							able = false;
						}
					}
				}
				if (able) System.out.println("Yes");
				else System.out.println("No");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

int bubble(int *, int);

int main(){

  int i, n, A[N], count;

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

  count=bubble(A, n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

int bubble(int *A, int n){

  int i, j, sub, count=0;

  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        sub=A[j];
        A[j]=A[j-1];
        A[j-1]=sub;
        count++;
      }
    }
  }
  return count;
}



Measured memory_bytes: 2144
A, B = map(int, input().split())
S = input()
falg = False

if S.count('-') == 1: 
  code_1, code_2 = S.split('-')
  if (len(code_1) == A) and (len(code_2) == B):
    flag = True
  else:
    flag = False

  if (code_1+code_2).isdecimal() and flag:
    flag = True
  else:
    flag = False

else:
  flag = False
        
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	int len = s.Length;

	int ans = 1000;
	for (int i = 0; i <= len - 3; i++)
	{
	    int x = int.Parse(s.Substring(i, 3));
	    ans = Math.Min(ans, Math.Abs(x - 753));
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fi first
#define se second

typedef long long ll;
typedef std::pair < int, int > pr;

using std::cin;
using std::cout;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }

int n, a[55], id;
std::vector < pr > ans;
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    id = 0;
    for (int i = 1; i <= n; ++i)
        if (id == 0 || abs(a[i]) > abs(a[id]) ) id = i;
    for (int i = 1; i <= n; ++i)
        if (i != id) ans.push_back(std::make_pair(id, i)), a[i] += a[id];
    if (a[id] > 0) {
        for (int i = 2; i <= n; ++i) ans.push_back(std::make_pair(i - 1, i));
    } else {
        for (int i = n - 1; i; --i) ans.push_back(std::make_pair(i + 1, i));
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); ++i) cout << ans[i].fi << ' ' << ans[i].se << '\n';
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int X,A,B;
  cin>>X>>A>>B;
  int ans=X;
  ans-=A;
  while(ans>=B){
    ans-=B;
  }

  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256