akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(n%(a+b)==0){
        cout<<n/(a+b)*a<<endl;
    }
    else{
        if(n%(a+b)>=a){
            cout<<n/(a+b)*a+a<<endl;
        }
        else{
            cout<<n/(a+b)*a+n%(a+b)<<endl;
        }
    }
    
    
    

    
        
}


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

	typedef long long ll;
	typedef vector<int> vi;
	typedef pair<int,int> pi;

	#define F first
	#define S second
	#define PB push_back
	#define MP make_pair
	#define what_is(x) cerr << #x << " is " << x << endl;
	#define MT make_tuple
	#define eb emplace_back
	#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

	#define REP(i,a,b) for (int i = a; i <= b; i++)
	#define FOR(i,n) for (int i=0;i < n ; i++)
	#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

	void err(istream_iterator<string> it) {}
	template<typename T, typename... Args>
	void err(istream_iterator<string> it, T a, Args... args) {
		cerr << *it << " = " << a << endl;
		err(++it, args...);
	}
	clock_t startTime;
	long double getTime(){
		return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
	}

	bool compare(pair<ll,int> a,pair<ll,int> b){
		return a.F < b.F;
	}

	bool compare1(pair<string,int>a ,pair<string, int> b){
		return a.S<b.S;
	}

	int main(){
		startTime=clock();
		ll n;
		ll m;
		ll a;
		ll b;
		cin >> n >> m;
		std::vector<pair<ll,int>> v[n];
		FOR(i,m){
			cin >> a >> b;
			v[a-1].eb(MP(b,i+1)); 
		}
		FOR(i,n){
			sort(v[i].begin(),v[i].end(),compare);
		}
		std::vector<pair<string,int>> w;
		FOR(i,n){
			FOR(j,v[i].size()){
				string s=to_string(j+1);
				string t=to_string(i+1);
				int len1=6-s.length();
				int l2=6-t.length();
				string ans1(len1,'0');
				string ans2(l2,'0');
				string ans=ans2+t+ans1+s;
				w.eb(MP(ans,v[i][j].S));
			}
		}
		sort(w.begin(),w.end(),compare1);
		for(auto x : w){
			cout << x.F <<"\n";
		}

		return 0;
	}

