akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll k, x, y;
  cin >> k >> x >> y;

  auto dis = [](ll x, ll y, ll a, ll b) { return abs(x - a) + abs(y - b); };

  vP ans;
  ll nx = 0, ny = 0;
  while (dis(nx, ny, x, y) >= 2 * k) {
    if (x - nx >= k)
      nx += k;
    else if (nx - x >= k)
      nx -= k;
    else if (y - ny >= k)
      ny += k;
    else
      ny -= k;
    ans.emplace_back(nx, ny);
  }
  if (dis(nx, ny, x, y) == k) {
    ans.emplace_back(x, y);
    goto ANS;
  }

  if (dis(nx, ny, x, y) % 2 == 1) {
    if (k % 2 == 0) {
      puts("-1");
      return 0;
    }
    if (dis(nx + k, ny, x, y) < 2 * k)
      nx += k;
    else if (dis(nx - k, ny, x, y) < 2 * k)
      nx -= k;
    else if (dis(nx, ny + k, x, y) < 2 * k)
      ny += k;
    else
      ny -= k;
    ans.emplace_back(nx, ny);
  }

  ll alpha, xdir, ydir;
  if (dis(nx, ny, x, y) == k) {
    ans.emplace_back(x, y);
    goto ANS;
  }

  alpha = (2*k - dis(nx, ny, x, y)) / 2;
  xdir = 1, ydir = 1;
  if (x < nx) xdir = -1;
  if (y < ny) ydir = -1;
  if (abs(x - nx) < abs(y - ny)) {
    nx -= xdir * alpha;
    ny += ydir * (k - alpha);
  } else {
    nx += xdir * (k - alpha);
    ny -= ydir * alpha;
  }
  ans.emplace_back(nx, ny);
  ans.emplace_back(x, y);

ANS:
  ll s = ans.size();
  ll prex = 0, prey = 0;
  cout << s << endl;
  rep(i, s) {
    cout << ans[i].first << " " << ans[i].second << endl;
    assert(dis(prex, prey, ans[i].first, ans[i].second) == k);
    tie(prex, prey) = ans[i];
  }

  return 0;
}


