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

int check(int tmp,int *card){
	int i,cnt;

	if(tmp >= 10){
		return 1;
	}
	
	cnt = 0;
	for(i = 0;i < tmp;i++){
		if(card[i] == 0){
			cnt++;
		}
	}

	return (cnt >= 4) ? 1 : 0;
}

int main(){
	int c1,c2,c3,i;
	int card[10];

	while(scanf("%d %d %d",&c1,&c2,&c3) != EOF){
		memset(card,0,sizeof(card));
		card[c1-1] = 1;
		card[c2-1] = 1;
		card[c3-1] = 1;

		if(check(20-c1-c2,card)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
string a,b,c;

int main(){
  cin >> a >> b >> c;
  a[0]= a[0] + 'A'-'a';
  b[0]= b[0] + 'A'-'a';
  c[0]= c[0] + 'A'-'a';
  
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 60;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  vector<ll> dp(20005, INF);
  dp[0] = 0;
  // dp[i]:=iだけ体力を減らすときの消費魔力の最小値
  for (int i = 0; i < n; i++) {
    for (int j = a[i]; j < 20005; j++) {
      dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
    }
  }
  ll ans = INF;
  for (int i = h; i < 20005; i++) {
    ans = min(ans, dp[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(void){
    int a, b, ans;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='+') ans=a+b;
        if(op=='-') ans=a-b;
        if(op=='*') ans=a*b;
        if(op=='/') ans=a/b;
        if(op=='?')break;
        cout<<ans<<endl;
        ans=0;
    }
}


Measured memory_bytes: 3096
s = input()
n = len(s)
a = (n-1)//2
b = (n+3)//2

c = s[0:a]
d = c[::-1]
e = s[b-1:n]
f = e[::-1]

t = s[::-1]

if c==d and e==f and s==t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
L, R = [int(elem) for elem in input().split()]
diff = R - L + 1
if L == 0 or diff >= 2019:
    print(0)
    exit(0)

min_rem = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        rem = (i * j) % 2019
        min_rem = min(rem, min_rem)
print(min_rem)


Measured memory_bytes: 41820
#include <stdio.h>
 int main(void){
  float a, b,c;
  scanf("%f", &a);
  scanf("%f", &b);
  scanf("%f", &c);
  if (a < b && b < c){
  	printf("Yes\n");
  }
  else {
  	printf("No\n");
  	}
  return 0;
}


Measured memory_bytes: 2048
N = int(input())
F = [list(map(int, input().split(' '))) for i in range(N)]
P = [list(map(int, input().split(' '))) for i in range(N)]
ans = -float('inf')
for i in range(1, 1 << 10):
    cost = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if ((i >> k) & 1) == 1:
                if F[j][k] == 1:
                    count += 1
        cost += P[j][count]
    ans = max(cost, ans)
print(ans)


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
	c := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			b[c] = a[n-i-1]
		} else {
			b[n-c-1] = a[n-i-1]
			c++
		}
	}

	for k, v := range b {
		suffix := " "
		if k == n-1 {
			suffix = "\n"
		}
		fmt.Printf("%d%s", v, suffix)
	}
}


Measured memory_bytes: 8576
#define scanf_s scanf
#define gets_s gets
#define sscanf_s sscanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	char num[11],a;
	int n[10];
	while (gets_s(num) != NULL) {
		for (int i = 0; num[i] != '\0'; ++i) {
			a = num[i];
			sscanf_s(&a, "%d", &n[i]);
		}
		for (int i = 10; i >= 1; --i) {
			for (int j = 0; j < i - 1; ++j) {
				n[j] = (n[j] + n[j + 1]) % 10;
			}
		}
		printf("%d\n", n[0]);
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N; cin >> N;
    vll L(N); rep(i, N) cin >> L[i];

    sort(all(L));
    L.push_back(inf);
    //for (auto elem : L) cout << elem << " "; cout << endl;

    ll cnt = 0;
    rep(a_index, N - 2) reprr(b_index, a_index + 1, N - 1) {
        ll a = L[a_index], b = L[b_index];
        ll l = b_index + 1; ll r = N;
        //cout << "a: " << a << ", b: " << b << ", c: ";
        while (l + 1 < r) {
            ll c_index = (r + l) / 2;
            ll c = L[c_index];
            (c < a + b) ? l = c_index : r = c_index;
        }
        if (L[(r + l) / 2] >= a + b) l--;
        //cout << "c: " << L[l] << " +" << (l - b_index) << endl;
        cnt += (l - b_index);
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
  // freopen("input.txt","r",stdin);
    FastIO;

    int n,k;
    while(cin>>n>>k){

        int m = 2*n - 1;

        if(k == 1 || k == m){
            cout<<"No\n";
            continue;
        }
        cout<<"Yes\n";

        int lo=1,hi=m;

        deque<int>dq;

        dq.pb(k);
        int now = 1;

        while(lo<k && k<hi){
            if(now){
                dq.push_front(lo++);
                dq.push_back(hi--);
            }
            else{
                dq.push_front(hi--);
                dq.push_back(lo++);
            }
            now ^= 1;
        }
        vector<int>v;
        while(lo<k) v.pb(lo++);
        while(k<hi) v.pb(hi--);

        for(int i=1; v.size(); i ^= 1){
            if(i) dq.push_front(v.back());
            else dq.push_back(v.back());
            v.pop_back();
        }
        assert(dq.size() == m);

        while(dq.size()){
            cout<<dq.front()<<endl;
            dq.pop_front();
        }

    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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;
}


ll dp[110][100500];
int main(){
  ll N,W;
  cin >> N >> W;
  for(int i=0; i<110; i++){
    for(int j=0; j<100100; j++){
      dp[i][j] = INFLL;
    }
  }
  dp[0][0] = 0;
  vector<ll> w(N),v(N);
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<100100; j++){
      if(j >= v[i]){
        chmin(dp[i+1][j], dp[i][j-v[i]]+w[i]);
      }
      chmin(dp[i+1][j], dp[i][j]);
    }
  }
  ll ans = 0;
  for(int i=0; i<100100; i++){
    if(dp[N][i] <= W){
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int* mallocint(int si)
{
    int *tmp = (int*) malloc(si * sizeof(int));
    memset(tmp, 0, sizeof(int) * si);
    return tmp;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int *h = mallocint(n);
    int *isbad = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> h[i];
    for( int j = 0; j < m; j++ )
    {
        int a, b;
        cin >> a >> b;
        if( h[a - 1] > h[b - 1] )
        {
            isbad[b - 1] = 1;
        }
        else if( h[a - 1] < h[b - 1] )
        {
            isbad[a - 1] = 1;
        }
        else
        {
            isbad[a - 1] = 1;
            isbad[b - 1] = 1;
        }
    }
    int ans = 0;
    for( int i = 0; i < n; i++ )
    {
        if( isbad[i] == 0 ) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 4420
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int a,b;
    cin >> a >> b;
    for (int p = 1;p <= 1300;p++){
        int p1 = p * 0.08;
        int p2 = p * 0.1;
        if (p1 == a && p2 == b){
            cout << p << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  long long s=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
      s+=i;
    }
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 1732
//#############################################################################
//----------------------------Karma is Real------------------------------------
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void print_matrix(vector<vector<ll>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
void print_vector(vector<ll> vec){
    for(auto e : vec){cout<< e <<" ";}
    cout<<endl;
}
map<int,int> get_count(vector<ll> vec){
    map<int,int> count;
    for(auto e: vec){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    ll n,w;
    cin>>n>>w;
    vector<ll> val(n),wt(n);
    for(ll i = 0; i<n; i++){
        cin>>wt[i]>>val[i];
    }
    ll mxN = accumulate(all(val),1LL);
    vector<ll> dp(mxN,1e11); dp[0] = 0;
    vector<ll> tmp(mxN,1e11); 
    for(ll i = 0; i<n; i++){
        for(ll j = 0; j<mxN; j++){
            if(val[i]>=j){
                tmp[j] = min(dp[j],wt[i]);
            } else {
                tmp[j] = min(dp[j],wt[i]+dp[j-val[i]]);
            }
        }
        swap(tmp,dp);
    }
    ll ans  = mxN;
    for(ll j = 0; j<mxN; j++){
        if(dp[j]>w){break;}
        ans = j;
    }
    cout<<ans<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
    return 0;
}
//#############################################################################

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;






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


    float d, t, s;
    cin >> d >> t >> s;

    if (d/s <= t) cout << "Yes";
    else cout << "No";

    return 0;


}


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

int main(){

    ll n;
    cin >>n;
    vector<int> a(n+2);

    a[0]=0;
    a[n+1]=0;
    ll su=0;

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

    for(int i=1;i<=n;i++){
        if(a[i-1]<a[i]&&a[i+1]<a[i]){
            cout << su-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]) << endl;
        }else if(a[i-1]>a[i]&&a[i+1]>a[i]){
            cout << su-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]) << endl;
        }else{
            cout << su << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
time = []
mod_10 = []

for i in range(5):
    t = int(input())
    time.append(t)
    mod_10.append(t % 10)
    if mod_10[i] == 0:
        mod_10[i] = 10

flag = False
min_mod = min(mod_10)

for i in range(5):
    if mod_10[i] == min_mod and not flag:
        flag = True
    else:
        time[i] = ((time[i] + 9) // 10) * 10

print(sum(time))

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

using namespace std;

int main()
{
    int i, j;
    int n; cin >> n;
    vector<int> card(n); for (i=0; i<n; i++) cin >> card.at(i);
    int a_point=0, b_point=0;
    int max_point=0, point_index=-1;

    for (i=0; i<n; i++)
    {
        max_point = 0;
        point_index = -1;
        for (j=0; j<n; j++)
        {
            if (max_point < card.at(j))
            {
                max_point = card.at(j);
                point_index = j;
            }
        }
        if (i % 2 == 0) a_point += max_point;
        else b_point += max_point;
        card.at(point_index) = 0;
    }

    cout << a_point - b_point << endl;
}

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

int main() {
  int n, d, a;
  cin>>n>>d>>a;

  pair<int, int> xh[n];
  for (int i=0; i<n; i++) cin>>xh[i].first>>xh[i].second;
  sort(xh, xh + n);

  queue<pair<long long, long long>> q;

  long long sum = 0;
  long long cnt = 0;
  for (int i=0; i<n; i++) {
    while (!q.empty()) {
      auto front = q.front();
      if (xh[i].first <= front.first + d) {
        break;
      }
      sum -= front.second;
      q.pop();
    }
    if (sum >= xh[i].second) {
      continue;
    }
    long long tmp_cnt = ((xh[i].second - sum) - 1) / a  + 1;
    long long damage = tmp_cnt * a;
    q.push(make_pair(d + xh[i].first, damage));
    cnt += tmp_cnt;
    sum += damage;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int H,W,i,ii;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0){break;}
        else{for(i=0;i<H;i=i+1)
            {for(ii=0;ii<W;ii=ii+1)
            {
            if(0<i && i<H-1 && 0<ii && ii<W-1){cout<<".";}
            else{cout<<"#";}
            }cout<<endl;}cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//#define int long long
#define PI 3.14159265
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mod=1e9+7;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    double arr[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    double dp[n+1][n+1]={};
    memset(dp,0.0,sizeof(dp));
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1.0-arr[i]);
            else
            {
                dp[i][j]+=dp[i-1][j]*(1.0-arr[i]);
                dp[i][j]+=dp[i-1][j-1]*arr[i];
            }
        }
       // cout<<dp[i][n];
    }
    double ans=0.0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<ans;

}


Measured memory_bytes: 70656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    int count = 0;
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
        sum += a[i];
    }

    for(int i=0;i<n;++i)
    {
        if(4 * m *a[i] >= sum)
        {
            count++;
        }
    }
    if(count >= m)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    long long n;
    cin>>n;
    long long a=1,b=1,c=1;
    for(int i=0;i<n;i++){
        a=(a*10)%MOD;
        b=(b*9)%MOD;
        c=(c*8)%MOD;
    }
    cout<<(MOD*2+a+c-2*b)%MOD<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3648
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w-1]
b = A[w]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)


Measured memory_bytes: 62704
# D
import math
Q = int(input())
A_list = []
B_list = []
for _ in range(Q):
    A, B = map(int, input().split())
    A_list.append(min(A, B))
    B_list.append(max(A, B))
    
for i in range(Q):
    A = A_list[i]
    B = B_list[i]
    R = int(math.sqrt(A*B))
    
    
    if A >= B - 1:
        print(2*A-2)
    elif R*R == A*B:
        print(2*R-3)
    elif R*(R+1) >= A*B:
        print(2*R-2)
    else:
        print(2*R-1)
    

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

using namespace std;

typedef long long ll;

int n;
string s;

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

  cin >> n;
  cin >> s;
  ll cr = 0, cg = 0, cb = 0;
  for(int i = 0; i < n; ++i) {
    if(s[i] == 'R') ++cr;
    if(s[i] == 'G') ++cg;
    if(s[i] == 'B') ++cb;
  }
  ll ans = cr * cg * cb;
  for(int i = 0; i < n; ++i) {
    int l = i - 1, r = i + 1;
    while(l >= 0 && r < n) {
      string temp = "";
      temp += s[l];
      temp += s[i];
      temp += s[r];
      sort(temp.begin(), temp.end());
      if(temp == "BGR") --ans;
      --l;
      ++r;
    }
  }
  cout << ans << '\n';
  return 0;
}


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

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let mut a=a.chars().collect_vec();
    for i in 0..8 {
        a.pop();
    }
    let a:String=a.iter().collect();
    println!("{}",a)
}

Measured memory_bytes: 2156
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    r = a[0]
    for c in a[1:]:
        r = fractions.gcd(r,c)

    return r



print(main())




Measured memory_bytes: 16652
#include <stdio.h>

int main()
{
  int i, j = 0, n, A[100000], x, a;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    scanf("%d",&A[i]);
  for (i = 0; i < n; i++)
    if (A[i] <= A[n-1]){
      x = A[i];
      A[i] = A[j];
      A[j] = x;
      j++;
    }
  for (i = 0; i < n; i++){
    if (i == j-1)
      printf("[%d]",A[i]);
    else
      printf("%d",A[i]);
    if (i < n-1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}



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

set<int> s;
int main(){

int n,k;
cin>>n>>k;

while(k--){
    int a;
    cin>>a;
    for(int i = 0 ; i < a; i++){
        int l;
        cin>>l;
        s.insert(l);
    }
}

int ans = n - s.size();
cout<<ans<<endl;



}


Measured memory_bytes: 3596
a, b, c, d = map(int, input())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))


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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	int N;
	cin >> N;
	vector<ll> atDepth(N+1);
	for (auto &v : atDepth)
		cin >> v;

	if (atDepth[0])
	{
		if (atDepth[0] > 1 or N)
		{
			cout << -1 << endl;
			return 0;
		}
		cout << 1 << endl;
		return 0;
	}
	vector<ll> up(N+1);
	up[0]= 1;
	for (int depth(1); depth <= N; ++depth)
	{
		up[depth] = up[depth-1] * 2;
		up[depth] -= atDepth[depth];
		up[depth] = min(up[depth], (ll)1e18);
		if (up[depth] < 0)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	ll ans(0);
	ll curFree(0);
	for (int depth(N); depth >= 0; --depth)
	{
		ans += curFree + atDepth[depth];
		if (depth)
			curFree = min(up[depth-1], atDepth[depth] + curFree);
	}
	cout << ans << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int mcount = t.size();
  
  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int count = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i + j) != t.at(j)) {
        count++;
      }
    }
    mcount = min(mcount, count);
  }
  
  cout << mcount << endl;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