Measured memory_bytes: 13976
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);

	if(a+b+c==17){
		if(a==5&&b==5){
			puts("YES");
			return 0;
		}
		if(b==5&&c==5){
			puts("YES");
			return 0;
		}
		if(c==5&&a==5){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int i,n,x,k=200;
main(){
cin>>n;
while(i++<n){
 int a;cin>>a;x+=a;
 if(a%10!=0)k=min(k,a);
}
cout<<(x%10!=0?x:(k==200?0:x-k));
}

Measured memory_bytes: 256
from math import degrees, atan2

a, b, x = map(int, input().split())

S = x / a
if S >= a * b / 2:
    h = 2 * (a * b - S) / a
    theta = atan2(h, a)
else:
    w = 2 * S / b
    theta = atan2(b, w)
print(degrees(theta))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ref(i,n) for (int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int n;
ll a[201];
ll v2(ll x){
    ll k=-1;
    while(x){
        k++;
        x/=2;
    }
    return k;
}

int main()
{
    cin>>n;
    ref(i,n){
        int t;
        cin>>t;
        ref(i,t) cin>>a[i];
        string s;
        cin>>s;
        set<ll> v,vv,vk;
        ll k=0;bool rr=1;
        for(int i=t-1;i>=0;i--){

            if(s[i]=='0') v.insert(a[i]);
            else{
                    //cout<<s[i];
                bool r=0;
                while(v.size()){
                        auto it=v.begin();
                        v.erase(v.begin());
                    ll x=*it;

                    auto ii=vv.end();auto ik=vk.end();
                        bool used=0;
                        for(int j=vv.size()-1;j>=0;j--){
                                ii--;ik--;

                            ll q=v2(x);

                            if(*ik>q) continue;
                            if(*ik==q) x=x^*ii;
                            if(*ik<q){
                                vk.insert(q);
                                vv.insert(x);
                                used=1;
                                break;
                            }
                        }
                        it++;
                        if(!used&&x) {
                            vv.insert(x);
                            vk.insert(v2(x));
                        }
                }
                auto ii=vv.end();auto ik=vk.end();
                for(int j=vv.size()-1;j>=0;j--){
                        ii--;ik--;
                    if(a[i]>>*ik) a[i]^=*ii;

                    if(!a[i]) {r=1;break;}
                }
                if(r==0) {cout<<1<<endl; rr=0;break;}

            }

            }
            if(rr) cout<<0<<endl;
        }
     return 0;
    }



Measured memory_bytes: 3600
#include <cstdio>
#include <unordered_map>
using namespace std;
 
int main() {
    int n;
    scanf("%d", &n);
 
    unordered_map<int, int> c;
    for (int i = 0; i < n; ++ i) {
        int a;
        scanf("%d", &a);
        c[a] ++;
    }
 
    int res = 0;
    for (auto &e : c) {
        if (e.second & 1) res ++;
    }
    printf("%d\n", res);
 
    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define eb emplace_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool mm[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

int main(){
	int a,b; cin>>a>>b;
	cout<<a*b<<ENDL;

}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
#define ll long long int

int main(void)
{
	int n;
	cin >> n;
	string a;
	cin >> a;
	if (n % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	else
	{
		for (int i = 0;i < n / 2;i++)
		{
			if (a[i] != a[n / 2+i])
			{
				cout << "No" << endl;
				return 0;

			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
//
// Created by sark2 on 14-07-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cases int t;cin>>t;while(t--)
typedef long double ld;

int main() {
    IOS

    int n,k;
    cin>>n>>k;
    int h[n+1];
    for(int i = 1; i <= n; i++)cin>>h[i];

    int dp[n+1];
    dp[n] = 0;
    dp[n-1] = abs(h[n-1]-h[n]);

    for(int i = n-2; i >=1; i--){
        dp[i] = INT_MAX;
        for(int j = i+1; j <=n && j-i<=k; j++){
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[1];

}


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

int main(){
  string s;
  cin >> s;
  bool can = false;
  if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) can = true;
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if (n>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main()
{
	int n, i, j;
	while (cin >> n && n)
	{
		unsigned long long int no, t, num, sum[4000] = {0}, a[4000], f[4000] = {0};
		for (i = 0, j = 0; i < n; i++)
		{
			cin >> no >> t >> num;
			if (!f[no-1] && (sum[no-1] += t * num) >= 1000000)
			{
				a[j] = no;
				f[no-1] = 1;
				j++;
			}
		}
		if (j == 0)
			cout << "NA" << endl;
		else
			for (i = 0; i < j; i++)
				cout << a[i] << endl;
	}
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

string fld[12];

bool vis[12][12];

signed main(){
    while(cin>>fld[0]){
        for(int i=1;i<12;i++)cin>>fld[i];
        memset(vis,0,sizeof(vis));

        int ans=0;
        rep(i,12)rep(j,12){
            if(fld[i][j]!='1'||vis[i][j])continue;
            queue<pint>que;
            que.push(pint(i,j));
            vis[i][j]=true;
            while(que.size()){
                int y,x;
                tie(y,x)=que.front();
                que.pop();
                rep(k,4){
                    int ny=y+dy[k],nx=x+dx[k];
                    if(ny<0||ny>=12||nx<0||nx>=12||vis[ny][nx]||fld[ny][nx]!='1')continue;
                    vis[ny][nx]=true;
                    que.push(pint(ny,nx));
                }
            }
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

set<int> s;
int n, k, d, a;

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, n) s.insert(i);
	FOR(i, 1, k) {
		cin >> d;
		FOR(j, 1, d) {
			cin >> a;
			if (s.find(a) == s.end()) continue;
			s.erase(s.find(a));
		}
	}
	cout << s.size();
}


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

int main(){
	int N,Alice=0,Bob=0,max_p=0,max_i;
	cin>>N;
	vector<int> card(N);
	for (int i = 0; i < N; i++) {
		cin>>card.at(i);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if(max_p<card.at(j)){
	            max_p=card.at(j);
				max_i=j;
            }
		}
		if(i%2==0)
			Alice+=card.at(max_i);
		else
			Bob+=card.at(max_i);
		card.at(max_i)=0;
		max_p=0;
		max_i=0;
	}
	cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i=0,n,d,j,k,saidai=0,c=0,l;
    string s;
    bool used[26];
    cin >> n >> s;
    for(i=0;i<n;i++)
    {
        for(l=0;l<26;l++)
        {
            used[l]=false;
        }
        for(j=0;j<i;j++)
        {
            char h=s.at(j);
            if(used[h-'a']==false)
               {
                   used[h-'a']=true;
               }
            else
            {
                continue;
            }
            for(k=i;k<n;k++)
            {
                if(s.at(j)==s.at(k) )
                {
                    c++;
                    break;
                }
            }
        }
        if(saidai<c)
        {
            saidai=c;
        }
        c=0;
    }
    cout << saidai << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;

    string board[50];

    rep(i, H) {
        cin >> board[i];
    }

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

    rep(i, H) {
        rep(j, W) {
            if (board[i][j] == '#') continue;

            int num = 0;
            rep(d, 8) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 || H <= ni) continue;
                if (nj < 0 || W <= nj) continue;
                if (board[ni][nj] == '#') num++;
            }

            board[i][j] = char(num + '0');
        }
    }

    rep(i, H) cout << board[i] << endl;

    return 0;
}


Measured memory_bytes: 256
cd = []
for i in range(3):
  p = input().split(" ")
  p = [int(j) for j in p]
  cd.append(p)

n = input()
n = int(n)
tf = []

for i in range(n):
  p = input()
  for j in range(3):
    if int(p) in cd[j]:
      tf.append([j, cd[j].index(int(p))])

id0 = [i[0] for i in tf]
id1 = [i[1] for i in tf]
df = [i[0] - i[1] for i in tf]
sm = [i[0] + i[1] for i in tf]

if id0.count(0) == 3:
  print("Yes")
elif id0.count(1) == 3:
  print("Yes")
elif id0.count(2) == 3:
  print("Yes")
elif id1.count(0) == 3:
  print("Yes")
elif id1.count(1) == 3:
  print("Yes")
elif id1.count(2) == 3:
  print("Yes")
elif df.count(0) == 3:
  print("Yes")
elif sm.count(2) == 3:
  print("Yes")
else:
  print("No")

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

int main() {
    int N ;
    cin >> N ;
    
    
    // 1の位の数字だけを取り出すときは10で割った余りを求めれば良い
    int ans = N%10 ;
    
    //同じ処理をする条件分岐が複数あるときはswitchを使う
    switch( ans ){
        case 2 :
        case 4 :
        case 5 :
        case 7 :
        case 9 :
            cout << "hon" << endl;
            break;
        case 0 :
        case 1 :
        case 6 :
        case 8 :
            cout << "pon" << endl;
            break;
        case 3 :
            cout << "bon" << endl;
    }
    
}


Measured memory_bytes: 3504
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a < 3200) cout << "red" << "\n";
	else cout << s << "\n";

	return 0;
}

Measured memory_bytes: 384
from collections import Counter

H, W = map(int, input().split())
cnt = Counter()

for _ in range(H):
    cnt.update(Counter(input()))

H_r = H % 2
W_r = W % 2

if H_r == 0 and W_r == 0:
    cnt1 = cnt2 = 0
    cnt4 = (H * W) // 4
elif H_r == 1 and W_r == 0:
    cnt1 = 0
    cnt2 = W // 2
    cnt4 = (W // 2) * (H // 2)
elif H_r == 0 and W_r == 1:
    cnt1 = 0
    cnt2 = H // 2
    cnt4 = (W // 2) * (H // 2)
else:
    cnt1 = 1
    cnt4 = (W // 2) * (H // 2)
    cnt2 = ((H * W) - cnt4 * 4 - cnt1 * 1) // 2

odd = 0
for c in cnt.values():
    t = min(c // 4, cnt4)
    c -= 4 * t
    cnt4 -= t

    t = min(c // 2, cnt2)
    c -= 2 * t
    cnt2 -= t

    t = min(c, cnt1)
    c -= t
    cnt1 -= t

    if c > 0: break
print('Yes' if cnt1 == cnt2 == cnt4 == 0 else 'No')


Measured memory_bytes: 3316
#include<bits/stdc++.h> 
using namespace std;
int k, a, b, z;
int main(){
	scanf("%d", &k);
	scanf("%d%d", &a, &b);
	for(int i=a; i<=b; i++){
		if(i%k==0){
			z++;
			break;
		}
	}
	if(z==0){
		printf("NG");
	}
	else{
		printf("OK");
	}
	return 0;
}

Measured memory_bytes: 3720
from collections import defaultdict
from math import gcd

n = int(input())

zeros = 0
d = defaultdict(lambda: [0, 0])
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zeros += 1
        continue
    g = gcd(a, b)
    a, b = a // g, b // g
    if a == 0:
        b = 1
    if b == 0:
        a = 1
    if b < 0:
        a, b = -a, -b
    if a <= 0:
        d[(b, -a)][1] += 1
    else:
        d[(a, b)][0] += 1


mod = 1000000007
ans = 1
for v in d.values():
    ans = ans * (pow(2, v[0], mod) + pow(2, v[1], mod) - 1) % mod

ans = (ans - 1 + zeros) % mod
print(ans)


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

using namespace std;

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

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    if (x % 2 and i % 2) {
      ++ans;
    }
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 3608
#include<iostream>

using namespace std;

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

    int d = 100000;
    int r = 0;

    for(int i = 0; i < n; i++)
    {
        r = d * 0.05;
        if(r % 1000 > 0)
            r = r + (1000 - r % 1000);
        d = d + r;
    }

    cout << d << endl;
} 

Measured memory_bytes: 1160
n = int(input())
s = [int(input()) for _ in range(n)]

if sum(s) % 10 == 0:
    sur = [si for si in s if si % 10 != 0]
    if len(sur):
        print(sum(s) - min(sur))
    else:
        print(0)
else:
    print(sum(s))


Measured memory_bytes: 2940
using namespace std;
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#define sqr(x) (x)*(x)
#define ll long long
#define mp make_pair
#define pb push_back
#define in insert
#define mtr(x,y,z) mp(mp(x,y),z)
#define fi first
#define se second
#define lch(x) ((x)<<1)
#define rch(x) (((x)<<1)|1)
#define all(x) (x).begin(),(x).end()
#define fpi(x) freopen(x,"r",stdin);
#define fpo(x) freopen(x,"w",stdout);
#define fprio fpi("in.txt");fpo("out.txt"):
#define fast ios::sync_with_stdio(false);
/*************************************************/

using namespace std;
string s,t;
int main()
{
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	if (s==t) cout<<"Yes";
	else cout<<"No";
return 0;}

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

int main(){
  int n;
  cin >> n;
  int cnt = n/100;
  int sum = n%100;
  if(sum>=0&&sum<=cnt*5){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long m=1e9+7;
long long fact[1000001],inv[1000001];

long long modRecursive(long long a,long long b,long long c)
{
	if(b == 0) return 1;
	if(b%2 ==0) return modRecursive((a*a)%c,b/2,c);
	else return ((a%c)*(modRecursive((a*a)%c,b/2,c)))%c;
}

int main()
{
    int n,ans=INT_MAX;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=a[0]; i<=a[n-1]; i++)
    {
        int x=0;
        for(int j=0; j<n; j++)
            x+=pow(a[j]-i,2);
        ans=min(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

mod pcl {

}



use std::cmp::{max, min};

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n = it.next().unwrap().parse::<i32>().unwrap();
    let x = it.next().unwrap().parse::<i32>().unwrap() - 1;
    let y = it.next().unwrap().parse::<i32>().unwrap() - 1;

    let dist = |a, b| {
        let v_loop = y - x + 1;
        let skip = y - x - 1;
        match (a <= x, y <= b) {
            (true, true) => b - a - skip,
            (true, false) => (x - a) + min(b - x, v_loop - (b - x)),
            (false, true) => min(y - a, v_loop - (y - a)) + (b - y),
            (false, false) => min(b - a, v_loop - (b - a)),
        }
    };

    let mut count = vec![0; n as usize];
    for a in 0..n {
        for b in (a + 1)..n {
            let d = dist(a, b);
            debug_assert!(0 <= d && d < n);
            count[dist(a, b) as usize] += 1;
        }
    }

    for k in 1..n {
        println!("{}", count[k as usize]);
    }
}


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

int main(){
  int a, b;
  int d, r;
  double f;
  cin >> a >> b;
  d = a/b;
  r = a%b;
  f = (double)a/b;
  
  cout << d << " ";
  cout << r << " ";
  cout << fixed << setprecision(5) << f << endl;
  return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

const int maxN = 100001;

//1:indexed
class Bit{
private:
	int n;
	int dat[maxN + 1];

public:
	void init(int x){
		n = x;
	}

	int sum(int k){
		int ret = 0;
		while (k > 0){
			ret += dat[k];
			k -= k & -k;
		}
		return ret;
	}

	void add(int k, int x){
		while (k <= n){
			dat[k] += x;
			k += k & -k;
		}
	}
};

int n, q;
Bit bit;

int main(){
	std::cin >> n >> q;
	bit.init(n);
	rep(i, q){
		int a, b, c;
		std::cin >> a >> b >> c;
		if (a == 0)bit.add(b, c);
		else std::cout << bit.sum(c) - bit.sum(b - 1) << std::endl;
	}
	return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<int> cnt(n);
  vector<int> a(n);
  range(i, 0, n) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }
  vector<int> pos;
  range(i, 0, n) if(cnt[i] == n - 1) {
    pos.push_back(i);
  }
  if(pos.size() > 1) {
    cout << -1;
    return 0;
  }
  if(!pos.empty()) {
    vector<int> res = {pos[0]};
    range(i, 0, n) if(i != pos[0]) res.push_back(i);
    if(a[res[0]] == res[1]) swap(res[1], res[2]);
    for(int i : res) cout << i + 1 << " ";
    return 0;
  }
  set<int> cur;
  vector<int> res;
  range(i, 0, n) cur.insert(i);
  while(cur.size() > 1) {
    auto it = cur.begin();
    if(!res.empty() && a[res.back()] == *it) it = next(it);
    res.push_back(*it);
    cur.erase(it);
  }
  int c = *cur.begin();
  cur.erase(c);
  while(res.size()) {
    if(a[res.back()] == c) {
      cur.insert(res.back());
      res.pop_back();
    }
    else break;
  }
  if(cur.size() == 1 && a[c] == *cur.begin()) {
    res.push_back(*cur.begin());
    res.push_back(c);
    auto check = [&]() {
      range(i, 0, n - 1) if(a[res[i]] == res[i + 1]) return false;
      return true;
    };
    sort(res.begin() + n - 3, res.end());
    while(!check()) {
      assert(next_permutation(res.begin() + n - 3, res.end()));
    }
  } else {
    res.push_back(c);
    while(cur.size()) {
      int c = *cur.begin();
      if(a[res.back()] == c) c = *next(cur.begin());
      cur.erase(c);
      res.push_back(c);
    }
  }
  for(int i : res) cout << i + 1 << " ";
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    rep(i, 70000)
    {
        if ((int)(i * 1.08) == n)
        {
            cout << i << endl;
            return;
        }
    }
    puts(":(");
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main()
{
	int x, y, z; cin >> x >> y >> z;
	
	int ans = 1;
	int tmp = z + y + z;
	while (true) {

		tmp += y + z;

		if (x < tmp) {
			break;
		}
		ans++;

	}

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

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

using namespace std;

typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
char in[N];

int main(){
	scanf("%s", in + 1);
	n = strlen(in + 1);
	
	LL ans = 0;
	for(int i = 1; i <= n; ++i)
		if(in[i] == '1')
			ans += (i + 1) / 2;
	
	int it = 1;
	int pref = 0;

	while(it <= n){
		if(in[it] == '0'){
			ans += pref;
			++it;
			continue;
		}
		
		int t = it;
		while(t <= n && in[t] == '1')
			++t;
		
		pref += (t - it + 1) / 2;
		it = t;
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> pair_vec;
    for(int i = 0;i < n;i++) {
        string s;
        int p;
        cin >> s >> p;
        pair_vec.push_back(make_pair(make_pair(s, -p), i+1));
    }

    sort(pair_vec.begin(), pair_vec.end());
    for(int i = 0;i < n;i++) {
        cout << pair_vec[i].second << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
  int n,m;
  cin >> n>> m;
  ll n1=n,m1=m,mod=1e9+7;
  if(abs(n-m)>1) cout << 0<<endl;
  else{
  for(ll i=n-1;i>=1;i--) n1=(n1*i)%mod;
  for(ll i=m-1;i>=1;i--) m1=(m1*i)%mod;
  if(n==m) cout <<(n1*m1*2)%mod<<endl;
  else cout <<(n1*m1)%mod<<endl;
}
}


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

using namespace std;

vector<int> P, Q, ar;

int main() {
	int N;
	cin >> N;
	P.resize(N), Q.resize(N), ar.resize(N);
	for (int i = 0; i < N; i++)
		cin >> P[i];
	for (int i = 0; i < N; i++)
		cin >> Q[i];

	for (int i = 0; i < N; i++) {
		ar[i] = i + 1;
	}
	int cnt = 1;
	int Pc, Qc;
	
	do {
		if (P == ar)Pc = cnt;
		if (Q == ar)Qc = cnt;
		cnt++;
	} while (next_permutation(ar.begin(), ar.end()));

	cout << abs(Pc - Qc) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int max = Math.max(Math.max(a, b), c);
		System.out.println((max * 10) + (a + b + c - max));
	}

}

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

#define int long long int
#define double long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"


int32_t main()
{
	IOS;
	string s, ans = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'B')
		{
			if (i - 1 >= 0)
			{
				s.erase(s.begin() + i - 1);
				i--;
			}
			s.erase(s.begin() + i);
			i--;
		}

	}
	cout << s << endl;

	return 0;
}

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

using namespace std;

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

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

	int n;
	cin >> n;

	int a[n], b[n];
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	int max_bit = (1 << n) - 1;
	int max_a = 52;
	int dp[max_bit + 1][max_a + 1];

	int INF = 1010101;
	rep(i, max_bit + 1) rep(j, max_a+1) dp[i][j] = INF;
	dp[0][0] = 0;

	rep(bit, max_bit + 1){
		int cnt = __builtin_popcount(bit);

		int t = cnt;
		vector<pii> v;

		rep(i, n){
			if(!((bit >> i) & 1)){
				v.push_back({i, t++});
			}
		}
		
		rep(j, max_a + 1){
			if(dp[bit][j] == INF) continue;

			for(pii p : v){
				int ns;
				if(abs(p.first - cnt) % 2 == 0){
					ns = a[p.first];
				}else{
					ns = b[p.first];
				}

				if(ns >= j){
					dp[bit | (1 << p.first)][ns] 
				     = min(dp[bit | (1 << p.first)][ns], dp[bit][j] + (p.second - cnt));
				}
				
			}
			
		}
	}

	int ans = INF;
	rep(i, max_a+1) ans = min(ans, dp[max_bit][i]);
	if(ans == INF) ans = -1;

	cout << ans << endl;
}


Measured memory_bytes: 54528
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int v[N];
  for (int i = 0; i < N; i++) cin >> v[i];
  sort(v, v + N);
  long double ans = v[0];
  for (int i = 1; i < N; i++) ans = (ans + v[i]) / 2;
  cout << fixed << setprecision(12) << ans << '\n';
  return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	n%=10;
	if(n==3)
	cout<<"bon";
	else{
		if(n==0||n==1||n==6||n==8)
		cout<<"pon";
		else
		cout<<"hon";
	}
	re 0;
}

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

int main(void){
	int n,s;

	while(1){
		cin >> n >> s;
		if(n==0&&s==0)break;
		int *r = new int[n];
		for(int i=0; i<n; i++)
			cin >> r[i];

		int cnt=0;
		sort(r,r+n);
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++)
				if(r[i]+r[j]>s){
					cnt+=n-j;
					break;
				}
		}
		
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
int r,g,b;
int ans=0;
int main()
{
	cin>>r>>g>>b;
	ans=r*100+g*10+b;
	if(ans%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;

class UnionFind {
public:
	vector<int> s, p;

	UnionFind() {}
	UnionFind(int size) {
		s.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		s[x] = 1;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		x = findSet(x);
		y = findSet(y);

		if (x == y)return;

		if (s[x] < s[y])swap(x, y);

		p[y] = x;
		s[x] += s[y];
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}

	int size(int x) {
		return s[findSet(x)];
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind un = UnionFind(n);
	rep(i, 0, m) {
		int x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		un.unite(x,y);
	}

	set<int>st;
	rep(i, 0, n) {
		st.insert(un.findSet(i));
	}
	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 5760
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //        freopen ("INPUT.txt" , "r" , stdin);
 //        // freopen ("OUTPUT.txt" , "w" , stdout);
 //    #endif

	int N,K;
	string S;
	cin>>N>>K>>S;
	S[K-1]=(char)((int)S[K-1]-(int)'A'+(int)'a');
	cout<<S<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n, x;
    cin>>n>>x;
    int t=0;
    
    set<int>S;
    int mul=n/x;
    n=(n)-(mul)*x;
    S.insert(n);
    int ans=n;

    while(t<4*(1e8)){
        int mul=n/x;
        n=min((n)-(mul)*x,abs(n-x));
        ans=min(n, ans);
        if(S.find(n)!=S.end()){
           break;
       }
       S.insert(n);

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

   return 0;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A.sort()
A = np.array(A, dtype=int)
cs = A[::-1].cumsum()[::-1]


def test(k):
    # 幸福度が k 以上になる握手を採用する
    counts = N - np.searchsorted(A, k - A)
    return counts.sum() >= M


def count(k):
    counts = N - np.searchsorted(A, k - A)
    cnt = counts.sum()

    pos = np.searchsorted(A, k - A)
    ret = ((A * counts)[pos < N] + cs[pos[pos < N]]).sum()
    ret -= abs(M - cnt) * k
    return ret


ok = 0
ng = max(A) * 2 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid

ans = count(ok)
print(ans)


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

using namespace std;
int main() {
  int L, R; cin >> L >> R;
  int Lquo=L/2019;
  int Rquo=R/2019;
  int ans=2019*2019;
  if (Lquo<Rquo){
    cout << 0 << endl;
  }else{
    int Lmod=L%2019;
    int Rmod=R%2019;
    for(int i=Lmod+1;i<=Rmod;i++){
      for(int j=Lmod;j<i;j++){
        if((i*j)%2019<ans){
          ans=(i*j)%2019;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
ll a,b;
int main(){
    cin>>a>>b;
    if(a==b){
        cout<<0<<endl;
        return 0;
    }
    int c=a+b;
    if(c%2==0){
        cout<<c/2<<endl;
        return 0;
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;
int i,j,k;
int N[4];
inline void solve(){
  INPUTS(i,4,N);
  sort(N,N+4);
  if(N[0]==1&&N[1]==4&&N[2]==7&&N[3]==9)OUTPUT("YES");
  else OUTPUT("NO");
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

    int num[7505]={};
    int k,s;
int solve();
int main(){

    cin>>k>>s;
    int ans=0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k;y++){
            if(0<=s-x-y&&s-x-y<=k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
int main() {
  string A;
  cin >> A;
  int ans = 0;
  rep(i, 6) {
    if(A.at(i) == '1') {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    char s; cin >> s;

    if(s=='A') cout << 'T' << endl;
    else if(s=='T') cout << 'A' << endl;
    else if(s=='C') cout << 'G' << endl;
    else cout << 'C' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int change(int);
int main(void) {
  int money, mai;
  scanf("%d", &money);
  while(money > 0) {
    money = 1000 - money;
    mai = change(money);
    printf("%d\n", mai);
    scanf("%d", &money);
  }
  return 0;
}

int change (int kane){
  int count = 0, i = 0;
  int wei[6] = {500, 100, 50, 10, 5, 1};
  while(kane > 0 && i < 6) {
    while(1){
      if(kane - wei[i] >= 0){
      kane = kane - wei[i];
      count++;
      }else
	break;
    }
    i++;
  }
  return count;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int t[1000000];
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int visit[7];
		memset(visit, 0, sizeof(visit));
		for (int i = 0; i < n; ++i)
			scanf("%d", t+i);
		for (int i = 0; i < n; ++i)
			++visit[t[i]/10 >= 6 ? 6 : t[i]/10];
		for (int i = 0; i < 7; ++i)
			printf("%d\n", visit[i]);
	}

	return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, k;
    cin >> n >> k;
    ll ans = k;
    for (int i = 1; i < n; i++){
        ans = ans * (k-1);
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

int main() {
    int n, a[200000];
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++) {
        cin >> vec.at(i);
        a[i]=vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++) {
        if(a[i]<vec.at(n/2)) cout << vec.at(n/2) << " ";
        else cout << vec.at(n/2-1) << " ";
    }
    
}

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

int main()
{
  string s,t;
  cin >> s;
  cin >> t;
  int cnt = 0;
  for (int i = 0; i < 3; i++)
  {
    if(s[i]==t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256