akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> [(Int,Int,Int,Int)] -> [Bool]
solve t abcds = map solveB abcds

solveB :: (Int,Int,Int,Int) -> Bool
solveB (a,b,c,d) =
  (a >= b) && (d >= b) &&
  (a - g * ((a - (c+1)) `div` g) - b >= 0)
  where g = gcd b d

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> [Bool]
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_t]:remLines1 = remLines0
      t = readBInt bs_t
      abcds = map (\[x1,x2,x3,x4] ->
                     (readBInt x1,readBInt x2,readBInt x3,readBInt x4))
              remLines1
  in solve t abcds

outAnswer :: [Bool] -> IO ()
outAnswer bs = do
  forM_ bs $ \b -> do
    putStrLn (if b then "Yes" else "No")

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 1020
#include <stdio.h>

#define MAX_DATA 50

typedef struct {
    int m;
    int f;
    int r;
} SCORE;

int main(void)
{
    SCORE scores[MAX_DATA] = {};
    int i;
    
    for(i = 0; i < MAX_DATA; i++) {
        scanf("%d %d %d", &scores[i].m, &scores[i].f, &scores[i].r);
        if(scores[i].m == -1 && scores[i].f == -1 && scores[i].r == -1) {
            break;
        }
    }
    
    for(i = 0; ; i++) {
        if(scores[i].m == -1 && scores[i].f == -1 && scores[i].r == -1) {
            break;
        }
        
        int sum = scores[i].m + scores[i].f;
        if(scores[i].m == -1 || scores[i].f == -1) {
            printf("F\n");
        } else if(sum >= 80) {
            printf("A\n");
        } else if(sum >= 65 && sum < 80) {
            printf("B\n");
        } else if(sum >= 50 && sum < 65) {
            printf("C\n");
        } else if(sum >= 30 && sum < 50) {
            if(scores[i].r >= 50) {
                printf("C\n");
            } else {
                printf("D\n");
            }
        } else if(sum < 30) {
            printf("F\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2108
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       long min=2200200200l;
       long ans=0;
       int cnt=0;
       int[] a = new int[(int)N];
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextInt();
           min = Math.min(min, Math.abs(a[i]));
           if(a[i]<0)cnt++;
           ans=ans+Math.abs(a[i]);
       }

       if(cnt%2==1) {
    	   ans=ans-2*min;
       }
       
       System.out.println(ans);
   }
      

}

Measured memory_bytes: 51668
#include <iostream>

int main() {
	int x, i, k;

	std::cin >> x;

	for (i = 1; i <= x; i++) {
		int k = i;
		if (k % 3 == 0) {
			std::cout << " " << i;
			continue;
		}

		if(k){
			if (k % 10 == 3) {
				std::cout << " " << i;
				continue;
			}
		}

		k /= 10;
		if (k % 10 == 3) {
			std::cout << " " << i;
			continue;
		}
		
		k /= 10;
		if (k % 10 == 3) {
			std::cout << " " << i;
			continue;
		}

		k /= 10;
		if (k % 10 == 3) {
			std::cout << " " << i;
			continue;
		}
	}

	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N, M;
    cin >> N >> M;
    vector<pair <ll, ll > > ab;

    for(ll i = 0; i < M; i++){
        ll A, B;
        cin >> A >> B;
        ab.push_back(make_pair(B, A));
    }

    sort(ab.begin(), ab.end());

    ll select = 0;
    ll ans = 1;
    for(ll i = 0; i < M; i++){
        if(!(ab[select].first > ab[i].second)){
            ans++;
            select = i;
        }
    }

    cout << ans << endl;
    

} 

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    ll cnt = 0;
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    for(ll i = 0; i < k; i++) cnt+=a[i];
    cout << cnt << endl;
}


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


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

string s, t, u;
char c;
int a, b, n;

