akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int translate(char ch){
	switch(ch){
	case 'm':return 1000;
	case 'c':return 100;
	case 'x':return 10;
	case 'i':return 1;
	}
	return -1;	//must not reach here
}

int main(){

	int n,work_l,work_r,pre,result;
	char left[9],right[9];

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %s",left,right);

		pre = -1;
		work_l = work_r = 0;

		for(int k = 0; left[k] != '\0'; k++){
			if(left[k] >= '2' && left[k] <= '9'){
				pre = left[k] - '0';
			}else{
				if(pre != -1){
					work_l += pre*translate(left[k]);
					pre = -1;
				}else{
					work_l += translate(left[k]);
				}
			}
		}

		pre = -1;

		for(int k = 0; right[k] != '\0'; k++){
			if(right[k] >= '2' && right[k] <= '9'){
				pre = right[k] - '0';
			}else{
				if(pre != -1){
					work_r += pre*translate(right[k]);
					pre = -1;
				}else{
					work_r += translate(right[k]);
				}
			}
		}

		result = work_l + work_r;

		if(result/1000 == 0){
			//Do nothing
		}else if(result/1000 == 1){
			printf("m");
		}else{
			printf("%dm",result/1000);
		}
		result %= 1000;

		if(result/100 == 0){
			//Do nothing
		}else if(result/100 == 1){
			printf("c");
		}else{
			printf("%dc",result/100);
		}
		result %= 100;

		if(result/10 == 0){
			//Do nothing
		}else if(result/10 == 1){
			printf("x");
		}else{
			printf("%dx",result/10);
		}
		result %= 10;

		if(result == 1){
			printf("i");
		}else if(result > 1){
			printf("%di",result);
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n,x,t;
           cin>>n>>x>>t;
           cout<<(n+x-1)/x*t<<endl;
}

Measured memory_bytes: 3564
import java.util.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();

    boolean result = A <= 8 && B <= 8 ;
    System.out.println( result ? "Yay!" : ":(");
    
    }
}


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

int main(){
  int k,t;cin >> k >> t;
  vector<int> cake(t);
  for(int i=0; i<t; i++){
    cin >> cake.at(i);
  }
  sort(cake.begin(),cake.end(),greater<int>());
  if(k%2==0){
    if(cake.at(0)<=k/2){cout << 0 << endl;return 0;}
    else {cout << (cake.at(0)-(k/2))*2 -1 << endl; return 0;}
  }else{
    if(cake.at(0)<=k/2+1){cout << 0 << endl;return 0;}
    else{ cout<< (cake.at(0)-(k/2+1))*2 << endl; return 0;}
  }
}

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

int main()
{
  string s, t;

  cin >> s >> t;
  for (int i = 0; i < s.size(); i++)
  {
    cout << s[i];
    if (s.size() == t.size() || i != s.size() - 1)
      cout << t[i];
  }
  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);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long ans = a*c;
        if (ans < (a*d)) {
            ans = a*d;
        }
        if (ans < (b*c)) {
            ans = b*c;
        }
        if (ans < (b*d)) {
            ans = b*d;
        }

        System.out.println(ans);
    }
}


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

using namespace std;


void pl(long long num, int plus[]){
	int k = 0;
	while(num > 0){
		if(num%2 == 0) plus[k] = 0;
		else plus[k] = 1;
		k++;
		num = num / 2;
	}
}