from itertools import permutations as p
N = int(input())
A = [i for i in range(1, N+1)]
P = tuple(list(map(int, input().split())))
Q = tuple(list(map(int, input().split())))
cntp = 1
cntq = 1
for i in sorted(p(A)):
    if i != P:
        cntp += 1
    if i == P:
        cntp += 1
        break
for i in sorted(p(A)):
    if i != Q:
        cntq += 1
    if i == Q:
        cntq += 1
        break
print(abs(cntp-cntq))

Measured memory_bytes: 8052
#include <stdio.h>

int main(){
    int n, x = 0, y=0 ;
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i){
        if((i % 2 != 0) && (n >= 105)){
            x = 0;
            for(int j = 1; j <= i; ++j){
                if(i % j == 0) ++x;
                if(x == 9) break;
            }
            if(x == 8) ++y;
        }
    }
    printf("%d\n", y);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    long H,W;
    cin>>H>>W;
    unsigned long mindif = -1;
    for(int i = 1; i < H; i++){
        long size_A = i*W;
        long h = (H-i)/2;
        long size_B1 = W*h;
        long size_C1 = W*(H-i-h);
        long w = W/2;
        long size_B2 = (H-i)*w;
        long size_C2 = (H-i)*(W-w);
        vector<long> l1,l2;
        l1.push_back(size_A);
        l1.push_back(size_B1);
        l1.push_back(size_C1);
        l2.push_back(size_A);
        l2.push_back(size_B2);
        l2.push_back(size_C2);
        long max1 = *max_element(l1.begin(),l1.end());
        long min1 = *min_element(l1.begin(),l1.end());
        long max2 = *max_element(l2.begin(),l2.end());
        long min2 = *min_element(l2.begin(),l2.end());
        long dif = min(abs(max1-min1),abs(max2-min2));
        if(dif<mindif)
            mindif = dif;
    }
    swap(H,W);
    for(int i = 1; i < H; i++){
        long size_A = i*W;
        long h = (H-i)/2;
        long size_B1 = W*h;
        long size_C1 = W*(H-i-h);
        long w = W/2;
        long size_B2 = (H-i)*w;
        long size_C2 = (H-i)*(W-w);
        vector<long> l1,l2;
        l1.push_back(size_A);
        l1.push_back(size_B1);
        l1.push_back(size_C1);
        l2.push_back(size_A);
        l2.push_back(size_B2);
        l2.push_back(size_C2);
        long max1 = *max_element(l1.begin(),l1.end());
        long min1 = *min_element(l1.begin(),l1.end());
        long max2 = *max_element(l2.begin(),l2.end());
        long min2 = *min_element(l2.begin(),l2.end());
        long dif = min(abs(max1-min1),abs(max2-min2));
        if(dif<mindif)
            mindif = dif;
    }
    cout<<mindif;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-6
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long n, pre[200005], ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	FOR (i, 1, n) cin >> pre[i], pre[i] += pre[i - 1];
	ans = abs(pre[1] - pre[n] + pre[1]);
	FOR (i, 2, n - 1) ans = min(ans, abs(pre[i] * 2 - pre[n]));
	cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main() {
	int a;
	string ans = "Good";
	cin >> a;
	int pass[4] = {0};
	int b[4] = {1000,100,10,1};
	for (int i=0;i<4;i++){
		pass[i] = a/b[i];
		a = a%b[i];
	}
	for (int i=0;i<3;i++){
		if(pass[i]==pass[i+1]){
			ans = "Bad";
		}
	}
	cout << ans;

}