int main() {
    cin >> s >> n;
    for (int i=0; i<n; i++) {
        cin >> t >> a >> b;
        if (t == "print") {
            for (int j=a; j<=b; j++) cout << s[j];
            cout << endl;
        }
        if (t == "replace") {
            cin >> u;
            s.replace(a, b-a+1, u);
        }
        if (t == "reverse") {
            for (int j=0; 2*j<b-a+1; j++) {
                c = s[a+j];
                s[a+j] = s[b-j];
                s[b-j] = c;
            }
        }
    }
}


Measured memory_bytes: 3200
using System;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var max = int.Parse(Console.ReadLine()) + 1;
        var dp = new int[max];
        for (int i = 0; i < max; i++) {
            dp[i] = max;
        }
        dp[0] = 0;
        for (int i = 0; i < max; i++) {
            for (int m_nine = 9; i + m_nine < max; m_nine *= 9) {
                dp[i + m_nine] = Math.Min(dp[i + m_nine], dp[i] + 1);
            }
            for (int m_six = 1; i + m_six < max; m_six *= 6) {
                dp[i + m_six] = Math.Min(dp[i + m_six], dp[i] + 1);
            }
        }
        var answer = dp[^1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27652
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int a[N];
char ch[215];
void wt()
{
	for (int i=1;i<=210;i++) cout<<ch[i];
	cout<<endl;
}
int op(int x,int y)
{
	int tmp=x;
	for (int i=1;i<=y;i++) tmp*=2;
	return tmp;
}
signed main()
{
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=k+1;i<=n;i++)
	{
		if (a[i]>a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 5196
N,K=map(int,input().split())
A=[]
C=[]
for i in range(N):
    a,b=map(int,input().split())
    T=[a,b]
    A.append(T)
A.sort()
counter=0
for i in range(N):
     counter+=A[i][1]
     if counter>=K:
         counter=i
         break   
print(A[counter][0])

Measured memory_bytes: 20104
x, y = map(int, input().split())

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)

MOD = int(1.0e+9 + 7)
N = int(7.0e+5) # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

if((2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0 or
   (2 * y - x) < 0 or (2 * x - y) < 0):
    print(0)
else:
    print(cmb(X + Y, Y, MOD))

Measured memory_bytes: 87700
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=new int[n];
		for(int i = 1;i<=100;i++) {
			for(int j = 1;j<=100;j++) {
				for(int k = 1;k<=100;k++) {
					var p=i*i+j*j+k*k+i*j+i*k+j*k;
					if(p<=n){
						a[p-1]++;
					}
				}
			}
		}
		Console.WriteLine("{0}",String.Join("\n",a));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27760
#include <iostream>
#include <algorithm>

using namespace std;

int main () {
  int n[3];
  cin >> n[0];
  cin >> n[1];
  cin >> n[2];

  sort(n, n+3);

  cout << n[2] * 10 + n[1] + n[0] << endl;

  return 0;
}


Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main() {
	string s;
	cin >> s;
	int n = s.size(),cnt=0;

	rep(i, n-1) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	
}



Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
vector<bool> sieve(int n){
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  repd(i, 2, n+1){
    if(is_prime[i]){
      for(int j = 2*i;j <= n;j += i)is_prime[j] = false;
    }
  }
  return is_prime;
}
///////////////////////////////////////////////////////////

int n,a[110000];int b[110000];
signed main(){
  cin>>n;
  int s,t;
  rep(i,110000)b[i] = -1;
  rep(i,n+1){
    cin>>a[i];
    if(b[a[i]] >= 0){
      s = b[a[i]];
      t = n-i;
    }else{
      b[a[i]] = i;
    }
  }
  if(n == 1){
    cout << 1 << endl << 1 << endl;
    return 0;
  }
  COMinit();
  cout << n << endl;
  repd(k,2,n+2){
    int ans = (COM(n-1, k-2) + COM(n-1,k))%MOD;
    int f = COM(s+t, k-1), m = COM(n-1, k-1);
    ans = (ans + f) % MOD;
    ans = (ans + 2*(m-f+MOD)%MOD)%MOD;
    cout << ans << endl;
  }
}




Measured memory_bytes: 120064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;

//////////////////////////////////////////////////////
int getDigit(long long x){
	int ret = 0;
	while(true){
		if (x == 0) return ret;
		x = x / 10;
		ret++;
	}
}

int main(){
	ll N;
	int ret = -1;
	scanf("%lld",&N);
	
	for (ll A = 1;A*A<=N;A++){
		if (N % A != 0 ) continue;
		ll B = N / A;

		if (ret == -1) ret = max(getDigit(A),getDigit(B));
		ret = min(ret,max(getDigit(A),getDigit(B)));
	}
	
	PRINTD(ret);
	return 0;
}









Measured memory_bytes: 256
from math import floor

A, B = map(int, input().split())
a = set()
b = set()
for i in range(floor(A / 0.08), floor((A + 1) / 0.08) + 1):
    if floor(i * 0.08) == A:
        a.add(i)

for i in range(floor(B / 0.1), floor((B + 1) / 0.1) + 1):
    if floor(i * 0.1) == B:
        b.add(i)

seq = a & b
if seq:
    print(min(seq))
else:
    print(-1)


Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  vll hs(n);
  rep(i, n) cin >> hs[i];

  vector<bool> chk(n, true);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    if (hs[a] <= hs[b]) chk[a] = false;
    if (hs[b] <= hs[a]) chk[b] = false;
  }
  ll ans = 0;
  rep(i, n) if (chk[i]) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    int res = 0;
    rep(i, n){
        rep(j, n){
            chmax(res, abs(a[i] - a[j]));
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> A(n);
	vector <ll> pre(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		pre[i] = A[i];
		if (i > 0)
			pre[i] += pre[i - 1];
	}
	ll ans = INF;
	for (int i = 0; i < n - 1; i++) {
		ans = min(ans, abs(pre[n - 1] - 2 * pre[i]));
	}
	cout << ans;
}


Measured memory_bytes: 2560
N = input()
X = [0]*N
L = [0]*N
for i in range(N):
  X[i], L[i] = map(int, raw_input().split())

XL = [(X[i], L[i]) for i in range(N)]
XL.sort()
for i in range(N):
  X[i], L[i] = XL[i]

ans = N
m = -10**20
for i in range(N):
  if X[i]-L[i]<m:
    ans -= 1
    m = min(m, X[i]+L[i])
  else:
    m = max(m, X[i]+L[i])
print ans


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

int main(){
    string s;
    cin >> s;
    if(s=="SUN")cout << 7;
    if(s=="MON")cout << 6;
    if(s=="TUE")cout << 5;
    if(s=="WED")cout << 4;
    if(s=="THU")cout << 3;
    if(s=="FRI")cout << 2;
    if(s=="SAT")cout << 1;
    cout << endl;
}

Measured memory_bytes: 3628
A,B,M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

m = []
for _ in range(M):
    x,y,c = list(map(int, input().split()))
    m.append([x,y,c])

nedan = min(a)+min(b)
for j in range(M):
    nedan = min(nedan,a[m[j][0]-1]+b[m[j][1]-1]-m[j][2])

print(nedan)




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

using namespace std;

#define vec vector
#define pb push_back
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0; i<(int)(n); i++)
//typedef long long Int;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst) : src(src),dst(dst) {}
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vec<Edge> Edges;
typedef vec<Edges> Graph;

#define MAXMN 500
int B[MAXMN];
int R[MAXMN];

int gcd(int a, int b)
{   
  return b != 0 ? gcd(b, a % b) : a;
}


bool augment(const Graph& g, int u,
	     vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e,g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  return match;
}


int main(int argc, char **argv) {
  int M,N;
  Graph g; g.reserve(MAXMN+MAXMN);
  while(cin>>M>>N,M) {
    g.clear();
    g.resize((M+N)*2);
    REP(i,M) cin>>B[i];
    REP(i,N) cin>>R[i];
    REP(i,M) {
      Edges es, es2;
      REP(j,N) {
	if(gcd(B[i],R[j])!=1) { es.pb(Edge(i,M+j)); es2.pb(Edge(M+j,i)); }
      }
      g[i] = es;
      g[M+i] = es2;
    }
    cout << bipartiteMatching(g,M) << endl;
  }
  return 0;
}

Measured memory_bytes: 3720
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vi in(m);
		rep(i,n){
			int a,b;
			cin>>a>>b;
			in[a-1]=max(in[a-1],b);
		}
		int out=0;
		rep(i,m)out+=in[i];
		cout<<out<<endl;
	}
	}







Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int n;
	cin>>n;
	string s[n];
	int t[n];
	rep(i,n) cin>>s[i]>>t[i];
	string x;
	cin>>x;
	int ans=0;
	bool ok=false;
	rep(i,n){
		if(ok) ans+=t[i];
		else{
			if(s[i]==x) ok=true;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    string s;
    cin >> s;
    REP(i, s.length()) {
        if(i > 4) {
            cout << s[i];
        }else {
            cout << s[i];
            if(i == 3) cout << ' ';
        }
    }
    cout << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		//System.out.println(s3);

		if(1 <= k && k <= a) {
			System.out.println(k);
		} else if(a < k && k <= a + b){
			System.out.println(a);
		} else {
			System.out.println(a - (k - a - b));
		}

		sc.close();

	}

}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int k;  cin >> k;
    string s;   cin >> s;


    if(s.size() <= k)   return cout << s, 0;

    cout << s.substr(0, k) << "...";


}