long long num(long long p_num,int s[],int len){
	long long re = 0;
	int p[len]; for(int i = 0; i < len; i++) p[i] = 0;
	pl(p_num,p);
	p[len-1] = 0;
	int j = 0;
	long long a = 0;
	for(int i = 0; i < len; i++){
		a = 10*a+s[i];
		if(p[j] == 1){
			//plus
			re+=a;
			a = 0;
		}
		j++;
	}
	re+=a;
	return re;
}
int main(void)
{
	string ss; cin>>ss;
	int len = ss.size();
	int s[len];
	long long ans = 0;
	for(int i = 0; i < len; i++){
		s[i] = (int)ss[i]-48;
	}
	for(long long i = 0; i<pow(2,len-1); i++){
		ans+=num(i,s,len);
		//cout<<"i = "<<i<<endl;
		//cout<<num(i,s,len)<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int n = 0;
    rep(i, b - a) n += i + 1;
    cout << n - b << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n, m = LI()
a = []
b = []
for _ in range(m):
    ai, bi = LI()
    a.append(ai)
    b.append(bi)

b1 = set(bi for ai, bi in zip(a, b) if ai == 1)
an = set(ai for ai, bi in zip(a, b) if bi == n)

s = b1 & an
ans = 'POSSIBLE' if len(s) > 0 else 'IMPOSSIBLE'
print(ans)


Measured memory_bytes: 32380
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

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




int dp[100005];
int main() {
    int n;
    cin >> n;
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] = INF;
        for (int j = 1;j<=i;j*=6) {
            chmin(dp[i], dp[i-j]+1);
        }
        for (int j = 9; j <= i; j *= 9) {
            chmin(dp[i], dp[i - j] + 1);
        }
    }
   
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  if(s.size() > 2){
    cout << s.at(0) << s.size() - 2 << s.at(s.size()-1);
  }
  else cout << s;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 A, B, C, K;
    cin >> A >> B >> C >> K;
    for (i32 i = 0; i < K; i++) {
        if (A >= B) B *= 2;
        else if (B >= C) C *= 2;
    }
    cout << YN("Yes", "No", A < B && B < C) << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001];
