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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

ll n, arr[nax], k;
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    cin >> arr[1];
    ll maxi = 0;
    ll gcd = arr[1];
    maxi = arr[1];
    for(int i = 2; i <= n; i++)
    {
        cin >> arr[i];
        maxi = max(maxi, arr[i]);
        gcd = __gcd(arr[i], gcd);
    }
    if(k > maxi || k % gcd != 0)
        cout << "IMPOSSIBLE";
    else
        cout << "POSSIBLE";
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInts();
            var list = new List<int>();
            for (int i = 0; i < NM[0]; i++)
            {
                list.Add(ReadInt());
            }
            var ansarray = new int[list.Count];
            for (int i = 0; i < NM[1]; i++)
            {
                var B = ReadInt();
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j] <= B)
                    {
                        ansarray[j]++;
                        break;
                    }
                }
            }

            WriteLine(ansarray.ToList().IndexOf(ansarray.Max()) + 1);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, c=0;
 cin >> n;
 int a[n];
 for(int i=0;i<n;i++) cin >> a[i];
 sort(a,a+n);
 for(int i=0;i<n-1;i++) if(a[i]==a[i+1]) c=1;
 if(c==0) cout << "YES";
 if(c==1) cout << "NO";
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int a,b,i,c=0,k;
	scanf("%d%d%d",&a,&b,&k);
	for(i=100;i>=1;i--){
		if(a%i==0&&b%i==0)c++;
		if(c==k){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else {
            n[i] = '1';
        }
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<bool> b(n,false);
    int cnt = 0;
    for(int i = n; i > 0; i--) {
        if(i*2 > n) {
            if(a[i-1]) {
                b[i-1] = true;
                cnt++;
            }
        } else {
            int rem = 0;
            for(int j = i*2; j <= n; j+=i) {
                if(b[j-1]) rem = 1-rem;
            }
            if(rem != a[i-1]) {
                b[i-1] = true;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    rep(i,n) if(b[i]) cout << i+1 << " ";
    cout << endl;
}

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

using namespace std;

int main()
{
    int h, w, i, j;
    cin>>h>>w;
    char S[h][w];
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            cin>>S[i][j];
        }
    }
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            cout<<S[i][j];
        }
        cout<<"\n";
        for(j=0; j<w; j++)
        {
            cout<<S[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

ll fact(int n){
	if(n == 0) return 1;
	return (n * fact(n-1)%MOD)%MOD;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;

	cout << fact(n) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string S; cin >> S;
  int N = S.size()+1;
  int tmp[N] = {0}; 
  if(S[0]=='<'){
    int i=0; tmp[0] = 0;
    while(S[i]=='<' && i<N-1){
      tmp[i+1]=max(i+1, tmp[i+1]); i++;
    }
  }
  if(S[N-2]=='>'){
    int i=N-1; tmp[i] = 0;
    while(S[i-1]=='>' && i>0){
      i--;  tmp[i]=max(N-i-1, tmp[i]); 
    }
  }
  rep(i, N-2){
    if(S[i]=='>' && S[i+1]=='<'){
      tmp[i+1]=0;
      int j=i, k=0;
      while(S[j]=='>'){
        j--; k++; tmp[j+1]=max(k, tmp[j+1]);
      }
      j=i+1; k=0;
      while(S[j]=='<'){
        j++; k++; tmp[j]=max(k, tmp[j]);
      }
    }
  }
  ll ans = 0;
  rep(i, N){
    ans += (ll) tmp[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 2820
#include <stdio.h>
 
class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* checkTable;
};
 
int main(){
    Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d",&tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);
 
    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}



Measured memory_bytes: 2700
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  int a[100];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  int M=0,C[100]={0};
  for(int i=0;i<n;i++){
    M=max(M,a[i]);
    C[a[i]]++;
  }
  bool F=1;
  for(int i=1;i<=M;i++){
    if((2*i<M&&C[i]>0)||(2*i==M&&C[i]!=1)||(2*i==M+1&&C[i]!=2)||(2*i>M+1&&C[i]<2)){
      F=0;
      break;
    }
  }
  if(M==1&&n>2){
    F=0;
  }
  puts(F?"Possible":"Impossible");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vll A(6);
  FOR(i,0,6){
    ci(A[i])
  }
  SORT(A);
  ll count=0;
  FOR(i,1,5){
    if(A[i]==A[i+1]&&A[i]==A[i-1]){
      co("NO")
        break;
    }
    if(i==4){
      co("YES")
    }
  }
    }

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
using llong = long long;

int sum[3005];
int n;
int l[2005];
int a, b;

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

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

    llong ans = 0;
    for (int i = 0; i < n; i++) {
        a = l[i];
        for (int j = i + 1; j < n; j++) {
            llong left = max({0, a - l[j], l[j] - a});
            llong right = a + l[j];

            ans += sum[right - 1] - sum[left];
            if (left < a && a < right) ans--;
            if (left < l[j] && l[j] < right) ans--;
        }
    }

    ans /= 3;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] array = str.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);

		if(a < b && b < c) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 24400
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        c: char,
    }

    let flag = match c {
        'a' | 'e' | 'i' | 'o' | 'u'  => true,
        _ => false,
    };

    if flag {
        println!("vowel");
    } else {
        println!("consonant");
    }
        
}


Measured memory_bytes: 2152
use 5.018;
use utf8;
use strict;
use warnings;
use feature qw/say/;

my $s = <STDIN>;
chomp($s);
my @editor;
for my $ch (split //, $s) {
    push @editor, '0' if $ch eq '0';
    push @editor, '1' if $ch eq '1';
    pop @editor if $ch eq 'B';
}

say(join('', @editor));


Measured memory_bytes: 768
#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(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{

int n ;
cin>>n;
cout<<"ABC"<<n<<endl;

 return 0;
}