Measured memory_bytes: 3676
N, M = map(int, input().split())
AB = []
for i in range(M):
    AB.append([int(i) for i in input().split()])
AB.sort()

MinBar = 1
abar = AB[0][0]
bbar = AB[0][1]
for i in range(1, M):
    if AB[i][0] < bbar:
        bbar = min(bbar, AB[i][1])
    else:
        MinBar += 1
        abar = AB[i][0]
        bbar = AB[i][1]
print(MinBar)

Measured memory_bytes: 21648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
using ll = long long;
using ull = unsigned long long;

vector<int> v;
vector<int> c;

int main(){
    int n;
    cin >> n;
    rep(i, n){
        int vn;
        cin >> vn;
        v.pb(vn);
    }

    rep(i, n){
        int cn;
        cin >> cn;
        c.pb(cn);
    }

    int cost = 0;
    rep(i, n){
        if(v[i] > c[i]){
            cost += v[i] - c[i];
        }
    }

    println(cost);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  int n;
  int num[26],tmp[26];
  char str[55];
  int i,j,k,l;

  for(i=0;i<26;i++) num[i]=50;
  scanf("%d%*c",&n);
  while(n--){
    scanf("%s%*c",str);
    l=strlen(str);
    memset(tmp,0,sizeof(tmp));
    for(i=0;i<l;i++) tmp[str[i]-'a']++;
    for(i=0;i<26;i++) if(num[i]>tmp[i]) num[i]=tmp[i];
  }

  for(i=0;i<26;i++){
    while(num[i]--) putchar(i+'a');
  }

  putchar('\n');
  return 0;
}

      



