akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,d;
	cin>>n>>d;
	if(n%(d*2+1)==0)cout<<n/(d*2+1)<<endl;
	else cout<<n/(d*2+1)+1<<endl;

	return 0;

}


Measured memory_bytes: 384
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n, num[10004];
int board[102][102];

int main()
{
	int r, c;
	scanf("%d %d", &r, &c);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
	int at = 0;
	for (int i = 1; i <= r; i++) {
		if (i % 2) {
			for (int j = 1; j <= c; j++) {
				if (!num[at]) at++;
				board[i][j] = at;
				num[at]--;
			}
		}
		else {
			for (int j = c; j >= 1; j--) {
				if (!num[at]) at++;
				board[i][j] = at;
				num[at]--;
			}
		}
	}

	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			if (j > 1) printf(" ");
			printf("%d", board[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 384
n,a,b,c=map(int,input().split())
l=[int(input())for _ in range(n)]
ans=9999999999
def four(n):
  a=""
  while n:a=str(n%4)+a;n//=4
  return a
for i in range(4**n):
  s=four(i).zfill(n)
  anss=0
  aa=bb=cc=0
  coa=cob=coc=0
  for j in range(n):
    if s[j]=="1":aa+=l[j];coa+=1
    if s[j]=="2":bb+=l[j];cob+=1
    if s[j]=="3":cc+=l[j];coc+=1
  if coa==0 or cob==0 or coc==0:anss=999999999;continue
  anss+=(coa+cob+coc-3)*10
  anss+=abs(aa-a)+abs(bb-b)+abs(cc-c)
  ans=min(ans,anss)
print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int h = std.nextInt();
        int w = std.nextInt();
        String[][] table = new String[h][w];
        String[][] update = new String[2 * h][w];
        for (int i = 0; i < h; i++) {
            String line = std.next();
            String[] split = line.split("");
            for (int j = 0; j < w; j++) {
                table[i][j] = split[j];
            }
        }

        int index = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < w; k++) {
                    String s = table[i][k];
                    update[index][k] = s;
                }
                index++;
            }
        }

        Arrays.stream(update).forEach(it -> {
            String line = Arrays.stream(it).collect(Collectors.joining());
            System.out.println(line);
        });
    }
}


Measured memory_bytes: 29012
#include <iostream>

using namespace std;

int black[202020];

int main() {
  char c;
  int N;
  
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> c;
    black[i + 1] = black[i];
    if (c == '#') black[i + 1]++;
  }
  int min = N;
  for (int i = 0; i <= N; ++i) {
    int left_black = black[i];
    int right_white = (N - i) - (black[N] - black[i]);
    int sum = left_black + right_white;
    if (sum < min) min = sum;
  }
  cout << min << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll C;
    cin >> C;
    ll K;
    cin >> K;
    vector<ll> T(N,0);
    for(ll i=0;i<N;i++)cin>>T[i];
    sort(T.begin(), T.end());
    //最終バスの人数、出発時刻
    ll people=1;
    ll bus=T[0];
    ll count=1;
    for(ll i=1;i<N;i++){
        //新しいバス不要
        if(T[i]<=bus+K&&people<C){
            people++;
        }
        else{
            bus=T[i];
            people=1;
            count++;
        }
    }
    print(count)


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 dp[105][305],w[105],v[105],W;
void Solve() {
    read(N);read(W);
    for(int i = 1 ; i <= N ; ++i) {
        read(w[i]);read(v[i]);
    }
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = i ; j >= 1 ; --j) {
            for(int k = w[i] - w[1] ; k <= 3 * N ; ++k) {
                dp[j][k] = max(dp[j][k],dp[j - 1][k - (w[i] - w[1])] + v[i]);
            }
        }
    }
    int64 ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(W < i * w[1]) break;
        ans = max(dp[i][min(W - i * w[1],1LL * 3 * N)],ans);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 512