bool vis[100001];
void dfs(ll dp[],vector<ll>g[],bool vis[],ll i)
{
vis[i]=true;
for(ll j=0;j<g[i].size();j++)
{
	if(!vis[g[i][j]])dfs(dp,g,vis,g[i][j]);
	dp[i]=max(dp[i],1+dp[g[i][j]]);
}
}
int main() {
	// your code goes here
	ll n,m,x,y;
	cin>>n>>m;
	vector<ll>g[n+1];
	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
	}
	memset(dp,0,n+1);
	memset(vis,false,n+1);
	for(ll i=1;i<=n;i++)
	{
		if(!vis[i])dfs(dp,g,vis,i);
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)ans=max(ans,dp[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int inf = 2147483646;
const double eps = 1e-7;
typedef long long LL;

int n,t;
int main() {
    cin>>n;
    int k = n/100,m=n%100;
    t=5;
    while (m && k) {
        if(m>=t) {
            m-=t;
            k--;
        }
        else {
            t--;
        }
    }
    if (k == 0 && m>0) cout<<0<<endl;
    else cout<<1<<endl; 
    return 0;
}

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

int a[100007];
int main(){
	int n;
	
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = n-1;i>0;i--){
		if(a[i]<a[i-1]){
			a[i-1]--;
		}
		if(a[i]<a[i-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 640
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9384
n = int(input())
h_list = list(map(int,input().split()))

count = 0
bestcount = count
for i in range(n-1):
    if h_list[i] >= h_list[i+1]:
        count += 1
    else:
        bestcount = max(count,bestcount)
        count= 0
print(max(count,bestcount))

Measured memory_bytes: 63984
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B;
  cin >> A >> B;

  cout << (A - 1) * (B  - 1) << "\n";
  
  return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input!{
        n: usize,
        mut a: [i64; n],
    }


    a.sort();

    let mut tmp = 1f64;

    for &aa in a.iter() {
        tmp *= aa as f64;
        if tmp > 1000000000000000000f64 {
            println!("{}", -1);
            return;
        }
    }

    let mut ans = 1i64;

    for &aa in a.iter() {
        ans *= aa;
    }

    println!("{}", if ans > 1000000000000000000 { -1 } else { ans });
}


Measured memory_bytes: 5076
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vector<bool> prime(10000000+1, true);
	prime[0] = prime[1] = false;
	FOR(i, 2, sqrt(10000000)+1) {
		if(prime[i]) {
			for(int j = i*i; j <= 10000000; j += i) {
				prime[j] = false;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		while(n) {
			if(prime[n] && prime[n-2] && prime[n-6] && prime[n-8]) {
				cout << n << endl;
				break;
			} else {
				n--;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2328
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int E = int.Parse(str[1]);
        long[,] cost = new long[N,N];
        long INF = 1000000000000000;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i != j){
                    cost[i,j] = INF;
                }
            }
        }
        for(int i=0;i<E;i++){
            str = Console.ReadLine().Split(' ');
            int f = int.Parse(str[0]);
            int t = int.Parse(str[1]);
            cost[f,t] = Math.Min(int.Parse(str[2]),cost[f,t]);
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                for(int k=0;k<N;k++){
                    if(cost[j,i] != INF && cost[i,k] != INF){
                        cost[j,k] = Math.Min(cost[j,k],cost[j,i]+cost[i,k]);
                    }
                }
            }
        }
        bool NegativeCycle = false;
        for(int i=0;i<N;i++){
            if(cost[i,i] < 0){
                NegativeCycle = true;
            }
        }
        if(NegativeCycle){
            sb.Append("NEGATIVE CYCLE\n");
        }
        else{
            for(int i=0;i<N;i++){
                for(int j=0;j<N-1;j++){
                    sb.Append(cost[i,j] == INF ? "INF " : (cost[i,j]+" "));
                }
                sb.Append(cost[i,N-1] == INF ? "INF" : (cost[i,N-1]+""));
                sb.Append("\n");
            }
        }
    }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 100000;
int n;
int h[MAX_N];

int main()
{
  cin >> n;
  forn(i,n) cin >> h[i];

  int res = 0, temp = 0;
  for (int i = n-2; i >= 0; i--) {
    if (h[i] >= h[i+1]) {
      temp++;
    } else {
      chmax(res,temp);
      temp = 0;
    }
  }
  chmax(res,temp);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct no{
  no *l,*r;
  int key;
  no(){l=r=NULL;key=-1;};
};
typedef no* node;
string s[2];
node h[2];
int x,p;
int get_num(){
  int res=0;
  while(p<s[x].size()&&isdigit(s[x][p]))res=res*10+(s[x][p++]-'0');
  return res;
}
node make_tree(){
  node po=new no();
  if(s[x][p]=='(')++p,po->l=make_tree();
  if(s[x][p]=='[')p++;
  if(isdigit(s[x][p]))po->key=get_num();
  if(s[x][p]==']')p++;
  if(p<s[x].size()&&s[x][p]=='(')++p,po->r=make_tree();
  p++;
  return po;
}
void ch(node n1,node n2,int p){
  if(p)cout<<'(';
  if(n1->l!=NULL&&n2->l!=NULL)ch(n1->l,n2->l,1);
  if(n1->key>=0&&n2->key>=0)cout<<'['<<n1->key+n2->key<<']';
  if(n1->r!=NULL&&n2->r!=NULL)ch(n1->r,n2->r,1);
  if(p)cout<<')';
}
main(){
  r(i,2)cin>>s[i];
  r(i,2)p=0,x=i,h[i]=make_tree();
  ch(h[0],h[1],0);
  cout<<endl;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  vector<int> co(110,0);
  int a,b,c; cin >> a >> b >> c;
  co[a]++;
  co[b]++;
  co[c]++;
  int ans = 0;
  rep(i,110){
    if(co[i]!=0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int n, m;
string s, t;

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

int main() {
    cin >> s >> t;
    n = s.length();
    m = t.length();
    lint ans = LLONG_MAX;
    for (int i = 0; i <= n - m; i++) {
        lint cand = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) {
                cand++;
            }
        }
        chmin(ans, cand);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
program hihi;
var 
	N, M, i, total, count : integer;
	A : array[1..100] of integer;
begin
	readln(N, M);
    for i:=1 to N do 
    	read(A[i]);
    total:=0;
    for i:=1 to N do 
    	total:= total + A[i];
    count:=0;
    for i:=1 to N do 
    	if A[i]>= total / (4 *M) 
        	then count:= count + 1;
    if count >= M 
    	then writeln('Yes')
        else writeln('No');
end.
        

Measured memory_bytes: 1384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	printf("%d", a - 2 * b > 0 ? a - 2 * b : 0);

	return 0;
}


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


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

  
int main() {
	
	while (1) {
		int n; cin >> n;
		if (n == 0)break;

		int buf; cin >> buf;

		int mi = buf; int ma = buf;

		int sum = buf;
		for (int i = 1; i < n; i++) {
			cin >> buf;
			sum += buf;
			mi = min(mi, buf);
			ma = max(ma, buf);
		}

		cout << (sum-(mi+ma))/(n-2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
use proconio::input;
use superslice::*;

macro_rules! chmax {
    ($max_v: expr, $v: expr) => {
        if $v > $max_v {
            $max_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        a: [i64; n],
        b: [i64; m],
    };
    let ca = std::iter::once(0)
        .chain(a.iter().scan(0, |acc, a_i| {
            *acc += a_i;
            Some(*acc)
        }))
        .collect::<Vec<_>>();
    let cb = std::iter::once(0)
        .chain(b.iter().scan(0, |acc, b_i| {
            *acc += b_i;
            Some(*acc)
        }))
        .collect::<Vec<_>>();

    let mut ans = 0;
    for i in 0..=n {
        let x = k - ca[i];
        if x < 0 {
            continue;
        }
        let j = cb.upper_bound(&x);
        chmax!(ans, i + j - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12700
#include<stdio.h>
#define N 200000
#define NIL -1
typedef struct Node {
  int parent;
  int left;
  int right;
} node;
int n, depth[N], height[N];
node tree[N];
void culDepth(int, int);
void culheight(int);
int getSibiling(int);
void print(int);
int main() {
  int node, i, j, k, left, right, rooti;
  for (i = 0; i < N; i++) {
    tree[i].parent = NIL;
    tree[i].left = NIL;
    tree[i].right = NIL;
  }
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &node, &left, &right);
    tree[node].left = left;
    tree[node].right = right;
    if (left != NIL) {
      tree[left].parent = node;
    }
    if (right != NIL) {
      tree[right].parent = node;
    }
  }
  for (i = 0; i < n; i++) {
    if (tree[i].parent == NIL) {
      rooti = i;
    }
  }
  culDepth(rooti, 0);
  culHeight(rooti);
  for (i = 0; i < n; i++) {
    print(i);
  }
  return 0;
}
void culDepth(int i, int d) {
  depth[i] = d;
  if (tree[i].left != NIL) {
    culDepth(tree[i].left, d + 1);
  }
  if (tree[i].right != NIL) {
    culDepth(tree[i].right, d + 1);
  }
  return;
}
int culHeight(int i) {
  int h1, h2;
  h1 = 0;
  h2 = 0;
  if (tree[i].left != NIL) {
    h1 = culHeight(tree[i].left) + 1;
  }
  if (tree[i].right != NIL) {
    h2 = culHeight(tree[i].right) + 1;
  }
  if (h1 < h2) {
    height[i] = h2;
  } else {
    height[i] = h1;
  }
  return height[i];
}
int getSibiling(int i) {
  int j, k;
  if (tree[i].parent == NIL) {
    return NIL;
  }
  if (tree[tree[i].parent].left != i && tree[tree[i].parent].left != NIL) {
    return  tree[tree[i].parent].left;
  }
  if (tree[tree[i].parent].right != i && tree[tree[i].parent].left != NIL) {
    return tree[tree[i].parent].right;
  }
  return NIL;
}
void print(int i) {
  int deg = 0;
  printf("node %d: parent = %d, sibling = %d, ", i, tree[i].parent, getSibiling(i));
  printf("degree = ");
  if (tree[i].left != NIL) {
    deg++;
  }
  if (tree[i].right != NIL) {
    deg++;
  }
  printf("%d, ", deg);
  printf("depth = %d, height = %d, ", depth[i], height[i]);
  if (tree[i].parent == NIL) {
    printf("root\n");
  } else if (tree[i].left == NIL && tree[i].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
struct good{
    int a,b,c;
};
int main() {
    cs
    int n;cin>>n;
    vector<good> v(n);
    for(auto &i:v) cin>>i.a>>i.b>>i.c;
    Rep(i,n) {
        v[i].a+=max(v[i-1].b,v[i-1].c);
        v[i].b+=max(v[i-1].a,v[i-1].c);
        v[i].c+=max(v[i-1].a,v[i-1].b);
    }
    cout<<max(v[n-1].a,max(v[n-1].b,v[n-1].c));
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    int n, m;
    set<int> s1{1, 3, 5, 7, 8, 10, 12};
    set<int> s2{4, 6, 9, 11};
    
    cin >> n >> m;
    if(s1.count(n) > 0 && s1.count(m) > 0)
        cout << "Yes" << endl;
    else if(s2.count(n) > 0 && s2.count(m) > 0)
        cout << "Yes" << endl;
    else if(n == 2 && m == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
}
  

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


int main(){
  string s; 
  cin >>s;
  if (s=="Sunny") cout << "Cloudy";
  if (s=="Cloudy") cout << "Rainy";
  if (s=="Rainy") cout << "Sunny";


}

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

const int N = 200005;

int n, q;
char s[N];
char t[N], d[N];

int fall(int x) {
  for (int i=0; i<q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') --x;
      else ++x;
    }
    
    if (x < 0) return -1;
    if (x >= n) return 1;
  }
  
  return 0;
}

int main() {
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  
  for (int i=0; i<q; i++) {
    getchar();
    scanf("%c %c", t + i, d + i);
  }
  
  int l = 0, r = n-1;
  int ansL = -1;
  while (l <= r) {
    int mid = l + r >> 1;
  
    if (fall(mid) == -1) {
      ansL = mid;
      l = mid + 1;
    } else r = mid - 1;
  }
  
  int ansR = n;
  l = 0, r = n-1;
  while (l <= r) {
    int mid = l + r >> 1;
    
    if (fall(mid) == 1) {
      ansR = mid;
      r = mid - 1;
    } else l = mid + 1;
  }
  
  printf("%d\n", n - min(n, (ansL+1) + (n-ansR)));
  return 0;
}


Measured memory_bytes: 768
var
	N,i,j,tmp,ans:Longint;
	A:Array[1..50]of Longint;
begin
	read(N);
	for i:=1 to N do begin
		read(A[i]);
		for j:=i-1 downto 1 do begin
			if A[j]>A[j+1]then begin
				tmp:=A[j];
				A[j]:=A[j+1];
				A[j+1]:=tmp;
			end;
		end;
	end;
	for i:=1 to N do begin
		if i mod 2=0 then begin
			A[i]:=(24-A[i])mod 24;
		end;
		for j:=i-1 downto 1 do begin
			if A[j]>A[j+1]then begin
				tmp:=A[j];
				A[j]:=A[j+1];
				A[j+1]:=tmp;
			end;
		end;
	end;
	tmp:=0;
	ans:=24;
	for i:=1 to N do begin
		if ans>A[i]-tmp then ans:=A[i]-tmp;
		tmp:=A[i];
	end;
	writeln(ans);
end.


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define all(v) begin(v),end(v)
#define pb push_back
#define inf (1e9)
#define eps (1e-9)

typedef long long Integer ;
typedef long double Real;
const Real PI = acosl(-1);
typedef pair<int, int> P;

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, set<T> v) {
  os << "(set";
  for (T item: v) os << ' ' << item;
  os << ")";
  return os;
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

//           ^   >  v   <
int dx[] = { -1, 0, 1,  0 };
int dy[] = {  0, 1, 0, -1 };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<bool> vb;

int table[11][331];
int memo[10];

void f(int size, int depth, int sum) {
  if (size + 1 == depth) {
    table[size][sum]++;
  }
  else {
    rep (i, 10) {
      if (memo[i] == 0) {
        memo[i] = 1;
        f(size, depth+1, sum+i*depth);
        memo[i] = 0;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  random_device dev;
  mt19937 rand(dev());

  rep (i, 10) {
    memset(memo, 0, sizeof(memo));
    f(i+1, 1, 0);
  }

  int n,s;
  while (cin >> n >> s) {
    if (s > 330) {
      cout << 0 << endl;
    } else {
      cout << table[n][s] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1252
A,B,M=map(int, input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x = [0] * M
y = [0] * M
c = [0] * M
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())



ans=min(a)+min(b)



for i in range(M):

    if ans>a[x[i]-1]+b[y[i]-1]-c[i]:
        ans=a[x[i]-1]+b[y[i]-1]-c[i]

print(ans)

Measured memory_bytes: 23340
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int min=1000000000;
		int sum=0;
		for(int i=0;i<s.length()-(t.length()-1);i++)
		{
			sum=0;
			for(int j=0;j<t.length();j++)
			{
				if(s.charAt(i+j)!=t.charAt(j)) sum++;
			}
			//System.out.println(sum);
			min=Math.min(min, sum);
			
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 35604
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define Spa putchar(32)
const int maxn=55;
int A[maxn];
LL read()
{
	LL s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(LL x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int opop;
	LL a=read()-1,b=read();
	for(int i=2;i<=50;++i)
	{
		opop=0;
		if(a%(1LL<<i)+1>(1LL<<(i-1)) && ((a+1)&1)) opop^=1;
		if(b%(1LL<<i)+1>(1LL<<(i-1)) && ((b+1)&1)) opop^=1;
		A[i]=opop;
	}
	opop=0;
	if(a%4+1==2||a%4+1==3) opop^=1;
	if(b%4+1==2||b%4+1==3) opop^=1;
	A[1]=opop;
	LL ans=0;
	for(int i=1;i<=50;++i)if(A[i])
	{
		ans|=(1LL<<(i-1));
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,d,x;
  cin >> n >> d >> x;
  int ans = x;
  rep(i,n){
    int a;
    cin >> a;
    ans += (d-1)/a+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 103912
#include <stdio.h>

long int min(long int a, long int b) {
	if (a < b) {
		return a;
	}
	else {
		return b;
	}
}

int main(void) {
	long int n, i, ans;
	long int attack1;
	long int attack2;

	scanf("%d", &n);
	long int a[1000000], b[1000000] = { 0 };
	for (i = 1; i <= n + 1; i++) {
		scanf("%ld", &a[i]);
	}
	for (i = 1; i <= n + 1; i++) {
		scanf("%ld", &b[i]);
	}

	ans = 0;

	//minは小さいほうを返す。同値の時は、bを返す操作

	attack1 = min(a[1], b[1]);
	attack2 = min(a[2], b[1] - attack1);
	ans = ans + (attack1 + attack2);

	for (i = 2; i <= n; i++) {
		attack1 = min(a[i] - attack2, b[i]);
		attack2 = min(a[i + 1], b[i] - attack1);

		ans += (attack1 + attack2);
	}

	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int A,B;
main(){
  cin>>A>>B;
  for(int C=1;C<=3;C++){
    if(A*B*C%2==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REV(i, n) for (int i = (n - 1); i >= 0; --i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
using namespace std;

struct Edge {
  int source;
  int target;
  int cost;
  Edge(int source = 0, int target = 0, int cost = 0)
      : source(source), target(target), cost(cost) {}

  bool operator<(const Edge &e) const { return cost < e.cost; }
};

struct UnionFindTree {
  vector<int> R;
  UnionFindTree(int N) : R(N) {
    for (int i = 0; i < N; ++i) R[i] = i;
  }

  bool same(int s, int t) { return (root(s) == root(t)); }

  int root(int x) {
    if (x == R[x]) return x;
    return R[x] = root(R[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    R[ry] = rx;
  }
};

// Kruskal's Algorithm
int kruskal(int N, vector<Edge> &edges) {
  int totalCost = 0;
  sort(edges.begin(), edges.end());
  UnionFindTree dset(N);

  int s, t;
  for (auto &e : edges) {
    if (!dset.same(e.source, e.target)) {
      totalCost += e.cost;
      dset.unite(e.source, e.target);
    }
  }
  return totalCost;
}

int main() {
  int V, E;
  cin >> V >> E;
  vector<Edge> edges;
  rep(i, E) {
    int s, t, c;
    cin >> s >> t >> c;
    edges.emplace_back(s, t, c);
  }
  cout << kruskal(V, edges) << endl;
}



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

int main(){
  int A,B;
  cin >> A >> B;
  
  int K = (A+B)/2;
  if((A+B)%2 == 0) {
    cout << K << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
    using namespace std;
 
    typedef long long ll;
    typedef long double ld;
 
    typedef pair<int, int> pi;
    typedef pair<ll,ll> pl;

    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<vi> vvi;

 
    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    #define F0R(i, a) for (int i=0; i<(a); i++)
    
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
 
    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
    
    #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
    const int MOD = 1000000007;
    const char nl = '\n';
 
    int main() 
    {
        ios_base::sync_with_stdio(0); cin.tie(0);
        ll n,d;cin>>n>>d;
        ll count=0;
        while(n--)
        {
          ll x,y;cin>>x>>y;

          if((x*x + y*y) <= d*d) count++;
        }

        cout<<count<<nl;
    }


Measured memory_bytes: 3704
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let x: usize = read();
    let l: Vec<usize> = (0..n).map(|_| read()).collect();
    
    let mut ans = 1;
    let mut d = 0;
    for i in 0..n {
        d += l[i];
        if d <= x {
            ans += 1;
        }
    }

    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
//https://juppy.hatenablog.com/entry/2019/10/08/M-SOLUTIONS_%E3%83%97%E3%83%AD%E3%82%B3%E3%83%B3%E3%82%AA%E3%83%BC%E3%83%97%E3%83%B3_-C-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder
const int mod = 1000000007;
struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int n,a,b,c;
mint solve(){
    combination c(2*n);
    mint ans=0;
    rep(i,n){
        mint pk1=c(n+i-1,i)*(mint(a)/(a+b)).pow(n)*(mint(b)/(a+b)).pow(i);
        mint pk2=c(n+i-1,i)*(mint(b)/(a+b)).pow(n)*(mint(a)/(a+b)).pow(i);
        ans+=(pk1+pk2)*(n+i)*100/(a+b);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>a>>b>>c;
    cout<<solve().x<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	ll a, b, q;
	cin >> a >> b >> q;
	
	vector<ll> s(a);
	vector<ll> t(b);
	
	for(ll i=0; i < a; i++) cin >> s[i];
	for(ll i=0; i < b; i++) cin >> t[i];
	
	for(ll i=0; i < q; i++) {
		ll start;
		cin >> start;
		
		ll dist = numeric_limits<ll>::max();
		auto s_it = lower_bound(s.begin(), s.end(), start);
		auto t_it = lower_bound(t.begin(), t.end(), start);
		
		for(auto S = s_it-1; S <= s_it; S++) {
			for(auto T = t_it-1; T <= t_it; T++) {
				if(S == s.end() || S < s.begin()) continue;
				if(T == t.end() || T < t.begin()) continue;
				
				dist = min(dist, abs(start - *S) + abs(*S - *T));
				dist = min(dist, abs(start - *T) + abs(*T - *S));
			}
		}
		
		cout << dist << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2944
#akash mandal: jalpaiguri government engineering college
import sys,math

def ii(): return int(input())
def mii(): return map(int,input().split())
def lmii(): return list(mii())


def main():
    A,B,C=mii()
    print("Yes" if B*C>=A else "No")
                
                
            
        
            
    
        
if __name__=="__main__":
    main() 

Measured memory_bytes: 62124
import sys


blood_types = { 'A': 0, 'B': 0, 'AB': 0, 'O': 0 }

for line in sys.stdin:
    num, blood_type = line.rstrip('\n').split(',')
    blood_types[blood_type] += 1
for type in ['A', 'B', 'AB', 'O']:
    print blood_types[type]

Measured memory_bytes: 4216
n,m= map(int,input().split())
rg = [[999999999 for _ in range(n)] for _ in range(n)]
rgflg = [[False for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b,c= map(int,input().split())
    rg[a-1][b-1] = c
    rgflg[a-1][b-1] = True
    rg[b-1][a-1] = c
    rgflg[b-1][a-1] = True
count=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            if rg[i][j] > rg[i][k] + rg[k][j]:
                rg[i][j] = rg[i][k] + rg[k][j]
                if rgflg[i][j]==True or rgflg[j][i]==True:
                    rgflg[i][j]=False
                    rgflg[j][i]=False
                    count+=1
print(count)

Measured memory_bytes: 3440
n = int(input())

a_list = [int(i) for i in input().split()]
q = int(input())

ary = [0 for _ in range((10**5) + 1)]

for i in a_list:
    ary[i] += 1

ans = []

f_ans = sum(a_list)
for _ in range(q):
    b, c = map(int, input().split())
    f_ans += (c-b)*ary[b]
    ary[c] += ary[b]
    ary[b] = 0

    ans.append(f_ans)

for a in ans:
    print(a)


Measured memory_bytes: 20496
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
        //Xを軸としてK-1を左右に表示させる
		int Zahyou = K-1;
		for(int i=X-Zahyou; i<=X+Zahyou; i++) {
			System.out.print(i+" ");
		}

	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define itn int
#define int lint
#define rep(i, n) for (int i = 0; i < (n); i++)
#define prep(i, n) for (int i = 0; i < (n); ++i)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back
int ax[90001];
int ay[90001];
int memo[90001]={};
int h,w,d;
signed main(){
    cin>>h>>w>>d;
    rep(i,h){
        rep(j,w){
            int a;
            cin>>a;
            ax[a]=i,ay[a]=j;
        }
    }
    for(int i=d+1;i<=90000;i++){
        memo[i]=memo[i-d]+abs(ax[i]-ax[i-d])+abs(ay[i]-ay[i-d]);
    }
    int q;
    cin>>q;
    prep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<memo[r]-memo[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
// Problem : A - ABCxxx
// Contest : AtCoder - AtCoder Beginner Contest 068
// URL : https://atcoder.jp/contests/abc068/tasks/abc068_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
string s;cin>>s;
cout<<"ABC"+s;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))

using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

ll dp[100001][13];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
   // freopen("B.txt", "r", stdin);
    #endif
    string s;
    cin >> s;
    int n = s.length();
    dp[0][0]=1;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<13; j++)
        {
            if(s[i]=='?')
            {
                for(int d=0; d<10; d++)
                    dp[i+1][(j*10+d)%13]=(dp[i][j]+dp[i+1][(j*10+d)%13])%mod;
            }
            else
            {
                dp[i+1][(j*10+s[i]-'0')%13]=(dp[i][j]+dp[i+1][(j*10+s[i]-'0')%13])%mod;
            }
        }
    }
    cout << dp[n][5];
}


Measured memory_bytes: 10604
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

string Sorting_String(string s) {
    char[] str;
    for (int i = 0; i < s.length; i++)
        str ~= s[i];
    for (int i = 0; i < str.length; i++)
        for (int j = i + 1; j < str.length; j++) {
            if (str[i] > str[j]) {
                auto tmp = str[i];
                str[i] = str[j];
                str[j] = tmp;
            }
        }
    
    return to!string(str);
}

int Change_To_Int(string s) {
    int res = 0;
    for (int i = 1; i < s.length; i++)
        res += ((to!int(s[i]) - 48) * ((10 ^^ i) / 10));
    
    return res;
}

int Reverse_To_Int(string s) {
    char[] str;
    str ~= " ";
    for (int i = 1; i < s.length; i++)
        str ~= s[s.length - i];
    int res = Change_To_Int(to!string(str));
    
    return res;
}

int main()
{
    int N;
    N = readln().chomp().to!int();
    
    for (int i = 0; i < N; i++) {
        string s = readln();
        auto str = Sorting_String(s);
        int num1 = Change_To_Int(str);
        int num2 = Reverse_To_Int(str);
        int ans = num1 - num2;
        writeln(ans);
    }

    return 0;
}

Measured memory_bytes: 1052