Measured memory_bytes: 256
import numpy as np
import heapq

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n >= m:
    print(0)
else:
    npx = np.array(x)
    li = list(np.diff(npx, n = 1))

    print(sum(heapq.nsmallest(len(li)-n+1, li)))


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

int main(){
	int n,cnt=0,x;
	set<int> s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(s.find(x)!=s.end()){
			s.erase(x);
//			cout<<"00"<<endl;
			cnt++;
		}else{
			s.insert(x);
		}
	}
	cout<<n-2*cnt<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

const int MAXM = 1e5+3;
const ll inf = 1e15;


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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

lli gcd(lli a, lli b) { 
   if (b == 0) return a; 
   return gcd(b, a % b);  
} 
lli n,m;

vector<vector<char> >g;
vector<vector<lli> >dp;
lli f(lli i,lli j){
  if(i==n || j==m || g[i][j] == '#'){
    return 0;
  }
  if(i==n-1 && j==m-1){ return 1;}
  if(dp[i][j] != -1){return dp[i][j];}
  dp[i][j] = (f(i+1,j) + f(i,j+1)) %mod;
  return dp[i][j];
}


void solve(){
cin>>n>>m;
g.resize(n , vector<char>(m));
dp.resize(n , vector<lli>(m,-1));
fo(i,n){
  fo(j,m){
    cin>>g[i][j];
  }
}

cout<<f(0,0)<<endl;

}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;

}