#include<cstdio>
int main()
{
	int a ,b,c ,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		a=a*b;
		c=c*d;
		if(a>c)
			printf("%d\n",a);
		else
			printf("%d\n",c);
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>

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

    int ans=0;
    for(int i=0; i<n; ++i){
        int j=0;
        while(j+i+1<n && a[i+j]>=a[i+j+1]){
            ++j;
        }
        i+=j;
        ans = max(ans, j);
    }
    cout << ans;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n];
	int odd = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2 == 1) {
			odd++;
		}
	}
	if(odd % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
arr = []

for i in range(N):
  arr.append(i+1)

for j in range(K):
  S = input()
  d1 = input().split()
  for k in range(len(d1)):
    if int(d1[k]) in arr:
      arr.remove(int(d1[k]))

print(len(arr))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//cin>>str;
//cout<<str<<endl;]
  int X, N;
  cin>>X>>N;
  int a[N] = {0};
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int Ns = N -1;
  int Nl = N + 1;
  int issmall = 0;
  int islarge = 0;
  for(int j=0;j<100;j++){
    Ns = X -j;
    Nl = X + j;
    issmall = 0;
    islarge = 0;
    for(int i=0;i<N;i++){
      if(Ns==a[i]){
        issmall = 1;
      }
      if(Nl==a[i]){
        islarge = 1;
      }
      if(issmall==1&&islarge==1){
        break;
      }
    }
    if(issmall==0){
      cout<<Ns;
      return 0;
    }else if(islarge==0){
      cout<<Nl;
      return 0;
    } 
  }
}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

void print(int a[],int s,int e){for(int i=s;i<=e;i++)cout<<a[i]<<" ";cout<<"\n";}
void print(vector<int> &v,int s,int e){for(int i=s;i<=e;i++)cout<<v[i]<<" ";cout<<"\n";}
void print(vector<int> &v){for(int x:v)cout<<x<<" ";cout<<"\n";}

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*b;x%=m;return x;}



int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    string s;
    cin>>s;
    cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<"\n";;

    return 0;
}


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

int main(void){
    // Your code here!
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    if(s[0] == '2' || s[0] == '4' || s[0] == '5' || s[0] == '7' || s[0] == '9'){
        cout << "hon" << endl;
    }
    if(s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8'){
        cout << "pon" << endl;
    }
    if(s[0] == '3'){
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  bool ok = true;
  if(s[0] != '1' || s[n - 1] != '0') ok = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) ok = false;
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  rep2(i, n / 2 + 1, n) s[i] = '0';
  reverse(all(s));
  vector<vl> g(n);
  ll u = 0, v = 0;
  rep2(i, 1, n) {
    v++;
    g[u].push_back(v);
    if(s[i] == '1') u = v;
  }
  set<P> st;
  rep(i, n) for(auto v : g[i])
      st.insert({min(i + 1, v + 1), max(i + 1, v + 1)});
  for(auto p : st) cout << p.first << ' ' << p.second << '\n';
}

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

int main(){
    int n, m, c, count=0;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0; i<m; i++) cin>>b[i];
    int a[m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++) cin>>a[j];
        int s=0;
        for(int j=0; j<m; j++) s+=a[j]*b[j];
        if((s+c)>0) count++;
    }
    cout<<count;
}


Measured memory_bytes: 256
object Main extends App {
  def distSq(p1:(Double,Double), p2:(Double, Double)): Double = {
    math.pow(p1._1 - p2._1, 2) + math.pow(p1._2 - p2._2, 2)
  }

  def getCenterPoint(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double) = {
    def removeSignZero(z: Double) = if (math.abs(z) == 0) 0.0 else z
    val det = (a * e - b * d)
    Seq((c * e - b * f) / det, (a * f - c * d) / det).map(removeSignZero)
  }

  val n = readInt
  (1 to n)
    .map(_ => readLine.split(" ").map(_.toDouble))
    .map { case Array(x1, y1, x2, y2, x3, y3) => {
      val p1 = (x1, y1)
      val p2 = (x2, y2)
      val p3 = (x3, y3)
      val (aSq, bSq, cSq) = (distSq(p1, p2), distSq(p2, p3), distSq(p3, p1))
      val cosA = (bSq + cSq - aSq) / (2 * math.sqrt(bSq * cSq))
      val sinA = math.sqrt(1 - math.pow(cosA, 2))
      val R = math.sqrt(aSq) / (2 * sinA)
      val centers = getCenterPoint(
        2 * x2 - 2 * x1,
        2 * y2 - 2 * y1,
        math.pow(x2, 2) - math.pow(x1, 2) + math.pow(y2, 2) - math.pow(y1, 2),
        2 * x3 - 2 * x2,
        2 * y3 - 2 * y2,
        math.pow(x3, 2) - math.pow(x2, 2) + math.pow(y3, 2) - math.pow(y2, 2)
      )
      Seq(centers(0), centers(1), R).map(d => f"$d%.3f").mkString(" ")
    }}
    .foreach(println)

}