Measured memory_bytes: 128
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))
#for deque append(),pop(),appendleft(),popleft(),count()
I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

a,b=li()
if(a==b):
    print("Yes")
else:
    print("No")


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

int main(){

    char c;
    int flag = 0;

    while(1){
        c = getchar();
        if(c == '9'){
            flag = 1;
        }
        else if(c == '\n'){
            break;
        }
    }

    if(flag == 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

}


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


#define int long long 

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, w1, mx; vector <int> v[4]; cin >> n >> mx;
	for(int i = 1; i <= n; i++) {
		int w, val; cin >> w >> val;
		if(i == 1) {
			w1 = w;
		}
		v[w - w1].push_back(val);
	}
	for(int i = 0; i < 4; i++) {
		sort(v[i].begin(), v[i].end(), greater <int> ());
		for(int j = 1; j < v[i].size(); j++) {
			v[i][j] += v[i][j - 1];
		}
	}
	int ans = 0;
	for(int i = 0; i <= v[0].size(); i++) {
		for(int j = 0; j <= v[1].size(); j++) {
			for(int k = 0; k <= v[2].size(); k++) {
				int t = w1 * i + (w1 + 1) * j + (w1 + 2) * k;
				if(t > mx) continue;
				int l = min((int)v[3].size(), (mx - t) / (w1 + 3));
				ans = max(ans, (i > 0 ? v[0][i - 1] : 0) + (j > 0 ? v[1][j - 1] : 0) + (k > 0 ? v[2][k - 1] : 0) + (l > 0 ? v[3][l - 1] : 0));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
    int N,Y,x,y,z;
    cin>>N>>Y;
    Y/=1000;
    for(x=0;x<=N;x++)for(y=0;y<=N-x;y++)if(10*x+5*y+N-x-y==Y){cout<<x<<" "<<y<<" "<<N-x-y<<endl;return 0;}
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>k>>n;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
ll mx=0;
for(ll i=0;i<n;i++)
{
    ll a=v[i];
    ll b=v[(i+1)%n];
    if(i==n-1)
    {
        mx=max(mx,k-a+b);
        continue;
    }
    mx=max(mx,(ll)abs(b-a));
}
cout<<k-mx<<endl;
return 0;
}


Measured memory_bytes: 2420
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto A = readAs!(int[]);
	auto S = A.sum;
	if(N - S < 0) writeln(-1);
	else writeln(N-S);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	auto s = v;
	sort(s.begin(), s.end());
	int ccnt = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] != s[i])ccnt++;
	}
	if (ccnt == 2 || ccnt == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) sort(v.begin(),v.end())
