akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int mod = 1e9 + 7;
inline void reduce(int &x) { x += x >> 31 & mod; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
//ruogu_alter
const int N = 505;
int n, p[N * N], dis[N][N], has[N][N];
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
//
bool isvalid(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= n) return false;
  return true;
}
int main() {
  n = getint();
  rep(i, n * n) p[i] = getint() - 1;
  rep(i, n) rep(j, n) dis[i][j] = min(min(i, j) + 1, min(n - i, n - j)), has[i][j] = true;
  int res = 0;
  rep(i, n * n) {
    int x = p[i] / n, y = p[i] % n; --dis[x][y]; res += dis[x][y]; has[x][y] = 0;
    queue<pii> qu;
    qu.emplace(mp(x, y));
    while (!qu.empty()) {
      pii u = qu.front(); qu.pop();
      rep(i, 4) {
        int fx = u.first + dx[i], fy = u.second + dy[i];
        if (!isvalid(fx, fy) || dis[fx][fy] <= dis[u.first][u.second] + has[fx][fy]) continue;
        dis[fx][fy] = dis[u.first][u.second] + has[fx][fy];
        qu.emplace(fx, fy);
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

const int inf=1000000000;

namespace Dinic
{
	int hd[200010],n,cnt,cur[200010],q[200010],l,r,dis[200010];
	struct node{int to,next,c;}e[1200100];
	void init(int N)
	{
		n=N,cnt=1;
		for (int i=1; i<=n; i++) hd[i]=0;
	}
	void addedge(int x,int y,int c)
	{
		e[++cnt]=(node){y,hd[x],c},hd[x]=cnt;
		e[++cnt]=(node){x,hd[y],0},hd[y]=cnt;
	}
	bool bfs()
	{
		for (int i=1; i<=n; i++) dis[i]=-1;
		q[l=r=1]=1,dis[1]=0;
		while (l<=r)
		{
			int x=q[l++];
			for (int i=hd[x]; i; i=e[i].next)
				if (e[i].c&&dis[e[i].to]==-1) dis[e[i].to]=dis[x]+1,q[++r]=e[i].to;
		}
		return dis[n]!=-1;
	}
	int dfs(int x,int f)
	{
		if (x==n) return f;
		for (int &i=cur[x]; i; i=e[i].next)
			if (e[i].c&&dis[e[i].to]==dis[x]+1)
			{
				int nw=dfs(e[i].to,min(e[i].c,f));
				if (nw) return e[i].c-=nw,e[i^1].c+=nw,nw;
			}
		return 0;
	}
	long long solve()
	{
		int nw;
		long long ans=0;
		while (bfs())
		{
			for (int i=1; i<=n; i++) cur[i]=hd[i];
			while (nw=dfs(1,inf<<1)) ans+=nw;
		}
		return ans;
	}
}

int n,p[100010],q[100010],belp[100010],belq[100010],x,vsp[100010],vsq[100010],vtp[100010],vtq[100010],ans;

int main()
{
	scanf("%d",&n);
	Dinic::init(2*n+2);
	for (int i=1; i<=n; i++) scanf("%d",&p[i]),p[i]++;
	for (int i=1; i<=n; i++) scanf("%d",&q[i]),q[i]++;
	for (int i=1; i<=n; i++)
		if (!belp[i])
		{
			belp[i]=i,x=i;
			for (x=p[x]; x!=i; x=p[x]) belp[x]=i;
		}
	for (int i=1; i<=n; i++)
		if (!belq[i])
		{
			belq[i]=i,x=i;
			for (x=q[x]; x!=i; x=q[x]) belq[x]=i;
		}
	ans=0;
	for (int i=1; i<=n; i++) 
	{
		if (i!=p[i]&&p[i]!=q[i]&&i!=q[i]) Dinic::addedge(1+belp[i],1+n+belq[i],1); else
		if (i!=p[i]&&p[i]==q[i]) Dinic::addedge(1+belp[i],1+n+belq[i],1),Dinic::addedge(1+n+belq[i],1+belp[i],1); else
		if (i==p[i]&&p[i]!=q[i]) vsq[belq[i]]++; else if (i==q[i]&&p[i]!=q[i]) vtp[belp[i]]++; else ans++;
	}
	for (int i=1; i<=n; i++) Dinic::addedge(1,i+1,inf+vsp[i]),Dinic::addedge(i+1,2*n+2,inf+vtp[i]);
	for (int i=1; i<=n; i++) Dinic::addedge(1,i+n+1,inf+vsq[i]),Dinic::addedge(i+n+1,2*n+2,inf+vtq[i]);
	ans+=Dinic::solve()-2ll*n*inf;
	return printf("%d\n",n-ans),0;
}

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

#define int long long

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

int N;
int a[300000];

signed main() {
    cin >> N;
    for (int i = 0; i < 3 * N; i++) {
        cin >> a[i];
    }
    sort(a, a + 3 * N);
    int ans = 0;
    for (int i = N; i < 3 * N; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define mod 1000000007

int main() {
	ll h, w, m;
	ll hi, wi;
	ll maxh = -1;
	ll maxw = -1;
	ll ans;
	set <pair<int, int>>p;
	cin >> h >> w >> m;
	vector<int> vh(h);
	vector<int> vw(w);
	vector<int> buf1;
	vector<int> buf2;
	vector <pair<int, int>> a;
	rep(i, m) {
		cin >> hi >> wi;
		hi--;	wi--;
		vh[hi]++;
		vw[wi]++;
		p.emplace(hi, wi);
	}
	rep(i, h) {
		if (maxh < vh[i]) {
			maxh = vh[i];
			buf1.clear();
			buf1.push_back(i);
		}
		if (maxh == vh[i])buf1.push_back(i);
		
	}
	rep(i, w) {
		if (maxw < vw[i]) {
			maxw = vw[i];
			buf2.clear();
			buf2.push_back(i);
		}
		if (maxw == vw[i])buf2.push_back(i);
		
	}
	ans = maxh + maxw;
	
	bool b = false;
	for (int i : buf1)	for (int j : buf2) {
		if (p.count(pair<int, int> {i, j}))continue;
		cout << ans << endl;
		return 0;
	}
	ans--;

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

Measured memory_bytes: 23744
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int n,m;
vector<vector<int>> to(200001,vector<int>());
vector<int> ans(100001,0);
queue<int> q;

int main() {
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    q.push(1);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        rep(i,to[now].size()){
            if(ans[to[now][i]] == 0){
                q.push(to[now][i]);
                ans[to[now][i]] = now;
            }
        }

    }
    bool ok = true;
    for(int i = 2; i <= n; i++){
        if(ans[i] == 0) ok = false; 
    }
    if(ok){
        dunk("Yes");
        for(int i = 2; i <= n; i++){
            dunk(ans[i]);
        }
    }
    else dunk("No");

    return 0;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sysp system("pause")
//}

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;}
inline long long digitnumbersum(long long a){long long b=0;while(a){a/=10;b++;}return b;}
inline long long mysqrt(long long a){
long long i=0;for(i=1;a>0;i++){a-=i*2+1;}return i-1;}
//}

long long n,a;

int main(){
	cin>>n;
	a=mysqrt(n);
	for(int i=a;i!=0;i--){
		if(n%i==0){
			debug(i);
			dump(digitnumbersum(n/i));
			system("pause");
			return 0;
		}
	}
	dump(digitnumbersum(n));
	system("pause");
}
 

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

int main() {
  int n;
  cin >> n;
  vector<int> a[101];
  int max=0;
  for(int i=0; i<n; i++) {
    int x,y;
    cin >> x >> y;
    a[y].push_back(x);
    if(max<y) max=y;
  }
  sort(a[max].begin(),a[max].end());
  cout << a[max][0] << " " << max << endl;
  return 0;
}


Measured memory_bytes: 1224
N, Q = map(int, input().split())
S = input()
Ls = len(S)
x = [0 for _ in range(Ls)]
for i in range(Ls - 1):
    x[i + 1] = x[i]
    if S[i:i + 2] == 'AC':
        x[i + 1] += 1
for i in range(Q):
    l, r = map(int, input().split())
    print(x[r - 1] - x[l - 1])


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

int main() {
  int N, M, X = 0;
  int max;
  
  cin >> N;
  vector<string> s(N);
   for(int i = 0; i < N ; i++) {
     cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
   for(int i = 0; i < M ; i++) {
     cin >> t.at(i);
  }
  
  max = 0;
  for(int i = 0; i < N ; i++) {
    for(int j = M-1; j >= 0 ; j--) {
      if(s.at(i) == t.at(j) && t.at(j) != "") {
        X--;
        t.at(j) = "";
      }
    }
    for(int k = N-1; k >= i; k--) {
      if(s.at(i) == s.at(k) && s.at(k) != "") {
        X++;
        s.at(k) = "";
      }
    }
    if(max < X) {
      max = X;
    }
    X = 0;
  }
  cout << max << endl;
}


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

typedef long long ll;

int main(){
    ll n, x, m=0, f; cin>>n;
    f=n;
    vector<int> nums;
    while(n!=0){
        nums.push_back(n%10);
        n/=10;
    }
    for(x=0; x<nums.size(); x++) m+=nums[x];
    cout<<(f%m ? "No" : "Yes");
}

Measured memory_bytes: 256
n, l = map(int, input().split())
taste = [l+i-1 for i in range(1, n+1)]

apple1 = float('inf')
apple2 = -float('inf')
flag = 0
for i in taste:
    if i == 0:
        apple = i
        flag = 0
        break
    elif (apple2 < i < 0):
        apple2 = i
        flag = 1
    elif (0 < i < apple1):
        apple1 = i
        flag = 2
        
if flag == 1:
    pie = (sum(taste) - apple2)
elif flag == 2:
    pie = (sum(taste) - apple1)
else:
    pie = (sum(taste) - apple)
    
print(pie)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> l(n , 0);
  REP(i, n - 1)
  {
    for (int j = i + 1; j < n; j++)
    {
      l.at(min(j - i, abs(i - x) + abs(j - y) + 1))++;
    }
  }
  for (int i = 1; i < n ; i++)
  {
    cout << l.at(i) << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long

const int maxn=1e5+10;

int a[maxn];

int main()
{
    int n,i;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if ((n&1) || a[n/2]==a[n/2+1])
    {
        printf("0");
        return 0;
    }
    printf("%d",a[n/2+1]-a[n/2]);
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

unsigned getdigit(unsigned NUM){
    return log10(NUM) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int n;
    cin >> n;
    map<string,int> S;
    vector<string> s(n);
    int mx = 0;
    for (int i = 0;i < n;i++){
        cin >> s[i];
        S[s[i]]++;
        mx = max(mx,S[s[i]]);
    }
    vector<string> ans(n);
    int j = 0,cnt = 0;
    for (int i = 0;i < n;i++){
        if (S[s[i]] == mx){
            ans[j] = s[i];
            S[s[i]] = -1;
            j++;
        }
    }
    sort(ans.begin(),ans.end());

    for (int i = 0;i < n;i++){
        if (ans[i] != "") cout << ans[i] << endl;;
    }
}

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

using namespace std;

int main() {
    string S; cin >> S;
    int count_0 = 0, count_1 = 0;
    for (int i=0; i<S.length(); i++) { 
        (char)S[i] == '0' ? count_0++ : count_1++;
    }
    int result = min(count_0, count_1) * 2;
    cout << result << endl;
    return 0;
}

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

int main()
{
    //チョコレートの最大サイズ分の配列　5つくらい余裕を持っておく
    int c[10][1005];

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    //答え(小さいものを選ぶので無限にする)
    int ans = INF;

    // 1 << h-1 = 2^(h-1)
    //線を引くor引かないの２通り
    rep(div, 1 << (h-1))
    {
         //2進数でビットが立っているところで分ける(div)
        int group =0;
        vector<int> id(h);
        rep(i,h)
        {
            id[i] = group;
            //シフトして１(線を引く)なら次からのグループをインクリする
            if(div >> i&1) group++;
        }
        //グループ数を表す為にインクリ
        group++;

        //縦グループ数分、横全て初期化
        rep(i,group)rep(j,w) c[i][j] = 0;
        //ホワイトチョコレートの箇所をインクリ
        rep(i,h)rep(j,w) {
            //１(文字コード49)と0(文字コード48)を足し引きすると1のみインクリできる
            //グループ内にあるホワイトチョコレートの数を入れる
            c[id[i]][j] += (s[i][j] -'0');
        }
        //縦に切っていく
        //答えの候補　グループの数-1が線の数
        int num = group - 1;
        vector<int> now(group);
        //指定した列を現在の数に追加する
        auto add = [&](int j)
        {
            //各グループの現在の数を格納
            rep(i,group) now[i] += c[i][j];
            //超えた場合はfalse;
            rep(i,group) if(now[i] > k) return false;           
            return true;
        };

        rep(j,w)
        {
            //列の数だけ横に増やしていき、超える時にnumをインクリする
            if(!add(j))
            {
                num++;
                //初期化
                now = vector<int>(group);
                if(!add(j))
                {
                    //1回目で失敗したら対象外にする
                    num = INF;
                    break;
                }                
            }         
        }
        //小さい方を洗濯
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;cin>>x;
  if(x<1200)cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;

  return 0;

}


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

int main(){
    int n;
    cin >> n;
    
    int *p, *p_min;
    p = new int[n];
    p_min = new int[n];
    int i;
    for (i=0;i<n;i++){
        cin >> p[i];
    }

    int count = 1;
    p_min[0] = p[0];
    for (i=1;i<n;i++){
        if(p_min[i-1] >= p[i]){
            count += 1;
            p_min[i] = p[i];
        }
        else{
            p_min[i] = p_min[i-1];
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())
A = list(map(int,input().split()))
C = {i:0 for i in range(1,N+1)}
loop = [1]
C[1] = 1
tmp = A[0]
for i in range(N):
    x = A[tmp-1]
    #print(x)
    if C[x] == 1:
        loop.append(tmp)
        X = x
        break
    else:
        loop.append(tmp)
        C[x] = 1
        tmp = x
#print(loop)
lenloop = len(loop)
tail = 0
for i in loop:
    if i != X:
        tail += 1
    else:
        break
if K > tail:
    loop = loop[tail:]
    K -= tail
    lenloop -= tail
    XX = K % lenloop
    ans = loop[XX]
    #print(tail,loop,XX)
else:
    ans = loop[K]
print(ans)

Measured memory_bytes: 39848
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve(){
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 10000; ++i) {
        if ((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

#undef int
int main() {
    init();
        solve();
}

Measured memory_bytes: 256
use std::cmp;

struct SegmentTree {
    len: usize,
    node: Vec<usize>,
}

impl SegmentTree {
    fn new(n: usize) -> SegmentTree {
        let mut len: usize = 1;
        while len < n { len *= 2; }
        let node: Vec<usize> = vec![0; 2 * len - 1];
        SegmentTree { len, node }
    }

    fn update(&mut self, mut i: usize, x: usize) {
        i += self.len - 1;
        self.node[i] = x;
        while i > 0 {
            i = (i - 1) / 2;
            self.node[i] = {
                cmp::max(
                    self.node[2 * i + 1],
                    self.node[2 * i + 2],
                )
            };
        }
    }

    fn get(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> usize {
        if r <= a || b <= l {
            0
        } else if a <= l && r <= b {
            self.node[k]
        } else {
            cmp::max(
                self.get(a, b, 2 * k + 1, l, (l + r) / 2),
                self.get(a, b, 2 * k + 2, (l + r) / 2, r),
            )
        }
    }
}

const MOD: usize = 998_244_353;

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut x: Vec<i32> = Vec::with_capacity(n);
    let mut d: Vec<i32> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        x.push(iter.next().unwrap().parse().unwrap());
        d.push(iter.next().unwrap().parse().unwrap());
    }

    let mut ord: Vec<usize> = (0..n).collect();
    ord.sort_by(|&i, &j| x[i].cmp(&x[j]));
    let mut st = SegmentTree::new(n);
    let mut dp: Vec<usize> = vec![0; n + 1];
    dp[n] = 1;
    for i in (0..n).rev() {
        let (mut left, mut right) = (i, n);
        while right - left > 1 {
            let mid = (left + right) / 2;
            if x[ord[mid]] < x[ord[i]] + d[ord[i]] {
                left = mid;
            } else {
                right = mid;
            }
        }
        let k = cmp::max(i, st.get(i, right, 0, 0, st.len));
        st.update(i, k);
        dp[i] = (dp[i + 1] + dp[k + 1]) % MOD;
    }
    println!("{}", dp[0]);
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), wa(n);
  rep(i,m){
    int p;
    string s;
    cin >> p >> s;
    p--;
    if(ac[p]) continue;
    if(s == "AC"){
      ac[p] = 1;
    } else {
      wa[p]++;
    }
  }
  int AC = 0, WA = 0;
  rep(i, n){
    AC += ac[i];
    if(ac[i]) WA += wa[i];
  }
  cout << AC << " " << WA << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int n, x;
    std::cin >> n >> x;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

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

    int count = 0;
    for (int i = 0; i < n - 1; i++) {
        if (x < a[i]) {
            std::cout << count << std::endl;
            return 0;
        }
        count++;
        x -= a[i];
    }
    if (x == a[n - 1]) {
        count++;
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    ll maxx, minx, maxy, miny;
    rep(i,n)
    {
        ll x,y;
        cin >> x >> y;
        if (i==0)
        {
            maxx = x+y;
            minx = x+y;
            maxy = x - y;
            miny = x - y;
        }
        maxx = max(maxx, x+y);
        maxy = max(maxy, x-y);
        minx = min(minx, x+y);
        miny = min(miny, x-y);
    }
    ll ans = max(maxx - minx, maxy - miny);
    cout << ans << endl;
}


Measured memory_bytes: 3668
#include<stdio.h>

int main(void){
    int x, y;
    int z = 0;
    int i;
    
    scanf("%d", &x);
    scanf("%d", &y);
    
    for(i = 0; i < 2; i++){
        if (x > y){
            z += x;
            x -= 1; 
        } else if(x == y){
            z += x;
            x -= 1;
        } else if(x < y){
            z += y;
            y -= 1;
        }
    }

    printf("%d\n", z);

  return 0;  
}

Measured memory_bytes: 128
n = int(input())

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

for i in range(len(a)):
    mod1 = a[i] % 2
    if mod1 == 0:
        mod2 = a[i] % 3
        mod3 = a[i] % 5
        if mod2 != 0 and mod3 != 0:
            print('DENIED')
            exit()
print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> P(N, 0);
  for(auto& p : P){
    cin >> p;
  }
  vector<int> Q(N, 0);
  for(auto& q : Q){
    cin >> q;
  }
 
  vector<int> R(N, 0);
  for(int ii=0; ii<N; ii++){
    R[ii] = ii+1;
  }
  int pos_P = -1;
  int pos_Q = -1;
  int pos = 0;
  do{
    if(pos_P!=-1 && pos_Q!=-1){
      break;
    }
    if(P==R) pos_P = pos;
    if(Q==R) pos_Q = pos;
    pos++;
  }while(next_permutation(R.begin(), R.end()));
  cout << abs(pos_Q - pos_P) << 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;
typedef pair<int,int> P;

int main(void) {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        int A; cin >> A;
        if(A%2==0) {
            if(A%3!=0 && A%5!=0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 3608
import itertools
N, M, X = map(int,input().split())
arr = []
for i in range(N):
    arr.append(list(map(int,input().split())))

costl = []

for p in itertools.product([0,1],repeat=N):
    f = [0]*M
    cost = 0
    for i in range(N):
        if p[i] == 1:
            for j in range(M):
                f[j] += arr[i][j+1]
            cost += arr[i][0]
    if all(point >= X for point in f):
        costl.append(cost)

print(min(costl) if len(costl) >= 1 else -1)

Measured memory_bytes: 9248
#include <stdio.h>

#define MAX 100000

int n,D[MAX];

typedef struct node {
  int item;
  int left;
  int right;
} Node;

Node T[MAX];

/*
int getdepth(int u){

  int d=0;

  while(T[u].parent!=-1){

    u=T[u].parent;

    d++;
  }
  return d;
}
*/

void print(int u){

  int i,j=0,c;

  printf("node %d: parent = %d, depth = %d, ", u,T[u].item,D[u]);

  if(T[u].item==-1) printf("root, ");
  else if(T[u].left==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");    

  for(i=0, c=T[u].left; c!=-1; i++, c=T[c].right){

    if(i) printf(", ");
	
    printf("%d",c);
  }
   
  printf("]");

}

int setdepth(int u,int p){
  
  D[u]=p;

  if(T[u].right!=-1){

    setdepth(T[u].right,p);
  }

  if(T[u].left!=-1){

    setdepth(T[u].left,p+1);
  }

}


int main(){

  int i,j,d,v,r,l,c;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].item=T[i].left=T[i].right=-1;


  for(i=0;i<n;i++){

    scanf("%d%d",&v,&d);

    for(j=0;j<d;j++){

      scanf("%d",&c);

      if(j==0) T[v].left=c;
      else T[l].right=c;

      l=c;
      T[c].item=v;
      
     
    }

  }
  for(i=0;i<n;i++){

    if(T[i].item==-1) r=i;
  }

  setdepth(r, 0);

  for(i=0;i<n;i++){
    print(i);
    printf("\n");
  }
  
  return 0;

}



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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

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

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n;

int main(){
	cin >> n;
	Int ans = 1;
	for(int i = 1; i <= n; i++){
		ans *= i;
		ans %= INF;
	}
	
	cout << ans << endl;
	
	return 0;
}

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


int main(){
  
  ll a;
  double b;
  cin>>a>>b;
  long long b100 = round(b*100);
  cout<<a*(b100)/100<<endl;
}


Measured memory_bytes: 3768
a = gets.chomp.to_i#chomp.split(" ").map(&:to_i)
b = []
sum = 0
a.times do
  t = gets.chomp.to_i
  b << t
end

c = b.sort
hsh = {}
c.each_with_index do |t,i|
  hsh[t] = i
end
d = 0
b.each_with_index do |t,i|
  if (hsh[t] - i).abs % 2 == 1#c.index(t) - i 
    d += 1
  end 
end
#d = b.map.with_index{|t,i| (c.index(t)-i).abs}.select{|t| t % 2 ==1}.size
p d / 2
#p b,c,d


Measured memory_bytes: 9840
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main(){
	int i, N, M;
	int a[110];
	cin >> N >> M;

	for(i=0; i<N; i++){
		cin >> a[i];
	}

	sort(a, a + N, greater<int>());

	int sum = 0;
	for(i=0; i<N; i++){
		sum += a[i];
	}

	double dt = sum / (M * 4.0);
	if(a[M-1] >= dt) cout << "Yes";
	else cout << "No";

	return 0;

}


Measured memory_bytes: 504
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        List<Sum> list = new ArrayList<>();
        
        for (int i = 0; i < N; i++) {
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	
        	list.add(new Sum(a,b));
        }
        
        Collections.sort(list);
        Collections.reverse(list);
        
        long sumA = 0;
        long sumB = 0;
        int count = 0;
        for (Sum s : list) {
        	if (count % 2 == 0) {
        		sumA += s.a;
        	} else {
        		sumB += s.b;
        	}
        	
        	count++;
        }
        
        System.out.println(sumA - sumB);
    }
    
    static class Sum implements Comparable<Sum> {
    	int a;
    	int b;
    	long sum;
    	
    	public Sum(int a, int b) {
    		this.a = a;
    		this.b = b;
    		this.sum = a + b;
    	}

		@Override
		public int compareTo(Sum o) {
			return this.a - o.a + this.b - o.b;
		}

		
    }
}

Measured memory_bytes: 88612
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
long long n,a[1000000],ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) a[i]=a[i]-i-1;
	sort(a,a+n);
	if (n%2==1)
		for (int i=0;i<n;i++) ans+=abs(a[i]-a[n/2]);
	else
		for (int i=0;i<n;i++) ans+=abs(a[i]-(a[n/2]+a[n/2-1])/2);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int n, k, ta, tb, ma;

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main() {
	scanf("%d%d", &n, &k);
	scanf("%d", &ta);
	ma = ta;
	n--;
	while (n--) {
		scanf("%d", &tb);
		ma = max(ma, tb);
		ta = gcd(ta, tb);
	}
	if (ma >= k && (ma - k) % ta == 0)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    FIO;
    ll n, k;   cin >> n >> k;
    ll ans = 0;
    while(n--){
        ll x;   cin >> x;
        ans += (x >= k) ? 1 : 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n<=999){
		cout<<"ABC"<<endl;
	}
	else{
		cout<<"ABD"<<endl;
	}
} 
	

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    long long int s;
    scanf("%lld", &s);
    long long int buf = 1000000000;
    long long int x, y;
    x = (buf - s%buf)%buf;
    y = (x+s)/buf;
    printf("0 0 %lld 1 %lld %lld", buf, x, y);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	string s;
	cin >> s;

	stack<int> q;
	rep(i, s.size()) {
		if (s[i] == 'S') {
			q.push(1);
		}
		else {
			if (q.size() && q.top() == 1) {
				q.pop();
			}
			else {
				q.push(0);
			}
		}
	}
	cout << q.size() << endl;

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1001
#define mod 1000000007

void primeNumber();
void factorization(int[], int);

int prime[MAX_N] = {};

int main(){
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	int num[n + 1] = {};

	primeNumber();
	repl(i, 2, n + 1) {
		factorization(num, i);
	}

	ll ans = 1;
	rep(i, n + 1) {
		ans = (ans * (num[i] + 1)) % mod;
	}

	cout << ans << endl;

	return 0;
}

void primeNumber() {
	prime[1] = 1;
	repl(i, 2, MAX_N + 1) {
		if (prime[i] == 1) continue;
		int j = i * 2;
		while(j < MAX_N) {
			prime[j] = 1;
			j += i;
		}
	}
}

void factorization(int num[], int i) {
	int tmp = i;
	if (prime[i] != 0) {
		repl(i, 2, i + 1) {
			if (tmp == 1) break;
			if (tmp % i == 0) {
				tmp /= i;
				num[i]++;
				i--;
			}
		}
	} else {
		num[i]++;
	}
}

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

namespace lec10D
{

    class Program
    {
      
       public static  double[,] c ;
        public static double[] a ;
        public static double[] b ;
        public static int[,] k_arr;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            c = new double[n+2,n+2];
            a = new double[n+1];
             b = new double[n+1];
            k_arr =  new int[n + 2, n + 2];
            string[] input_a = Console.ReadLine().Split(' ');
            string[] input_b = Console.ReadLine().Split(' ');
            double all = 0.0;

            for (int i = 0; i < n; i++)
            {
                a[i + 1] = double.Parse(input_a[i]);
                b[i] = double.Parse(input_b[i]);
                c[i + 1, i] = 0;
                all += b[i];
            }
            b[n] = double.Parse(input_b[n]);
            c[n + 1, n] = 0;
            all += b[n];


            for (int h = 0; h < n; h++)
            {
                for (int i = 1; i <= n - h; i++)
                {
                    int j = i + h;
                    int s;
                    int e;
                    if (h != 0) {
                        s = k_arr[i, j - 1];
                        e = k_arr[i + 1, j];
                    }
                    else
                    {
                        s = i;
                        e = j;
                    }
                    for (int k = s; k <= e; k++)
                    {
                        c[i, j] = Min( i ,j ) ;
                    }

                }
            }

            Console.WriteLine("{0:F9}",(c[1,n]+all));

            Console.ReadLine();

        }
        static double Min(int  i, int j )
        {
            double t;
            double min  = c[i, i - 1] + c[i + 1, j];
            int k;
            for ( k = i; k <= j; k++)
            {

                t = c[i, k - 1] + c[k + 1, j];
                if (t < min)
                {
                    min = t;
                }
            }

            k_arr[i, j] = k;

            double re_all =  0.0;
            re_all += b[i-1];

            for (int index_a = i ; index_a <= j; index_a++)
            {
                re_all += a[index_a]+ b[index_a];

            }
            return (min+re_all);
        }
    }
}


Measured memory_bytes: 21416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll a,b,c;
 cin>>a>>b>>c;
 ll val1=min(a,b);
 ll val2=max(a,b);
 bool ok=(c>=val1&&c<=val2);
 if(ok) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;

ll v[1000001];

void solve()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        ll a;
        cin >> a;
        a++;
        v[a-1]++;
        v[a]++;
        v[a+1]++;
    }
    
    ll mx = 0;
    for(int i = 0;i <= 1000000;i++)
    {
        if(mx < v[i])
        {
            mx = v[i];
        }
    }
    cout << mx << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $N, $Y);

for ($x = 0; $x <= $N; $x++) {
    for ($y = 0; $y <= $N - $x; $y++) {
        $z = $N -$x - $y;
        if (10000 * $x + 5000 * $y + 1000 * $z == $Y) {
            echo "$x $y $z";
            return;
        }
    }
}
echo '-1 -1 -1';

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

typedef long long int ll;
typedef long double ld;

/// pair,set,vector

ll n,x,a[100005];

int main()
{
    cin>>n>>x;
    for(int i=1;i<=n;++i) cin>>a[i];
    ll ans=0;
    for(int i=2;i<=n;++i){
        ans+=(max(0LL,-x+a[i]+a[i-1]));
        a[i]-=max(0LL,-x+a[i]+a[i-1]);
        if(a[i]<0){
            a[i]=0;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define INF 1 << 30
#define pb push_back
#define mp make_pair

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

const int MAX = 100000;

struct Edge {
    int t;
    int w;
};

int n;
vector<Edge> G[MAX];
int dist[MAX];
int visited[MAX];


void bfs(int s) {
    queue<pii> q;
    rep(i, n) dist[i] = INF;
    rep(i, n) visited[i] = 0;
    dist[s] = 0;
    q.push(mp(s, 0));

    while (!q.empty()) {
        int e = q.front().first;
        int d = q.front().second;
        q.pop();

        visited[e] = 1;
        dist[e] = d;

        rep(i, G[e].size()) {
            if (!visited[G[e][i].t]) {
                q.push(mp(G[e][i].t, d + G[e][i].w));
            }
        }
    }
}


void solve(void) {
    bfs(0);
    int m = 0;
    int x;
    rep(i, n) {
        if (dist[i] != INF && dist[i] > m) {
            m = dist[i];
            x = i;
        }
    }

    bfs(x);
    int ans = 0;
    rep(i, n) {
        if (dist[i] != INF) ans = max(ans, dist[i]);
    }

    printf("%d\n", ans);
}


int main(void) {
    int s, t, w;
    scanf("%d", &n);
    rep(i, n - 1) {
        scanf("%d %d %d", &s, &t, &w);
        Edge e; e.t = t; e.w = w;
        Edge u; u.t = s; u.w = w;
        G[s].push_back(e);
        G[t].push_back(u);
    }

    solve();

    return 0;
}

Measured memory_bytes: 8460
#include <stdio.h>
#include <math.h>
int main(){
    int i,d,n,k,buf;
    scanf("%d%d",&n,&k);
    double ans=0,p=(1/(double)n);
    for(i=1;i<=n;i++){
    buf=i;
    d=0;
    while(buf<k){
        buf*=2;
        d++;
    }
    ans+=p*pow(0.5,(double)d);
    }
    printf("%.12lf",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;

int main(){
    int n, W; cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, 0, n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    rep(i, 0, n + 1) dp[i][0] = 0;
    rep(i, 0, W + 1) dp[0][i] = 0;
        
    rep(i, 0, n){
        rep(j, 0, W+1){
            if(j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int sum = 0;
	
	for_(i,0,5) {
		int in; cin >> in;
		if (in < 40) in = 40;
		sum += in;
	}
	
	cout << sum / 5 << endl;
}

Measured memory_bytes: 1164
p=input
n,m=map(int,p().split())
l=[p().split()for _ in[0]*n]
r=[1,-1]
print(max([sum(sorted([sum([int(x[i])*r[k>>i&1]for i in range(3)])for x in l],reverse=True)[:m])for k in range(8)]))

Measured memory_bytes: 3444
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;
 
int main(){
 
  string W,T;
  int i=0,count=0;
 
  cin >>W;
  while(cin >>T){
    if(T=="END_OF_TEXT") break;
    for(i=0;i<T.size();i++){
      T[i]=tolower(T[i]);
    }
    if(T==W) count++;
  }
  cout <<count <<endl;
 
  return 0;
}

Measured memory_bytes: 3140
while 1:
    m,f,r = (int(x) for x in input().split())
    score = m + f
    if m ==-1 and f ==-1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif score >= 80:
        print("A")
    elif 65 <= score < 80:
        print("B")
    elif 50 <= score < 65:
        print("C")
    elif 30 <= score < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
  } else if (abs(a - b) <= d && abs(b - c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
void t(ll x,ll y,ll z)
{
    printf("%lld %lld %lld\n",x,y,z);
    exit(0);
}
void f()
{
    ll c,m;
    for(ll i=1;i<=3500;i++)
        for(ll j=1;j<=3500;j++)
		{
            c=n*i*j;
            m=4*i*j-n*i-n*j;
            if(m>0&&c%m==0)t(i,j,c/m);
        }
}
int main()
{
    cin>>n;
    if(n%2==0)t(n,n,n/2);
    if(n%3==0)t(n,n/3*2,n/3*2);
    if((n-3)%4==0)t((n+1)/4,(n+1)*(n+1)/4,(n+1)*(n+1)*n/4);
    if((n-1)%4==0)f();
}

Measured memory_bytes: 256
use std::cmp;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n = sc.read();
    let h: Vec<usize> = sc.vec(n);
    let a: Vec<u64> = sc.vec(n);

    let mut seg = SegmentTree::new(n + 1, 0, |a, b| cmp::max(a, b));
    let mut dp = vec![0; n + 1];
    for i in 0..n {
        dp[h[i]] = cmp::max(dp[h[i]], seg.query(0, h[i] + 1) + a[i]);
        seg.update(h[i], dp[h[i]]);
    }
    println!("{}", dp.into_iter().max().unwrap());
}
/// Segment Tree for range queries
pub struct SegmentTree<T, F> {
    seg: Vec<T>,
    n: usize,
    f: F,
    initial_value: T,
}

impl<T: Copy, F> SegmentTree<T, F>
where
    F: Fn(T, T) -> T,
{
    pub fn new(size: usize, initial_value: T, f: F) -> SegmentTree<T, F> {
        let mut m = 1;
        while m <= size {
            m <<= 1;
        }
        SegmentTree {
            seg: vec![initial_value; m * 2],
            n: m,
            f: f,
            initial_value: initial_value,
        }
    }

    pub fn update(&mut self, k: usize, value: T) {
        let mut k = k;
        k += self.n - 1;
        self.seg[k] = value;
        while k > 0 {
            k = (k - 1) >> 1;
            self.seg[k] = (self.f)(self.seg[k * 2 + 1], self.seg[k * 2 + 2]);
        }
    }

    /// Get the minimum value in the array in the range [a, b)
    ///
    /// # Panics
    ///
    /// Panics if `a >= b`.
    pub fn query(&self, a: usize, b: usize) -> T {
        assert!(a < b);
        self.query_range(a, b, 0, 0, self.n)
    }

    fn query_range(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> T {
        if r <= a || b <= l {
            self.initial_value
        } else if a <= l && r <= b {
            self.seg[k]
        } else {
            let x = self.query_range(a, b, k * 2 + 1, l, (l + r) >> 1);
            let y = self.query_range(a, b, k * 2 + 2, (l + r) >> 1, r);
            (self.f)(x, y)
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14588