akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#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 FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


struct RollingHash {
	static const int base1 = 1007, base2 = 2009;
	static const int mod1 = 1000000007, mod2 = 1000000009;
	vector<long long> hash1, hash2, power1, power2;

	// construct
	RollingHash(const string& S) {
		int n = (int)S.size();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		power1.assign(n + 1, 1);
		power2.assign(n + 1, 1);
		for (int i = 0; i < n; ++i) {
			hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
			hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
			power1[i + 1] = (power1[i] * base1) % mod1;
			power2[i + 1] = (power2[i] * base2) % mod2;
		}
	}

	// get hash of S[left:right]
	inline pair<long long, long long> get(int l, int r) const {	
		long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
		if (res1 < 0) res1 += mod1;
		long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
		if (res2 < 0) res2 += mod2;
		return { res1, res2 };
	}

	// get lcp of S[a:] and T[b:]
	inline int getLCP(int a, int b) const {
		int len = min((int)hash1.size() - a, (int)hash1.size() - b);
		int low = 0, high = len;
		while (high - low > 1) {
			int mid = (low + high) >> 1;
			if (get(a, a + mid) != get(b, b + mid)) high = mid;
			else low = mid;
		}
		return low;
	}
};


string s, t;
int main() {
	cin >> s >> t;
	RollingHash a(s), b(t);
	REP(i, (ll)s.size() - (ll)t.size() + 1) {
		if (a.get(i, i + t.size()) == b.get(0, t.size()))cout << i << endl;
	}
}



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

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 998244353;

int main() {
  int n;
  string x;
  cin >> n >> x;
  vector<int> div;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0 && (n / i) % 2 == 1) div.push_back(i);
  }
  int m = div.size();
  ModInt ans = 0;
  vector<ModInt> c(m, 0);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < div[i]; j++) {
      c[i] = c[i] * 2 + (int)(x[j] - '0');
    }
    string y = x;
    for (int j = div[i]; j < n; j++) {
      y[j] = (char)(y[j - div[i]] ^ 1);
    }
    if (y <= x) c[i] += 1;
    for (int j = 0; j < i; j++) {
      if (div[i] % div[j] == 0 && (div[i] / div[j]) % 2 == 1) c[i] -= c[j];
    }
    ModInt w = 2 * div[i];
    ans += w * c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 772
#include <iostream>
#include <cstdio>

using namespace std;

void main_body( void )
{
	long long D, T, S;

	cin >> D >> T >> S ;

	if ( ( ( D + ( S - 1 ) ) / S ) <= T )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main( int argc, char *argv[] )
{
	int c;

	if ( argc > 1 )
	{
		c = atoi( argv[ 1 ] );
	}
	else
	{
		c = 1;
	}

	for ( int i = 0; i < c; i++ )
	{
		main_body();
	}

	return 0;
}


Measured memory_bytes: 3624
import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = scan.nextInt();
        int[] out = new int[n];
        for(int i = 0; i < n; i++){
            out[a[i] - 1] = i + 1;
        }
        for(int i = 0; i < n; i++) System.out.print(out[i] + " ");
        scan.close();
    }
    public static void main(String[] args){
        new Main().solve();
    }
}


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

void merge(vector<int> &A,int left, int mid,int right){
      int n1=mid-left;
      int n2=right-mid;
      vector<int> L(n1);
      vector<int> R(n2);
      for(int i=0;i<n1;i++)  L.at(i)=A.at(left+i);
      for(int i=0;i<n2;i++) R.at(i)=A.at(mid+i);
      L.push_back(1e9);
      R.push_back(1e9);
      int i=0;
      int j=0;
      for(int k=left;k<right;k++){
        cnt++;
          if(L.at(i)<=R.at(j)) {
              A.at(k)=L.at(i);
              i++;
          }
          else{
              A.at(k)=R.at(j);
              j++;
          }
      }
      return;
    }

void mergeSort(vector<int> &A,int left,int right){
      if(left+1<right){
          int mid=(left+right)/2;
          mergeSort(A,left,mid);
          mergeSort(A,mid,right);
          merge(A,left,mid,right);
      }
      return;
      }

  int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int n;
      cin>>n;
      vector<int> A(n);
      rep(i,n) cin>>A.at(i);
      mergeSort(A,0,n);
      for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<A.at(i);
      }
      cout<<endl<<cnt<<endl;
      return 0;
  }