#define ALL(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int D,G;
int p[15],c[15];
int cnt;
int f[15][1005];

int main()
{
	scanf("%d%d",&D,&G);
	for(int i=1;i<=D;++i)
	   scanf("%d%d",&p[i],&c[i]),cnt+=p[i];
	for(int i=1;i<=D;++i)
		for(int j=0;j<=cnt;++j)
			for(int k=0;k<=p[i]&&k<=j;++k)
				f[i][j]=max(f[i][j],f[i-1][j-k]+k*i + (k==p[i]?c[i]/100:0));
	int ans;
	for(int i=0;i<=cnt;++i)
    {
    	f[D][i]*=100;
    	//cout<<f[D][i]<<endl;
    	ans=i;
    	if(f[D][i] >= G) break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3812
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import defaultdict

    NIL = -1

    n = int(input())

    pre = list(map(int, input().split()))
    in_ = list(map(int, input().split())) # pythonではinは予約語
    post = []

    pos = 0

    def rec(l, r,):
        global pos # posはglobal変数だと明示する
        if l >= r:
            return
        root = pre[pos]
        pos += 1
        m = in_.index(root)
        rec(l, m)
        rec(m+1, r)
        post.append(str(root))

    rec(0, n)
    print(' '.join(post))


Measured memory_bytes: 5996
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

template<typename T>
class UnionFind {
public:
    UnionFind(size_t  size) : data_(size, -1) {}

    bool unite(T x, T y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data_[y] < data_[x]) {
                std::swap(x, y);
            }
            data_[x] += data_[y];
            data_[y] = x;
        }
        return x != y;
    }

    bool isSameGroup(T x, T y) {
        return root(x) == root(y);
    }

    T root(T x) {
        return data_[x] < 0 ? x : data_[x] = root(data_[x]);
    }

    // --
    size_t size(T x) {
        return -data_[root(x)];
    }

private:
    std::vector<T> data_;
};


