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

int main(void)
{
	int balls[200000] = {
		0,
	};
	long long count[200000] = {
		0,
	};

	int n;
	long long total = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &balls[i]);
		count[balls[i] - 1]++;
	}

	for (int i = 0; i < n; i++)
	{
		total += (count[i]) * (count[i] - 1) / 2;
	}

	for (int i = 0; i < n; i++)
	{
		printf("%lld\n", total - count[balls[i] - 1] + 1);
	}

	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
vector<int> topological_sort(vector<vector<int>> &E){
	int N = E.size();
	vector<int> deg(N, 0);
	for (int i = 0; i < N; i++){
		for (int j : E[i]){
			deg[j]++;
		}
	}
	queue<int> Q;
	for (int i = 0; i < N; i++){
		if (deg[i] == 0){
			Q.push(i);
		}
	}
	vector<int> ans;
	while (!Q.empty()){
		int v = Q.front();
		Q.pop();
		ans.push_back(v);
		for (int w : E[v]){
			deg[w]--;
			if (deg[w] == 0){
				Q.push(w);
			}
		}
	}
	return ans;
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int s, t;
    cin >> s >> t;
    E[s].push_back(t);
  }
  vector<int> ans = topological_sort(E);
  for (int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    cin >> N;
    cout << (1000 - N%1000) % 1000 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N; cin>>N;
  vector<pair<ll,ll>> VX(N),VY(N);
  ll X[N],Y[N];
  rep(i,N){
    cin>>X[i]>>Y[i];
    VX[i]={X[i],i};
    VY[i]={Y[i],i};
  }
  sort(VX.begin(),VX.end());
  sort(VY.begin(),VY.end());
  int ans=N;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(X[i]==X[j]&&Y[i]==Y[j]) continue;
      if(X[i]==X[j]){
        ll b=abs(Y[i]-Y[j]);
        int tmp=0;
        int ok[N]={};
        for(auto p:VY){
          ll k=p.second;
          if(ok[k]==0) tmp++,ok[k]=1;
          rep(l,N) if(l!=k&&X[k]==X[l]){
            if(abs(Y[l]-Y[k])==b) ok[l]=1;
          }
        }
        ans=min(ans,tmp);
      }else if(Y[i]==Y[j]){
        ll a=abs(X[i]-X[j]);
        int tmp=0;
        int ok[N]={};
        for(auto p:VX){
          int k=p.second;
          if(ok[k]==0) tmp++,ok[k]=1;
          rep(l,N) if(l!=k&&Y[k]==Y[l]){
            if(abs(X[l]-X[k])==a) ok[l]=1;
          }
        }
        ans=min(ans,tmp);
      }else{
        ll a=X[i]-X[j], b=Y[i]-Y[j];
        int tmp=0;
        int ok[N]={};
        for(auto p:VX){
          int k=p.second;
          if(ok[k]==0) tmp++,ok[k]=1; 
          rep(l,N) if(l!=k){
            if(X[l]>X[k]){
              if(a*Y[k]+b*(X[l]-X[k])==a*Y[l]) ok[l]=1;
            }else{
              if(a*Y[k]-b*(X[k]-X[l])==a*Y[l]) ok[l]=1;
            }
          }
        }
        ans=min(ans,tmp);
      }
    }
  }
  cout<<ans<<endl;
          
  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int dp[51][51][2501];

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

    int n, a;
    cin >> n >> a;
    int x[n];
    rep(i, n) cin >> x[i];
    dp[0][0][0] = 1;
    rep(i, n) rep(j, n) rep(k, 2501){
        if(k + x[i] < 2501) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
    }
    int res = 0;
    FOR(i, 1, n + 1) {
        res += dp[n][i][a * i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 50048
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long A, B, C, K; cin >> A >> B >> C >> K;
	long long num = 0;
	if (K % 2 == 0) {
		num = A - B;
	}
	else {
		num = B - A;
	}
	if (num > pow(10, 18)) {
		cout << "Unfair" << endl;
	}
	else cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

queue<pair<int, pair<int, int>>> Q;
int H, W, count;
char G[55][55];
int dist[55][55];
int black[55][55];

int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, -1, 1};

int main(){
    cin >> H >> W;
    int blackcount = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> G[i][j];
            if (G[i][j] == '#'){
                black[i][j] = -1;
                blackcount += 1;
            }
        }
    }

    memset(dist, -1, sizeof(dist));
    pair<int, int> SOURCE = make_pair(0, 0);
    Q.push(make_pair(0, SOURCE));

    while (!Q.empty()){
        int d = Q.front().first, r = Q.front().second.first, c = Q.front().second.second;//takes out nearest node
        Q.pop();
        if(dist[r][c] != -1) continue;//check if visited
        dist[r][c] = d;//update the distance
        for (int i=0; i<4; i++){
            if(r + dr[i] >= 0 && r + dr[i] < H && c + dc[i] >= 0 && c + dc[i] < W && black[r][c] != -1) //check that neighbour is not black
                Q.push(make_pair(d + 1, make_pair(r + dr[i], c + dc[i])));
        }
    }

    int ans = dist[H -1][W -1];

    int area = H*W;
    if (ans != -1){
        cout << area - ans -  blackcount - 1 << "\n";
    } else{
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   Fast_IO();
   ll n,k;
   cin>>n>>k;
   ll ans=0,maxi,mini;
   f(i,k,n+1){
      maxi = (n*(n+1))/2;
      maxi -= ((n-i+1)*(n-i))/2;
      mini = (i*(i-1))/2;
      ans=ans%mod;
      ans+= abs(maxi-mini+1)%mod;
   }
   CC(ans);
}



Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
 