Measured memory_bytes: 6256
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		int i;
		int sum = 0;
		
		while (n-- > 0){
			int x, y, h, w;
			
			scanf("%d %d %d %d", &x, &y, &h, &w);
			if (x + y + h > 160 || w > 25){
				sum += 0;
			}
			else if (x + y + h > 140 || w > 20){
				sum += 1600;
			}
			else if (x + y + h > 120 || w > 15){
				sum += 1400;
			}
			else if (x + y + h > 100 || w > 10){
				sum += 1200;
			}
			else if (x + y + h > 80 || w > 5){
				sum += 1000;
			}
			else if (x + y + h > 60 || w > 2){
				sum += 800;
			}
			else {
				sum += 600;
			}
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 600
x = int(input())
import math
for i in range(10**5):
    z = (x - i ** 5)
    if z == 0:
        b = 0
    else:
        b = (x - i ** 5) ** (1/5)
    #print(i, b)
    if i ** 5 - math.floor(abs(b)) ** 5 == x:
        print(i, math.floor(abs(b)))
        exit()
    if i ** 5 - (-math.floor(abs(b))) ** 5 == x:
        print(i, -math.floor(abs(b)))
        exit()
    if i ** 5 - math.ceil(abs(b)) ** 5 == x:
        print(i, math.ceil(abs(b)))
        exit()
    if i ** 5 - (-math.ceil(abs(b))) ** 5 == x:
        print(i, -math.ceil(abs(b)))
        exit()


Measured memory_bytes: 9448
#include<stdio.h>
int main(void){
  int n,h,i,sum=0;
  

  while(1){
    scanf("%d",&n);

    if(n==0)break;
    
    for(i=0;i<n/4;i++){
      scanf("%d",&h);
      sum+=h;
    }
    printf("%d\n",sum);
    sum=0;  
}
  
  return (0);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
int prime_check(int n);

int main(void){
	int i,c,n;
	int data[6000];
	i=3;c=0;
	data[c++]=2;
	for(i=3;i< 50030;i+=2){
		if( prime_check(i)==1){
			data[c]=i;
			c++;
		}
	}
	while(scanf("%d",&n)!=EOF){
		for(i=0;i<6000;i++){
			if(data[i]>=n){
				break;
			}
		}
		if(n==data[i]){
			printf("%d %d\n",data[i-1],data[i+1]);
		}else{
			printf("%d %d\n",data[i-1],data[i]);
		}
	}
	return 0;
}

int prime_check(int n){
	int i;
	if(n<2){return 0;}
	if(n==2){return 1;}
	if(n%2==0){return 0;}
	for(i=3;i<sqrt(n);i+=2){
		if(n%i==0){return 0;}
	}
	return 1;
}

Measured memory_bytes: 616
import sys
import math

INF = 10**9+7

def k(i):
    if(i == 1):
        return 1
    else:
        return(i * k(i-1))

def comb(n, r):
    if(n == r or r == 1):
        return 1
    else:
        return k(n) / (k(n-r) * k(r))

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()
a = nil()

b = []

for i in range(n):
    b.append(a[i])


sum = 0

c1 = 0
c2 = 0

if a[0] == 0:
    a[0] = 1
    c1 += 1;

for i in range(0, n-1):
    sum += a[i]

    sum2 = sum + a[i+1]

    if sum2 == 0:
        if sum >0:
            a[i+1] -= 1
            sum2 -= 1
            c1 +=1

    if(sum * sum2 >= 0):
        k = abs(sum2) + 1

        h = k - (abs(sum) - 1)
        l = k - h

        if sum > 0 :
            a[i] -= l
            sum -= l
            a[i + 1] -= h
        else:
            a[i] += l
            sum += l
            a[i + 1] += h

        c1 += h+l


sum = 0

a = b

if a[0] == 0:
    a[0] = -1
    c2 += 1;
else:
    c2 = abs(a[0]) + 1
    if a[0] > 0:
        a[0] = -1
    else:
        a[0] = 1

for i in range(0, n-1):
    sum += a[i]

    sum2 = sum + a[i+1]

    if sum2 == 0:
        if sum >0:
            a[i+1] -= 1
            sum2 -= 1
            c2 +=1

    if(sum * sum2 >= 0):
        k = abs(sum2) + 1

        h = k - (abs(sum) - 1)
        l = k - h

        if sum > 0 :
            a[i] -= l
            sum -= l
            a[i + 1] -= h
        else:
            a[i] += l
            sum += l
            a[i + 1] += h

        c2 += k

print(min(c1, c2))






Measured memory_bytes: 14332
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long long ll;
ll N,X,Y,Z,t,mod=1e9+7;
vector<int> A[1001],B[1001];//t乗したらi-cycleになるものたち,2
ll dp[1001][1001],f[1001][1001],g[1001][1001],fac[1001];
ll ret[1001][1001];
void add(ll &x,ll y){
	x+=y;
	if(x>=mod) x-=mod;
}
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
ll pw(ll a,ll x){
	ll ret=1;
	while(x){
		if(x%2) ret=ret*a%mod;
		a=a*a%mod;
		x/=2;
	}
	return ret;
}
ll inv(ll a){
	return pw(a,mod-2);
}
ll invfac[1001];
int main(){
	fac[0]=1;
	rep(i,1000) fac[i+1]=fac[i]*(i+1)%mod;
	rep(i,1001) invfac[i]=inv(fac[i]);
	cin>>N>>X>>Y>>Z;
	t=abs(X+Z-Y);
	rep1(i,N){
		A[i/gcd(i,t)].pb(i);
	}
	dp[0][0]=1;
	rep1(i,N){
		rep(j,A[i].size()){
			int a=A[i][j];
			int m=a/i;
			rep(k,N/i+1) dp[j+1][k]=0;
			rep(k,N/i+1){//num of cycle
				for(int h=0;k+h*m<=N/i;h++){
					add(dp[j+1][k+h*m],dp[j][k]*invfac[h]%mod*inv(pw(m,h))%mod*pw(i,h*(m-1))%mod);
				}
			}
		}
		rep(k,N/i+1) f[i][k]=dp[A[i].size()][k]*fac[k]%mod;
	}
/*	rep1(i,N){
		cout<<"  cycle"<<i<<endl;
		rep(j,N/i+1){
			printf("f[%d][%d]=%lld\n",i,j,f[i][j]);
		}
		cout<<endl;
	}*/
	rep1(i,N){
		B[i/gcd(i,2)].pb(i);
	}
	dp[0][0]=1;
	rep1(i,N){
		rep(j,B[i].size()){
			int a=B[i][j];
			int m=a/i;
			rep(k,N/i+1) dp[j+1][k]=0;
			rep(k,N/i+1){//num of cycle
				for(int h=0;k+h*m<=N/i;h++){
					add(dp[j+1][k+h*m],dp[j][k]*invfac[h]%mod*inv(pw(m,h))%mod*pw(i,h*(m-1))%mod);
				}
			}
		}
		rep(k,N/i+1) g[i][k]=dp[B[i].size()][k]*fac[k]%mod;
	}
/*	rep1(i,N){
		cout<<"  cycle"<<i<<endl;
		rep(j,N/i+1){
			printf("g[%d][%d]=%lld\n",i,j,g[i][j]);
		}
		cout<<endl;
	}*/
	ret[0][0]=1;
	rep1(i,N){ //using cycle
		rep(j,N+1){
			for(int k=0;i*k+j<=N;k++){ //num
				add(ret[i][i*k+j],ret[i-1][j]*f[i][k]%mod*g[i][k]%mod*inv(pw(i,k))%mod*invfac[k]%mod);
			}
		}
	}
	ll ans=ret[N][N]*fac[N]%mod;
	if(X+Y+Z==0) ans=ans*invfac[N]%mod*pw(N,N)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 32612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
typedef long long lint;
template< typename T > using Vec = vector< T >;

int main() {
	int N;
	cin >> N;
	
	Vec< int > a(N);
	for_(i,0,N) cin >> a[i];
	
	int cnt[2] = {0,0};
	for_(i,0,N) {
		if (a[i] % 2 == 1) ++cnt[0];
		if (a[i] % 4 == 0) ++cnt[1];
	}
	
	if (cnt[0] + cnt[1] == N) {
		puts(cnt[0] <= cnt[1] + (N % 2) ? "Yes" : "No");
	} else {
		puts(cnt[0] > cnt[1] ? "No" : "Yes");
	}
}

Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  string s;
  cin >> s;
  size_t r = s.rfind('Z'), l = s.find('A');
  if (r == string::npos || l == string::npos || (int) r - (int) l < 0) {
    cout << -1 << endl;
    return 0;
  }
  int t = -1;
  string w;
  for (auto &c : s) {
    if (c == 'A' && t) {
      t = 0;
      w += 'A';
    }
    if (c == 'Z' && !t) {
      t = 1;
      w += 'Z';
    }
  }
  if (w.back() == 'A') w.pop_back();
  cout << w << endl;
}

Measured memory_bytes: 3220
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


/////////////////////////////////////////////////////////////////



int main(){
    string s;ll k;cin>>s>>k;
    int n=s.size();
    rep(i,0,n-2){
        if(s[i]=='a')continue;
        if('z'+1-s[i]<=k){
            k-='z'+1-s[i];
            s[i]='a';
        }
    }
    s[n-1]=(s[n-1]-'a'+k)%26+'a';
    cout<<s<<endl;
    return 0;
}

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

const int INF = 1001001001;
int d[100005];

int n;
vector<vector<int>> to(100005);
vector<vector<int>> length(100005);
// stack<int> q;
void dfs(int c_v){
  for(int i=0;i<to[c_v].size();i++){
    int n_v = to[c_v][i];
    int l = length[c_v][i];
    if (d[n_v] != INF) continue;
    // q.push(to[c_v][i]);
    d[n_v] = (d[c_v]+l)%2;
    dfs(n_v);
  }
  // q.pop();
}

int main() {
  cin >> n;
  rep(i,n-1) {
    int u,v,w;
    cin >> u >> v >> w;
    --u; --v;
    to[u].push_back(v);
    to[v].push_back(u);
    length[u].push_back(w);
    length[v].push_back(w);
  }
  // cout << "ok" << endl;
  rep(i,n) d[i] = INF;
  // q.push(0);
  d[0] = 0;
  dfs(0);
  rep(i,n)cout << d[i] << endl;
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    vector<int> A;
    for(int i=0; i<N;i++){
      int aa; cin>>aa; A.push_back(aa);
    }
    sort(A.begin(),A.end());
    int max_k=0;
    for(int i=0; i<N;i++){
      int a=A[i];
      int a_k = upper_bound(A.begin(),A.end(), a) - lower_bound(A.begin(),A.end(), a);
      int b_k = upper_bound(A.begin(),A.end(), a+1) - lower_bound(A.begin(),A.end(), a+1);
      int c_k = upper_bound(A.begin(),A.end(), a-1) - lower_bound(A.begin(),A.end(), a-1);
      int k=a_k+b_k+c_k;
      max_k=max(k, max_k);
    }

    cout<<max_k<<endl;

    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
	double x;
	int m,n;
	char bin[14];
	
	bin[8] = '.';
	bin[13] = 0;
	while (scanf("%lf", &x), x>=0){
		x -= (n = x);
		for (int i=0; i<8; i++){
			bin[7-i] = '0'+(n%2);
			n /=2;
		}
		for (int i=0; i<4; i++){
			bin[9+i] = '0' + ((x*=2)>=1.0);
			x -=m=x;
		}
		if (n || x>0){
			puts("NA");
			continue;
		}
		printf("%s\n",bin);
	}
	
	return 0;
}

Measured memory_bytes: 1044
from itertools import accumulate
n,x = map(int,input().split())
a = list(map(int,input().split()))
b = list(accumulate(a))
b = [0]+b
tmp = 0
cnt = 0
for i in range(n-1):
    t = b[i+2]-b[i]-x-tmp
    tmp = 0
    if t>0:
        cnt += t
        tmp += min(t,a[i+1])    
print(cnt)


Measured memory_bytes: 14528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

void solve()
{
  ll n;
  cin>>n;
  ll i,j;
  ll a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll freq[63];
  clr(freq);
  ll res=0;
  for(i=0;i<n;i++)
  {
    for(j=0;j<=60;j++)
    {
      ll no = 1ll<<j;
      no&=a[i];
      if(no==0)
      {
        ll tans = (1ll<<j);
        tans%=mod;
        tans*=freq[j];
        tans%=mod;
        res+=tans;
        res%=mod;
      } 
      else{
        // cout<<a[i]<<" "<<j<<"\n";
        ll tans = (1ll<<j);
        tans%=mod;
        tans*=(i-freq[j]);
        tans%=mod;
        res+=tans;
        res%=mod;
        freq[j]++;
      }
    }
  }
  cout<<res<<"\n";
}


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

  if (fopen("input.txt", "r"))
  {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cout << setprecision(20);

  ll t = 1;

  // cin>>t;

  while (t--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 5940
#include <stdio.h>

int main(void){
    int n1,n2;
    char m;
    for(;scanf("%d %c %d",&n1,&m,&n2),m != '?';){
        switch(m){
            case '+': printf("%d\n",n1+n2); break;
            case '-': printf("%d\n",n1-n2); break;
            case '*': printf("%d\n",n1*n2); break;
            case '/': printf("%d\n",n1/n2); break;
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


#include <cstdlib> // atoi
#include <cctype> // isdigit
using namespace std;

int main() {
    string str;
    int A[10];
    int B[10];
    
    cin >> str;
    
    int N = str.length();
    
    // char -> int 変換 (数字でなかったら -1)
    int i = 0;
    for ( char ch : str ) {
        A[i] = isdigit(ch) ? atoi(string(1,ch).c_str()) : -1;
        //cout << A[i]<< endl;
        i++;
    }
    
    int min = 753;
    for (int i=0;i<N-2;i++) {
        int temp = A[i]*100 + A[i+1]*10 + A[i+2];
        int min_temp = abs(temp-753);
        if (min_temp<min) min = min_temp;
    }
    
    cout << min << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv){
  int r;
  
  while(cin >> r) {
    if (r < 1200) {
      cout << "ABC" << endl;
    } else if (r < 2800) {
      cout << "ARC" << endl;
    } else {
      cout << "AGC" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N;
int A[Max];
pair<int, int> s[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(A, N);

    rep(i, N) {
        s[i] = make_pair(A[i], i+1);
    }

    sort(s, s+N);

    rep(i, N) {
        auto& ss = s[i];
        printf("%d ", ss.second);
    }
    printf("\n");


    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<ll,ll>;
using T = std::tuple<int,int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
const ll INF = std::numeric_limits<ll>::max() / 2;

int R, C, N;
vector<T> edges;
vector<P> graph[200000];
bool visited[200000];
ll values[200000];

template <int n>
void dfs(int u, ll value, vector<P> (&graph)[n], bool (&visited)[n]){
    visited[u] = true;
    values[u] = value;
    
    for(const P& e : graph[u]){
        int v, a;
        tie(v, a) = e;

        // value + ? = a
        if(!visited[v]){dfs(v, 1ll * a - value, graph, visited);}
    }
}

template <int n>
P dfs2(int u, vector<P> (&graph)[n], bool (&visited)[n]){
    visited[u] = true;

    P result = std::make_tuple(INF, INF);
    if(u < R){fst(result) = min(fst(result), values[u]);}
    else{snd(result) = min(snd(result), values[u]);}
    
    for(const P& e : graph[u]){
        int v = fst(e);
        if(!visited[v]){
            P nextResult = dfs2(v, graph, visited);
            fst(result) = min(fst(result), fst(nextResult));
            snd(result) = min(snd(result), snd(nextResult));      
        }
    }

    return result;
}

void sayNo(){
    puts("No");
    exit(0);
}

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

    std::cin >> R >> C >> N;

    for(int i=0;i<N;++i){
        int r, c, a;
        std::cin >> r >> c >> a;

        --r; --c;
        
        graph[r].emplace_back(R+c, a);
        graph[R+c].emplace_back(r, a);
        edges.emplace_back(r, R+c, a);
    }

    int M = R + C;
    for(int i=0;i<M;++i){
        if(!visited[i]){
            dfs(i, 0, graph, visited);
        }
    }

    for(const T& e : edges){
        int u, v, a;
        tie(u, v, a) = e;

        if(values[u] + values[v] != a){
            sayNo();
        }
    }

    memset(visited, 0, sizeof(visited));

    for(int i=0;i<M;++i){
        if(!visited[i]){
            P minPair = dfs2(i, graph, visited);
            ll a, b;
            tie(a, b) = minPair;

            if(a + b < 0){sayNo();}
        }
    }

    puts("Yes");
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for (int i = 0; i < k; ++i) {
        if (a + i <= b)
            ans.insert(a + i);
    }
    for (int i = k-1; i >= 0; --i) {
        if (b - i >= a)
            ans.insert(b - i);
    }
    for (auto i : ans) cout << i << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 100000;

signed main() {
	int dp[55][3010] = {};
	for (int N, M, S; cin >> N >> M >> S&&N;) {
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		rep(m, 1, M + 1) {
			rrep(i, 1, N*N + 1) {
				rep(j, 0, S + 1) {
					if (j + m > S)break;
					(dp[i][j + m] += dp[i - 1][j]) %= MOD;
				}
			}
		}
		cout << dp[N*N][S] << endl;
	}
	return 0;
}

Measured memory_bytes: 3700
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author takaesumizuki
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        Integer eat = new Integer(str);
        Integer refundMoney = eat/15*200;
        Integer payMoney = eat * 800;
        Integer diffMoney = payMoney - refundMoney;
        System.out.println(diffMoney);
        
    }
    
}


Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

long long lcm(long long a, long long b) {
	return a / __gcd(a, b) * b;
}

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

	vector<long long> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	long long ans = accumulate(t.begin(), t.end(), 1LL, lcm);
	// long long ans = accumulate(
	// 	t.begin(), t.end(), 1LL,
	// 	[](long long &a, long long &b) {
	// 		return a / __gcd(a, b) * b;
	// 	});
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input());
list = []
for i in range(N):
 list.append(int(input()))
list = sorted(list, reverse=True)
result = 0;
for j in range(N):
 if j == 0:
  result = int(list[j]/2);
 else:
  result = result + list[j];
print(result)

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

int main(){
	int N;
	cin >> N;
	ll ans = (ll)N*(N-1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int w,a,b;
    cin >> w >> a >> b;
    if(abs(a-b)<=w) cout << 0 << endl;
    else{

    cout << min(abs(a+w-b),abs(b+w-a))  << endl;    }

}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

#define MAX 500000
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;


signed main()
{   
    gearup;
    int a;string s;
    cin >> a >> s;
    cout <<(a>=3200?s:"red") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
const int MAXN=1e5+5,MAXM=2e5+5;

int n,m;

int inDgr[MAXN];
struct E{int next,to,val;} e[MAXM];int ecnt,G[MAXN];
void addEdge(int u,int v,int w){e[++ecnt]=(E){G[u],v,w};G[u]=ecnt;}

bool ab[MAXN],vis[MAXN];
int f[MAXN];
std::queue<int> que;
inline bool topoDP()
{
	for(int i=1;i<=n;i++) if(!inDgr[i]) que.push(i),vis[i]=true;
	while(!que.empty())
	{
		int u=que.front();que.pop();
		for(int i=G[u];i;i=e[i].next)
		{
			int v=e[i].to;
			if(f[v])
			{
				if(f[v]!=f[u]+e[i].val) return false;
			}else f[v]=f[u]+e[i].val;
			if(--inDgr[v]==0) que.push(v),vis[v]=true;
		}
	}
	for(int i=1;i<=n;i++) if(ab[i]&&!vis[i]) return false;
	return true;
}

int main()
{
	int i;scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		int u,v,w;scanf("%d%d%d",&u,&v,&w);
		addEdge(u,v,w);inDgr[v]++;ab[u]=true,ab[v]=true;
	}
	if(topoDP()) puts("Yes");
	else puts("No");
	return 0;
}
/*
3 3
1 2 1
2 3 1
1 3 5
*/

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll ans = max((N - 1) / A, max((N - 1) / B, max((N - 1) / C, max((N - 1) / D, (N - 1) / E )))) + 5;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl

int LIS(vector<int> A){
    int N=A.size();
    vector<int> D;
    for(int i=0;i<N;i++){
        int pos=distance(D.begin(),lower_bound(D.begin(), D.end(),A[i]+1));
        if(pos==D.size()){
            D.push_back(A[i]);
        }else{
            D[pos]=A[i];
        }
    }
    return D.size();
}

signed main(void){
    int N,a;
    vector<int> A;
    cin >> N;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    reverse(A.begin(),A.end());
    cout << LIS(A) << endl;
    return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  int ans=0;
  for(int i=0; i<N; i++){
    ans += L+i;
  }
  if( N+L-1<0){
    cout << ans -(L + N -1);
  }
  else if (L>0){
    cout << ans - L;
  } 
  else {
    cout << ans ;
  }
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
d={}
for ai in a:
    if ai not in d:
        d[ai]=1
    else:
        d[ai]+=1

s={}
for ai in d:
    k=d[ai]
    if ai-1 in d:
        k+=d[ai-1]
    if ai+1 in d:
        k+=d[ai+1]
    s[ai]=k

print(max(s.values()))

Measured memory_bytes: 59628
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    vector<int> a;
    REP(i, n)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    reverse(a.begin(), a.end());
    vector<int> b, c;
    REP(i, n)
    {
        if (i % 2 == 0)
        {
            b.push_back(a[i]);
        }
        else
        {
            c.push_back(a[i]);
        }
    }
    reverse(c.begin(), c.end());
    copy(c.begin(), c.end(), back_inserter(b));
    REP(i, n)
    {
        if (i == 0)
        {
            cout << b[i];
        }
        else
        {
            cout << " " << b[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 5108
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(void){
    string s;
    cin>>s;
    if(s == "ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3648
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    }
}

Measured memory_bytes: 21972
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <cmath> 
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
#define MAX_SIZE 10000000
vector<bool> V(MAX_SIZE,false);
int main(){
      fast
      ll n;
      cin>>n;
      ll a = n % 100;
      ll a1 = n /100;
      ll m = 5 * a1 ;
      if(a<=m && n>=100) cout<<1<<endl;
      else cout<<0<<endl;
}

Measured memory_bytes: 1536
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    cin >> n;
    string ans;
    while(n>26){
        ll tmp = (n%26);
        if(tmp == 0){
            tmp = 26;
        }
        n /=26;
        if(tmp==26){
            n--;
        }
        ans.push_back(tmp+('a'-1));
    }
    ll tmp = (n%26);
    if(tmp == 0){
        tmp = 26;
    }
    ans.push_back(tmp+('a'-1));
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3156
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        int B = sc.nextInt();
		
      	if(B % A == 0){
                  System.out.println(A+B);
        }
      else{
              System.out.println(B-A);
      }


    }
}

Measured memory_bytes: 21844
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize,
    }
    let mut ct = 0;
    let min = std::cmp::min(a,b);
    let mut ans = min;
    for i in (1..min+1).rev() {
        if a % i == 0 && b % i == 0 {
            ct += 1;
        }
        if ct == k {
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}


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

int main(void){
  int n,x,d=0,cnt=1;
  cin>>n>>x;
  vector<int> l(n);
  r(i,n)cin>>l.at(i);
  r(i,n){
      d+=l.at(i);
      if(d>x)break;
      else cnt++;
  }
  cout<<cnt<<endl;



  return 0;
}


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

typedef long long LL;

LL A,B,Ans;

int main(){
	int i,d;
	LL x;
	scanf("%lld%lld",&A,&B);
	if(A==B){
		puts("1");
		return 0;
	}
	for(d=59;(A>>d&1)==(B>>d&1);d--)
		if(A>>d&1)
			A-=1ll<<d;
	Ans=(1ll<<d+1)-A;
	for(i=d-1;~i&&~B>>i&1;i--);
	x=(1ll<<i+1)-1;
	if(x<A)
		Ans-=A-x-1;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vl p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    vl q(n);
    rep(i, n) {
        cin >> q[i];
        q[i]--;
    }

    vl perm(n);
    rep(i, n) {
        perm[i] = i;
    }

    ll a, b;
    ll cnt = 0;
    // {0, 1, … , n-1} の全順列を昇順に出力
    do {
        bool ok1 = true;
        rep(i, n) {
            if(perm[i] != p[i]) {
                ok1 = false;
            }
        }
        if(ok1) {
            a = cnt;
        }
        bool ok2 = true;
        rep(i, n) {
            if(perm[i] != q[i]) {
                ok2 = false;
            }
        }
        if(ok2) {
            b = cnt;
        }
        cnt++;
    } while(next_permutation(all(perm)));

    out(abs(a - b));
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        boolean [] node = new boolean[n + 1];
        for (int i = 0; i < m; ++i) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            node[a] = !node[a];
            node[b] = !node[b];
        }
        for (int i = 1; i <= n; ++i) {
            if (node[i]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


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

int main() {
  char S[200001], T[200001];

  long int i, j, k, len, l, tmpl, can_change;

  char c, d, tmpc;

  scanf("%s", S);
  scanf("%s", T);

  l = len = strlen(S);
  k = 0;
  for (i = 0; i < l; i++) {
    c = S[i];
    if (c >= 'a') {
      k++;
      tmpl = i;
      for (j = i; j < l; j++) {
        if ((tmpc = S[j]) == c) {
          S[j] = k;
          tmpl = j + 1;
        } else if (tmpc >= 'a') {
          tmpl = j + 1;
        }
      }
      l = tmpl;
    }
  }
  can_change = k >= 26;

  l = len;
  k = 0;
  for (i = 0; i < l; i++) {
    c = T[i];
    if (c >= 'a') {
      k++;
      tmpl = i;
      for (j = i; j < l; j++) {
        if ((tmpc = T[j]) == c) {
          T[j] = k;
          tmpl = j + 1;
        } else if (tmpc >= 'a') {
          tmpl = j + 1;
        }
      }
      l = tmpl;
    }
  }

  for (i = 0; i < len; i++) {
    c = S[i];
    d = T[i];
    if (c < d) {
      printf("No\n");
      return 0;
    } else if (c != d) {
      if (!can_change) {
        printf("No\n");
        return 0;
      }
      for (j = i; j < len; j++) {
        if ((tmpc = S[j]) == c) {
          S[j] = d;
        }
      }
    }
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    int A, B;
    vector<pair<int, int>> v;
    for(int i = 0; i < N; i++){
        cin >> A >> B;
        v.push_back({A,B});
    }
    
    sort(v.begin(), v.end());
    priority_queue<int> que;
    int pos = 0;
    ll ans = 0;
    
    for(int i = 1; i <= M; i++){
        while(i >= v[pos].first && pos < N){
            que.push(v[pos].second);
            pos++;
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1908
#include<cstdio>
#include<unordered_map>
#define int long long
std::unordered_map<int,int>f;
int t,n,a,b,c,d;
inline int mn(int x,int y)
{return x<y?x:y;}
int dfs(int x)
{
	if(f.count(x))return f[x];
	f[x]=1e18;
	if(x<=2e9)f[x]=mn(f[x],x*d);
	if(!(x%2))f[x]=mn(f[x],dfs(x/2)+a);
	if(!(x%3))f[x]=mn(f[x],dfs(x/3)+b);
	if(!(x%5))f[x]=mn(f[x],dfs(x/5)+c);
	if(x%2)f[x]=mn(f[x],dfs(x-1)+d);
	if(x%3)f[x]=mn(f[x],dfs(x-x%3)+x%3*d);
	if(x%5)f[x]=mn(f[x],dfs(x-x%5)+x%5*d);
	if(x%2)f[x]=mn(f[x],dfs(x+1)+d);
	if(x%3)f[x]=mn(f[x],dfs(x-x%3+3)+(3-x%3)*d);
	if(x%5)f[x]=mn(f[x],dfs(x-x%5+5)+(5-x%5)*d);
	return f[x];
}
signed main()
{
	for(scanf("%lld",&t);t;--t)
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d),
		f.clear(),f[0]=0,printf("%lld\n",dfs(n));
	return 0;
}

Measured memory_bytes: 9752
def CountingSort(A, B, k):
  C = [0 for i in range(k + 1)]

  for j in range(0, n):
    C[A[j]] += 1

  for i in range(1, k + 1):
    C[i] = C[i] + C[i - 1]

  for j in reversed(range(0, n)):
    B[C[A[j]]] = A[j]
    C[A[j]] -= 1

n = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(n + 1)]

CountingSort(A, B, max(A))
print(*B[1:])



Measured memory_bytes: 224384
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    int testCases = 1;
    // cin>>testCases;
    while(testCases--){
       string S, T; cin>>S>>T;
       int ans = INT_MAX;
       for(int i=0; i<=S.length()-T.length(); ++i){
           int count = 0;
           for(int j=0; j<T.length(); ++j){
               if(S[i+j]!=T[j]) count++;
           }
           
       ans = min(ans, count);
       }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3632
N = int(input())
S = list(input())

Rcnt = 0
Gcnt = 0

excep = 0

for i in range(len(S)):
    if S[i] == 'R':
        Rcnt += 1
    elif S[i] == 'G':
        Gcnt += 1
    for j in range(1, len(S)):
        if i+j+j < len(S) and S[i] != S[i+j]:
            if S[i] != S[i+j+j] and S[i+j] != S[i+j+j]:
                excep += 1
        elif i+j+j >= len(S):
            break

print(Rcnt * Gcnt * (N - Rcnt - Gcnt) - excep)

Measured memory_bytes: 73836