int main()
{
    int64_t N, W;
    std::cin >> N >> W;


    UnionFind<int64_t> uf(N+W);

    for (size_t i = 0; i < N; ++i) {
        int64_t ki;
        std::cin >> ki;
        for (int64_t j = 0; j < ki; ++j) {
            int64_t l;
            std::cin >> l;
            l--;
            uf.unite(i, l + N);
        }
    }

    for (int64_t i = 1; i < N; ++i) {
        if (!uf.isSameGroup(0, i)) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define sbp(p, n) rep(i, n) { int a, b; scanf("%d %d", &a, &b); p[i] = make_pair(a, b); }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

#define INF 10000000000000000

int main(void)
{
	ll n, x[5];
	cin >> n;
	rep(i, 5) cin >> x[i];
	ll m = INF;
	rep(i, 5) chmin(m, x[i]);
	cout << 4 + (1 + (n - 1) / m) << endl;
	return 0;
}

Measured memory_bytes: 384
fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
fn main() {
    assign! {
        n: i32
    }
    println!("{}", (1000 - n % 1000) % 1000);
}

Measured memory_bytes: 2168
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

li = [a,b,c,d,e]

ans = False
for i in range(5):
    for j in range(i + 1, 5):
        if li[j] - li[i] > k:
            ans = True
            break


if ans:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 9056
#include <iostream>
#include <map>

using namespace std;

int main() {
  string s;
  cin >> s;
  map<char, int> cc;
  for(int i = 0; i < s.size(); ++i) {
    cc[s[i]]++;
  }
  if(cc.size() != 2) {
    cout << "No" << endl;
    return 0;
  }
  for(auto c : cc) {
    if(c.second != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  long n,a[100001],i,k=1;
  scanf("%ld",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%ld",&a[i]);
  }
  for(i=1;i<n;i++)
  {
    if(a[i]<a[i+1])
    {
      k++;
    }
  }
  long c1[k],l1=1,large;
  for(i=1;i<=k;i++)
  {
    c1[i]=0;
  }
  for(i=1;i<n;i++)
  {
    if(a[i]<a[i+1])
    {
      l1++;
    }
    else
    {
      c1[l1]=c1[l1]+1;
    }
  }
  large=c1[1];
  for(i=2;i<=l1;i++)
  {
    if(c1[i]>=large)
    {
      large=c1[i];
    }
  }
  printf("%ld\n",large);
  return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#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(a) a.begin(), a.end()

int main()
{
  int N;
  string S;
  cin >> N >> S;
  int dp[200010][2];
  REP(i, 200010)
  REP(j, 2)
  dp[i][j] = INT32_MAX;
  dp[0][0] = 0, dp[0][1] = 0;
  REP(i, N)
  {
    if (S[i] == '.')
    {
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = 1 + min(dp[i][0], dp[i][1]);
    }
    else
    {
      dp[i + 1][0] = 1 + dp[i][0];
      dp[i + 1][1] = min(dp[i][0], dp[i][1]);
    }
  }
  cout << min(dp[N][0], dp[N][1]) << endl;
  return 0;
}

Measured memory_bytes: 2180
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (_ : m : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  lrs <- sequence . replicate m $ unsafeListToTuple . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    (l, r) = ((,) <$> maximum . fst <*> minimum . snd) . unzip $ lrs
  print $ max 0 (r - l + 1)

unsafeListToTuple :: [Int] -> (Int, Int)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 43388
import java.util.Scanner;

public class Main {

	public static long F(long A, long B) {
		return Math.max(String.valueOf(A).length(), String.valueOf(B).length());
	}

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

		long N = scan.nextLong();
		long B = 0;

		for(long i=(long)Math.sqrt(N); i >=1 ; i--) {
			if(N%i==0) {
				B=N/i;
				System.out.println(F(i, B));
				break;
			}
		}
		scan.close();
	}
}


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

int main(){
  int N;
  cin>>N;
  vector<int> a(N+1);
  for(int i=1;i<=N;++i) cin>>a[i];
  vector<int> b(N+1);
  int cnt=0;

  for(int i=N;i>=1;--i){
    int sum=0;
    for(int j=2;j*i<=N;++j){
      sum +=  b[j*i];
    }
    b[i]=(sum-a[i]+2)%2;
    if(b[i]!=0) ++cnt;
  }
  
  cout<<cnt<<endl;
  for(int i=1;i<=N;++i){
    if(b[i]!=0) cout<<i<<endl;
  }
}

Measured memory_bytes: 2432
n = int(input())
h = [0]+list(map(int,input().split()))
ans,temp = 0,-1
while True:
  for i in range(n+1):
    if temp==0 and h[i]!=0:
      ans += 1
    temp = h[i]
    h[i] = max(h[i]-1,0)
  if all(v==0 for v in h):
    break
print(ans)

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int h, w, c;
int tab[16][16];
bool vis[16][16];
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};
void change(int x, int y, int cf, int ct){
  tab[y][x] = ct;
  REP(i,4){
	int tx = x + dx[i], ty = y + dy[i];
	if(tab[ty][tx] == cf)
	  change(tx, ty, cf, ct);
  }
}

int num(int x, int y){
  if(vis[y][x] || tab[y][x] != c) return 0;
  vis[y][x] = true;
  int res = 1;
  REP(i,4){
	int tx = x + dx[i], ty = y + dy[i];
	res += num(tx,ty);
  }
  return res;
}

int dfs(int idx){
  if(idx == 4){
	if(tab[1][1] != c)
	  change(1,1,tab[1][1],c);
	fill((bool*)vis, (bool*)vis+16*16, false);
	return num(1,1);
  }

  int res = 0;
  int prv[16][16];
  REP(y,h+2) REP(x,w+2) prv[y][x] = tab[y][x];
  for(int i=1;i<=6;++i){
	if(tab[1][1] == i) continue;
	change(1,1,tab[1][1],i);
	res = max(res, dfs(idx+1));

	REP(y,h+2) REP(x,w+2) tab[y][x] = prv[y][x];
  }

  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  while(cin>>h>>w>>c, h){
	fill((int*)tab, (int*)tab+16*16, -1);
	REP(y,h) REP(x,w) cin >> tab[y+1][x+1];
	cout << dfs(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (auto &x : d){
		cin >> x;
	}
	
	sort(d.begin(), d.end());

	int cnt = 0;
	int num1 = d[N / 2 - 1];
	int num2 = d[N / 2];

	cout << num2 - num1 << endl;



	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
pii a[maxn]; 
int n, D, A, sumA;
ll ans;
int main()
{
	scanf("%d", &n);
	scanf("%d%d", &D, &A);
	for(int i = 1; i <= n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
	sort(a + 1, a + n + 1);
	set<pli> S;
	for(int i = 1; i <= n; ++i)
	{
		while(!S.empty() && a[i].first > S.begin()->first)	
		{
			sumA -= S.begin()->second;
			S.erase(S.begin());
		}
		a[i].second -= sumA;
		if(a[i].second <= 0) continue;
		int step = (a[i].second + A - 1) / A;
		ans += step; 
		S.emplace(a[i].first + 2ll * D, step * A);
		sumA += step * A;
	} 
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int x = input.nextInt();
        int a = input.nextInt();

        if (x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}


Measured memory_bytes: 23252
import java.util.*;
public class Main {
	public static void main(String[] args) {
		A();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		for(int i=0;i<3;i++) {
			if(s1.charAt(i)!=s2.charAt(2-i)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
	
}

Measured memory_bytes: 22868
h, w = map(int, input().split())
a = [input() for _ in range(h)]
#print(a)
a = [ai for ai in a if set(ai) != {'.'}] #.がないときにはリストに入れる tf .のみを剥がす
#print(a)
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))] #iとjの反転
#print(a)
#for ai in a:
#    print(ai)
a = [ai for ai in a if set(ai) != {'.'}]
#print(a)
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]
#print(a)
for ai in a:
    print(ai)


Measured memory_bytes: 3064