Measured memory_bytes: 44544
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		ll n,k;
		cin>>n>>k;

		vector<ll> price;

		for(ll i=0; i<n; i++) {
			ll x;
			cin>>x;
			price.push_back(x);
		}

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

		ll sum = 0;
		for(ll i=0; i<k; i++) {
			sum = sum + price[i];
		}

		cout<<sum<<endl;
		return 0;
	}


Measured memory_bytes: 3640
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		int count = 0;
		boolean cut = true;
		int inc = 0;
		out: for (int i = 0; i < n; i++) {
			if (cut) {
				if (i == n - 1 || i == n - 2) {
					count++;
					break;
				}
				if (a[i + 1] - a[i] > 0) {
					inc = 1;
					cut = false;
				} else if (a[i + 1] - a[i] < 0){
					inc = -1;
					cut = false;
				} else {
					inc = 0;
				}
			} else {
				switch (inc) {
					case 1:
						if (a[i + 1] - a[i] < 0) {
							count++;
							cut = true;
						} else if (i == n - 2) {
							count++;
							break out;
						}
						break;
					case -1:
						if (a[i + 1] - a[i] > 0) {
							count++;
							cut = true;
						} else if (i == n - 2) {
							count++;
							break out;
						}
						break;
					default:
						if (i == n - 2) {
							count++;
							break out;
						}
						break;
				}
			}
		}
		System.out.println(count);
 	}
}

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

int main()
{
while(true) {
int n, m;
vector<vector<int> > f;
vector<bool> invite;
scanf("%d%d", &n, &m);
if(n == 0)
break;
f.resize(n);
invite.resize(n);
for(int  i= 0; i < m; ++i) {
int a, b;
scanf("%d%d", &a, &b);
a -= 1, b -= 1;
f[a].push_back(b);
f[b].push_back(a);
}
for(int i = 0; i < f[0].size(); ++i) {
int x = f[0][i];
invite[x] = true;
for(int j = 0; j < f[x].size(); ++j) {
int y = f[x][j];
invite[y] = true;
}
}
int ans = 0;
for(int i = 1; i < n; ++i)
ans += invite[i];
printf("%d\n", ans);
}
return 0;
}

Measured memory_bytes: 1200
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, k ;
int  a[N];
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> n >> k;
	rep(i, 1, n) cin >> a[i];
	sort (a + 1, a + 1 + n);
	int  ans = 0;
	rep(i, 1, k) ans += a[i];
	cout  << ans;
	ioi
}


Measured memory_bytes: 3636
#include<set>  
#include<map>  
#include<stack>  
#include<cstdio>  
#include<queue>  
#include<cmath>  
#include<vector>  
#include<climits>  
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 2200000
struct edge{
    int v,w;
    edge(){}
    edge(int V,int W){v=V,w=W;}
};
int n,m;
struct node{
    int u,k;
    node(){}    
    node(int U,int K){u=U,k=K;}
    friend bool operator < (node a,node b){return a.u==b.u?a.k<b.k:a.u<b.u;}
};
struct node1{
    int u,v,k;
    node1(){}   
    node1(int U,int V,int K){u=U,v=V,k=K;}
};
vector<node> Make_zx;
vector<node1> Make_xx;
vector<edge> G[MAXN+5];
int dis[MAXN+5];
bool vis[MAXN+5];
queue<int>Q;
int SPFA(int S,int T){
    memset(vis,0,sizeof(vis));
    memset(dis,0x3f,sizeof(dis));
    dis[S]=0,vis[S]=1,Q.push(S);
    while(!Q.empty()){
        int u=Q.front(),v,w,siz=G[u].size();
        Q.pop();
        vis[u]=0;
        for(int i=0;i<siz;i++){
            v=G[u][i].v,w=G[u][i].w;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    Q.push(v);
                }
            }
        }
    }
    return dis[T]==INF?-1:dis[T]/2;
}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++){
        int p=read()-1,q=read()-1,c=read()-1;
        Make_zx.push_back(node(p,c));
        Make_zx.push_back(node(q,c));
        Make_xx.push_back(node1(p,q,c));
        Make_xx.push_back(node1(q,p,c));
    }
    sort(Make_zx.begin(),Make_zx.end());
    for(int i=0;i<int(Make_zx.size());i++){
        G[n+i].push_back(edge(Make_zx[i].u,1));
        G[Make_zx[i].u].push_back(edge(n+i,1));
    }
    for(int i=0;i<int(Make_xx.size());i++){
        int l1=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].u,Make_xx[i].k))-Make_zx.begin(),
        l2=lower_bound(Make_zx.begin(),Make_zx.end(),node(Make_xx[i].v,Make_xx[i].k))-Make_zx.begin();
        G[l1+n].push_back(edge(l2+n,0));
    }
    printf("%d\n",SPFA(0,n-1));
    return 0;
}