Measured memory_bytes: 9216
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define int long long
#define ls i<<1
#define rs i<<1|1
#define mid (l+r)/2

using namespace std;

const int N=1e5+7;
const int mod=998244353;
int n,m,k,t,x,y,z;
int dis[N],vis[N],cnt[N];

#define pr pair<int,int>
#define ff first
#define ss second

void solve(int sum=0){
    cin>>n>>m;
    if(m>=n) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

#undef int
int main(){
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
    solve();
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int x[100000];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &x[i]);
	ll a = 2, b = 2;
	for (int i = n - 1; i >= 0; i--) {
		if (b - b % x[i] < a) {
			cout << "-1" << endl;
			re 0;
		}
		b -= b % x[i];
		if (a % x[i] != 0) a = a - a % x[i] + x[i];
		b += x[i] - 1;
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}

int main()
{
	string a,b,c;
	int n;
	scanf("%i",&n);
	cin>>a>>b>>c;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		set<char> st;
		st.insert(a[i]);
		st.insert(b[i]);
		st.insert(c[i]);
		ans+=st.size()-1;
	}
	printf("%i\n",ans);
	return 0;
}


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

int main() {
  int a;
  int i,n1,n2,n3,n4;

  cin >> a;
  
  n4 = a/1000;
  n3 = (a - n4 * 1000) /100 ;
  n2 = (a - n4 * 1000 - n3 * 100)/10;
  n1= (a- n4* 1000 - n3*100 - n2 *10);
  	if(n4 == n3 || n3 == n2 || n2 == n1)
          cout << "Bad" << endl;
  	else
          cout << "Good" << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define MAXN 200000

/*
Algorithm:
* For each robot i, find out the next robot j that will not be activated if robot i is activated. This can be done with segment tree and processing from the right most robot.
* dp[i] -> Number of possible subset from robot i until N. dp[i] = dp[i + 1] + dp[nxt[i]]
*/

int N, nxt[MAXN + 3], dp[MAXN + 3];
pair<int, int> robots[MAXN + 3];
int tree[4 * MAXN + 3];

void update(int node, int l, int r, int idx, int val) {
    if (r < idx || l > idx)
        return;

    if (l == r) {
        tree[node] = val;
        return;
    }

    int m = (l + r)/2;
    update(2 * node, l, m, idx, val);
    update(2 * node + 1, m + 1, r, idx, val);

    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

void update(int idx, int val) {
    update(1, 1, N, idx, val);
}

int query(int node, int l, int r, int le, int ri) {
    if (r < le || l > ri)
        return 0;

    if (l >= le && r <= ri)
        return tree[node];

    int m = (l + r)/2;
    return max(
        query(2 * node, l, m, le, ri),
        query(2 * node + 1, m + 1, r, le, ri)
    );
}

int query(int le, int ri) {
    return query(1, 1, N, le, ri);
}

int solve(int idx) {
    if (idx == N + 1)
        return 1;

    if (dp[idx] != -1)
        return dp[idx];

    int leave = solve(idx + 1);
    int take = solve(nxt[idx]);

    return dp[idx] = (leave + take)%MOD;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        int X, D;
        scanf("%d%d", &X, &D);

        robots[i] = {X, D};
    }

    sort(robots + 1, robots + N + 1);

    memset(tree, 0, sizeof(tree));

    nxt[N] = N + 1;
    update(N, nxt[N]);

    for (int i = N - 1; i >= 1; i--) {
        int l = i + 1;

        int lo = 1, hi = N, mid;
        while (hi >= lo) {
            mid = (lo + hi)/2;
            if (robots[mid].first >= robots[i].first + robots[i].second)
                hi = mid - 1;
            else
                lo = mid + 1;
        }

        int r = hi;

        if (l <= r) {
            nxt[i] = query(l, r);
        } else {
            nxt[i] = l;
        }

        update(i, nxt[i]);
    }

    memset(dp, -1, sizeof(dp));

    printf("%d\n", solve(1));
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

int main(void)
{
	ll r;
	cin >> r;
	cout << r*r << endl;
	return 0;
}

Measured memory_bytes: 256
import heapq

V = int(input())
E = V - 1
G = {}
for i in range(V):
    G[i] = {}

for _ in range(E):
    s, t, c = [int(_) for _ in input().split()]
    s -= 1  # 0-indexed
    t -= 1  # 0-indexed
    G[s][t] = c
    G[t][s] = c
Q, K = [int(_) for _ in input().split()]
K -= 1  # 0-indexed
XY = [[int(_) for _ in input().split()] for _ in range(Q)]

INF = float('inf')

que = []
i = K
d = 0
D = [INF] * V
D[i] = 0
used = [False] * V
used[i] = True

while True:
    for j in G[i].keys():
        heapq.heappush(que, (d + G[i][j], j))
    v = -1
    while que:
        d, j = heapq.heappop(que)
        if not used[j]:
            v = j
            break
    if v == -1:
        break
    else:
        used[v] = True
        D[v] = d
        i = v
for x, y in XY:
    x -= 1  # 0-indexed
    y -= 1  # 0-indexed
    print(D[x] + D[y])

Measured memory_bytes: 87040
def get_center_and_radius(x1, y1, x2, y2, x3, y3):
    if (y2-y1)*(x3-x1)==(y3-y1)*(x2-x1):
        return -1, -1, -1
        
    d = 2*(x1-x2)*(y1-y3)-2*(x1-x3)*(y1-y2)
    cx = ((x1**2-x2**2+y1**2-y2**2)*(y1-y3)-(x1**2-x3**2+y1**2-y3**2)*(y1-y2))/d
    cy = ((x1**2-x3**2+y1**2-y3**2)*(x1-x2)-(x1**2-x2**2+y1**2-y2**2)*(x1-x3))/d
    r2 = (x1-cx)**2+(y1-cy)**2
    
    return cx, cy, r2
    
def is_inclusive(cx, cy, r2):
    for xi, yi in xy:
        if (xi-cx)**2+(yi-cy)**2>r2+1e-10:
            return False
    
    return True
    
N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
R2 = 10**18

for i in range(N):
    for j in range(i+1, N):
        xi, yi = xy[i]
        xj, yj = xy[j]
        cx, cy = (xi+xj)/2, (yi+yj)/2
        r2 = (cx-xi)**2+(cy-yi)**2
        
        if is_inclusive(cx, cy, r2):
            R2 = min(R2, r2)

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            xi, yi = xy[i]
            xj, yj = xy[j]
            xk, yk = xy[k]
            cx, cy, r2 = get_center_and_radius(xi, yi, xj, yj, xk, yk)
            
            if cx==-1:
                continue
            
            if is_inclusive(cx, cy, r2):
                R2 = min(R2, r2)

print(R2**0.5)

Measured memory_bytes: 46316
n = int(input())
dic = dict()
dic["AC"] = 0
dic["WA"] = 0
dic["TLE"] = 0
dic["RE"] = 0

for i in range(n):
    x = input()
    dic[x] += 1
print("AC x", dic["AC"])
print("WA x", dic["WA"])
print("TLE x", dic["TLE"])
print("RE x", dic["RE"])

Measured memory_bytes: 9204
# define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

#define S_MAX 500000
#define INFTY 1000000000

void merge(int A[], int left, int mid, int right);
void mergeSort(int A[], int left, int right);

int merge_cnt = 0;

int main(void) {

	int n;
	int i;
	int s[S_MAX + 1];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	mergeSort(s, 0, n);
	
	for (i = 0; i < n; i++) {
		printf("%d",s[i]);
		if (i != n - 1) {
			printf(" ");
		}
	}
	printf("\n%d\n", merge_cnt);
	return 0;
}

void merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int i, j, k;

	int L[S_MAX];
	int R[S_MAX];

	//L[0...n1], R[0...n2] ?????????
	for (i = 0; i <= n1 - 1; i++) {
		L[i] = A[left + i];
	}
	for (i = 0; i <= n2 - 1; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	i = 0;
	j = 0;
	for (k = left; k <= right - 1; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i = i + 1;
		}
		else {
			A[k] = R[j];
			j = j + 1;
		}
		merge_cnt++;
	}
}

void mergeSort(int A[], int left, int right) {
	int mid;

	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}

}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int ch(char c){ return c-'0'; }

