akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int N, M;
	cin >> N >> M;
	int x[M], y[M], num[N], pos[N];
	for(int i=0; i<M; i++){ cin >> x[i] >> y[i]; x[i]--; y[i]--; }
	for(int i=0; i<N; i++){ num[i] = 1; pos[i] = 0; }
	pos[0] = 1;
	for(int i=0; i<M; i++){
		if(pos[x[i]]){
			if(num[x[i]] == 1){ pos[x[i]] = 0; pos[y[i]] = 1; num[x[i]]--; num[y[i]]++; }
			else{
				pos[y[i]] = 1; num[x[i]]--; num[y[i]]++;
			}
		}else{
			num[x[i]]--; num[y[i]]++;
		}
	}
	int res = 0;
	for(int i=0; i<N; i++) if(pos[i]) res++;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 922337203685477580
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll dp[105][100005];
int main()
{
	boost
	ll n,W;
	cin>>n>>W;
	ll wt[n],v[n];
	ll i,j;
	for(i=0; i<n; i++)
		cin>>wt[i]>>v[i];
	ll maxi=0;
	ll ans=0;
	for(i=0; i<=n; i++)
	{
		for(j=0; j<=100004; j++)
		{
			dp[i][j]=inf;
		}
	}
	dp[0][0]=0;
	for(i=1; i<=n; i++)
	{
		for(j=0; j<=100004; j++)
		{
			if(j>=v[i-1])
				dp[i][j]=min(dp[i-1][j],wt[i-1]+dp[i-1][j-v[i-1]]);
			else
				dp[i][j]=dp[i-1][j];
		//	if(j%10==0)
		//		cout<<dp[i][j]<<endl;
			if(dp[i][j]<=W)
			{
		//		cout<<j<<" ";
				ans=max(ans,j);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;

/*
0 1 -5000

0 1 -4998






任意の要素から任意の要素を足して単調増加にできるかなー
2N回以下で!

a[i]>=a[i+1]なる最小のiをkとする
このとき

ak,ak+1が非負なら足すだけで達成
akが正、ak+1が負だと、
akもak+1も負だと、ak+1をakに足すだけで達成

前処理で「全部非負」あるいは[全部非正]を達成したい
絶対値最大値のうち大きいほうを全部に足す
*/

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<pair<ll,ll> > res;

    ll m = 1e7, M = -1e7, argm = -1, argM = -1;
    for (int i = 0; i < N; i++) {
        if (a[i] > M) {
            M = a[i]; argM = i;
        } 
        if (a[i] < m) {
            m = a[i]; argm = i;
        }
    }
    if (abs(m) > abs(M)) {
        M = m; argM = argm;
    }

    for (int i = 0; i < N; i++) {
        if (i != argM) {
            a[i] += M;
            res.push_back(make_pair(argM+1,i+1));
        }
    }

    if (a[0] >= 0) {
        for (int i = 0; i < N-1; i++) {
            if (a[i] > a[i+1]) {
                a[i+1] += a[i];
                res.push_back(make_pair(i+1,i+2));
            }
        }
    } else {
        for (int i = N-1; i >= 1; i--) {
            if (a[i-1] > a[i]) {
                a[i-1] += a[i];
                res.push_back(make_pair(i+1,i));
            }
        }
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
        cout << res[i].first << " " << res[i].second << endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int ans = 1;
	for(int i=1;i*i<=m;i++){
		if(m%i == 0){
			int d = i;
			if((LL)d*n <= m && (m-d*n)%d == 0) ans = max(ans, d);
			d = m/i;
			if((LL)d*n <= m && (m-d*n)%d == 0) ans = max(ans, d);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
INF = 1000000007

dp = [0] * (N + 1)
dp[0] = 1

if 1 not in a:
	dp[1] = 1
    
for i in range(2, N + 1):
	if i not in a:
		dp[i] = dp[i - 1] + dp[i - 2]
		dp[i] %= INF

print(dp[N])


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

const int N = 2020;
bitset<N*N> dp;

int main() {
  int n, a, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    dp |= ( dp << a );
    dp[a] = 1;
    sum += a;
  }
  sum = (sum+1)/2;
  while (1) {
    if ( dp[sum] ) {
      cout << sum << "\n";
      return 0;
    }
    sum++;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	cin >> s;
	ll ans=0LL;
	ll sum = 0LL;
	rep(i,s.size()){
		if(s[i]=='B'){
			sum++;
		}else{
			ans += sum;
		}
	}


	cout<<ans<<endl;
}
/*
WWWW..WWBBB..BB
*/

Measured memory_bytes: 3724
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	string s; cin>>s; cout<<s[0]<<s[1]<<s[2]<<endl;
	return 0;
}

Measured memory_bytes: 3620
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<int> C;
#define X real()
#define Y imag()
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
string s;
cin>>s;
if(s[2]==s[3]&&s[4]==s[5])
cout<<"Yes";
else
cout<<"No";

}return 0;}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    string n;
    cin >> n;
    F(i,0,3){
        if(n[i]=='1') n[i]='9';
        else if(n[i]=='9') n[i]='1';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   vector<int> a(n);
   rep(i,n)cin>>a[i];
   sort(a.begin(),a.end());reverse(a.begin(),a.end());
   a.push_back(0);
   int k=1;
   while(k<a[k])k++;
   int x = 0, y = a[k-1]-k;
   while(a[k+x]==k)x++;
   if ((x%2==0)&&(y%2==0))cout << "Second" << endl;
   else cout << "First" << endl; 
}

Measured memory_bytes: 3972
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    M, K = map(int, rl().split())
    
    if M == 1:
        if 1 <= K:
            print(-1)
        else:
            print(0, 0, 1, 1)
        exit()
    
    if 1 << M <= K:
        print(-1)
        exit()
    
    ans = []
    for i in range(1 << M):
        if i != K:
            ans.append(i)
    ans.append(K)
    for i in range((1 << M) - 1, -1, -1):
        if i != K:
            ans.append(i)
    ans.append(K)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 94144
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = (Console.ReadLine().Trim() + " 0").Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ans = 0;
        for (int i = 0; i < n; i++)
            if (a[i + 1] < a[i]) ans += a[i] - a[i + 1];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, m; cin >> n >> m;
	int a[n]; rep(i,n) a[i] = -1;
	int s[m], c[m]; rep(i,m) cin >> s[i] >> c[i];
	rep(i,m) {
		--s[i];
		if(a[s[i]] != -1 and a[s[i]] != c[i]) {
			cout << -1 << '\n';
			return 0;
		}
		a[s[i]] = c[i];
	}
	reverse(a, a + n);
	int st = pow(10, n - 1);
	for(int i = (st == 1 ? 0 : st); i < st * 10; ++i) {
		int tmp = i;
		bool ok = true;
		for(int j = 0; j < n; ++j) {
			if(a[j] != -1 and tmp % 10 != a[j]) {
				ok = false;
				break;
			}
			tmp /= 10;
		}
		if(ok) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

class light{
	int[] switches;
	int p;
	
	public light(int[] switches){
		this.switches = switches;
		this.p = 0;
	}
	public void setp(int p){
		this.p = p;
	}
}

public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		light[] ls = new light[m];
		
		for(int i=0; i<m; i++){
			int k = sc.nextInt();
			int[] switches = new int[k];
			for(int j=0; j<k; j++){
				switches[j] = sc.nextInt();
			}
			ls[i] = new light(switches);
		}
		
		for(int i=0; i<m; i++){
			ls[i].setp(sc.nextInt());
		}
		
		int patterns = 1;
		for(int i=0; i<n; i++){
			patterns *= 2;
		}
		
		int[] on_off = new int[n];
		for(int i=0; i<patterns; i++){
			int p_copy = i;
			for(int j=0; j<n; j++){
				on_off[j] = p_copy % 2;
				p_copy = (p_copy - p_copy%2) / 2;
			}
			int all_ok = 1;
			pattern: for(int j=0; j<m; j++){
				light light = ls[j];
				int sum = 0;
				for(int k=0; k<light.switches.length; k++){
					sum += on_off[light.switches[k]-1];
				}
				if(sum % 2 != light.p){
					all_ok = 0;
					break pattern;
				}
			}
			if(all_ok == 1){
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b>c+d){
		printf("Left\n");
	}
	else if(a+b==c+d){
		printf("Balanced\n");
	}
	else{
		printf("Right\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3e5 + 7;
 
int n, lg;
int a[N], ps[N], t[6 * N], p[N], dp[N][30];
bool is[N];
 
int big(int x) {
	int pnt = x - 1 + (1 << (lg));
	while (pnt > 1) {
		if (pnt % 2 == 0 && t[pnt + 1] != N + 1)
			return t[pnt + 1];
		pnt /= 2;
	}
	return N + 1;
}
void up(int x) {
	int pnt = x - 1 + (1 << (lg));
	while (pnt) {
		t[pnt] = min(t[pnt], x);
		pnt /= 2;
	}
}
 
int mnb(int l, int r) {
	int tmp = 0;
	while ((1 << tmp) <= r - l + 1)
		tmp++;
	tmp--;
	return min(dp[l][tmp], dp[r - (1 << tmp) + 1][tmp]);
}
 
void solve() {
	cin >> n;
	int res = n;
	lg = ceil(log2(n));
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= 25; j++)
			dp[i][j] = N + 1;
	for (int i = 1; i <= n + 1; i++)
		is[i] = ps[i] = 0, p[i] = N + 1;
	for (int i = 1; i <= (1 << (lg + 1)); i++)
		t[i] = N + 1;
	for (int i = 1; i <= n; i++)
		cin >> a[i], is[a[i]] = 1;
	for (int i = 1; i <= n + 1; i++)
		ps[i] = ps[i - 1] + is[i];
	for (int i = 1; i <= n; i++)
		p[a[i]] = min(p[a[i]], big(a[i])), up(a[i]);
	for (int i = 1; i <= n; i++)
		dp[i][0] = p[i];
	for (int j = 1; j <= 25; j++)
		for (int i = 1; i + (1 << j) - 1 <= n; i++)
			dp[i][j] = min(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
   for (int i = 0; i < n; i++) {
   		int l = i + 1, r = n + 2;
		while (r - l > 1) {
			int md = (r + l) / 2;
			if (mnb(i + 1, md - 1) >= md)
				l = md;
			else
				r = md;	
		}
		res = min (res, ps[n + 1] - ps[l - 1] + ps[i]); 
   }	   
   cout << res << endl;
}
 
 
int main() {
	solve();
 
	
	return 0;
}
 
 


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

using namespace std;

const int INF = 1e9 + 5;

int min_self(int &a , int b){
    a = min(a , b);
return a;
}

int main (){
    int N;
scanf("%d" , &N);
    vector<int> h(N) , dp(N , INF);
    for(int &x : h){
        scanf("%d" , &x);
    }
    dp[0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j : {(i + 1) , (i + 2)}){
            if(j < N){
                min_self(dp[j] , dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d" , dp[N - 1]);
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d,p,q;
	cin>>a>>b>>c>>d;
	if(a*c>a*d)
	{
		p=a*c;
	}
	else
	{
		p=a*d;
	}
	if(b*c>b*d)
	{
		q=b*c;
	}
	else
	{
		q=b*d;
	}
	if(p>q)
	{
		cout<<p<<endl;
	}
	else
	{
		cout<<q<<endl;
	}
}

Measured memory_bytes: 3632
import collections
N = int(input())
S_list = [input() for i in range(N)]
C = collections.Counter(S_list)
L = C.most_common()
max_ = L[0][1]
ans = []
#print("========")
for i in L:
    if i[1] == max_:
        ans.append(i[0])
    else:
        break
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 47640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
int main(){
    int n;
    cin>>n;
    int a[n];
    rep1(i,n) cin>>a[i];
    int co=0;
    rep1(i,n) if (a[i]!=i) co++;
    if ((co<=2) ? cout<<"YES"<<endl : cout<<"NO"<<endl);
    return 0;
}

Measured memory_bytes: 256
M=10**9+7
f=[1]
for j in range(1,10**6):f+=f[-1]*j%M,
i=[pow(f[-1],M-2,M)]
for j in range(1,10**6)[::-1]:i+=i[-1]*j%M,
x,y=map(int,input().split())
n,m=divmod(x+y,3)
print((m<1)*(x*2>=y)*(y*2>=x)*f[n]*i[~n-n+y]*i[~y+n]%M)

Measured memory_bytes: 82200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll A , V;
  cin >> A >> V;
  ll B , W;
  cin >> B >> W;
  ll T;
  cin >> T;
  ll D = abs(A - B);
  ll D2 = (V - W)*T;
  puts(D<=D2?"YES":"NO");
}


Measured memory_bytes: 3536
import bisect
n = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

# B➡Cの対応表を作る
numb = [0]*n
for i,c in enumerate(B):
    numb[i] = n-bisect.bisect_right(C,c)
#print(numb)
for i in range(n-1,0,-1):
    numb[i-1] += numb[i]
#print(numb)
ans = 0
for i in range(n):
    j = bisect.bisect_right(B,A[i])
    if j < n:
        ans += numb[j]
print(ans)

Measured memory_bytes: 23092
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,x;
int a[110]={0},l[110];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int i,j,pos=-1;
    cin>>n>>x;
    for(i=2;i<=n+1;i++)
        cin>>l[i],a[i]=a[i-1]+l[i];
    for(i=1;i<=n+1;i++)
        if(a[i]<=x)
            pos=i;
    cout<<pos<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll oo = 1e9 + 10;
const ll mod = 998244353,maxn = 110;
const double PI = acos(-1); 

ll solve(ll a, ll b, ll cs, ll cw, ll s, ll w){

    ll ans = 0, cnt = 0, ans2 = 0;
    for (ll i=0; i<=cs; i++){
        if (i*s > a) break;
        ll tmp = i + min((a - i*s)/w, cw);
        if (tmp > ans) {
            ans = tmp, cnt = i;
        }
    }
    cs -= cnt;
    cw -= (ans - cnt);
    cnt = 0;

    for (ll i=0; i<=cs; i++){
        if (i*s > b) break;
        ll tmp = i + min((b - i*s)/w, cw);
        if (tmp > ans2) {
            ans2 = tmp, cnt = i;
        }
    }
    ans += ans2;
    return ans;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x, sum = 0, less = 1000000;
    cin >> n >> x;
    vector<int> v(n);

    for (auto &it: v) cin >> it, sum += it, less = min (less, it);

    cout << (x - sum)/less + n << endl;
    return 0; 
}

Measured memory_bytes: 3664
n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()
asum = sum(a)

ans = 1

for i in range(len(a)-1):
    asum -= a[i]
    if a[i]>2*asum:
        break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 63856
#include<stdio.h>
 
int main(void){
  int a,b,c,cnt=0;
 
  scanf("%d%d%d",&a,&b,&c);
  for(;a<=b;a++){
    cnt+=c%a?0:1;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}



Measured memory_bytes: 2624
n,x,y = list(map(int, input().split()))

ans = [0]*(n)
for i in range(n-1):
    for j in range(i+1, n):
        r1 = min(j-i, (abs(x-i-1) + 1 +  abs(y-j-1) ), (abs(y-i-1) + 1 +  abs(x-j-1) ) )
        ans[r1] += 1

for i in ans[1:]:
    print(i)

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

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

	s.at(k-1) += 32;

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))

ans=0
for i in range(n):
    if a[i]>=b[i]:
        ans+=b[i]
    else:
        ans+=a[i]
        res=b[i]-a[i]
        if a[i+1]>res:
            ans+=res
            a[i+1]-=res
        else:
            ans+=a[i+1]
            a[i+1]=0
print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define endl '\n'
#define forn(i, n) for(int i=0;i<n;i++)
#define lli long long int
#define pii pair<int,int>
#define fi first
#define se second
#define psi pair<int,pii>
#define pb push_back
#define vi vector<int>
#define vii vector< vi >

using namespace std;

const int MAXN = 1000001;

int Solve(string cad) {
	if(cad.size() < 4) return 0;
	return
		cad[0] == 'Y' && 
		cad[1] == 'A' && 
		cad[2] == 'K' && 
		cad[3] == 'I';
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string cad;
	cin>>cad;
	if(Solve(cad)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

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

    public class Solve
    {
        public static void Answer()
        {
            var xyz = IO.ReadSplitInt;
            int n = 0;
            for (int i = 0; i < 1000000; i++)
            {
                if (xyz[0] < (i + 1) * xyz[2] + i * xyz[1])
                {
                    n = i - 1;
                    break;
                }
            }
            WriteLine(n);
        }

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

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

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

            #endregion
        }

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

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

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

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

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

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

typedef long long ll;

typedef pair<ll, int> p;

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

    int A, B, C;
    cin >> A >> B >> C;

    if(A <= C && C <= B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200;
char s[N];
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	int ans=0;
	for(int i=1,j=len;i<=len/2;i++,j--){
		if(s[i]!=s[j])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long int min = 10000000;
    long long int max = -10000000;
    long long int x, sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        if (min > x){
            min =x;
        }
        if (max < x){
            max = x;
        }
        sum = sum + x;
    }
    cout << min << " ";
    cout << max << " ";
    cout << sum << endl;
}




Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
long double PI=3.14159265358979323;
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  double A,B;
  int H,M;
  double c;
  cin>>A>>B>>H>>M;
  if(H%12*30<M*5.5){
    if(M*5.5-H%12*30>=180)c=360-(M*5.5-H%12*30);
    else c=M*5.5-H%12*30;
  }
  else{
    if(H%12*30-M*5.5>=180)c=360-(H%12*30-M*5.5);
    else c=H%12*30-M*5.5;
  }
  cout<<fixed<<setprecision(30)<<sqrt(A*A+B*B-2*A*B*cos(PI/2*c/90))<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

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

    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (!a) cout << 1;
    if (!b) cout << 2;
    if (!c) cout << 3;
    if (!d) cout << 4;
    if (!e) cout << 5;
    
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<int>S;
    vector<int>B;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(S.count(x)){
        S.erase(x);
        B.push_back(x);}
        else
        S.insert(x);
    }
    sort(B.begin(),B.end());
    if((int)B.size()<2){
        printf("0\n");
    }
    else
    {
        int x=(int)B.size();
        printf("%lld",1LL*B[x-1]*B[x-2]);
    }
    return 0;
}

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

int main() {
    set<string> se;
    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        se.insert(s);
    }

    cout << se.size() << endl;

    return 0;
}

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

int main()
{

    while (1)
    {
        int h, w;
        cin >> h >> w;

        if (h == 0 && w == 0)
            break;

        string wid = "", midWid = "";
        for (int i = 0; i < w; i++)
        {
            wid += "#";
            if (i == 0 || i == w - 1)
            {
                midWid += "#";
            }
            else
                midWid += ".";
        }
        for (int i = 0; i < h; i++)
        {
            if (i == 0 || i == h - 1)
            {
                cout << wid << endl;
            }
            else
                cout << midWid << endl;
        }
        cout << endl;
    }
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n;
    cin >> n;
    cout << n * (n-1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int t=0;
    int x;
    cin >> x;
    while(t*(t+1)/2 < x){
        t++;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9;
int main()
{
	int n, m;
	cin>>n>>m;
	vector<P> g[15];
	for(int i=0; i<m; i++){
		int a, b, c;
		cin>>a>>b>>c;
		a--; b--;
		g[a].push_back(P(b, c));
		g[b].push_back(P(a, c));
	}
	int dp[14][1<<14];
	for(int i=0; i<n-1; i++){
		if(i==0) fill(dp[i], dp[i]+(1<<(n-1)), 0);
		else fill(dp[i], dp[i]+(1<<(n-1)), INF);
	}
	int s[1<<15]={};
	for(int i=0; i<(1<<n); i++){
		for(int x=0; x<n; x++){
			if((i&(1<<x))==0) continue;
			for(auto pr:g[x]){
				int y=pr.first;
				if((i&(1<<y))==0) continue;
				s[i]+=pr.second;
			}
		}
		s[i]/=2;
	}
	for(int i=1; i<(1<<(n-1)); i++){
		for(int j=i; j>0; j=(j-1)&i){
			int sum=s[i]-s[i-j]-s[j];
			for(int x=0; x<n-1; x++){
				if((j&(1<<x))==0) continue;
				for(auto pr:g[x]){
					int y=pr.first;
					if(((i-j)&(1<<y))==0) continue;
					dp[y][i]=min(dp[y][i], dp[x][j]+sum-pr.second);
				}
			}
		}
	}
	int ans=INF;
	for(int i=1; i<(1<<(n-1)); i++){
		int sum=s[(1<<n)-1]-s[i]-s[(1<<n)-1-i];
		for(auto pr:g[n-1]){
			int y=pr.first;
			if((i&(1<<y))==0) continue;
			ans=min(ans, dp[y][i]+sum-pr.second);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>

typedef long long ll;

using namespace std;

ll N,A[200001],C[200001];

int main() {
  ll sum=0,val;
  cin>>N;
  for(ll i=0;i<N+1;i++){
    C[i]=0;
  }
  for(ll i=1;i<N+1;i++){
    scanf("%lld",&A[i]);
    C[A[i]]++;
  }

  for(ll i=1;i<N+1;i++){
    sum+=C[i]*(C[i]-1)/2;
  }

  for(ll i=1;i<N+1;i++){
    val=sum-(C[A[i]]*(C[A[i]]-1)/2)+((C[A[i]]-1)*(C[A[i]]-2)/2);
    printf("%lld\n",val);
  }

}


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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------
int n,x,l[100005];
void solve()
{
	cin>>n>>x;
	rep(i,0,n)cin>>l[i];
	int ans=1;
	int c=0,num=0;
	while(num<n)
	{
		c+=l[num++];
		if (c<=x)ans++;
		else break;

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

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

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
n = int(input())
pair_list = [ [ int(v) for v in input().split() ] for i in range(n) ]
pair_list.reverse()


ans = 0
a = 0
for i in pair_list:
    x, y = i
    x += a
    if x % y != 0:
        z = y - (x % y)
    else:
        z = 0
    a += z
    ans += z




print(ans)

Measured memory_bytes: 62296
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int num[101];

int main(){ _;
  int n,m,p;
  while(cin>>n>>m>>p,!(n==0&&m==0&&p==0)){
    int sum=0;
    REP(i,n){
      cin>>num[i];
      sum+=num[i];
    }
    m--;
    cout<<(num[m]==0?0:(100-p)*sum/num[m])<<endl;
  }
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b/x - a/x;
    if(a%x==0) ans++;
    P(ans);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <utility>

#define MAX_N (100000L)
#define MAX_M (100000L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, M, as[MAX_N], bs[MAX_M], cs[MAX_M];
  scanf("%ld %ld", &N, &M);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }
  for (long j = 0; j < M; j++) {
    scanf("%ld %ld", &bs[j], &cs[j]);
  }

  // solve
  priority_queue<pair<long, long>> que;
  // add initial cards
  for (long i = 0; i < N; i++) {
    que.push(make_pair(as[i], 1));
  }
  // add numbers that can be introduced
  for (long j = 0; j < M; j++) {
    que.push(make_pair(cs[j], bs[j]));
  }
  long num = 0, ans = 0;
  while (num < N) {
    const long c = que.top().first, b = que.top().second, n = min(N - num, b);
    que.pop();
    num += n;
    ans += c * n;
    // printf("c = %ld, b = %ld, ans = %ld\n", c, b, ans);
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 8816
#include <iostream>
#include<cmath>
using namespace std;
int main(void){
    int K,S;
    cin>>K>>S;
    
    int X,Y,Z,ans;
    ans=0;
   
    for(X=0;X<=K;X++){
        for(Y=0;Y<=K;Y++){
            Z=S-X-Y;
            if(Z<=K && 0<=Z){
                ans=ans+1;
            }
                
        }
                
    }
    
       
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let f xs =
    let rec aux c xs =
        match List.skipWhile ((=) 0) xs with
        | [] -> c
        | ys -> aux (c + 1) (List.skipWhile (fun y -> y > 0) ys)
    aux 0 xs

[<EntryPoint>]
let main _ =
    let n = read int
    let hs = reads int
    seq {
        let mutable xs = hs
        while List.exists (fun x -> x > 0) xs do
            yield f xs
            xs <- List.map (fun x -> if x > 0 then x - 1 else x) xs
    }
    |> Seq.sum
    |> printfn "%i"
    0

Measured memory_bytes: 14044
#include<iostream>
#include<string>
#include<stack>
#include<cctype>
#include<cstdio>

#define PRECISE "6"
#define BUF_SIZ 1024

using namespace std;

double CalcPeaterExpression(string &exp){
	stack<double> st;

	for(unsigned int i = 0; i < exp.length(); i++){
		double v1, v2, v;
		int sign = 1;

		if( exp[i] == ' ' ) continue;

		if( i+1 < exp.length() && exp[i] == '-' && isdigit(exp[i + 1]) ){
			sign = -1;
			i++;
			goto PARSE_NUMBER;
		}

		switch( exp[i] ){
			case '+': case '-': case '*': case '/':
				v1 = st.top(); st.pop();
				v2 = st.top(); st.pop();
				//}else continue;
				switch( exp[i] ){
					case '+': v = v1 + v2; break;
					case '-': v = v2 - v1; break;
					case '*': v = v1 * v2; break;
					case '/': v = v2 / v1; break;
				}
				st.push( v );
				continue;
		}

PARSE_NUMBER:;		
		if( isdigit(exp[i]) ){
			double num = 0;
			do{
				num *= 10.0;
				num += (double)(exp[i] - '0');
				++i;
			}while( i < exp.length() && isdigit(exp[i]) );
			st.push( sign * num );
		}
	}
	return st.top();
}

int main(void){
	while( true ){
		char buf[BUF_SIZ];
		string s;

		cin.getline( buf, sizeof(buf)/sizeof(*buf) );
		if( cin.eof() ) break;

		s = buf;
		printf("%."PRECISE"f\n", CalcPeaterExpression( s ));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    map<string,int> mp;
    for(int i=0;i<N;i++){
     string s;
     cin >>s;
     mp[s]++;
   }  
   int mx=0;
   for(auto p :mp){
       mx=max(mx,p.second);
   }
   for(auto p : mp){
       if(p.second != mx) continue;
       cout <<p.first <<endl;
   }

}

Measured memory_bytes: 19152
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
int dp[222];
main()
{
	while(cin>>N,N)
	{
		vector<pair<int,int> >A;
		for(int i=0;i<N;i++)
		{
			int a,b;cin>>a>>b;
			A.push_back(make_pair(a,-b));
		}
		cin>>M;
		for(int i=0;i<M;i++)
		{
			int a,b;cin>>a>>b;
			A.push_back(make_pair(a,-b));
		}
		sort(A.begin(),A.end());
		for(int i=1;i<=N+M+4;i++)dp[i]=1e9;
		for(pair<int,int>p:A)
		{
			int r=-p.second;
			int L=0,R=N+M+1;
			while(R-L>1)
			{
				int X=L+R>>1;
				if(dp[X]<r)L=X;
				else R=X;
			}
			dp[R]=r;
		}
		int ans=0;
		while(dp[ans+1]<1e9)ans++;
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3020
#!C:\Users\t.kida\vs_code\atcoder\.venv\Scripts\python.exe
import numpy
import scipy

A, B, C = [ int(x) for x in input().split(" ") ]
ans = 0
if(A + B < C):
    ans = B + (A+B) + 1
else:
    ans = B + C

print(ans)

Measured memory_bytes: 21664
#include <stdio.h>

int a[9];
int b[9];
int main(){
	for(int i=0;i<9;i++)scanf("%d",a+i);
	int n;
	scanf("%d",&n);
	for(int _=0;_<n;_++){
		int t;
		scanf("%d",&t);
		for(int i=0;i<9;i++)if(a[i]==t)b[i]=1;
	}
	if(  b[0]&&b[3]&&b[6]
	   ||b[1]&&b[4]&&b[7]
	   ||b[2]&&b[5]&&b[8]
	   ||b[0]&&b[1]&&b[2]
	   ||b[3]&&b[4]&&b[5]
	   ||b[6]&&b[7]&&b[8]
	   ||b[0]&&b[4]&&b[8]
	   ||b[2]&&b[4]&&b[6])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF=2e9;
int N,K,x[100005],ans=INF;
int main()
{
	scanf("%d %d",&N,&K);
	for(int i=1;i<=N;i++)
	scanf("%d",&x[i]);
	for(int i=1;i<=N-K+1;i++)
	{
		if(x[i+K-1]<=0)
		ans=min(ans,abs(0-x[i]));
		else if(x[i]>=0)
		ans=min(ans,abs(x[i+K-1]-0));
		else
		ans=min(ans,abs(0-x[i])+abs(x[i+K-1]-0)+min(abs(0-x[i]),abs(x[i+K-1]-0)));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
void getH(int,int);

typedef struct {
  int parent;
  int child;
  int brother;
  int child2;
  int deg;
} node;

node n[100000];
int H;
int main()
{
  int a,c,d,e,i,j,num,depth;
  scanf("%d", &num);
  for(i=0;i<num;i++){
    n[i].parent=-1;
    n[i].brother=-1;
 n[i].child=-1;
  }
  for(i=0;i<num;i++){

    scanf("%d",&a);
    n[a].deg=0;    
scanf("%d%d",&n[a].child,&n[a].child2);

    if(n[a].child2!=-1){
      n[n[a].child2].parent=a;
      n[n[a].child2].brother=n[a].child;
      n[a].deg++;
}
 if(n[a].child!=-1){
n[n[a].child].parent=a;
      n[n[a].child].brother=n[a].child2;
 n[a].deg++;
}

  }
  
for(i=0;i<num;i++){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,n[i].parent,n[i].brother,n[i].deg);
    
c=n[i].parent;    
    depth=0;    
while(c!=-1){
depth++;
      c=n[c].parent;


}
    printf("depth = %d, ",depth);
    H=0;    
getH(i,0);
    printf("height = %d, ",H);    

if(n[i].parent==-1)
      printf("root\n");
    else if(n[i].child==-1&&n[i].child2==-1)printf("leaf\n");
    else printf("internal node\n");

 }

  

    return 0;
  }



void getH(int x,int h){
  if(x==-1)return;

  getH(n[x].child,h+1);
getH(n[x].child2,h+1);

 if(H<h)H=h;
}

Measured memory_bytes: 612
N = int(input())
a = list(map(int, input().split()))

array1 = [0] * 8
over3200 = 0

for i in range(N):
  if 0 < a[i] < 400:
    array1[0] = 1
  elif 400 <= a[i] < 800:
    array1[1] = 1
  elif 800 <= a[i] < 1200:
    array1[2] = 1
  elif 1200 <= a[i] < 1600:
    array1[3] = 1
  elif 1600 <= a[i] < 2000:
    array1[4] = 1
  elif 2000 <= a[i] < 2400:
    array1[5] = 1
  elif 2400 <= a[i] < 2800:
    array1[6] = 1
  elif 2800 <= a[i] < 3200:
    array1[7] = 1
  else:
    over3200 += 1
A = array1.count(1)
B = array1.count(0)

ansmax = A + over3200
ansmin = max(A, 1)
    
print(ansmin, ansmax)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX = 1000 + 10;
char arr[MAX];

int main(){
  scanf("%s", arr);
  bool N=0,W=0,S=0,E=0,ans=true;
  int len = strlen(arr);
  for(int i = 0 ; i < len ; i++){
    if(arr[i] == 'N')N=1;
    else if(arr[i] == 'W')W=1;
    else if(arr[i] == 'S')S=1;
    else if(arr[i] == 'E')E=1;
  }
  if( (N&&!S) || (S&&!N) ) ans = false;
  if( (W&&!E) || (E&&!W) ) ans = false;
  if(ans) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func isEnough(T, A, B int, h *[]int) bool {
	cnt := 0
	for _, point := range *h {
		if remain := point - T*B; remain > 0 {
			cnt += remain / (A - B)
			if remain%(A-B) != 0 {
				cnt++
			}
		}
	}

	if cnt > T {
		return false
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)

	N, A, B := scanInt(), scanInt(), scanInt()
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = scanInt()
	}
	sort.Ints(h)

	left, right := 0, h[N-1]
	for left < right {
		middle := ((right - left) / 2) + left
		if isEnough(middle, A, B, &h) {
			right = middle
		} else {
			left = middle + 1
		}
	}

	fmt.Println(left)
}


Measured memory_bytes: 4276
#include<stdio.h>
int main(void){
	int a,b,c,h;
	
	scanf("%d%d%d",&a,&b,&c);
	
	if (a>b) {h=a; a=b; b=h;}
	if (b>c) {h=b; b=c; c=h;}
	if (a>b) {h=a; a=b; b=h;}

	printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596