Measured memory_bytes: 95984
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    bool flag = false;
    if(S[2] == S[3] && S[4] == S[5]) flag = true;
    if(flag)
        print("Yes");
    else
        print("No");

    return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict, deque

N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]


def choose2(n):
    return (n * (n - 1)) // 2


counts = Counter(A)
total = 0
for x, count in counts.items():
    total += choose2(count)

for x in A:
    old = choose2(counts[x])
    new = choose2(counts[x] - 1)

    print(total - old + new)


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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(b, a);
    }
    sort(ab.begin(), ab.end());
    ll now_time = 0;
    rep(i, n) {
        now_time += ab[i].second;
        if ( now_time > ab[i].first ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int x;
   cin >> x;
   int a = x / 100;
   cout << "ai1333" << string(a, '3') << endl;

   return 0;
}


Measured memory_bytes: 3160
package main

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

func main() {
	N, S, Q := ReadInt(), ReadString(), ReadInt()
	s := []byte(S)
	trees := make([]SegTree, 26)
	for i := 0; i < 26; i++ {
		trees[i] = MakeSegTree(N)
	}
	for i, c := range []byte(S) {
		t := trees[c-'a']
		t.Update(i, true)
	}
	for q := 0; q < Q; q++ {
		if ReadInt() == 1 {
			i, c := ReadInt()-1, ReadString()
			trees[s[i]-'a'].Update(i, false)
			trees[c[0]-'a'].Update(i, true)
			s[i] = c[0]
		} else {
			l, r := ReadInt()-1, ReadInt()
			cnt := 0
			for i := 0; i < 26; i++ {
				if trees[i].Query(l, r) {
					cnt++
				}
			}
			fmt.Println(cnt)
		}
	}
}

type SegTree []bool

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	t := make([]bool, n*2)
	return t
}

func (t SegTree) Update(i int, x bool) {
	i += len(t) >> 1
	t[i] = x
	for i > 1 {
		i >>= 1
		t[i] = t[i*2] || t[i*2+1]
	}
}

func (t SegTree) Query(a, b int) bool {
	return t.queryRecur(a, b, 1, 0, len(t)>>1)
}