int main(){
    string s; cin >> s;
    int si = (int)s.size();
    int ans = 1e9+7;
    rep(i,si-2) ans = min(abs(ch(s[i])*100 + ch(s[i+1])*10 + ch(s[i+2])-753), ans);
    cout << ans << endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string s1 = s.substr(0, 4);
        string s2 = s.substr(4);
    cout << s1 << " " << s2 << endl;
    return 0;
}


Measured memory_bytes: 3612
import numpy as np
h, w = map(int, input().split())
s = np.array([list(input()) for i in range(h)])
a=s
c = 0

for i in range(h):
	for j in range(w):
		if s[i][j]=='.':
			if i-1>=0 and j-1>=0:
				if s[i-1][j-1]=='#':
					c+=1
			if j-1>=0:
				if s[i][j-1]=='#':
					c+=1
			if i+1<=h-1 and 0<=j-1:
				if s[i+1][j-1]=='#':
					c+=1
			if 0<=i-1:
				if s[i-1][j]=='#':
					c+=1
			if i+1<=h-1:
				if s[i+1][j]=='#':
					c+=1
			if 0<=i-1 and j+1<=w-1:
				if s[i-1][j+1]=='#':
					c+=1
			if j+1<=w-1:
				if s[i][j+1]=='#':
					c+=1
			if i+1<=h-1 and j+1<=w-1:
				if s[i+1][j+1]=='#':
					c+=1
			a[i][j]=c
			c=0