Measured memory_bytes: 8608
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll x = (x2-x1);
    ll y = (y2-y1);
    ll x3,y3, x4, y4;
    if(abs(x) >= abs(y))
    {
        if(x > 0)
        {
            cerr << "1" << endl;
            x3 = x2 - y;
            y3 = y2 + x;
            x4 = x3 - x;
            y4 = y3 - y;
        }
        else
        {
            cerr << "2" << endl;
            x3 = x2 - y;
            y3 = y2 + x;
            x4 = x3 - x;
            y4 = y3 - y;
        }
    }
    else
    {
        if(y > 0)
        {
            cerr << "3" << endl;
            x3 = x2 - y;
            y3 = y2 + x;
            x4 = x3 - x;
            y4 = y3 - y;
        }
        else
        {
            cerr << "4" << endl;
            x3 = x2 - y;
            y3 = y2 + x;
            x4 = x3 - x;
            y4 = y3 - y;
        }
    }
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

using namespace std;

int main(){
	int n,m,res=1e09;
	cin >> n >> m;
	vector<int> c(m);
	for(int i=0;i<m;++i)cin >> c[i];
	sort(c.begin(),c.end());
	vector<int> dp(n,1e09);
	for(int i=0;i<m;++i){
		dp[c[i]-1] = 1;
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(i+c[j]>=n)break;
			dp[i+c[j]] = min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 3204
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF=1e9;
int n,cnt[26],ans[26];
string s;

int main()
{
	cin>>n;
	for(int i=0;i<26;i++)
		ans[i]=INF;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		MEM(cnt,0);
		for(char j:s)
			cnt[j-'a']++;
		for(int j=0;j<26;j++)
			ans[j]=min(ans[j],cnt[j]);
	}
	for(int i=0;i<26;i++)
		for(int j=0;j<ans[i];j++)
			cout << char(i+'a');
	cout <<'\n';
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

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

int n, k;
string x;

int main(){
	cin >> n >> k >> x;
	int ans = 0;
	int cur = 0;
	for(int i=1;i<=n;i++){
		if(i==n||x[i]!=x[i-1]){
			ans += i-cur-1;
			cur = i;
		}
	}
	cout << min(ans+2*k, n-1) << endl;
	return 0;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,k;
	cin>>n>>k;
	ll a[n];
	REP(i,0,n-1) cin>>a[i];
	sort(a,a+n);
	int j;
	i=0;
	ll ans=1;
	if(a[n-1]<0){
		if(k&1){
			RAP(i,n-1,n-k){
				dbg(a[i]);
		 		(ans*=a[i])%=mod;
			 	if(ans<0) ans+=mod;
			}
		}else{
			REP(i,0,k-1) {
				(ans*=a[i])%=mod;
			 	if(ans<0) ans+=mod;
			}
		}
		// if(ans<0) ans+=mod;
		cout<<ans;
	}else if(a[0]>=0){
		RAP(i,n-1,n-k) (ans*=a[i])%=mod;
		cout<<ans; 
		dbg(a[0]);
	}else{
		i=0;
		j=n-1;
		while(k>0){
			if(k>=2){
				if(a[i]*a[i+1]>a[j]*a[j-1]){
					(ans*=a[i])%=mod;
					if(ans<0) ans+=mod;
					(ans*=a[i+1])%=mod;
					if(ans<0) ans+=mod;
					i+=2;
					k-=2;
				}else{

				(ans*=a[j])%=mod;
				if(ans<0) ans+=mod;
				j--;
				k--;	
				}
			}else{
				(ans*=a[j])%=mod;
				if(ans<0) ans+=mod;
				j--;
				k--;
			}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 5144
from bisect import bisect_left
import random
import time
import math


#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
#初期解
T = []
for _ in range(D):
    t = random.randrange(26)
    T.append(t)


last_day = [[-1] for _ in range(26)]
for d in range(D):
    test = T[d]
    last_day[test].append(d)
for i in range(26):
    last_day[i].append(D)


T0 = 10000
time_start = time.perf_counter()
while True:
    time_now = time.perf_counter()
    if time_now - time_start > 1.80:
        break
    #時間を正規化して温度を設定
    time_n = (time_now - time_start) / 1.80
    T1 = T0 ** (1 - time_n)
    for _ in range(100):
        #ランダムな日のテストをランダムに入れ替え
        d = random.randrange(365)
        q = random.randrange(26)
        old = T[d]
        T[d] = q
        #日程dでの元のテストold
        l = last_day[old]
        ind_old = l.index(d)
        dd_left = l[ind_old] - l[ind_old-1] - 1
        dd_right = l[ind_old+1] - l[ind_old] - 1
        dd = l[ind_old+1] - l[ind_old-1] - 1
        dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
        #日程dでのテストq
        l = last_day[q]
        ind_q = bisect_left(last_day[q],d)
        dd_left = d - l[ind_q-1] - 1
        dd_right = l[ind_q] - d - 1
        dd = l[ind_q] - l[ind_q-1] - 1
        dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
        #変更による差
        dif_s = dif_old + dif_q - S[d][old] + S[d][q]
        if (dif_s > 0) or (math.exp(dif_s / T1) > random.random()):
            del last_day[old][ind_old]
            last_day[q].insert(ind_q,d)
        else:
            T[d] = old
for d in range(365):
    print(T[d] + 1)



Measured memory_bytes: 88400
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

void invalid() {
    output(0);
    exit(0);
}

ll fact(ll n) {
    ll ans = 1;
    rep(i, 1, n + 1) (ans *= i) %= mod;
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N;
    string s;
    cin >> N >> s;
    
    ll ans = 1;
    int l = 1, r = 0;
    if(s[0] != 'B') invalid();
    int cur = 0;
    rep(i, 1, 2 * N) {
        if(s[i] == s[i - 1]) {
            cur ^= 1;
        }
        if(cur == 1) {
            ans *= (l - r);
            ans %= mod;
        }
        if(cur == 0) l++;
        else r++;
        if(l < r) invalid();
    }
    if(l != r) invalid();
    ans *= fact(N);
    ans %= mod;
    output(ans);
    
    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<complex>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D EPS = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  tmp = m - n;
  ans = tmp * (tmp - 1) / 2;
  ans -= n;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
R = int(input())

# 求解処理
ans = str()
if R < 1200:
    ans = "ABC"
elif R < 2800:
    ans = "ARC"
else:
    ans = "AGC"

# 結果出力
print(ans)


Measured memory_bytes: 9096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long x, y;
    cin >> x >> y;

    long long xx = abs(x);
    long long yy = abs(y);

    long long ans = LONG_LONG_MAX;

    if (x == y)ans = 0;

    if (x >= 0) {
        if (xx >= yy) {
            long long dx = -x, dy = y;
            long long play = 1;
            play += dy - dx;
            ans = min(ans, play);
        }
        if (xx >= yy) {
            long long dx = -x, dy = y;
            long long play = 1;
            play += xx - yy;
            if (dy > 0) play++;
            ans = min(ans, play);
        }
        if (xx < yy) {
            long long dx = x, dy = y;
            long long play = 0;
            play += yy - dx;
            if (dy < 0) play++;
            ans = min(ans, play);
        }
    }
    if (x < 0) {
        if (xx >= yy) {
            long long play = y - x;
            ans = min(ans, play);
        }
        if (xx >= yy) {
            long long dx = x, dy = y;
            long long play = xx - yy;
            if (dy > 0) play++;
            ans = min(ans, play);
        }
        if (xx <= yy) {
            long long dx = x, dy = y;
            long long play = 1;
            dx = -dx;
            play += yy - dx;
            if (dy < 0) play++;
            ans = min(ans, play);
        }
    }

    cout << ans << endl;

    return 0;
}
















































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

int main() {
  int n,count,ans=0;
  cin >> n;
  vector<int> a(n,0),b(n,0);
  r(i,n)cin >> a[i];
  r(i,n)cin >> b[i];
  r(i,n){
    count=accumulate(a.begin(),a.begin()+1+i,0)+accumulate(b.begin()+i,b.end(),0);
    ans=max(ans,count);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int cnt = 0;
void dfs(vector<int> &A, vector<int> B, int N) {
    // 数列の長さが N に達したら打ち切り
    if (A.size() == N) {
        rep(i, N) {
            if (A[i] % 2 == 0) {
                cnt++;
                break;
            }
        }
        return;
    }

    // 0からMまでの数字
    for (int v = B[A.size()] - 1; v <= B[A.size()] + 1; ++v) {
        A.push_back(v);
        dfs(A, B, N);
        A.pop_back();
    }
}

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

    int N;
    cin >> N;
    vector<int> A, B(N);
    rep(i, N) { cin >> B[i]; }

    dfs(A, B, N);
    cout << cnt << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
static const int INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> s(h, vector<char>(w, '0'));
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            cin >> s.at(ih).at(iw);
        }
    }

    vector<vector<int>> dp(h, vector<int>(w, INF));
    if(s.at(0).at(0)=='#') dp.at(0).at(0) = 1;
    else dp.at(0).at(0) = 0;

    int ihnext, iwnext, dpadd, R = 0, D = 1;
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            for(int id=R;id<=D;id++) {
                if(id==R) {
                    ihnext = ih+1;
                    iwnext = iw;
                }
                else {
                    ihnext = ih;
                    iwnext = iw+1;
                }
                if(ihnext>=h||iwnext>=w) continue;
                if(s.at(ihnext).at(iwnext)=='#'&&s.at(ih).at(iw)=='.') dpadd = 1;
                else dpadd = 0;
                chmin(dp.at(ihnext).at(iwnext), dp.at(ih).at(iw)+dpadd);
            }
        }
    }

    cout << dp.at(h-1).at(w-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          int
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m;
  ll a[m];
  std::vector<ll> v[m];
  for (ll i = 0; i < m; ++i)
  {
    cin>>k;
    fr(j,0,k)
    {
        cin>>x;
        v[i].pb(x);
    }
    
  }
  for (int i = 0; i <m; ++i)
  {
   cin>>a[i];
  }
  for (int i = 0; i < (1<<n); ++i)
  {   ll on =0;
    //    c(i);
    for(ll j=0;j<m;j++)
    {   c = 0;
      for(ll p=0;p<v[j].size();p++)
      {      
            if((i&(1<<(v[j][p]-1))))
            {
              c++;
             // cout<<(v[j][p])<<" ";
            }
      }
      
      if((c%2)!=a[j])
      {
        on = 1;
        break;
      }
    }
    if(on==0)
    {
    //c(i);
      ans++;
    }
  }
  
  cout<<ans<<" ";
}

signed main(){
   
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 100;


int main(){
  int N, X, L;
  cin >> N >> X;
  int d = 0, count = 0;
  while(d <= X){
    cin >> L;
    d = d + L;
    count++;
    if(count == N+1) break; 
  }
  cout << count << endl;
}

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

int main (void) {
    int i, j;
    int n;
    scanf("%d", &n);

    double  ans = 0;
    int     seq = 1;
    int     town[n+1][2];
    for ( i=1; i<=n; i++ ) {
        seq *= i;
        scanf("%d%d", &town[i][0], &town[i][1]);
    }
    for ( i=1; i<=n; i++ ) {
        for ( j=i+1; j<=n; j++ ) {
            ans += sqrt((town[i][0]-town[j][0])*(town[i][0]-town[j][0])+
                        (town[i][1]-town[j][1])*(town[i][1]-town[j][1])) * 2 * seq/n;
        }
    }
    ans /= seq;

    printf("%.7lf\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    LL a, b;
    cin >> a >> b;
    double k = ((b * b)  - (a * a)) / (double)(2 * (b - a));
    if (ceil(k) == floor(k)) {
        cout << (LL)k << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

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

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0; i<n1; i++) L[i] = A[left + i];
	for(int i=0; i<n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right){
	if(left+1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main(){
	int A[MAX], n, i;
	cnt = 0;
	
	cin >> n;
	for(i=0; i<n; i++)cin >> A[i];
	
	mergeSort(A, n, 0, n);
	
	for(i=0; i<n; i++){
		if( i )cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	cout << cnt << endl;
	
	return 0;
}

	


Measured memory_bytes: 6988
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n, tmp = 0, ans = 0;
    std::cin >> n;
    auto f = [&](int a) {
        int r = 0;
        while (a % 2 != 1 && a > 0)
        {
            a /= 2;
            r++;
        }
        return r;
    };
    if (n != 1)
    {
        for (int i = 1; i <= n; i++)
        {
            if (i % 2 == 0)
            {
                int j = f(i);
                if (tmp < j)
                {
                    ans = i;
                    tmp = j;
                }
            }
        }
    }
    else
    {
        ans = 1;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    string s;
    cin >> s;

    int ans = 0;
    rep(i,s.size()) if (s[i] == '1') ++ans;

    out(ans);



    return 0;
}








Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ci cin >>
#define co cout <<

int main() {
	int N;
	ci N;
	if (N >= 1000) {
		N -= 999;
		co "ABD";
	}
	else co "ABC" ;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];S(a=H[a],*Z=O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],b=O[a]),S(a,b-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 37216
n,m=map(int,input().split())
dic={}
if n==1 and m==0:
  print('0')
  exit()

for i in range(m):
  s,c=map(int,input().split())
  
  if s not in dic:
    if n==1 and s==1 and c==0:
      print('0')
      exit()
    elif s==1 and c==0:
      print('-1')
      exit()
    else:
      dic[s]=c
  elif dic[s]==c:
    continue
  else:
    print('-1')
    exit()

for i in range(1,n+1):
  if i==1 and i not in dic:
    print('1',end="")
  elif i in dic:
    print(dic[i],end='')
  else:
    print('0',end='')


Measured memory_bytes: 9148
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,q = LI()
d = LI()
nxm = [LI() for _ in range(q)]

for n,x,m in nxm:
    e = list(map(lambda x:(x-1)%m+1,d))
    f = list(accumulate(e))
    s = f[-1] * ((n-1)//k)
    if (n-1)%k != 0:
        s += f[(n-1)%k-1]
    tmp = (s+x%m)//m
    print(n-1-tmp)

    
    


Measured memory_bytes: 94044
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,m,q;
	while(cin>>n>>m>>q&&!(n==0&&m==0&&q==0))
	{
		int a[1001][37]={};//スイッチの述べ回数
		int b[1001][1001]={};//ランプの延べ回数
		
		char s[1001][37]={};
		char t[1001][1001]={};
		
		for(int i=0;i<q;i++)
		{
			cin>>s[i]>>t[i];
			for(int j=0;j<n;j++)
			{
				if(i==0&&s[i][j]=='0'){a[i][j]=0;}
				else if(i==0&&s[i][j]=='1'){a[i][j]=1;}
				else if(i!=0&&s[i][j]=='0'){a[i][j]=a[i-1][j];}
				else if(i!=0&&s[i][j]=='1'){a[i][j]=a[i-1][j]+1;}
			}
			
			for(int j=0;j<m;j++)
			{
				if(i==0&&t[i][j]=='0'){b[i][j]=0;}
				else if(i==0&&t[i][j]=='1'){b[i][j]=1;}
				else if(i!=0&&t[i][j]==t[i-1][j]){b[i][j]=b[i-1][j];}
				else if(i!=0&&t[i][j]!=t[i-1][j]){b[i][j]=b[i-1][j]+1;}
			}
		}
		
		for(int j=0;j<m;j++)
		{
			int count(0),ans;
			for(int k=0;k<n;k++)
			{
				if(b[q-1][j]==a[q-1][k])
				{
					bool flag=false;
					REP(l,q){if(b[l][j]!=a[l][k]){flag=true;break;}}
					if(!flag)
					{
						count++;
						ans=k;
					}
				}
				if(count>1){break;}
			}
			char x='A'+ans-10;
			if(count>1){cout<<'?';}
			else if(ans<10){cout<<ans;}
			else{cout<<x;}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 6244
N = int(input())
A = list(map(int, input().split()))

length = sum(A)
left = 0
left1 = 0
left2 = 0

for i in range(N):
    left += A[i]
    if left >= length//2:
        left1 = left
        left2 = left - A[i]
        break

right1 = length - left1
right2 = length - left2

print(min(abs(left1 - right1), abs(left2 - right2)))

Measured memory_bytes: 88144
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define r(i,n) for(int i=0;i<n;i++)
int a[26][51];
int main(){
  int n;
  cin>>n;
  r(i,n){
    string s;
    cin>>s;
    r(j,s.size())a[s[j]-'a'][i]++;
  }
  r(i,26){
    int p=10000000,cc=0;
    r(j,n){
      if(a[i][j])cc++;
      p=min(p,a[i][j]);
    }
    if(cc==n)for(int j=0;j<p;j++)cout<<(char)(i+'a');
  }
cout<<endl;
}

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

typedef long long ll;

int n;
vector<int> a(200010);

int main(){
    cin >> n;
    a.resize(n);


    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= (i+1);
    }

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

    ll res = 0;

    if (n % 2 == 1){        
        for (int i = 0; i < n; i++){
            res += abs(a[i] - a[n/2]);
        }
        cout << res << endl;
        return 0;
    } else {
        if (a[n/2 - 1] > 0){
            for (int i = 0; i < n; i++){
                res += abs(a[i] - a[n/2 - 1]);
            }
            cout << res << endl;
            return 0;
        }
        if (a[n/2] < 0){
            for (int i = 0; i < n; i++){
                res += abs(a[i] - a[n/2]);
            }
            cout << res << endl;
            return 0;
        }
        for (int i = 0; i < n; i++){
            res += abs(a[i]);
        }
        cout << res << endl;
        return 0;
    }
    
}

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

int main(){
	
	int n;
	string s;
	
	cin >> n;
	cin >> s;
	int ans = 0;
	
	for (int i = 0; i < n; i++){
		
		if (s[i] != s[i+1]){
			ans++;
		}
		
	}
	
	cout << ans;
	
}


Measured memory_bytes: 512
#include<stdio.h>
 
int main(void){
  int n=0;
  scanf("%d",&n);
  int array[50];
  for(int i=0;i<n;i++)
    scanf("%d",&array[i]);
  long long int sum=0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
      sum+=array[i]*array[j];
    }
  printf("%lld",sum);
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			int[] counter = new int[26];
			String str = "";
			while(scan.hasNext())
			str = str + scan.nextLine();
			String[] str2 = str.toLowerCase().split("[^a-z]");
			for(int i = 0; i < str2.length;i++){
				for(int j = 0 ; j < str2[i].length();j++){
					int num = (int)str2[i].charAt(j) - (int)'a';
					counter[num] ++;
				}
			}
			for(int i = 0 ; i < counter.length;i++){
				System.out.println((char)((int)'a'+ i)+" : "+counter[i]);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 998'244'353;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
constexpr int ms = 3013;
// End of template code!
long long dp[ms][ms];

int main() 
{
    buff();
    int n, S;
    cin >> n >> S;
    vector<long long> v(n + 1);
    for(int i = 1; i <= n; ++i) cin >> v[i];

    dp[0][0] = 1ll;
    long long ans = 0; 
    for(int i = 1; i <= n; ++i)
    {
        if(S >= v[i]) {
            long long good_R = (n - i + 1);
            long long add = (dp[i - 1][S - v[i]] * good_R) % MOD;
            ans = (ans + add) % MOD;
        }
        // agora tenho que fazer o update dos L's
        for(int j = 0; j < ms; ++j) {
            dp[i][j] = dp[i - 1][j]; 
            if(j >= v[i]) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - v[i]]) % MOD;
            }
        }
        dp[i][0] = (dp[i][0] + 1) % MOD;
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 70912
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  =long long;


int main()
{
  ll k,n,temp;
  cin>>k>>n;
 ll a[n];
  ll maxi =0 ;
  cin>>a[0];
  for(ll i=1;i<n;i++){
    cin>>a[i];
    maxi = max(maxi,a[i]-a[i-1]);
  }
maxi = max(maxi,k+a[0]-a[n-1]);
cout<<k-maxi;

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
data = []
for i in range(1, N+1):
    s, p = input().split()
    p = int(p)
    data.append((s,p,i))

data = sorted(data, key=lambda t: t[0]+str(100 - t[1]).zfill(3))

for d in data:
    print(d[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)


int main(){
	string S;
	cin>>S;
	if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
		cout<<"Bad"<<endl;
	}		
	else{
		cout<<"Good"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
int a[100005],b[100005];

int main()
{
    int n,total;
    scanf("%d%d",&n,&total);
    for (int i=0; i<n; i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }

    sort(a,a+n);
    sort(b,b+n);
    int pos = upper_bound(b,b+n,a[n-1])-b;
    int pos2 = n-1;
    int ans = 0;
   while(total>0 && pos2>=pos)
   {
       total -=b[pos2];
       pos2--;
       ans++;
   }
  // cout<<ans<<endl;

    while(total>0)
    {//cout<<total<<endl;
        total -= a[n-1];
        ans++;
    }
    printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

int main()
{
    int H,W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));

    vector<bool> deletedRow(H, true);
    vector<bool> deletedCol(W, true);

    rep(i, H) rep(j, W) {
        cin >> a[i][j];
        if(a[i][j] == '#'){
            deletedRow[i] = false;
            deletedCol[j] = false;
        }
    }

    rep(i, H) {
        if(!deletedRow[i]){
            rep(j, W) {
                if(!deletedCol[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3672
N=int(input())
XL=sorted([list(map(int,input().split())) for i in range(N)],key=lambda c:(c[0]+c[1]))
a=-float("inf")
ans=0
x,l=XL[0]
for i in range(N):
    X,L=XL[i]
    if X-L>=a:
        ans+=1
        a=X+L
print(ans)

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

ll N;

int main()
{
	scanf("%lld",&N);

	ll ans = 2;
	FOR(i,0,N){
		ans = (ans + 1) * 2;
	}

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

	return 0;
}


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

main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel";
  else
    cout << "consonant";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;

int main(){
	double a, b, c;
	scanf("%lf%lf%lf", &a, &b, &c);
	c = c/360.0*2.0*3.14159265358979;
	double S = a*b*sin(c)/2.0;
	double d = sqrt(a*a+b*b-2*a*b*cos(c));
	double L = a+b+d;
	double h = b*sin(c);
	printf("%lf\n%lf\n%lf\n", S, L, h);
	return 0;
}

Measured memory_bytes: 1256
#!/usr/bin/perl

my ($a,$b,$c,$d) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $r = 'Yes';
while(1){
  $c -= $b;
  if( $c<=0 ){
    last;
  }
  $a -= $d;
  if( $a<=0 ){
    $r = 'No';
    last;
  }
}

print "$r\n";



Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()

bool is[8];
int main(){
		int n;
	cin>>n;
	int ans=0;
	for(int x,i=0; i<n; ++i){
		scanf("%d",&x);
		if(x<3200)
			is[x/400]=true;
		else
			++ans;
	}
	int ct=0;
	for(int i=0; i<8; ++i)
		ct+=is[i];
	cout<<max(1,ct)<<" "<<max(1,ans+ct)<<endl;
	
}




Measured memory_bytes: 256
s = list(input())
bef=int(s[0])*10+int(s[1])
aft=int(s[2])*10+int(s[3])

ans=''
if 0<aft<13 and 0<bef<13:
  ans='AMBIGUOUS'
elif (100>aft>12 or aft==0) and 0<bef<13:
  ans='MMYY'
elif (100>bef>12 or bef==0) and 0<aft<13:
  ans='YYMM'
else:
  ans='NA'
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n;
	ll tp = n%10;
	switch(tp){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			print("hon");
			break;
		case 3:
			print("bon");
			break;
		default:
			print("pon");
			break;
	}
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.length();i++)
    {
        sum=sum+s[i]-'0';
    }
    if(sum%9==0)
    cout<<"Yes"<<"\n";
    else
    {
        cout<<"No";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    rep(A+1, a) rep(B+1, b) rep(C+1, c) if (500*a+100*b+50*c==X) ans++;
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int count = 0;
        for (int i = 0; i < N; i++) {
            double X = sc.nextDouble();
            double Y = sc.nextDouble();
            double distance = Math.sqrt(Math.pow(X, 2) + Math.pow(Y, 2));
            if (distance <= D)
                count++;
        }
        sc.close();
 
        System.out.println(count);
    }
}

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

int main() {
    int n; cin >> n;
    vector<int> t(n);
    int sum = 0;
    for (int i=0; i<n; ++i) {
        cin >> t[i];
        sum += t[i];
    }
    int m; cin >> m;
    vector<pair<int, int>> p_x(m);
    for (int i=0; i<m; ++i) {
        int p, x; cin >> p >> x;
        p_x[i] = make_pair(--p, x);
    }
    for (int i=0; i<m; ++i) {
        int ans = sum;
        ans -= t[p_x[i].first];
        ans += p_x[i].second;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    int[] a = new int[x];
    for(int i = 0; i < x; i++){
      a[i] = Integer.parseInt(sc.next());
    }
    int count = 0;
    int tmp = 0;
    for(int i = 0; i < x; i++){
      int min_j = i;
      for(int j = i; j < x; j++){
        if(a[j] < a[min_j]){
          tmp = j;
          j = min_j;
          min_j = tmp;
        }
      }
      if(min_j != i){
        count++;
        tmp = a[min_j];
        a[min_j] = a[i];
        a[i] = tmp;
      }
    }
    for(int i = 0; i < (x - 1); i++){
      System.out.printf("%d ", a[i]);
    }
    System.out.printf("%d\n%d\n", a[x - 1], count);
  }
}


Measured memory_bytes: 26388