akhauriyash/Code-Regression huggingface dataset:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = a - b

rate = a

if rate >= k:
    
    print(1)
    
elif cnt==0:

    print(-1)
else:
    
    if (k-rate) % cnt == 0:
        
        num = (k-rate) // cnt 
        
        print(1+ num*2)
    
    else:
        
        num = ((k-rate) // cnt) + 1
        
        if num>=1 :
        
            print(num*2+1)
        
        else:
            
            print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <queue>

int odd[100010];
int even[100010];

typedef std::pair<int, int> P;

int main(){
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int v;
        std::cin >> v;
        if(i % 2){
            odd[v]++;
        }else{
            even[v]++;
        }
    }
    int oddMax = 0, evenMax = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P>> pqOdd;
    std::priority_queue<P, std::vector<P>, std::greater<P>> pqEven;
    for(int i = 0; i < 100010; i++){
        pqOdd.push(std::make_pair(odd[i], i));
        pqEven.push(std::make_pair(even[i], i));
        if(i < 2) continue;
        pqOdd.pop();
        pqEven.pop();
    }

    std::pair<int, int> oddSec = pqOdd.top(); pqOdd.pop();
    std::pair<int, int> evenSec = pqEven.top(); pqEven.pop();
    if(pqOdd.top().second == pqEven.top().second){
        oddMax = std::max(oddSec.first, evenSec.first);
        evenMax = pqOdd.top().first;
    }else{
        oddMax = pqOdd.top().first;
        evenMax = pqEven.top().first;
    }
    std::cout << n - oddMax - evenMax << std::endl;

}


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

typedef long long ll;

using namespace std;

void solve()
{
	char a;
	cin>>a;
	
	if(isupper(a))
	{
		cout<<"A";
	}
	else if(islower(a))
	{
		cout<<"a";
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
//	int t;
//	cin>>t;
//	while(t--)
//	{
//		solve();
//	}

	solve();

	return 0;
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) {
        new Main().solve();
    }

    final int infinity = Integer.MAX_VALUE / 256;
    int next(final int n, final int time) {
        if (n == N - 1) return time;
        int lb = 0, ub = infinity;
        Predicate<Integer> f = (Integer x) -> {
            return time <= S[n] + F[n] * x;
        };
        if (f.test(lb)) {
            ub = lb;
        } else {
            while (lb + 1 < ub) {
                int mid = lb + (ub - lb) / 2;
                if (f.test(mid)) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }
        }
        return S[n] + F[n] * ub;
    }

    void calc(int n) {
        if (n == N - 1) {
            System.out.println(0);
            return;
        }
        int t = S[n];
        for (; n < N - 1; n++) {
            t = next(n + 1, t + C[n]);
        }
        System.out.println(t);
    }

    int N;
    int[] S, F, C;
    void solve() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        S = new int[N - 1];
        F = new int[N - 1];
        C = new int[N - 1];
        for (int i = 0; i < N - 1; i++) {
            C[i] = scanner.nextInt();
            S[i] = scanner.nextInt();
            F[i] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            calc(i);
        }
    }
}