for ai in a:
	print("".join(ai))

Measured memory_bytes: 12420
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <unordered_set>

using namespace std;

int main(int argc, char** argv) {
	static const int COST[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

	int N, M;

	cin >> N >> M;

	vector<int> A(M);
	

	for (int i = 0; i < M; i++)
		cin >> A[i];

	sort(A.begin(), A.end(), std::greater<int>());


	// i本で作れる桁数の最大
	vector<int> dp(N+1, -1);

	dp[0] = 0;

	for (int i = 1; i <= N; i++) {
		for (int k = 0; k < A.size(); k++) {
			int prev = i - COST[A[k]];
			if (prev >= 0 && dp[prev] != -1) {
				dp[i] = max(dp[i], dp[prev] + 1);
			}
		}
	}

	// dp[N]
	int k = dp[N]; // 桁数
	int n = N; // 残り本数
	vector<int> ans;
	
	while (k) {
		for (int i = 0; i < A.size(); i++) {
			int prev = n - COST[A[i]];

			if (prev >= 0 && dp[prev] == k - 1) {
				ans.push_back(A[i]);
				n -= COST[A[i]];
				k--;
				break;
			}
		}
	}

	for (auto a : ans)
		cout << a;
	cout << endl;

}


Measured memory_bytes: 384
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
 
import java.util.*;
 
public class Main {
    long MOD = (long) 1e9 + 7;
 
    InputStream in;
    OutputStream out;
 
    public Main() {
        this(System.in, System.out);
    }
 
    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }
 
    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);
 
        // write your code
        int h = sc.nextInt(), w = sc.nextInt();
        boolean[][] map = new boolean[h + 2][w + 2];
 
        int bs = 0;
        for (int i = 1; i <= h; i++) {
            String s = sc.next();
            for (int j = 1; j <= w; j++) {
                map[i][j] = s.charAt(j - 1) == '.';
                if (!map[i][j]) bs++;
            }
        }
 
        int[][] d = new int[h + 2][w + 2];
 
        int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
        if (!map[1][1] || !map[h][w]) {
            out.println(-1);
        } else {
            for (int[] a : d) Arrays.fill(a, 1 << 28);
            d[1][1] = 0;
            PriorityQueue<P> q = new PriorityQueue<>();
            q.add(new P(1, 1, 0));
 
            boolean goal = false;
            while (!q.isEmpty()) {
                P cur = q.remove();
                if (d[cur.y][cur.x] != cur.c) continue;
                if (cur.y == h && cur.x == w) {
                    out.println(w * h - bs - cur.c - 1);
                    goal = true;
                    break;
                }
 
                for (int i = 0; i < 4; i++)
                    if (map[cur.y + dy[i]][cur.x + dx[i]]) {
                        if (d[cur.y + dy[i]][cur.x + dx[i]] > cur.c + 1) {
                            q.add(new P(cur.x + dx[i], cur.y + dy[i], cur.c + 1));
                            d[cur.y + dy[i]][cur.x + dx[i]] = cur.c + 1;
                        }
                    }
            }
            if (!goal) {
                out.println(-1);
            }
        }
 
        out.flush();
    }
 
    class P implements Comparable<P> {
        int x, y, c;
 
        P(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }
 
        @Override
        public int compareTo(P o) {
            return c - o.c;
        }
    }
 
    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (int i = n - 1; i >= a; i--)