#define ARRAY_MAX 100005
 
int main(){

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    VSORT(a);
    int mini = INF;
    for(int i = 0;i < n-k+1;i++){
        mini = min(mini,a[i+k-1]-a[i]);
    }
    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
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 fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll x,y;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>x>>y;
    ll ans = 0,tmp=x;
    while(1){
        tmp *= 2;
        ans++;
        if(tmp>y)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, A, B = map(int, input().split())

ans = 0
# 1～Nのループ
for i in range(1, N+1):

    sum1 = 0
    num = i
    # 各桁の値を合計していく
    while num > 0:
        sum1 += num % 10
        num //= 10
    # 条件に合っていれば答えに足す
    if sum1 >= A and sum1 <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

	ll now = 0;
	REP(i, k+10){
		now *= 10;
		now %= k;
		now += 7;
		now %= k;
		if(now == 0){
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,i,j=1,k,d=0,t,q;
string s;
char c;
vector<char> v;
cin>>s;
for(i=0;i<s.length();i++)
{
v.push_back(s[i]);
}
cin>>q;
for(i=0;i<q;i++)
{
cin>>t;
if(t==1)
j=j*(-1);
else if(t==2)
{
cin>>d>>c;
if(d==1&&j==1)
    v.insert(v.begin(),c);
else if(d==1&&j==-1)
    v.push_back(c);
else if(d==2&&j==1)
    v.push_back(c);
else
   v.insert(v.begin(),c);
}
}
char a[v.size()+1];
a[v.size()]=0;
if(j==1){
//cout<<v.size()<<endl;
for(i=0;i<v.size();i++)
{
a[i]=v[i];
}}
else{
  for(i=0;i<v.size();i++)
{
a[i]=v[v.size()-1-i];
}
}
cout<<a<<endl;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int a,b,c=0,d=0,k=0,n,h,w,m,ans=0;
    string s,s2;
    cin >> s; 
    rep(i,s.size()){
        if(i%2==0){
            cout << s[i];
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    string s,t; cin >> s >> t;
    bool check = false;
    for(int i = s.size()-1; i >= 0; i--){
        bool flg = true;
        for(int j = 0; j < t.size(); j++){
            if (s[i-j] != t[t.size()-j-1] && s[i-j] != '?') flg = false;
        }
        if (flg){
            for(int j = 0; j < t.size(); j++){
                s[i-j] = t[t.size()-j-1];
            }
            check = true;
            break;
        }
    }
    if (!check){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0; i < s.size(); i++){
        if (s[i] == '?') cout << 'a';
        else cout << s[i];
    }
    cout << endl;
}
  



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
#define endl "\n"
#define forl for(int i=0;i<n;i++)
const ll MAXN=1000001;
bool prime[1000001];
void SieveOfEratosthenes() 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=1000000; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}

ll mex(vel a,int n){
	sort(a.begin(),a.end());
	int j=a[0];
	if(j!=0) return 0;
	else{
		for(int i=1;i<n;i++){
				if(a[i]!=a[i-1]){
					if(a[i]!=a[i-1]+1){
						return j+1;
						}else j++;
					}
			}
			return j+1;
		}
}

int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

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

ll c(ll m,ll n){
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans=(ans*(m-i+1))/i;
		}
		return ans;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll test;
test=1;
while(test--){
string n;
cin>>n;
ll ans=0;
for(int i=0;i<n.length();i++){
	ans+=n[i]-'0';
	}
	if(ans%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
}


Measured memory_bytes: 3716
def main():
    input = sys.stdin.readline
    try:
        a,b,t = map(int, input().split())
        result = 0
        for i in range(a, t+1, a):
            result += b
        print(result)

    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n;
    cin >> n;
    vector<li> av(n), bv(n);

    for (int i = 0; i < n; ++i) {
        cin >> av[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> bv[j];
    }

    vector<li> delta(n);
    for (int i = 0; i < n; ++i) {
        delta[i] = av[i] - bv[i];
    }

    if (accumulate(av.begin(), av.end(), 0LL) < accumulate(bv.begin(), bv.end(), 0LL)) {
        cout << -1 << endl;
        return 0;
    }

    sort(delta.begin(), delta.end());
    reverse(delta.begin(), delta.end());

    li ans = 0;
    li neg_sum = 0;
    for (int i = 0; i < n; ++i) {
        if (delta[i] < 0) {
            ans += 1;
            neg_sum -= delta[i];
        }
    }

    for (int i = 0; i < n; ++i) {
        if (neg_sum <= 0) {
            break;
        }
        ans += 1;
        neg_sum -= delta[i];
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

using P = pair<int, int>;
template <typename T>
using V = vector<T>;

int main() {
	for (int n; (n = in);) {
		V<P> v(n);
		for (P &i: v)
			i = {in, in};
		times (i, in)
			v.push_back(P{in, in});
		sort(begin(v), end(v));
		V<int> d(v.size(), 1);
		int r {};
		for (int i: range(v.size())) {
			for (int j: range(i))
				d[i] = max(d[i], v[j].first < v[i].first && v[j].second < v[i].second ? d[j] + 1: 1);
			r = max(r, d[i]);
		}
		outl(r);
	}
}


Measured memory_bytes: 2628
Ask = input()
puts = Ask.split()


A = int(puts[0])
B = int(puts[1])
Ans = 0

Pos = False

if (A == B):
	Pos = True
elif (A**2 - B**2) % (2*(A-B)) == 0:
	Pos= True
	Ans =  (A**2 - B**2) / (2*(A-B))
	
if not Pos:
	print('IMPOSSIBLE')
else:
	print(int(Ans))


Measured memory_bytes: 3064
#include <stdio.h>


int main()
{
    int a;
    scanf("%d",&a);
    int dice[a][6],box,flg=0,cnt=0,cnt2=0,cnt3=0;
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<6;j++)
        {
            scanf("%d",&dice[i][j]);
            //printf("%d ",dice[i][j]);
        }
        //printf("\n");
    }
    for(int i=1;i<a;i++)
    {
        cnt = 0;
        cnt2 = 0;
        while(1)
        {
            if(dice[0][1]==dice[i][1]||4 < cnt){
                cnt = 0;
                cnt2 += 1;
                box = dice[0][5];
                dice[0][5] = dice[0][2];
                dice[0][2] = dice[0][0];
                dice[0][0] = dice[0][3];
                dice[0][3] = box;
                if(dice[0][0]==dice[i][0]&&dice[0][1]==dice[i][1]&&dice[0][2]==dice[i][2]&&dice[0][3]==dice[i][3]&&dice[0][4]==dice[i][4]&&dice[0][5]==dice[i][5]){
                    printf("No\n");
                    /*printf("%d",i);
                    for(int l=0;l<6;l++){
                        printf("%d ",dice[0][l]);
                    }
                    printf("\n");
                    for(int l=0;l<6;l++){
                        printf("%d ",dice[i][l]);
                    }*/
                    flg = 1;
                    break;
                }else if(4 < cnt2){
                    cnt3 += 1;
                    //printf("%d回目\n",cnt3);
                    break;
                }
            }else {
                cnt += 1;
                box = dice[0][5];
                dice[0][5] = dice[0][1];
                dice[0][1] = dice[0][0];
                dice[0][0] = dice[0][4];
                dice[0][4] = box;
            }
        }
        if(flg == 1) break;
    }
    if(cnt3 == a-1) printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2116
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if (b >= c)
	{
		printf("%lld\n", b + c);
	}
	else
	{
		ll ans = 0;
		c -= b;
		ans += b * 2;
		if (a >= c)
			ans += c, c = 0;
		else
			ans += a, c -= a;
		if (c > 0) ++ans;
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main() {
    int K,S;
    cin >> K >> S;

    int res = 0;
    for(int a = 0; a<=K; a++) {
        for(int b = 0; b<=K; b++) {
            int c = S - (a+b);
            if(c >= 0 && c <= K && S == a+b+c) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;
char arr[101][101];
int main()
{
    FAST
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            cin>>arr[i][j];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(arr[i][j]=='.')
            {
                int c=0;
                c+=(arr[i+1][j]=='#');
                c+=(arr[i][j+1]=='#');
                c+=(arr[i-1][j]=='#');
                c+=(arr[i][j-1]=='#');
                c+=(arr[i+1][j+1]=='#');
                c+=(arr[i+1][j-1]=='#');
                c+=(arr[i-1][j+1]=='#');
                c+=(arr[i-1][j-1]=='#');
                arr[i][j]=(char)(c+'0');
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
 
using namespace std;
 
int main()
{
    int a;
    cin>>a;
     if(a>=30)
     {
         cout<<"Yes"<<endl;
         return 0;
     }
     cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	cin>> n;

	vector<ll> cnt(60, 0);

	for(int i = 0; i<n; ++i){
		ll x;
		cin>> x;

		for(int j = 1, k = 0; j <= x; j<<=1LL, ++k) if(j & x) cnt[k]++;
	}

	ll ans = 0LL;

	for(int i = 0; i<60; ++i){
		ll temp = mod(cnt[i] * (n - cnt[i]), MOD);
		ans = mod(ans + mod(temp * mod(1LL << i, MOD), MOD), MOD);
	}
	cout<< ans << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b[a],f[a],r[a],v[a];
    int building[120]={0};
    for(int i=0;i<a;i++)
    {
        cin>>b[a]>>f[a]>>r[a]>>v[a];
        building[(b[a]-1)*30+(f[a]-1)*10+(r[a]-1)]+=v[a];
    }
    for(int i=0;i<120;i++)
    {
        cout<<" "<<building[i];
        if((i+1)%10==0)
            cout<<endl;
        if(i==59||i==29||i==89)
            cout<<"####################"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int a,b;

int main(){
	cin >>a >> b;
	int c[300] = {300000, 200000, 100000};
	int as = c[a-1] + c[b-1];
	if(a == 1 && b == 1) as += 400000;
	cout << as << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
def sol():
  n,m=map(int,input().split())
  neighbors={i+1:set() for i in range(n)}
  for i in range(m):
    a,b=map(int,input().split())
    neighbors[a].add(b)
    neighbors[b].add(a)
  res=[0 for _ in range(n)]
  que=deque([1])
  while len(que)>0:
    #print(que)
    a=que.popleft()
    for b in neighbors[a]:
      if res[b-1]==0:
        res[b-1]=a
        que.append(b)
  #print(neighbors,res)
  print('Yes')
  for b in res[1:]:
    print(b)
    
sol()

Measured memory_bytes: 120852
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, M, X;
  cin >> N >> M >> X;
  vector <int> C(N);
  vector< vector<int> > A (12, vector<int>(12) );
  rep(i,N){
    cin >> C[i];
    rep(j,M){
      cin >> A[i][j];
    }
  }
  int ans = inf;
  rep(s, 1<<N){
    int cost = 0;
    vector <int> d(M);
    rep(i,N){
      if (s>>i&1){
        cost += C[i];
        rep(j,M) d[j] += A[i][j];

      }
    }
    bool ok = true;
    rep(j,M) if (d[j] < X) ok = false;
    if(ok) ans = min(ans, cost);
  }
  if (ans == inf) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int x, a, b;
    cin >> x >> a >> b;

    cout << (abs(b - x) < abs(a - x) ? 'B' : 'A') << endl;
    
    return 0;
}


Measured memory_bytes: 256
// AOJ 1021 Emacs-like Editor
// 2018.3.2 bal4u

#include <stdio.h>
#include <string.h>

char text[101][1005]; int len[101];
char buf[1005]; int blen;

int main()
{
	int N, r, c, rr;
	char cmd[5], *p, *q, *t;

	N = -1;
	do {
		fgets(p=text[++N], 1005, stdin);
		while (*p >= ' ') p++; *p = 0;
		len[N] = p - text[N];
	} while (strcmp(text[N], "END_OF_TEXT"));
	r = 0, c = 0, blen = 0;
	while (1) {
		fgets(cmd, 5, stdin); if (*cmd == '-') break;
		if      (*cmd == 'a') c = 0;
		else if (*cmd == 'e') c = len[r];
		else if (*cmd == 'p') { c = 0, r--; if (r < 0) r = 0; }
		else if (*cmd == 'n') { c = 0, r++; if (r >= N) r = N - 1; if (r < 0) r = 0; }
		else if (*cmd == 'f') { if (c < len[r]) c++; else if (r < N-1) r++, c = 0; }
		else if (*cmd == 'b') {	if (c > 0) c--;	else if (r > 0) r--, c = len[r]; }
		else if (*cmd == 'd') {
			if (c == len[r]) {
				if (r < N-1) {
					memcpy(text[r]+len[r], text[r+1], len[r+1]+1);
					len[r] += len[r+1];
					for (rr = r+2; rr < N; rr++) {
						memcpy(text[rr-1], text[rr], len[rr]+1);
						len[rr-1] = len[rr];
					}
					N--;
				}
			} else {
				p = text[r] + c;
				while (*p) *p = *(p+1), p++;
				len[r]--;
			}
		}
		else if (*cmd == 'k') {
			if (c == len[r]) {
				if (r < N-1) {
					blen = -1;
					memcpy(text[r]+len[r], text[r+1], len[r+1]+1);
					len[r] += len[r+1];
					for (rr = r+2; rr < N; rr++) {
						memcpy(text[rr-1], text[rr], len[rr]+1);
						len[rr-1] = len[rr];
					}
					N--;
				}
			} else {
				blen = len[r]-c, memcpy(buf, text[r]+c, blen+1);
				len[r] -= blen; if (len[r] < 0) len[r] = 0; text[r][len[r]] = 0;
				c = len[r];
			}
		}
		else if (*cmd == 'y') {
			if (blen == -1) {
				for (rr = N-1; rr > r; rr--) {
					memcpy(text[rr+1], text[rr], len[rr]+1);
					len[rr+1] = len[rr];
				}
				N++;
				len[r+1] = len[r]-c, memcpy(text[r+1], text[r]+c, len[r+1]+1);
				len[r] = c, text[r][len[r]] = 0;
				r++, c = 0;
			} else if (blen > 0) {
				t = text[r]+c, p = text[r]+len[r], q = p+blen;
				while (p >= t) *q-- = *p--;
				memcpy(t, buf, blen);
				c += blen, len[r] += blen;
			}
		}
	}
	for (r = 0; r < N; r++) puts(text[r]);
	return 0;
}


Measured memory_bytes: 2032
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

const int mod = 1e9 + 7;

long long fac, n, a, b;

inline long long fastpow(long long x, long long y)
{
	long long ret = 1, base = x;
	while(y > 0)
	{
		if(y & 1)
			ret = ret * base % mod;
		base = base * base % mod;
		y >>= 1;
	}

	return ret;
}

inline long long calc(long long x)
{
	long long ret = 1;
	for(long long i = n;i >= n - x + 1;--i)
		ret = ret * i % mod;
	return ret;
}

inline long long calc1(long long x)
{
	long long ret = 1;
	for(long long i = x;i >= 1;--i)
		ret = ret * i % mod;
	return ret;
}

int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);

	printf("%lld\n", (fastpow(2, n) - calc(a) * fastpow(calc1(a), mod - 2) % mod - calc(b) * fastpow(calc1(b), mod - 2) % mod - 1 + 2 * mod) % mod);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    ll N;
    cin >> N;

    const ll MAX = 100;

    bool isFind;

    for (ll i = 0; i <= MAX; i += 4) {
        ll v = N - i;
        if (v < 0) break;
        isFind |= v % 7 == 0;
        if (isFind) break;
    }

    cout << (isFind ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<algorithm>
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define x second
#define y first
#define pu push_back
typedef complex<double> point;
bool ccw(point a,point b,point c){
  b-=a;
  c-=a;
  c*=conj(b);
  if(c.imag()<=0)return true;  
  return false;
}
int main(){
  int n;
  cin>>n;
  pair<int,int> a[100000];
  vector<int> st;
  for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
  sort(a,a+n);
  for(int i=0;i<n;i++){
    while(st.size()>=2){
      int s=st[st.size()-2];
      int e=st[st.size()-1];
      point S=point(a[s].x,a[s].y);
      point E=point(a[e].x,a[e].y);
      point N=point(a[i].x,a[i].y);
      if(ccw(S,E,N))break;
      st.pop_back();
    }
    st.pu(i);
  }
  for(int i=n-2;i>=0;i--){
    while(st.size()>=2){
      int s=st[st.size()-2];
      int e=st[st.size()-1];
      point S=point(a[s].x,a[s].y);
      point E=point(a[e].x,a[e].y);
      point N=point(a[i].x,a[i].y);
      if(ccw(S,E,N))break;
      st.pop_back();
    }
    st.pu(i);
  }
  st.pop_back();
  cout<<st.size()<<endl;
  cout<<a[st[0]].x<<' '<<a[st[0]].y<<endl;
  for(int i=st.size()-1;i>0;i--)cout<<a[st[i]].x<<' '<<a[st[i]].y<<endl;
  return 0;
}

Measured memory_bytes: 2460
S = input()
K = int(input())

if len(S) < K:
    for s in S:
        if s != '1':
            print(s)
            exit()
    print(1)
else:
    for i in range(K):
        if S[i] != '1':
            print(S[i])
            exit()
    print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n=5;
  int s=0;
  int m=0;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    s+=(d+9)/10*10;
    m=max(m,(d+9)/10*10-d);
  }
  cout<<s-m<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())

l=[0]*n

for i in range(k):
    d=int(input())
    a_list=list(map(int,input().split()))
    for a in a_list:
        l[a-1]+=1

cnt=0
for ll in l:
    if 0==ll:
        cnt+=1

print(cnt)





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

int n;
string s;
int res=0;
int main(){
  cin >> n >> s;
  char a='A',b='B',c='C';
  for(int i=0;i<n;i++){
    if(s[i]==a){
      if(s[i+1]==b){
        if(s[i+2]==c) res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
a_dict = {}
total = 0
for a in a_list:
    if a in a_dict:
        a_dict[a] += 1
    else:
        a_dict[a] = 1
    total += a

q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    if b in a_dict:
        if c in a_dict:
            a_dict[c] += a_dict[b]
        else:
            a_dict[c] = a_dict[b]
        total -= a_dict[b] * b
        total += a_dict[b] * c
        a_dict[b] = 0
    print(total)
        

Measured memory_bytes: 20956
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char


main :: IO ()
main = getLine >>= putStrLn . solve . map read . words
solve :: [Int] -> String
solve (a1:a2:a3:_)
  | a1 + a2 + a3 >= 22 = "bust"
  | otherwise = "win"

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;
#define INF 10000000;

ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;

    vector<int> h(n);
    REP(i, n)
    cin >> h[i];

    int ans = 0;
    int active = 0;

    for (int i = 0; i < n; i++)
    {
        if (active >= h[i])
        {
            active = h[i];
        }
        else
        {
            ans += h[i] - active;
            active = h[i];
        }
    }
    Cout(ans);

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC051B
{
    static class Program
    {
        static void Main()
        {
            int length = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            int currentValue = 0;
            int maxValue = 0;
            for(int i = 0; i < length; i++)
            {
                if (str[i] == 'I')
                {
                    currentValue++;
                    if (currentValue > maxValue)
                        maxValue = currentValue;
                }
                else
                    currentValue--;
            }
            Console.WriteLine(maxValue);
        }
    }
}

Measured memory_bytes: 11092
#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>>k;
 if(n>=13)
  cout<<k;
else if(n>=6 and n<=12)
  cout<<k/2;
else c(0);

}

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;
long long int t, ans;
int main(){
	//ios::sync_with_stdio(0), cin.tie(0);
	//cout<< fixed<< setprecision(10) << x << endl;
	cin>>t;
	for(int a = 1; a < t; a++){
        ans += a;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# F

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
from itertools import accumulate, combinations
input = sys.stdin.readline

mod = 998244353

N, S = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0] * (S+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(S+1):
        dp[i][j] += dp[i-1][j] * 2
        if j + A[i-1] <= S:
            dp[i][j+A[i-1]] += dp[i-1][j]
        dp[i][j] %= mod

# print(dp)
print(dp[-1][S] % mod)


Measured memory_bytes: 139972
#include<stdio.h>

int main(){
	int n,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}else if(x%10==3){
			printf(" %d",i);
		}else{
			while(x){
				x/=10;
				if(x%10==3){
					printf(" %d",i);
					break;
				}
			}
		}
		
		
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	double x1,x2,y1,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << setprecision(20) << fixed << sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2)) << endl;
	return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int sum=0,ans;
	for (int i = a; i >0; i--) {
		if (a%i == 0 && b%i == 0)sum++;
		ans = i;
		if (sum == k)break;
	}
	cout << ans;
	return 0;
}

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

int main()
{
  long long N;
  cin >> N;
  N--;
  long long now = 26;
  long long digit = 1;
  while(true)
  {
    if (now > N) break;
    else
    {
      N -= now;
      digit++;
      now *= 26;
    }
  }
  for (int i = 0; i < digit; i++)
  {
    long long tmp = (N%now) / (now/26);
    now /= 26;
    cout << char('a'+tmp);
  }
  cout << endl;
}


Measured memory_bytes: 3636
import math
n = int(input())

for i in range(n):
    s, t = map(int, input().split())
    a = min(s, t)
    b = max(s, t)
    r = a * b
    q = math.sqrt(r)
    x = int(q)
    if x == q:
        x -= 1

    if a + 1 >= b:
        ans = a * 2 - 2
    elif x * (x + 1) >= a * b:
        ans = x * 2 - 2
    else:
        ans = x * 2 - 1
    print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
 /*
typedef long long lng;
typedef vector < int >  vi;
typedef vector < lng >  vl;
typedef pair < int, int >  pii;
typedef vector < pii >  vpii;

const int inf = 1 << 30;
const long long linf = 1LL << 62;
const double PI = acos(-1.0), dinf = (double)(1LL << 62), eps = (double)(1e-9);

double distance(double x1, double y1, double x2, double y2)
{
    x1 -= x2;
    y1 -= y2;
    return sqrt(x1 * x1 + y1 * y1);
}
long long POW(long long b, long long p)
{
    if(p == 0)
        return 1;
    long long t = POW(b, p >> 1);
    if(p & 1)
        return t * t * b;
    return t * t;
}
long long bigmod(long long b, long long p, long long m)
{
    if(p == 0)
        return 1;
    long long t = POW(b, p >> 1) % m;
    t = (t * t) % m;
    if(p & 1)
        t = (t * b) % m;
    return t;
}
inline int getint()
{
    int x;
    scanf("%d", &x);
    return x;
}
inline long long getlng()
{
    long long x;
    scanf("%lld", &x);
    return x;
}

lng gcd(lng a, lng b)
{
    return !b ? a : gcd(b, a % b);
}

lng lcm(lng a, lng b)
{
    return (a / gcd(a, b)) * b;
}

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

#define theromeo421 main()
#define segtree int lft = node << 1, rgt = lft | 1, mid = (b + e) >> 1;
#define mem(x, y) memset(x, y, sizeof x);
#define II getint()
#define LL getlng()
#define sz(x) ((int)x.size())
#define sqr(x) ((x) * (x))
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define pr3(x,y,z) cout << x << ' ' << y << ' ' << z << endl
#define pr4(a,b,c,d) cout << a << ' ' << b << ' ' << c << ' ' << d << endl
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define repab(i, a, b) for(int i = a; i <= b; ++i)
#define repstl(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define repbstl(it, x) for(auto it = x.rbegin(); it != x.rend(); it++)
#define forch(it, x) for(auto it : x)
#define pb push_back
#define all(x) x.begin(), x.end()
#define xx first
#define yy second
#define dbg(x) cerr << #x << " :  " << x << endl;
#define read(a) freopen(a, "r", stdin);
#define write(a) freopen(a, "w", stdout);
#define prv(v) rep(i, v.size()) cout << v[i] << " \n"[i + 1 == v.size()];
#define prmp(x) repstl(it, x) pr2(it->xx, it->yy)
#define pause int ppause; cin >> ppause;
#define pf printf
#define sf scanf
 */
const int N = 101;
int n, W, arr[N], v[N];
map < long long , int > dp[N];

int call(int i, long long w)
{
    if(i == n)
        return 0;
    if(dp[i].find(w) != dp[i].end())
        return dp[i][w];
    int ret = call(i + 1, w);
    if(w + arr[i] <= W)
        ret = max(ret, v[i] + call(i + 1, w + arr[i]));
    return dp[i][w] = ret;
}

int main()
{
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        cin>>v[i];
        dp[i].clear();
    }
    printf("%d\n", call(0, 0));
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  int a;
  ll b;
  cin>>a>>b;
  vector<ll> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ll sum=0;
  for(int i=0;i<a-b;i++){
    sum+=vec.at(i);
  }
  cout<<sum<<endl;  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N = 5e2+5;

void solve(){
    int x,y;
    cin>>x>>y;
    string s;
    cin>>s;
    int ans=x,curr=y;
    for(int i=0;i<x;++i){
        if(s[i]=='N'){
            curr+=1;
        }
        if(s[i]=='S'){
            curr-=1;
        }
    }
    int me=0;
    for(int i=x;i<sz(s);++i){
        if(me==abs(curr)){
            cout<<ans<<endl;
            return;  
        }
        if(s[i]=='E' or s[i]=='W'){
            ans+=1;
            continue;
        }
        if(s[i]=='N'){
            curr+=1;
        }
        if(s[i]=='S'){
            curr-=1;
        }
        ans+=1;
        if(me==abs(curr)){
            cout<<ans<<endl;
            return;  
        }
        me+=1;
    }
    if(me==abs(curr)){
        cout<<ans<<endl;
        return;
    }
    cout<<"IMPOSSIBLE"<<endl;
}

int main(){
    ll x;
    cin>>x;
    ll y=100;
    for(int i=1;i<=4000;++i){
        ll curr=(ll)(y*0.01);
        y+=curr;
        if(y>=x){
            return cout<<i<<endl,0;
        }
    }
    return 0;
}

Measured memory_bytes: 3600
#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 n, m;
    cin >> n >> m;
    priority_queue<int> que;
    vector<vector<int>> ba(100005);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        ba[a].emplace_back(b);
    }

    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(auto p : ba[i]) que.push(p);

        if(que.empty()) continue;
        int t = que.top();
        que.pop();
        ans += t;

    }
    cout << ans << endl;
}

Measured memory_bytes: 8336
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int N, W, v[110], w[110];
int dp[10010];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];

    for (int sum_w = 0; sum_w <= W; sum_w++) {
        for (int i = 0; i < N; i++) {
            if (sum_w + w[i] <= W) {
                chmax(dp[sum_w + w[i]], dp[sum_w] + v[i]);
            }
        }
    }

    int ans = 0;
    for (int sum_w = 0; sum_w <= W; sum_w++) {
        chmax(ans, dp[sum_w]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3144