Measured memory_bytes: 49276
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  ll ret = 0;
  REP(i,1,N+1){
    if(i%3 == 0 || i%5 == 0) ;
    else {
      ret += i;
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
  cin>>s;
  int start=0,end=0;
  for(int i=0;i<s.length()-1;i++){
    if(s.at(i)=='A'){
      start=i;
      break;
    }
  }
  for(int i=s.length()-1;i>0;--i){
    if(s.at(i)=='Z'){
      end=i;
      break;
    }
  }
  cout<<(end-start)+1<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define MaxN 300+10
using namespace std;
int amount[300+10]={0};
int symbol[300+10]={0};
int queue[300+10][300+10]={0};
int main()
{
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
		for(int k=1;k<=M;k++)
			scanf("%d",&queue[i][k]);
	int mmm=N;
	for(int pp=1;pp<=M;pp++)
	{
		for(int k=1;k<=M;k++)
			amount[k]=0;
		for(int u=1;u<=N;u++)
			for(int r=1;r<=M;r++)
				if(symbol[queue[u][r]]==0)
				{
					amount[queue[u][r]]++;
					break;
				}
		int k=1;
		for(int j=1;j<=M;j++)	
			if(amount[j]>amount[k])
				k=j;
		symbol[k]=1;
		if(amount[k] < mmm)
			mmm=amount[k];
	}
	printf("%d\n",mmm); 
	return 0;
}

Measured memory_bytes: 512
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll ht,st,ha,sa;
    cin>>ht>>st>>ha>>sa;
    bool c=0;
    while(ha>0 || ht>0){
        if(c==0)ha-=st,c=1;
        if(ha<=0){
            cout<<"Yes\n";
            return 0;
        }
        if(c==1)ht-=sa,c=0;
        if(ht<=0){ 
            cout<<"No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s; 
  int cnt=0,i=0;
  cin >> s;
  while(i<s.length()){
    if(s.length()<=1)break;
    if(i+1>=s.length())break;
    if((s[i]=='0'&&s[i+1]=='1')||(s[i]=='1'&&s[i+1]=='0')){
      cnt+=2;
      s.erase(i,2);
      if(i!=0)i--;
      continue;
    }
    i++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    x, y, z = map(int, input().split())
    x, y = x-1, y-1
    edge[x].append(y)
    edge[y].append(x)

visited = [0] * N
def dfs(v):
    if visited[v] == 1:
        return
    visited[v] = 1
    for nv in edge[v]:
        dfs(nv)
ans = 0
for i in range(N):
    if visited[i] == 1:
        continue
    ans += 1
    dfs(i)

print(ans)


Measured memory_bytes: 104620
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int N=200005;
///Code begin..................................................................
inline LL Scan() {
    LL x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int vis[N];

bool comp(int a, int b){return a>b;}
int main ()
{
    int n, k, x;
    scanf("%d%d",&n,&k);
    FOR(i,1,n) scanf("%d",&x), ++vis[x];
    sort(vis+1,vis+N-4,comp);
    int sum=0;
    FOR(i,1,k) sum+=vis[i];
    printf("%d\n",n-sum);
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            var X = Calc(B);
            var A_ = Calc(A - 1);
            WriteLine(X ^ A_);
        }
        static long Calc(long N)
        {
            if (N < 0) return 0;
            var ret = 0L;
            for (long i = 1L << 41; 2 < i; i >>= 1)
            {
                if (0 != (i & N))
                {
                    if (0 != (N - (i - 1)) % 2) ret += i;
                    N -= i;
                }
            }
            if (N == 2) ret += 3;
            if (N == 1) ret += 1;
            return ret;
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27468
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	vector<int>a(10001,0);
	rep1(x, 100) {
		rep1(y, 100) {
			rep1(z, 100) {
				int f = x * x + y * y + z * z + x * y + y * z + z * x;
				if (f <= 10000)a[f]++;
			}
		}
	}
	rep1(i, n+1) {
		println(a[i]);
	}
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[]){
     int x, h;
     
     while(scanf("%d\n%d",&x,&h), (x+h)!=0)
	  printf("%lf\n",x*x+x*sqrt(h*h*4+x*x));

     return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
   
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}


Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun(int arr[],int n)
{
  vector<int>dp(n,0);
  dp[0]=0;
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<n;i++)
    dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i])); 
  return dp[n-1];
}
int main()
{
  int n;
  cin >>n;
  int *arr = new int[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  cout<<fun(arr,n);
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char st;
    char ch[] = {'A','C','G','T'};
    int count = 0;
    int count_max = 0;
    boolean con;
    
    for(int i = 0; i < s.length();i++){
    	st = s.charAt(i);
      	con = true;
      	count++;
      	for(int j = 0; j < 4 && con;j++){
          if(st == ch[j]) con = false;
        }
      	if(con) count = 0;
      	if(count > count_max) count_max = count;
    }
    
    System.out.println(count_max);
  }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  map<int,int> mp;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    mp[x]++;    
  }
  vector<P<int,int>> v;
  for(auto e:mp){
    if(e.second >= 2)v.emplace_back(e);
  }
  sort(v.rbegin(), v.rend());
  ll ans = 0;
  if(v.size() == 0){
    ans = 0;
  } else if(v.size() == 1){
    if(v.front().second >= 4){
      ans = (ll)v.front().first*v.front().first;
    } else {      
      ans = 0;
    }
  } else {
    if(v.front().second >= 4){
      ans = (ll)v.front().first*v.front().first;
    } else {      
      ans = (ll)v[0].first * v[1].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8232
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int i=0;
    string input;
    cin >> input;
    
    while(1){
        
   
        
        if(i % 2 == 0){ //odds
        
            if(input[i] == 'L') {
                cout << "No";
                break;
               
            }
        } else {
            if(input[i] == 'R') {
                cout << "No";
                break;
            
            }
        } 
        ///
        if(input[i] == '\0') {
            cout <<"Yes";
            break;
        }
        
        
        i++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
using namespace std;
 
int main() {
    //input
    int n;
    string str,ans; cin >> str;
    n = str.size();
 
    //compute
    for(int i = 0; i < n; i++){
            if(str.at(i) != 'B'){
                ans = ans + str.at(i);
            }else{
                if(ans.empty()){
                }else{
                    int m;
                    m = ans.size();
                    ans.erase(m - 1);
                }
            }
    }

    //output
    cout << ans << endl;
 
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<int> A(N);
	vector<float> D(N);
	float mid;
	int Sum=0;
	for (i=0;i<N;i++){
		cin>>A[i];
		Sum+=A[i];
	}
	float minD=101;
	int minI=-1;
	mid=(float)Sum/N;
	for (i=0;i<N;i++){
		D[i]=A[i]-mid;
		if (D[i]<0){
			D[i]=-D[i];
		}
		if (minD>D[i]){
			minD=D[i];
		}
	}
	for (i=0;i<N;i++){
		if (D[i]==minD){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
var r,b,g,c:longint;
    s1,s2,s3,s:string;
//procedure mo;
//begin
//        assign(input,fi);
//        reset(input);
//        assign(output,fo);
//        rewrite(output);
//end;

procedure nhap;
begin
        readln(r,b,g);
        str(r,s1);
        str(b,s2);
        str(g,s3);
        s:=s1+s2+s3;
        val(s,c);
        if (c mod 4=0)  then
                writeln('YES')
        else
                writeln('NO');
end;

begin
       // mo;
        nhap;
end.

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    long int a[n+1];
    long int b[n];
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    long int ans = 0;
    rep(i, n){
        if (a[i] >= b[i]) {
            ans += b[i];
        }else{
            ans += a[i];
            b[i] -= a[i];
            if (a[i+1] >= b[i]) {
                a[i+1] -= b[i];
                ans += b[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
                // cout << ans << endl;
            }
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{

    int n, x, temp, sum, bounce;
    int l[110];
    sum = 0;
    bounce = 1;
    cin>>n>>x;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        sum+=temp;
        l[i]=sum;
    }

    for(int i=0;i<n;i++)
    {
        if(l[i] > x)
        {
            break;
        }
        else
        {
            bounce++;
        }
    }

    cout<<bounce;

    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



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

	VLL v(26, 1);
	cin >> s;
	REP(i, n) {
		v[s[i] - 'a']++;
	}

	ll ans = 1;
	REP(i, 26) {
		ans *= v[i];
		ans %= mod;
	}

	ans = ans - 1 + mod;
	ans %= mod;

	cout << ans << endl;

}

Measured memory_bytes: 512
class MyQueue
  def initialize(size)
    @head = @tail = 0
    @size = size
    @q = Array.new(size)
  end

  def empty?
    @head == @tail
  end

  def full?
    @head == (@tail + 1) % @size
  end

  def enqueue(x)
    if full?
      raise "overflow"
    end

    @q[@tail] = x
    if @tail + 1 == @size
      @tail = 0
    else
      @tail += 1
    end
  end

  def dequeue
    raise 'underflow' if empty?

    x = @q[@head]
    if @head + 1 == @size
      @head = 0
    else
      @head += 1
    end

    x
  end
end

class MyProcess
  attr_accessor :name, :time
  def initialize(name, time)
    @name = name
    @time = time
  end

  def proc(proc_time)
    if @time <= proc_time
      rest_time = proc_time - @time
      @time = 0
    else
      @time -= proc_time
      rest_time = 0
    end
    rest_time
  end

  def ended?
    time.zero?
  end
end

n, q = gets().split.map(&:to_i)
que = MyQueue.new(n + 1)
n.times do
  name, time = gets().split
  time = time.to_i
  que.enqueue(MyProcess.new(name, time))
end

total_time = 0
while n > 0 do
  process = que.dequeue
  rest_time = process.proc(q)
  total_time += (q - rest_time)
  if process.ended?
    puts process.name + " " + total_time.to_s
    n -= 1
  else
    que.enqueue(process)
  end
end



Measured memory_bytes: 13296
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int sum = 0;
    for(int i = 0; i <= k; i++){
      for(int j = 0; j <= k; j++){
        if(n - i - j <= k && n - i - j >= 0){
          sum++;
        }
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21588
import collections


n = int(input())
odd = []
even = []
for i,j in enumerate(map(int,input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(collections.Counter(odd).items(),key=lambda x:(x[1]),reverse=True)
even = sorted(collections.Counter(even).items(),key=lambda x:(x[1]),reverse=True)

if len(odd) == 1 and len(even) == 1:
    if odd[0][0] == even[0][0]:
        print(n//2)
        exit()
    else:
        print(0)
        exit()

if odd[0][0] == even[0][0]:
    if len(odd) >= 2 and len(even) >= 2:
        if odd[0][1] + even[1][1] > odd[1][1] + even[0][1]:
            print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
        else:
            print((n//2 - odd[1][1]) + (n//2 - even[0][1]))
    else:
        if len(odd) == 1:
            print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
        else:
            print((n//2 - odd[1][1]) + (n//2 - even[0][1]))
else:
    print((n//2 - odd[0][1]) + (n//2 - even[0][1]))

Measured memory_bytes: 20316
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <utility>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))
#define rson(x) ((x<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);

int main()
{
    int sum,a,b;
    while(scanf("%d%d%d",&sum,&a,&b)!=EOF)
    {
        sum-=a;
        int ans=sum%b;
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;

void showIntArray(string a, int n) {
  for (int i=0; i<n; i++) {
    cout << a[i];
  } cout << endl;
}

int main() {
  int N, K;
  string S;
  cin >> N;
  char target;
  for (int i=0; i<N; i++) {
    cin >> S[i];
  }
  cin >> K;
  target = S[K-1];
  for (int i=0; i<N; i++) {
    if (i == K-1) {
      ;
    }
    else if (S[i] != target) {
      S[i] = '*';
    }
  }
  showIntArray(S, N);
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


#define pb          push_back
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b)    for(ll i=a;i<=b;i++)
#define repr(i, a, b) for(ll i=a;i>=b;i--)
#define pll pair<ll, ll>
#define tp tuple<ll,ll>


template<int D, typename T>
struct vec : public vector<vec<D - 1, T>> {
  static_assert(D >= 1,
                "Vector dimension must be greater than zero!");

  template<typename... Args>
  vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {
  }
};

template<typename T>
struct vec<1, T> : public vector<T> {
  vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

template<typename T>
inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }

template<typename T>
inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }




template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
  os << "(";
  os << v.first << ", "
     << v.second << ")";
  return os;
}

template<typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &v) {

    for (auto it : v)
        os << "[" << it.first << " : "
           << it.second << "]";

    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin())
      os << ", ";
  }
  os << "]\n";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i != v.size() - 1)
      os << ", ";
  }
  os << "]\n";
  return os;
}
struct UnionFind {
  int n;
  V<int> p, r;
  int gn;
  UnionFind(int _n = 0) : n(_n), p(n, -1), r(n, 1), gn(n) {}
  void merge(int a, int b) {
	assert(0 <= a && a < n);
	assert(0 <= b && b < n);
	int x = group(a), y = group(b);
	if (x == y) return;  // same
	gn--;
	if (r[x] < r[y]) swap(x, y);
	p[y] = x;
	r[x] += r[y];
  }
  int group(int a) {
	assert(0 <= a && a < n);
	if (p[a] == -1) return a;
	return p[a] = group(p[a]);
  }
  bool same(int a, int b) {
	assert(0 <= a && a < n);
	assert(0 <= b && b < n);
	return group(a) == group(b);
  }
};
class CConnectCities {
public:
void solve(std::istream& cin, std::ostream& cout) {
  ll n,m,x,y;
  cin>>n>>m;
  UnionFind union_find(n+1);
  rep(__,0,m-1)
  {
    cin>>x>>y;
    union_find.merge(x,y);
  }
  ll cnt=0;
  rep(i,1,n){ cnt+=!union_find.same(i,1);
  	union_find.merge(i,1);
	}
	cout<<cnt;


}
};


int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CConnectCities solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3988
s = list(raw_input())
n = len(s) - 1
for i in range(2**n):
    cmd = s[0]
    for j in range(n):
        if (i & (2**j)):
            cmd += "+"
        else:
            cmd += "-"
        cmd += s[j+1]
    if eval(cmd) == 7:
        print(cmd+"=7")
        break

Measured memory_bytes: 2568
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int x;
    cin>>x;
    int mx=1;
    loop(x,i,2){
        int cur=i*i;
        while(cur<=x){
            max_self(mx,cur);
            cur*=i;
        }
    }
    cout<<mx<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
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 gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------
int N ;
struct BIT {
  private:
   vector<int> bit;
 
  public:
   BIT(int size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(int a, int w) {
     for (int x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(int a) {
     int ret = 0;
     for (int x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
};

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N ;
    int n = N ;
    vint a, b ;
    REP(i,n){
        int c ;
        cin >> c ;
        if(i%2==0){
            a.PB(c) ;
        }
        else{
            b.PB(c) ;
        }
    }
    sort(ALL(a)) ;
    reverse(ALL(a)) ;
    sort(ALL(b)) ;
    reverse(ALL(b)) ;
    vint d ;
    REP(i,n){
        if(i%2==0){
            d.PB(a[SZ(a)-1]) ;
            a.pop_back() ;
        }
        else{
            d.PB(b[SZ(b)-1]) ;
            b.pop_back() ;
        }
    }
    vint f ;
    f = d ;
    sort(ALL(f)) ;
    vint h(n) ;
    REP(i,n){
        auto itr = LB(ALL(f),d[i]) ;
        int g = distance(f.begin(),itr) ;
        h[i] = g ;
    }

    ll ans = 0 ;
    REP(i,n){
        if(i%2!=h[i]%2){
            ans++ ;
        }
    }

    cout << ans/2 <<endl;



    

    return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


void dfs(string s, char ma, li n) {
    if (sz(s) == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= ma + 1; ++c) {
        dfs(s + c, max(ma, c), n);
    }
}

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

    dfs("", 'a' - 1, n);

    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
};
typedef struct node * Node;
Node root, NIL;
int maxh;
Node treeSearch(Node s, int w){
  while( s!= NIL && w!= s->key ){
    if ( w <s->key )s =s->left;
    else s = s->right;
  }
  return s;
}
void insert(int q){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = q;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
void inorder(Node o){
  if ( o == NIL ) return;
  inorder(o->left);
  printf(" %d", o->key);
  inorder(o->right);
}void preorder(Node t){
  if ( t == NIL ) return;
  printf(" %d", t->key);
  preorder(t->left);
  preorder(t->right);
}
int main(){
  int f, i, l;
  char C[20];
  scanf("%d", &f);
  maxh = 0;
  for (i=0;i<f;i++){
    scanf("%s", C);
    if ( C[0] == 'f' ){
      scanf("%d", &l);
      Node t = treeSearch(root, l);
      if (t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if (C[0] == 'i' ){
      scanf("%d", &l);
      insert(l);
    } else if ( C[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




Measured memory_bytes: 20480
import * as fs from 'fs';

export function main(input: string) {
  let [A, B, C, K] = input.split(" ").map(x => parseInt(x))
  
  let result = 0
  if(K <= A) {
    console.log(K);
  } else if(K <= A + B) {
    console.log(A);
  } else {
    console.log(A - (K - A - B));
  }
}

main(fs.readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    double ret = 0;
    rep(i, N) {
        double a;
        string s;
        cin >> a >> s;
        if(s == "JPY") {
            ret += a;
        }
        else {
            ret += 380000 * a;
        }
    }
    output(ret, 10);
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int max = A.at(0);
  long long humidai = 0;
  
  for(int i = 1; i < N; i++){
    if(A.at(i) < max){
      humidai += (max - A.at(i));
    }else{
      max = A.at(i);
    }
  }
  
  cout << humidai << endl;
}


Measured memory_bytes: 3948
N, M = map(int, input().split())
edges = [tuple(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

# UnionFindDataStructure
def find(v):
    if parent[v] == v:
        return v
    else:
        parent[v] = find(parent[v])
        return parent[v]

def union(a, b):
    rootA = find(a)
    rootB = find(b)
    parent[rootB] = rootA


ans = 0
for edge in edges:

    parent = [i for i in range(N)]

    for (a, b) in edges:
        if (a, b) == edge: continue
        union(a, b)

    for v in range(N):
        find(v)

    if len(set(parent)) > 1:
        ans += 1

print(ans)


Measured memory_bytes: 3064
using System;
using System.Linq;
namespace B___Uneven_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int count = 0;
            int[] arr = new int[N];
            for (int i = 0; i < N; i++)
            {
                arr[i] = i + 1;
            }
            count = arr.Count(n => n.ToString().Length % 2 == 1);
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13408
package main

// AtCoder ABC084 D - Like 2017 number - 2nd implementation
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func eratos(n int) (r []bool) {
	if n <= 1 {
		return nil
	}
	r = make([]bool, n+1)
	for i := 2; i <= n; i++ {
		r[i] = true
	}
	for i := 2; i*i <= n; i++ {
		if r[i] {
			for j := i * 2; j <= n; j += i {
				r[j] = false
			}
		}
	}
	return r
}

func main() {
	var q int
	fmt.Scan(&q)
	l := make([]int, q)
	r := make([]int, q)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < q; i++ {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r[i], _ = strconv.Atoi(sc.Text())
	}
	N := 1000000
	pn := eratos(N) // pn[2] == true, pn[4] == false, ...
	cs := make([]int, N+1)
	for i := 1; i < N; i++ {
		t := 0
		if pn[i] && pn[(i+1)/2] { // Like 2017 number?
			t = 1
		}
		cs[i+1] = cs[i] + t
	}
	for i := 0; i < q; i++ {
		fmt.Println(cs[r[i]+1] - cs[l[i]])
	}
}


Measured memory_bytes: 13568
N,M = map(int,input().split())
A = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
for x,y in XY:
    if uf.is_same(x,y): continue
    uf.unite(x,y)
for i in range(N):
    uf.root(i)

c = N - uf.count
if c==1:
    print(0)
    exit()
ex = c-2
if c+ex > N:
    print('Impossible')
    exit()

from collections import defaultdict
d = defaultdict(lambda: [])
for i,a in enumerate(A):
    r = uf.root(i)
    d[r].append(a)

ans = 0
hq = []
for k in d.keys():
    s = sorted(d[k])
    ans += s[0]
    for v in s[1:]:
        hq.append(v)

import heapq
heapq.heapify(hq)
for _ in range(ex):
    v = heapq.heappop(hq)
    ans += v
print(ans)

Measured memory_bytes: 29072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> arr;
    int a,b;
    arr[1]=arr[3]=arr[5]=arr[7]=arr[8]=arr[10]=arr[12]=1;
    arr[4]=arr[6]=arr[9]=arr[11]=2;
    arr[2]=3;
    cin>>a>>b;
    if(arr[a]==arr[b])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int n;
void dfs(int num,int mx,string s)
{
	if(num==n)
	{
		printf("%s\n",s.c_str());
		return;
	}
	int i;
	string t;
	for(i=0;i<=mx+1;i++)
	{
		dfs(num+1,max(mx,i),s+(char)('a'+i));
	}
	return;
}
int main(){
	int i;
	scanf("%d",&n);
	dfs(0,-1,"");
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll x;
	cin >> x;

	x -= 400;
	x /= 200;

	co(8 - x);

	return 0;
}


Measured memory_bytes: 3632
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	private final Scanner sc;
	private final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;
		this.out = out;
		this.err = err;
	}

	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int[] d = new int[N];
		int sum = 0;
		for(int i=0;i<N;i++) {
			d[i] = sc.nextInt();
			sum += d[i];
		}

		long total = 0;
		for(int i=0;i<N;i++) {
			total += (sum - d[i])*d[i];
		}
		out.println(total/2);
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string A,B;
  cin>>A>>B;
  int N=B.size();
  string ans;
  rep(i,0,N){
    ans+=A[i];
    ans+=B[i];
    }
  if(A.size()!=N)
    ans+=A[N];
  cout<<ans;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long double a, b, c;
int main() {
    DAU
    cin >> a >> b >> c;
    if (a + b + 2.0 * sqrt(a * b) < c)
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        a *= b;
        if (a % 2 == 0) System.out.println("Even");
        else System.out.println("Odd");
    }
}


Measured memory_bytes: 21844
def main():
    #print = out.append
    ''' Cook your dish here! '''
    n = get_int()
    li  = get_list()
    full_sm = sum(li)
    sm = 0
    res = full_sm
    for i in li:
        sm += i
        right = full_sm - sm
        res = min(res, abs(sm-right))
    print(res)



''' Coded with love at India by Satyam Kumar '''
import sys
#from collections import defaultdict
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 88400