#define show(x) cout << x << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vpair vector<pair<ll, ll>>
#define vtuple vector<tuple<ll, ll, ll>>
#define ff first
#define ss second
#define mod 1000000007
#define memset(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll m[n+1];
	memset(m,0);
	go(i,1,n) {
	    ll a;
	    cin>>a;
	    m[a]++;
	}
	go(i,1,n+1) show(m[i]);
	auto t2 = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
	clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits.h>

#define ll long long

using namespace std;

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

int main(){

    ll a,b,c,d;

    cin >> a >> b >> c >> d;

    //cで割り切れる個数
    ll cc =b / c - (a - 1) / c;

    //dで割り切れる個数
    ll dc = b / d - (a - 1) / d;

    //cとdの最小公倍数
    ll cdlcm = c * d / gcd(c,d);

    //最小公倍数で割り切れる数

    ll cdlcmc = b / cdlcm - (a - 1) / cdlcm;

    cout << b - (a - 1) - cc - dc + cdlcmc << endl;

    return 0;
}       

Measured memory_bytes: 256
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N,K = LMIIS()
    A = LMIIS()
    
    for i in range(K):
        light = [0]*(N+1)
        for i,a in enumerate(A):
            l = max(0,i-a)
            r = min(N,i+a+1)
            light[l] += 1
            light[r] -= 1
        num_light = 0
        for i in range(N):
            num_light += light[i]
            A[i] = num_light
        if A.count(N) == N:
            break
    
    print(*A)


    
main()

Measured memory_bytes: 124868