func (t SegTree) queryRecur(a, b, k, l, r int) bool {
	if b <= l || r <= a {
		return false
	}
	if a <= l && r <= b {
		return t[k]
	}
	lv := t.queryRecur(a, b, k*2, l, (l+r)>>1)
	rv := t.queryRecur(a, b, k*2+1, (l+r)>>1, r)
	return lv || rv
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 31064
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    
    int n;
    int[] a;
    long[] ans;
    List<int> list;
    Dictionary<int, int[]> dict;
    
    public void AtCoder(){
        
        n = int.Parse(Console.ReadLine());
        a = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++){
            a[i] = int.Parse(input[i]);
        }
        
        dict = new Dictionary<int, int[]>();
        list = new List<int>();
        for(int i=0; i<n; i++){
            if(dict.ContainsKey(a[i])){
                dict[a[i]][1]++;
            } else {
                dict.Add(a[i], new int[]{i, 1});
                list.Add(a[i]);
            }
        }
        list.Add(0);
        list.Sort((x, y) => y - x);
        int e = n;
        long cum = 0;
        long tmp = 0;
        
        ans = new long[n];
        for(int i=0; i<list.Count - 1; i++){
            e = Math.Min(dict[list[i]][0], e);
            cum += dict[list[i]][1];
            tmp = cum;
            tmp *= list[i] - list[i+1];
            ans[e] += tmp;
        }
        
        for(int i=0; i<n; i++) Console.WriteLine(ans[i]);
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 37444
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
  unsigned short A[MAX],B[MAX];
  int C[VMAX+1];
  int n, i, j;
  unsigned short k;

  scanf("%d", &n);
  
  //A = malloc(sizeof(short)*n+1);
  //B = malloc(sizeof(short)*n+1);
 
  for(i=1; i<=n; i++){
    scanf("%hd",&A[i]);
    if(k < A[i]) k = A[i];
  }
  k++;
  for(i=0; i<=k; i++){
    C[i] = 0;
  }

  for(j=1; j<=n; j++){
    C[A[j]]++;
  }

  for(i=1; i<=k; i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1; i<=n; i++){
    printf("%d",B[i]);
    if(i == n) break;
    printf(" ");
  }
  printf("\n");
 
  return 0;
  
}



Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n; cin >> n;
    vector<int> w(n); 
    int l=0, r=0;
    rep(i, n){ 
        cin >> w[i];
        r+= w[i];
    }
    int ans = 10000000;
    rep(t, n) {
        r -= w[t];
        l += w[t];
        ans = min(ans, abs(r-l));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
for i in range(N):
  if i == 0:
    A[i] = B[i]
  elif i < N-1:
    A[i] = min(B[i],B[i-1])
  elif i == N-1:
    A[i] = B[i-1]
#  print("i:",i,", A[i]:",A[i])
print(sum(A))


Measured memory_bytes: 3060
N,K = map(int,input().split())

import numpy as np
m = np.zeros((3*K,3*K), dtype=np.int32)

offset = 0

for _ in range(N):
  x,y,c = input().split()
  x,y = int(x),int(y)
  x %= 2*K
  y %= 2*K
  if c == 'B':
    m[x,y] += 1
  else:
    m[x,y] -= 1
    offset += 1

K2 = 2*K
m[K2:,:K2] = m[:K,:K2]
np.cumsum(m[:,:K2],axis=0, out=m[:,:K2])
m[:K2,:K2] = m[K:,:K2] - m[:K2,:K2]

m[:K2,K2:] = m[:K2,:K]
np.cumsum(m[:K2,:],axis=1, out=m[:K2,:])
m[:K2,:K2] = m[:K2,K:] - m[:K2,:K2]


m = m[:K2,:K2]
m += np.roll(np.roll(m,K,axis=0),K,axis=1)
print(m.max()+offset)

Measured memory_bytes: 78820
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    string S;
    cin >>S;
    int zeroCount = 0;
    int oneCount = 0;
    for (int i = 0; i < S.length(); ++i) {
        if(S[i] == '0'){
            zeroCount++;
        }else{
            oneCount++;
        }
    }

    int result =2* ( (zeroCount < oneCount)? zeroCount : oneCount );
    cout << result<< endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

string rotate(string str) {
    for (int i = 0; i < str.size(); i++) {
        if ('a' <= str[i] && str[i] < 'z')str[i]++;
        else if (str[i] == 'z')str[i] = 'a';
    }
    return str;
}

int main() {
    string str;
    while(getline(cin, str)) {
        for (int i = 0; i < 26; i++) {
            str = rotate(str);
            /*
            string tmp;
            bool flg = false;
            for (int i = 0; i < str.size(); i++) {
                if (str[i] != '.')tmp += str[i];
            }
            stringstream ss(tmp);
            while(ss >> tmp) {
                if (tmp == "the" || tmp == "this" || tmp == "that")flg = true;
                break;
            }
            if (flg) {
                cout << str << endl;
                break;
            }
            */
            if (str.find("the") != string::npos ||
                str.find("this") != string::npos ||
                str.find("that") != string::npos) {
                cout << str << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1180
while 1:
    H,M,S=list(map(int,input().split()))
    if H<0:break
    t=7200-(3600*H+60*M+S)
    print('{:02d}:{:02d}:{:02d}'.format(t//3600, (t%3600)//60, t%60))
    t *= 3
    print('{:02d}:{:02d}:{:02d}'.format(t//3600, (t%3600)//60, t%60))



Measured memory_bytes: 5608
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

bool isprim[114514];
vector<int> primlist;

void makelist(){
    for(int i = 0;i < 55555;++i){
        isprim[i] = 1;
    }
    
    for(int i = 2;i < 55555;++i){
        if(isprim[i] == 0)
            continue;
        primlist.push_back(i);
        for(int j = i+1;j < 55555;++j){
            if(j % i == 0)
                isprim[j] = 0;
        }
    }
}

int main(){
    makelist();
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0;i < primlist.size();++i){
        if(primlist[i] % 10 == 1){
            count++;
            cout << primlist[i];
            if(count == n){
                cout << endl;
                return 0;
            }
            cout << " ";
        }
    }
}

Measured memory_bytes: 384
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int maxRow(int parents[][3],int dp[][3],bool calculated[][3],int M[][3],int selection,int row){
	if(calculated[row][selection])return dp[row][selection];
	if(row==0){
		calculated[row][selection]=true;
		return dp[row][selection]=M[row][selection];
		
		}
		int max=-1;
		int parent=-1;
		for(int i =0;i<3;i++){
			if(i!=selection){
				if(max<maxRow(parents,dp,calculated,M,i,row-1)+M[row][selection]){
				max=maxRow(parents,dp,calculated,M,i,row-1)+M[row][selection];	
				parent=i;
				}
				
				
			}
		}
		calculated[row][selection]=true;
	
		parents[row][selection]=parent;
		return	dp[row][selection]=max; 
				
	}

int main(int argc, char** argv) {
	int N;
	cin>>N;
   int M[N][3];	
   bool calculated[N][3];
   int dp[N][3];
   int parents[N][3];
   


	for(int i =0;i<N;i++){
		for(int j=0;j<3;j++){
			cin>>M[i][j];
		calculated[i][j]=false;
		parents[i][j]=-1;
		}
	}
	
	//cout<<maxRow(dp,calculated,M,0,N-1)<<endl;	
		int max=-1;
		int head=-1;
		for(int i =0;i<3;i++){
		if(max<maxRow(parents,dp,calculated,M,i,N-1))
		max=maxRow(parents,dp,calculated,M,i,N-1);
		
		}
		/*int row=N-1;
		while(row!=-1){
		
			if(head==0)
			cout<<"A";
			else if(head==1)
			cout<<"B";
			else 
			cout<<"C";
			
			head=parents[row-1][head];
			row--;
		}
	
	*/
	cout<<max<<endl;
	
	return 0;
}

Measured memory_bytes: 14976
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#define INF 100000
using namespace std;

char G[20][20];
int used[20][20];
int ans;

void dfs(int x, int y, int H, int W){
    if (x<0 || x>= W || y<0 || y>= H || G[y][x]== '#') {
        return;
    }
    if (G[y][x]=='.') {
        ans++;
    }
    used[y][x]=0;
    if (used[y-1][x]) dfs(x, y-1, H, W);
    if (used[y+1][x]) dfs(x, y+1, H, W);
    if (used[y][x-1]) dfs(x-1, y, H, W);
    if (used[y][x+1]) dfs(x+1, y, H, W);
    
    return;
}


int main(){
    for (; ;) {
        int H, W;
        cin >> W>> H;
        if (H==0 && W==0) return 0;
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                used[i][j]=1;
                G[i][j]= '#';
            }
        }
        ans = 0;
        int sx=0,sy=0;
        for (int i=0; i<H; i++) {
            for(int j=0; j<W; j++){
                char p;
                cin >> p;
                G[i][j] = p;
                if (p=='@') {
                    sx = j;
                    sy = i;
                    G[i][j]= '.';
                }
            }
        }
        dfs(sx, sy, H, W);
       /* for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                cout << used[i][j]<<"|";
            }
            cout << endl;
        }
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                cout << G[i][j]<<"|";
            }
            cout << endl;
        }*/
        cout << ans<< endl;
    }
}

Measured memory_bytes: 1172
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

		int l = scan.nextInt();
		int k = scan.nextInt();

		//test
//		System.out.println(combination(50, 25));

		long result = 0;
		for(int thick = 0; thick <= 50; thick++){
			if(thick*k > l){
				break;
			}

			for(int thin = 0; thin <= 50; thin++){
				int height = thick*k + thin + (thick + thin - 1);

				if(height <= 0){
					continue;
				}
				if(height > l){
					break;
				}

				result += combination(thick + thin, thick);
			}
		}

		System.out.println(result);
	}

	static long combination(int n, int m){
//		long result = 1;
		BigInteger result = new BigInteger("1");

		int j = m;
		for(int i = 0; i < m; i++){
//			result *= n - i;
			result = result.multiply(BigInteger.valueOf(n - i));
		}

		for(int i = 1; i <= m ; i++){
//			result /= i;
			result = result.divide(BigInteger.valueOf(i));
		}

//		System.out.println(n+"C"+m+" = "+result.longValue());
		return result.longValue();
	}

}



Measured memory_bytes: 32980
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
#define GRID_SIZE 10
struct Grid
{
	Grid() : maxDeep(0){
		FOR(i, 0, GRID_SIZE){
			FOR(j, 0, GRID_SIZE)
				d[i][j] = 0;
		}
		emptyCount = GRID_SIZE*GRID_SIZE;
	}
	void addInk(int i, int j){
		if (i < 0 || GRID_SIZE <= i || j < 0 || GRID_SIZE <= j)
			return;
		if (d[i][j] == 0) --emptyCount;
		++d[i][j];
		if (d[i][j] > maxDeep) maxDeep = d[i][j];
	}
	void dropS(int i, int j){
		addInk(i, j);
		addInk(i - 1, j);
		addInk(i + 1, j);
		addInk(i, j - 1);
		addInk(i, j + 1);
	}
	void dropM(int i, int j){
		dropS(i, j);
		addInk(i - 1, j - 1);
		addInk(i - 1, j + 1);
		addInk(i + 1, j - 1);
		addInk(i + 1, j + 1);
	}
	void dropL(int i, int j){
		dropM(i, j);
		addInk(i, j - 2);
		addInk(i, j + 2);
		addInk(i - 2, j);
		addInk(i + 2, j);
	}
	void drop(int i, int j, int s){
		if (s == 1) dropS(i, j);
		else if (s == 2) dropM(i, j);
		else if (s == 3) dropL(i, j);
	}
	int emptyCount;
	int maxDeep;
	int d[GRID_SIZE][GRID_SIZE];
};
void getValue(string& line, int& i, int& j, int& s){
	string::size_type p1 = line.find(',');
	string::size_type p2 = line.find(',', p1 + 1);
	i = atoi(line.substr(0, p1).c_str());
	j = atoi(line.substr(p1 + 1, p2 - p1 - 1).c_str());
	s = atoi(line.substr(p2 + 1).c_str());
}
int main()
{
	Grid grid;
	string line;
	int i, j, s;
	while (cin >> line){
		getValue(line, i, j, s);
		grid.drop(i, j, s);
	}
	cout << grid.emptyCount << "\n" << grid.maxDeep << "\n";
	return 0;
}

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

using namespace std;
using ll = long long;

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  for(int i=0; i<N; ++i){
    cin >> h[i];
  }

  vector<ll> dp(N);
  vector<ll> costs(K);
  int stop_j = 0;
  for(int i=1; i<N; ++i){
    stop_j = 1;
    for(int j=1; j<=K; ++j){
      if(i-j >= 0){
        costs[j-1] = abs(h[i-j]-h[i]) + dp[i-j];
        stop_j = j;
      }else{
        break;
      }
    }
    dp[i] = *min_element(costs.begin(), costs.begin()+stop_j);
  }
  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define big 1000000007
vector<int> data;
vector<int> memo(200000);
vector<int> done(200000);
ll dp(int n)
{
    if (done[n] == 1)
    {
        return memo[n];
    }
  else{
    ll res;
    if (n==0){
    	return 0;
    }
    if (n == 1)
    {
        res = labs(data[n] - data[n - 1]);
        return res;
    }
	
    else
    {
        res = min(labs(data[n] - data[n - 1]) + dp(n - 1), labs(data[n] - data[n - 2]) + dp(n - 2));
    }
    done[n] = 1;
    memo[n] = res;
    return res;
  }
}
int main()
{
    ll n;
    cin >> n;
    data.resize(n);
    rep(i, n)
    {
        cin >> data[i];
     //  cout << data[i];
    }
   // cout << dp(n - 1); //その場所まで行くのにかかる最小コスト
  cout << dp(n-1);
}

Measured memory_bytes: 4480
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ABC117C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var M = ss.Next(int.Parse);
            var X = ss.Next(int.Parse, M).OrderBy(x => x).ToArray();

            var diffs = new int[M - 1];
            for (var i = 0; i < M - 1; i++) diffs[i] = X[i + 1] - X[i];

            var ans = diffs.OrderByDescending(x => x).Skip(N - 1).Sum();
            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 23520
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Work[] w = new Work[n];
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			w[i] = new Work(a, b);
		}
		if(new Main().solve(n,w)) System.out.println("Yes");
		else System.out.println("No");
		sc.close();

	}
	boolean solve(int n, Work[] w){
		Arrays.sort(w);
		int time = 0;
		for(Work work : w){
			time += work.A;
			if(time > work.B) return false;
		}
		return true;
	}
}

class Work implements Comparable<Work>{
	public int A; //かかる時間
	public int B; //締め切り時刻
	public Work(int A, int B){
		this.A = A;
		this.B = B;
	}
	@Override
	public int compareTo(Work o) {
		//締め切り時刻順にする
		return this.B - o.B;
	}	
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 
#define INF (1LL<<50)
#define MOD 1000000007

bool compareHeight(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.first > b.first;
}

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n),b(n);
	vector<pair<lli,lli>> t(n);

	REP(i,0,n){
		cin>>a[i]>>b[i];
		t[i] = make_pair(a[i]+b[i],i);
	}
	sort(t.begin(),t.end(),compareHeight);

	lli ans=0;
	REP(i,0,n){
		lli index = t[i].second;
		if(i%2==0)ans+=a[index];
		else ans-=b[index];
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
/*
ID: alec3
LANG: C++14
PROG: highcard
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("zerosum.in");
ofstream fout("zerosum.out");
const int MAXN = 100;



int main() {
    //ofstream fout("lightson.out");
    //ifstream fin("lightson.in");
    int n;
    cin >> n;
    string s;
    cin >> s;

    int reds = 0;
    for (int i= 0; i < s.size(); i++){
        if (s[i] == 'R') reds ++;
    }

    int ans = 0;
    for (int i= 0; i < reds; i++){
        if (s[i] == 'W')
            ans ++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    int h[100010];
    for(int i = 1; i <= N; i++){
        cin >> h[i];
    }
    
    int dp[100010];
    dp[0] = 0;
    dp[1] = abs(h[2] - h[1]);
    
    for(int i = 2; i < N; i++){
        dp[i] = min(dp[i-1] + abs(h[i + 1] - h[i]), dp[i-2] + abs(h[i + 1] - h[i - 1]));
    }

    
    cout << dp[N-1] << endl;
    


}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] List = new int [N];
        for(int i=0;i<N;i++) List[i] = sc.nextInt();
        int num = 0;
        for(int i=0;i<N-1;i++){
            int min = List[i];
            int min_num = i;
            boolean check = false;
            for(int j=i+1;j<N;j++){
                if(min > List[j]){
                    min = List[j];
                    min_num = j;
                    check = true;
                }
            }
            List[min_num] = List[i];
            List[i] = min;
            if(check) num++;
        }
        for(int i=0;i<N;i++) {
            System.out.print(List[i]);
            if(i<N-1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(num);
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
	int x;
	int a;
	int b;
	int f;
	int n;
	cin>>x>>a>>b;
	f=fabs(x-a);
	n=fabs(x-b);
	if(f<n){
		cout<<"A";
		cout<<endl;
	}
	else if(f>n){
		cout<<"B";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF 1e9+10;
#define LLINF 1e18+10;

using namespace std;

lint N, W, v[110], w[110], dp[110][10010];

int main(){
    cin >> N >> W;
    rep(i, N){
        cin >> v[i] >> w[i];
    }
    rep(i, N+1){
        rep(j, 10001){
            if(j == 0){
                dp[i][j] = 0;
            }else{
                dp[i][j] = LLINF;
            }
        }
    }
    REP(i, 1, N+1){
        rep(j, 10001){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j >= v[i-1]){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
            }
        }
    }
    lint ans;
    repr(j, 10001){
        if(dp[N][j] <= W){
            ans = j;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int cnt = 0;
    if (n % x == 0) cnt = n / x;
    else cnt = n / x + 1;
    cout << t * cnt << endl;
}


Measured memory_bytes: 3632
import math

N, D = map(int, input().split())
X = []
for i in range(N):
    point = list(map(int, input().split()))
    X.append(point)

ans = 0
for i in range(N):
    for j in range(i+1,N):
        dist = 0
        for d in range(D):
            dist += pow(X[i][d]-X[j][d], 2)
        for k in range(int(4*math.sqrt(1000))+1):
            if k*k == dist:
                ans += 1
                break
                
print(ans)

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

const int MAX_N = 110000;
int N, M;
int A[MAX_N], B[MAX_N];
pair<int, int> itv[MAX_N];

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
    itv[i].first = A[i];
    itv[i].second = B[i];
  }

  sort(itv, itv + N);

  ll sum = 0;

  for (int i = 0; i < N; ++i) {
    if (M - itv[i].second > 0) {
      sum += (ll) itv[i].first * itv[i].second;
      M -= itv[i].second;
    }
    else {
      sum += (ll) M * itv[i].first;
      break;
    }
  }
  cout << sum << endl;
}


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

int main()
{
    std::string r1, r2, r3;
    std::cin >> r1;
    std::cin >> r2;
    std::cin >> r3;

    std::cout << r1[0] << r2[1] << r3[2] << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
 
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (500 * i + 100 * j + 50 * k) == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n)cin >> x[i];
	vector<int> y =x;
	sort(ALL(y));
	map<int,int> m;

	rep(i,n)
	{
		if(i<n/2)m[y[i]]=y[n/2];
		else m[y[i]]=y[n/2-1];
	}

	rep(i,n)
	{
		cout<<m[x[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 12928