Measured memory_bytes: 3564
#include<stdio.h>

int main(){
	char s[11];
	int ans=0,tmp=0,i;
	scanf("%s",s);
	for(i=0;s[i]!=0;i++){
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
			tmp++;
		if(tmp>ans)ans=tmp;
		}else tmp=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>


using namespace std;


int main(int argc, char const *argv[])
{
    int A,B;

    cin>>A>>B;

    int A_co=0;

    int ans=0;

    if(B==10000){
        cout<<0<<endl;
        return 0;
    }

    int tta=10000;
    bool check=true;
    for(int i=0;i<100&&check;i++){
        if(i%10==0){
        tta++;
        tta-=100;
        }        
        for(int i=0;i<10;i++){
            
            if(tta>B){
                check=false;
                break;
            }
            if(tta>=A){


                ans++;
            }
            tta+=100;

        }
        tta+=10;



    }



    cout<<ans<<endl;

    return 0;
}


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

int main() {
  long long int a, b, k;

  cin >> a >> b >> k;

  if(a > k)
    cout << a-k << " " << b << endl;
  else {
    k -= a;
    a = 0;
    if(b >= k)
      b -= k;
    else
      b = 0;
    cout << a << " " << b << endl;
  }
  
  return 0;
}


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

int  main()
{
	int x;
	cin >> x;
	if (x == 0)
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return (0);
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,a;cin>>x>>a;
  print((x<a)?0:10);
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
string s;
int len;
int nxt[200005][30];
int dp[200005];
int main(){
	cin>>s;
	len=s.size();
	for (int i=0;i<26;i++){
		nxt[len][i]=-1;
	}
	for (int i=len-1;i>=0;i--){
		for (int j=0;j<26;j++){
			nxt[i][j]=nxt[i+1][j];
		}
		nxt[i][s[i]-'a']=i;
	}
	for (int i=0;i<=len;i++){
		dp[i]=1e9;
	}
	dp[len+1]=0;
	for (int i=len;i>=0;i--){
		for (int j=0;j<26;j++){
			int Nxt=nxt[i][j]+1;
			if (!Nxt){
				Nxt=len+1;
			}
			if (dp[Nxt]+1<dp[i]){
				dp[i]=dp[Nxt]+1;
			}
		}
	}
	/*for (int i=0;i<=len+1;i++){
		cout<<dp[i]<<" ";
	}
	cout<<endl;*/
//	cout<<"??"<<endl;
	string ans="";
	int now=0;
	while (true){
		for (int i=0;i<26;i++){
			if (nxt[now][i]==-1){
				char c='a'+i;
				ans+=c;
				cout<<ans;
				return 0;
			}
			else if (dp[nxt[now][i]+1]==dp[now]-1){
				char c='a'+i;
				ans+=c;
				now=nxt[now][i]+1;
			    break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 24836
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

class State
{
public:
	int p,c,b;
	State(int p, int c, int b)
		:p(p),c(c),b(b)
	{}

	bool operator<(const State& s) const
	{
		return c>s.c;
	}
};

int toBin(string s)
{
	int ret=0;
	for(int i=0; i<s.size(); i++)
		if(s[i]=='B') ret+=(1<<i);


	return ret;
}

bool v[16][1<<16];

int main()
{
	int N;
	while(cin >> N, N)
	{
		string S,D;
		cin >> S >> D;

		int T=toBin(D);

		memset(v,0,sizeof(v));
		priority_queue<State> q;
		for(int i=0; i<N; i++)
		{
			q.push(State(i,0,toBin(S)));
		}

		while(!q.empty())
		{
			State s=q.top(); q.pop();
			if(v[s.p][s.b]) continue;
			v[s.p][s.b]=1;

			if(s.b==T)
			{
				cout << s.c << endl;
				break;
			}

			for(int i=0; i<N; i++)
			{
				int f1 = (1<<s.p);
				int f2 = (1<<i);

				bool b1 = s.b & f1;
				bool b2 = s.b & f2;


				int tb=s.b;

				if(b1) tb|=f2; else tb&=(~f2);
				if(b2) tb|=f1; else tb&=(~f1);

				if(!v[i][s.b]) q.push(State(i,s.c+abs(s.p-i),s.b));

				
				if(b1==b2) continue;

				if(v[i][tb]) continue;

				q.push(State(i,s.c+abs(s.p-i),tb));
			}
		}
	}
}

Measured memory_bytes: 21000
from collections import deque
k = int(input())
d = deque()
for i in range(1, 10):
  d.append(i)
cc = 0
while cc < k:
  num = d.popleft()
  if num%10 == 0:
    d.append(10*num)
    d.append(10*num + 1)
  elif num%10 == 9:
    d.append(10*num+8)
    d.append(10*num+9)
  else:
    d.append(10*num+num%10-1)
    d.append(10*num+num%10)
    d.append(10*num+num%10+1)
  cc += 1
print(num)

Measured memory_bytes: 11940
n,m = map(int, input().split())
a = list(map(int,input().split()))
bclist = [list(map(int,input().split())) for _ in range(m)]

bclist=sorted(bclist, key = lambda x:x[1], reverse=True)

all = []


for i in range(m):
    all.extend([bclist[i][1]]*bclist[i][0])
    if len(all) >n:
        break

all.extend(a)
all.sort(reverse=True)

print(sum(all[:n]))

Measured memory_bytes: 35960
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int x, y;
    cin >> x >> y;

    int cnt1{}, cnt2{};
    for( auto &i : vector<int>{ 1, 3, 5, 7, 8, 10, 12 } )
    {
        if( i == x || i == y ) cnt1++;        
    }
    for( auto &i : vector<int>{ 4, 6, 9, 11 } )
    {
        if( i == x || i == y ) cnt2++;        
    }
	cout << ( cnt1 == 2 || cnt2 == 2 ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
N = gets.to_i
R = Array.new(N).map{Array.new(2)}
for i in 0..N-1
 R[i][0],R[i][1] = gets.chomp.split(" ");
end
_sort = R.sort_by {|x| x[1].to_i}.reverse.sort_by {|x| [x[0], i += 1]}
for i in 0..N-1
 m = R.index(_sort[i])
  puts m+1
end

Measured memory_bytes: 1788
a,b,c,d=[int(x) for x in input().split()]
count=a
sum=a
if count>=d:
    print(d)
else:
    count=count+b
    if count<d:
        if d-count<=c:
          print(sum+((d-count)*-1))
        else:
            print(sum+(c*-1))
    else:
        print(sum)

Measured memory_bytes: 9196
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  int b[n];
  for(int i = 0; i < n; i++){
    b[i] = a[i];
  }

  sort(b, b + n);

  ll sum[n + 1];
  sum[0] = 0;
  for(int i = 1; i <= n; i++){
    sum[i] = sum[i - 1] + b[i - 1];
  }

  int count = 0;
  for(int i = 0; i < n; i++){
    ll s = a[i];
    int k = 0;
    while(true){
      int j = distance(b, upper_bound(b + k, b + n, 2 * s));
      if(j <= k) break;
      s += sum[j] - sum[k];
      if(k == 0) s -= a[i];
      if(j == n){
        ++count;
        break;
      }
      k = j;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1792
import kotlin.math.abs

fun main() = Thread(null, ::abc170c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc170c() {
    val (x, n) = readLine()!!.split(' ').map { it.toInt() }
    val pList = if (n > 0) readLine()!!.split(' ').map { it.toInt() }.toSet() else emptySet()

    val list = (0..101).filter { it !in pList }
    val answer = list.minBy { abs(x - it) }

    println(answer)
}


Measured memory_bytes: 37236
#include <bits/stdc++.h>
#define FASTIO cin.tie(NULL); ios_base::sync_with_stdio(false);
#define ll long long int
#define ii pair<int,int>
#define endl '\n'
using namespace std;
void solve()
{
    int n, k, t;
    cin >> n >> k;
    ll ans = 0;
    vector<int> v;
    while(n--)
        cin >> t, v.push_back(t);
    sort(v.begin(), v.end());
    for(int i=0; i<k; i++)
        ans += v[i];
    cout << ans << endl;
}
int main()
{
   FASTIO
/* 	int t;
	cin >> t;
	while (t--) */
        solve();
}

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

#define MAX_Q 150
#define MAX_LEN 1000
string s, t;
int dp[MAX_LEN+1][MAX_LEN+1];

int align_dp() {
    fill((int*)dp, (int*)(dp+MAX_LEN+1), 0);
    // dp[i][j] := i-1番目、j-1番目までの文字で最長
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = max(dp[i][j] + 1, max(dp[i+1][j], dp[i][j+1]));
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    return dp[s.size()][t.size()];
}

int main() {
    int q;
    cin >> q;
    int res[MAX_Q+1];
    for (int i = 0; i < q; i++) {
        cin >> s;
        cin >> t;
        res[i] = align_dp();
    }
    for (int i = 0; i < q; i++)
        cout << res[i] << endl;
    return 0;
}



Measured memory_bytes: 7076
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	_ = nextInt()
	_ = nextInt()
	_ = nextInt()
	d2 := nextInt()

	if d2 == 1 {
		fmt.Printf("1")
	} else {
		fmt.Printf("0")
	}
}


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

int main() {
    char S[4], T[4];
    int match_count = 0;

    cin >> S >> T;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) match_count++;
    }
    cout << match_count << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 




int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
ll n,i,j,k;
sfl(n);
ll a[n];
f(i,0,n)sfl(a[i]);

ll c[65]={0};

for(i=0;i<=60;i++){

  for(j=0;j<n;j++){
    

    if((1LL<<i)&a[j]){c[i]++;
        
    }
  }

}

ll ans=0;

ll pw[62];
pw[0]=1;
f(i,1,61){
pw[i]=(pw[i-1]*2)%mod;
}


for(i=0;i<61;i++){
ll p=((c[i]%mod)*((n-c[i]+mod)%mod))%mod;

p=(p*pw[i])%mod;
//pfl(c[i]);
ans=(ans+p)%mod;
}
pf(ans);









   return 0;
 }

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
string s1,s2,s3,s;
cin>>s1>>s2>>s3;
s=" "+s1+" "+s2+" "+s3;
char h;
for(int i=0;i<s.length();i++)
{
if(s[i-1]==' '){
h=toupper(s[i]);	
cout<<h;
}}
	}


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

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
}
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n];
    int f=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==k)f=1;
    }
    int g=findGCD(a,n);
    if(f)cout<<"POSSIBLE\n";
    else if(k%g==0 and k<=*max_element(a,a+n))cout<<"POSSIBLE\n";
    else cout<<"IMPOSSIBLE\n";
    // cout<<g<<nl<<k<<nl<<*max_element(a,a+n)<<nl;
    bdyptb;
}

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

int main(){
char a, b;
cin >> a >> b;
if (a == 'H') {
    cout << b << endl;
}
else if (a == 'D') {
    if (b == 'H'){
        cout << 'D' << endl;
    }
    else if (b == 'D'){
        cout << 'H' << endl;
    }
}
}

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

using namespace std;

typedef long long ll;

vector<int> edge[100005];
bool ch[100005];
ll dp[100005][2];
ll mod = 1e9 + 7;

ll bfs(int x) {
	ch[x] = 1;
	ll b = 1, w = 1;
	for (int i = 0; i < edge[x].size(); i++) {
		if (!ch[edge[x][i]]) {
			bfs(edge[x][i]);
		}
		if (dp[edge[x][i]][0] == 0) {
			continue;
		}
		b *= dp[edge[x][i]][1];
		b %= mod;
		w *= (dp[edge[x][i]][0] + dp[edge[x][i]][1]) % mod;
		w %= mod;
	}
	dp[x][0] = b;
	dp[x][1] = w;
	return (dp[0][0] + dp[0][1]) % mod;
}

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

	cin >> N;

	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	cout << bfs(0) << endl;
	return 0;
}

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

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

    li h, w, d;
    cin >> h >> w >> d;

    if (d % 2 == 1) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cout << (((i + j) & 1) ? 'R' : 'B');
            }
            cout << endl;
        }
    } else {
        const int size = d / 2;
        vector<vector<char>> b(h, vector<char>(w));
        string colors = "RGBY";
        for (int k = -h; k <= w; ++k) {
            int cycle = (k + h) / 2;

            int init_color = cycle / size % 4;
            int offset = cycle % size;
            for (int v = 0; v < h; ++v) {
                int i = v;
                int j = k + v;

                int color_shifts = (offset + v) / size;
                int color = (init_color + color_shifts * 2) % 4;
                if (0 <= i && i < h && 0 <= j && j < w) {
                    b[i][j] = colors[color];
                }
            }
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cout << b[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
const long long INF = (long long)(1e18) + 1;

long long f(long long hp) {
	if (1 == hp){
		return 1;
	}
	return 2 * f(hp/2) +1;
}
int main() {
	long long H;
	cin >> H;
	cout << f(H) <<endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      String S = in.next();
      long K = in.nextLong();
      char sol = '1';

      for (int i = 0; i < S.length(); ++i) {
        if (S.charAt(i) != '1') {
          if (K - 1 >= i) {
            sol = S.charAt(i);
            break;
          }          
        }
      }

      System.out.println(sol);
    }
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int cnt = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -f; c = getchar();}
	while (isdigit(c)) {cnt = (cnt << 3) + (cnt << 1) + (c ^ 48); c = getchar();}
	return cnt * f;
}
long long n, k;
int main() {
//	freopen("replace.in", "r", stdin);
//	freopen("replace.out", "w", stdout);
	cin >> n >> k;
	n %= k;
	n = min (n, k - n);
	cout << n; 
	return 0;
}

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

vector<int> input(int N){
    vector<int> vec;    
    int temp = 0;
    for (int i = 0; i < N; i++ )    {
        cin >> temp;
        vec.push_back(temp);
    }
    return vec;
}


int main(){
    int N; // 100
    cin >> N;
    string str;
    cin >> str;
    vector<int> east_num(N);
    vector<int> west_num(N);

    if (str.at(0)=='E'){
        east_num.at(0) = 1;
        west_num.at(0) = 0;
    }else{
        east_num.at(0) = 0;
        west_num.at(0) = 1;
    }
    for (int i =0; i <N-1; i++)    {
        if(str.at(i+1) == 'E'){
            east_num.at(i+1) = east_num.at(i)+1;
            west_num.at(i+1) = west_num.at(i);            
        }
        else{
            east_num.at(i+1) = east_num.at(i);
            west_num.at(i+1) = west_num.at(i)+1;            
        }
    }
    int min_val = east_num.at(N-1) - east_num.at(0);
    for (int i =0; i <N-1; i++)    {
        int value = east_num.at(N-1) - east_num.at(i+1) + west_num.at(i);
        if (value < min_val) min_val = value;
    }    
  /*
   for (int i =0; i <N; i++)    {
      cout << east_num.at(i) << " ";
    }
      cout << endl;
  for (int i =0; i <N; i++)    {
      cout << west_num.at(i) << " ";
    }
      cout << endl;
   */  
    cout << min_val << endl;
}

Measured memory_bytes: 6080
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll t, a, b, c, i, j, k, x, y, n, m;
ll arr[100005];
string s;
char str[105][105];
int main() {
	cin >> n >> x >> t;
	a = n / x;
	if (n % x == 0)
		cout << a * t;
	else
		cout << a * t + t;
	return 0;
}
/*
4 6 8
4 6 8 6 8 6 8
24+18+4
46
4 6 8 2 9 9 9 9
36+20
56
*/

Measured memory_bytes: 3624
#include <iostream>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(void){
    int A[3];
    rep(i,3)cin>>A[i];

    int ans = A[0]+A[1];
    if(ans > A[1]+A[2])ans = A[1]+A[2];
    if(ans > A[0]+A[2])ans = A[0]+A[2];
    cout<<ans<<endl;
}


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

int main(){
    string s,s2;
    cin >> s;
    int K;
    cin >> K;
    int x[5],y[5];
    for(int i=0;i<5;i++){x[i]=-1; y[i]=-1;}
    int n = s.length();
    for(int i=0;i<n;i++){
        for(int j=1; j+i<=n;j++){
            bool ch = false;
            for(int k=0;k<5;k++){
                if(x[k]!=-1 && y[k]!=-1 && s.substr(x[k],y[k]) == s.substr(i,j)){ch=true; break;}
                if((x[k]==-1&&y[k]==-1 )|| s.substr(x[k],y[k]) > s.substr(i,j)){
                    ch = true;
                    for(int l=4;l > k;l--){
                        x[l] = x[l-1];
                        y[l] = y[l-1]; 
                    }
                    x[k] = i;
                    y[k] = j;
                    break;
                }
            }
            if(!ch) break;
        }
    }

    cout << s.substr(x[K-1],y[K-1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

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

ll x[55];
ll dp[55][10101];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,X;
    cin>>N>>A;
    X=A;
    REP(i,N){
        cin>>x[i];
        chmax(X,x[i]);
        x[i]-=A;
    }

    dp[0][N*A] = 1;
    for(int j=1;j<=N;j++){
        for(int t=0;t<=2*N*X;t++){
            if(t-x[j-1]<0 || t-x[j-1]>2*N*X) dp[j][t] = dp[j-1][t];
            else dp[j][t] = dp[j-1][t] + dp[j-1][t-x[j-1]];
        }
    }
    cout<<dp[N][N*A]-1<<endl;
}

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


int main() {
   string s;
   cin >> s;
   int aIndex, zIndex;
   for (int i=0; i<s.size(); i++) {
       if (s.at(i) == 'A') {
           aIndex = i;
           break;
       }
   }
   for (int i=s.size()-1; i>=0; i--) {
       if (s.at(i) == 'Z') {
           zIndex = i;
           break;
       }
   }
   
   cout << zIndex - aIndex + 1 << endl;
}


Measured memory_bytes: 3724
//ProblemD

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

constexpr int MAX_BITS = 20;

//ProblemD
void Solve() {
	int n;
	cin >> n;

	int pre[MAX_BITS]{};
	fillv(pre, -1);


	int left = 0;
	ll ans = 0;

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

		for (int j = 0, mask = 1; j < MAX_BITS; j++, mask <<= 1) {
			if (a & mask) {
				left = max(left, pre[j] + 1);
				pre[j] = i;
			}
		}
		ans += i - left + 1;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	vector<int> c(5);
	char a;
	while(cin >> c[0] >> a >> c[1] >> a >> c[2] >> a >> c[3] >> a >> c[4]){
		bool yaku=false;
		int cnt[5]={0};
		sort(c.begin(),c.end());
		if((c[0]==(c[1]-1) && c[0]==(c[2]-2) && c[0]==(c[3]-3) && c[0]==(c[4]-4)) || (c[0]==1 && c[1]==10 && c[2]==11 && c[3]==12 && c[4]==13)) {cout << "straight" << endl ; continue;} 
		for(int i=0;i<5;++i){
			for(int j=i+1;j<5;++j){
				if(c[i]==c[j] && c[i]!=-1) cnt[i]++, c[j]=-1; 
			}
		}
		for(int i=0;i<5;++i){
			if(cnt[i]==3) {cout << "four card" << endl;yaku=true; break;}
			else if(cnt[i]==2) {
				if(cnt[3]==1) {cout << "full house" << endl; yaku=true;  break;}
				else {cout << "three card" << endl; yaku=true; break;}
			}
			else if(cnt[i]==1) {
				if(cnt[2]==2) {cout << "full house" << endl;yaku=true; break;}
				else if (cnt[i+2]==1|| cnt[i+3]==1) {cout << "two pair" << endl; yaku=true; break;}
				else {cout << "one pair" << endl; yaku=true; break;} 
			}
		}
		if (!yaku) cout << "null" << endl;
	}
	return 0; 
}

Measured memory_bytes: 1208
l_a = list(str(input()))
l_b = list(str(input()))
l_c = list(str(input()))

x = l_a.pop(0)
ans=0
while ans==0:
    if x == "a":
        if len(l_a) != 0: x = l_a.pop(0)
        else:ans = "A"
    if x == "b":
        if len(l_b) != 0: x = l_b.pop(0)
        else:ans = "B"
    if x == "c":
        if len(l_c) != 0: x = l_c.pop(0)
        else:ans = "C"
print(ans)

Measured memory_bytes: 3064
(let ((n (read))
      (a (make-array 200000 :element-type 'integer
                            :initial-element 0
                            :adjustable t))
      (ans 0))
  (loop for i from 1 upto n
    do (setf (aref a i) (read))
       (setf ans (+ ans (abs (- (aref a i) (aref a (- i 1)))))))
  (setf ans (+ ans (abs (aref a n))))
  (loop for i from 1 upto n
        do (let* ((r (- (aref a i) (aref a (- i 1))))
                  (l (- (aref a (1+ i)) (aref a i)))
                  (temp (* r l))
                  (ret (- ans (* 2 (min (abs r) (abs l))))))
             (format t "~a~%" (cond ((= 0 temp) ans)
                                    ((< 0 temp) ans)
                                    (T ret))))))

Measured memory_bytes: 70756
#!/usr/bin/env python3
import sys


def solve(N: int, D: int):
    i, area = 1, (D*2 + 1)

    while N > area:
        area += (D*2 + 1)
        i += 1

    print(i)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define All(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll prim(int n, vector<vector<pll>> &edge)
{
	priority_queue<pll, vector<pll>, greater<pll>> pq;
	vector<bool> used(n, false);
	// 点0からスタート
	pq.push(pll(0, 0));
	ll all_len = 0;
	while (!pq.empty())
	{
		ll now = pq.top().second, len = pq.top().first;
		pq.pop();
		if (used[now])
			continue;
		used[now] = true;
		all_len += len;
		for (int i = 0; i < edge[now].size(); i++)
		{
			ll next_len = edge[now][i].first;
			ll next = edge[now][i].second;
			pq.push(pll(next_len, next));
		}
	}
	return all_len;
}

int main()
{
	int N;
	cin >> N;
	vector<pll> xy, yx;
	map<pll, ll> mp;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		ll x, y;
		cin >> x >> y;
		if(!mp.count(pll(x, y))) {
			mp[pll(x, y)] = cnt;
			xy.push_back(pll(x, y));
			yx.push_back(pll(y, x));
			cnt++;
		}
	}
	sort(All(xy));
	sort(All(yx));

	vector<vector<pll>> edge(cnt);

	for (int i = 0; i < cnt - 1; i++)
	{
		auto now = xy[i];
		int nowp = mp[now];
		
		auto next = xy[i + 1];
		int nexp = mp[next];
		edge[nowp].push_back(pll(min(llabs(now.first - next.first), llabs(now.second - next.second)), nexp));
		edge[nexp].push_back(pll(min(llabs(now.first - next.first), llabs(now.second - next.second)), nowp));
	}
	for (int i = 0; i < cnt - 1; i++)
	{
		auto now = yx[i];
		int nowp = mp[pll(now.second, now.first)];
		
		auto next = yx[i + 1];
		int nexp = mp[pll(next.second, next.first)];
		edge[nowp].push_back(pll(min(llabs(now.first - next.first), llabs(now.second - next.second)), nexp));
		edge[nexp].push_back(pll(min(llabs(now.first - next.first), llabs(now.second - next.second)), nowp));
	}
	cout << prim(cnt, edge) << endl;
}

Measured memory_bytes: 26976
import sys
input = sys.stdin.read

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

res = 0
mi = 10

for a in A:
    x, y = divmod(a, 10)
    if not y:
        res += x
    else:
        res += x + 1
        mi = min(mi, y)
print(res * 10 + mi - 10)


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll lcm(ll a, ll b) {
	return (a*b)/gcd(a,b) ; 
}
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}
void read(vt<ld> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

bool prime(ll t) {
	for(ll i  =2 ; i*i <= t ; ++i) {
		if(t%i==0) 
			return 0 ; 
	}
	return 1 ; 
}

// ==========Start Here==============


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int n ; ll  m ; 
	cin >> n >> m ; 
	vt<ll> a(n) ; 
	for(int i= 0 ; i < n ; ++i)
		cin >> a[i] ; 
	ll l = 1 ; 
	vt<int> tmp(n) ; 
	rep(i,0,n) {
		l = lcm(a[i],l) ; 
		int t = 0 ; 
		ll cpy = a[i] ; 
		while(cpy%2==0) {
			cpy /= 2 ; 
			t++;
		}
		//cout << t << endl ;
		tmp[i] = t ;
	}
	sort(all(tmp)) ; 
	if(tmp[0] != tmp[n-1]) {
		cout << 0 ; 
		return 0 ; 
	}
	//cout << l << endl ; 
	
	ll ans = (2*m)/l ; 
	cout << (ans+1)/2 ; 

 	return 0 ; 
 	
}

Measured memory_bytes: 4524
#include<stdio.h>

int main(void) {
  int i,x,y,tmp;
  for(i=0;;i++) {
    scanf("%d %d\n",&x, &y);
    if(x == 0 && y == 0) break;
    if(x > y ) {
      tmp = x;
      x = y;
      y = tmp;
      printf("%d %d\n",x, y);
    }else {
      printf("%d %d\n",x, y);
    }
  }
  return 0;
}



Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
3枚のカードは1枚に
2枚のカードはどれか1枚を犠牲にして1枚に
すなわち、
・3枚以上あるものは、そこから2を引く
・2枚のもののペアがあれば、1枚ずつ減らせる
・2枚のものが１つだけ残れば、1種類のカードを犠牲に
*/

void solve(){
    int n;
    cin >> n;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    int point = a[0];
    int count=1;
    vector<int> v;
    for(int i=1; i<n; i++){
        if(point!=a[i]){
            point = a[i];
            v.emplace_back(count);
            count=1;
        }
        else{
            count++;
        }
    }
    v.emplace_back(count);
    //cout << v[0] <<" "<< v[1]<<" " << v[2]<<" " << v[3] << endl;
    rep(i,v.size()){
        if(v[i]>=3){
            //偶数で2, 奇数で1
            v[i]=(v[i]+1)%2+1;
        }
    }
    int num2=0;
    rep(i,v.size()){
        if(v[i]==2) num2++;
    }
    cout << v.size()-num2%2 << endl;

}

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



Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>

using namespace std;

string s;
vector<bool> out;

int main(){
	do{
		s.clear();
		do{
			string temp;
			getline(cin,temp);
			s+=temp;
		}while(s[s.length()-1]!='.');
		if (s.length()!=1){
			stack<bool> st;	//(=0,[=1;
			int i=0,l=s.length();
			for (;i<l;i++){
				if (s[i]=='('){
					st.push(0);
				}
				else if (s[i]=='['){
					st.push(1);
				}
				else if (s[i]==')'){
					if (st.empty()){
						out.push_back(false);
						break;
					}
					int type=st.top();
					st.pop();
					if (type!=0){
						out.push_back(false);
						break;
					}
				}
				else if (s[i]==']'){
					if (st.empty()){
						out.push_back(false);
						break;
					}
					int type=st.top();
					st.pop();
					if (type!=1){
						out.push_back(false);
						break;
					}
				}
			}
			if (i==l){
				if (st.empty()){
					out.push_back(true);
				}
				else{
					out.push_back(false);
				}
			}
		}
	}while(s.length()!=1);
	for (int i=0;i<out.size();i++){
		printf("%s\n",out[i] ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 1200
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());

				int line[] = {0,0};
				for (int j=0;j<10;j++) {
					int next = Integer.parseInt(st.nextToken());
					if (next>line[0]&&next>line[1]) {
						line[Switch(next,line[0],line[1])] = next;
					} else if (next>line[0]) {
						line[0] = next;
					} else if (next>line[1]) {
						line[1] = next;
					} else {
						System.out.println("NO");
						break;
					}
					if (j==9) System.out.println("YES");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static int Switch(int ball,int l1,int l2) {
		return (ball-l1)>(ball-l2) ? 1 : 0;
	}
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k, Q, a[101010];
int cnt[101010];
void solve(){
	cin >> n >> k;
	cin >> Q;
	for(int i = 0; i < Q; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for(int i = 1; i <= n; i++){
		if(k > Q-cnt[i]){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1408
from collections import deque
s = input()
sque = deque(s)
q = int(input())
que = [0] * q
flg = False
for i in range(q):
    que[i] = (list(map(str,input().split())))
    if(len(que[i])==3):
        if que[i][1] == '1':
            if flg:
                sque.append(que[i][2])
            else:
                sque.appendleft(que[i][2])
        else:
            if flg:
                sque.appendleft(que[i][2])
            else:
                sque.append(que[i][2])
    else:
        if flg:
            flg = False
        else:
            flg = True
if flg:
    sque.reverse()
    print("".join(list(sque)))
else:
    print("".join(list(sque)))

Measured memory_bytes: 44652