akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int N = ni();
    	int A = ni();
    	int[] x = nia(N);

    	long[][][] dp = new long[N+1][N+1][50*N+1];
    	dp[0][0][0] = 1;

    	for (int i=1; i<=N; i++) {
    		for (int j=0; j<=i; j++) {
    			for (int k=0; k<=50*N; k++) {
    				if (j != 0 && k + x[i-1] <= 50*N) {
    					dp[i][j][k+x[i-1]] += dp[i-1][j-1][k];
    				}
    				dp[i][j][k] += dp[i-1][j][k];
    			}
    		}
    	}

    	long sum = 0;
    	for (int i=1; i<=N; i++) {
    		sum += dp[N][i][i*A];
    	}
    	out.println(sum);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 60356
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    long long int n,i,j,res = 0,temp;
    cin >> n;
    long long int a[n];
    for(i = 0;i<n;i++) {
        cin >> a[i];
        if(i>0){
            temp = a[i] - a[i-1];
            if(temp < 0) {
                res += (-1 * temp);
                a[i] += (-1*temp);
            }
        }
    }
        cout << res << endl;
    return 0;
}

Measured memory_bytes: 5180
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.10lf\n",  sqrt(d));
}

Measured memory_bytes: 128
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll dp[100010] = {};
ll N,M;
ll ans[100010] = {};

void dfs(ll cur, ll par){
    dp[cur] = 1;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur);
        dp[cur] *= dp[e];
        dp[cur] %= M;
    }
    dp[cur]++;
}

vector<ll> mul_left[100010], mul_right[100010];
vector<ll> mul[100010];

void dfs2(ll cur, ll par){
    ans[cur] = (dp[cur] - 1 + M) % M;
    ll cc = 1;
    mul_left[cur].push_back(cc);
    for(auto &e: mul[cur]){
        (cc *= dp[e]) %= M;
        mul_left[cur].push_back(cc);
    }
    cc = 1;
    mul_right[cur].push_back(cc);
    reverse(mul[cur].begin(), mul[cur].end());
    for(auto &e: mul[cur]){
        (cc *= dp[e]) %= M;
        mul_right[cur].push_back(cc);
    }
    reverse(mul[cur].begin(), mul[cur].end());

    for(auto &e: tree[cur]){
        if(e == par) continue;
        ll ps = lower_bound(mul[cur].begin(), mul[cur].end(), e) - mul[cur].begin();
        ll sz = mul[cur].size();
        ll val = mul_left[cur][ps] * mul_right[cur][sz - ps - 1] % M;
        // print(cur, val, ps, e, mul_left[cur][ps]);
        ll prev_cur = dp[cur];
        ll prev_e = dp[e];
        dp[cur] = val + 1;
        dp[cur] %= M;
        dp[e] = (dp[e] - 1 + M) * dp[cur] % M + 1;
        dp[e] %= M;
        // dp[cur] = val + 1;
        // dp[cur] %= M;
        dfs2(e, cur);
        dp[cur] = prev_cur;
        dp[e] = prev_e;
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    ll x[100010], y[100010];
    
    rep(i,0,N-1){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        tree[x[i]].push_back(y[i]);
        tree[y[i]].push_back(x[i]);
    }
    dfs(0, -1);

    rep(i,0,N){
        for(auto &e: tree[i]){
            mul[i].push_back(e);
        }
        sort(mul[i].begin(), mul[i].end());
    }

    dfs2(0, -1);
    rep(i,0,N) print(ans[i]);
}

Measured memory_bytes: 36992
import os
import sys

import numpy as np
import bisect

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

N, K = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

AB.sort()
A, B = list(zip(*AB))
B = np.array(B).cumsum()

print(A[bisect.bisect_left(B, K)])


Measured memory_bytes: 45232
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root, *NIL;

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[8],in[]="insert",pri[]="print";

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,in)==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,pri)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24048
while True:
    m, f, r = list(map(int, input().split()))
    if m == -1 & f == -1 & r == -1:
        break
    else:
        total = m + f
        if m == -1 or f == -1:
            print("F")
        elif total >= 80:
            print("A")
        elif total >= 65:
            print("B")
        elif total >= 50:
            print("C")
        elif total >= 30:
            if r >= 50:
                print("C")
            else:
                print("D")
        elif total < 30:
            print("F")


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

using namespace std;

int main(){
    int N;
    long long K;
    while(cin >> N >> K){
        vector<int> a(N);
        vector<vector<int>> A(200001);
        for(int i=0;i<N;i++){
            cin >> a[i];
            A[a[i]].push_back(i);
        }
        vector<int> next(N);
        for(auto& v : A){
            const int n = v.size();
            for(int i=0;i<n;i++){
                next[v[i]] = (v[(i+1)%n]+1)%N;
            }
        }
        int cycle = 0;
        int cur = 0;
        while(true){
            if(next[cur] <= cur+1) ++cycle;
            if(cur == N-1 && next[cur] == 0) ++cycle;
            cur = next[cur];
            if(cur == 0) break;
        }
        K %= cycle;
        cycle = 0;
        vector<int> res;
        if(K > 0){
            while(true){
                if(next[cur] <= cur+1){
                    if(cycle+1 == K){
                        if(cur != N-1 && next[cur] == 0) break;
                        res.push_back(a[cur]);
                        ++cur;
                        if(cur == N) break;
                        continue;
                    }
                    ++cycle;
                }
                cur = next[cur];
            }
        }
        if(!res.empty()) cout << res[0];
        for(int i=1;i<res.size();i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 14968
n,m=map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
l = sorted(l,key=lambda x:x[0])
cnt=0
i=0
ans=0
while cnt < m:
    if l[i][1] + cnt > m:
        ans+=l[i][0]*(m-cnt)
        break
    ans+=l[i][1]*l[i][0]
    cnt+=l[i][1]
    i+=1
print(ans)

Measured memory_bytes: 29792
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll n;
  cin>>n;
  ll a[n];
  lop(i,n) cin>>a[i];
  sort (a,a+n);
  ll ans=0,cnt=n-1;
  lopr(i,n)
  {
     if(i==n-1) {ans+=a[i];cnt--;}
     else {ans+=(min(2LL,cnt)*a[i]);cnt-=2;}
     if(cnt<=0) break;
  }
  cout<<ans<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll dp1[100][5]; //小さい
ll dp2[100][5]; //ぴったり

int ctoi(char c){
	return c - '0';
}

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

	if (s[0] == '0'){
		dp2[0][0] = 1;
	}else{ 
		dp1[0][0] = 1;
		dp1[0][1] = ctoi(s[0]) - 1;
		dp2[0][1] = 1;
	}

	for (int i = 1; i < s.length(); i++){
		for (int j = 0; j <= k; j++){
			dp1[i][j] += dp1[i-1][j];
			dp1[i][j+1] += dp1[i-1][j]*9;
			if (s[i] == '0'){
				dp2[i][j] = dp2[i-1][j];
			}else{
				dp1[i][j] += dp2[i-1][j];
				dp1[i][j+1] += dp2[i-1][j]*(ctoi(s[i])-1);
				dp2[i][j+1] = dp2[i-1][j];
			}
		}
	}

	cout << dp1[s.length()-1][k] + dp2[s.length()-1][k] << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
city = {}
for i in ab:
  for j in i:
    if j not in city:
      city[j] = 1
    else:
      city[j] += 1
for number in range(1, n+1):
  if number in city:
    print(city[number])
  else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    int t;
    FOR(i,1,n+1){
        int temp=0;
        t=i;
        REP(j,to_string(i).length()){
            //int t=i;
            temp+=t%10;
            t=t/10;
        }
        if(temp >= a && temp <= b)ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    int64_t m = 0,res=0,tmp;
    for(int i=1; i<n+1; i++){
        tmp = i;
        for(int j=0; j<100; j++){
            if(tmp%2==1){
                m = m>j?m:j;
                res = m>j?res:i;
                break;
            }
            tmp/=2;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int ll
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    string s; cin >> s;
    string t = "";
    rep(i, s.size()) {
        if(s[i] == 'A') t += "A";
        else if(i < s.size() - 1 && s.substr(i, 2) == "BC"){ 
            t += "D";
            i ++;
        } else t += s[i];
    }
    int n = t.size();
    ll ans = 0, cnt = 0;
    reverse(all(t));
    //cout << t << endl;
    for(auto& c : t) {
        if(c == 'A') {
            ans += cnt;
        } else if(c == 'D') {
            cnt ++;
        } else cnt = 0;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main()
{
	
    int x;
    cin>>x;
    int p=x,s=0;
    while(p>0)
    {
    	s+=p%10;
    	p/=10;
	}
	if(x%s==0)
	{
		cout<<"Yes";
		return 0;
	}
	else
	{
		cout<<"No";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int K;
    cin >> K;

    string S;
    cin >> S;

    for (int i = 0; i < min(K, (int)S.size()); ++i)
    {
        cout << S[i];
    }
    if (S.size() > K) cout << "...";

    return 0;
}


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

using namespace std;

int main(){
    int N, K, Q; cin >> N >> K >> Q; int A,  P[N];
    for (int i = 1; i <= N; i++)             P[i]  = K;
    for (int i = 0; i <  Q; i++) cin >> A, ++P[A];
    for (int i = 1; i <= N; i++)             P[i] -= Q;
    for (int i = 1; i <= N; i++) (P[i] > 0) ? (cout << "Yes" << endl) : (cout << "No"  << endl);

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 100;
int match[N];
bool vis[N];
vector<vector<int> > g;
bool findPath(int u) {
	vis[u] = true;
	for (auto v : g[u]) {
		if (match[v] == -1 || !vis[match[v]] && findPath(match[v])) {
			match[v] = u;
			return true;
		}
	}
	return false;
}
int maxMatch() {
	memset(match, -1, sizeof(match));
	int res = 0;
	for (int i = 0; i < g.size(); ++i) {
		memset(vis, 0, sizeof(vis));
		if (findPath(i))
			++res;
	}
	return res;
}
int main()
{
	int n;
	cin >> n;
	vector<pair<int, int> > A(n);
	vector<pair<int, int> > B(n);
	for (int i = 0; i < n; ++i)
		cin >> A[i].first >> A[i].second;
	for (int i = 0; i < n; ++i)
		cin >> B[i].first >> B[i].second;
	g.resize(n);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (A[i].first < B[j].first && A[i].second < B[j].second)
				g[i].push_back(j);
	printf("%d\n", maxMatch());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

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

int main(){
    int n,y;
    cin>>n>>y;
    int a=-1;
    int b=-1;
    int c=-1;

  
    rep(i,2000){
        rep(j,2000){
                if(10000*i+5000*j+1000*(n-i-j)==y && n-i-j>=0){
                    a=i;
                    b=j;
                    c=n-a-b;
                    break;
                }
            }
            if(a!=-1 && b!=-1)break;
        }
    cout<<a<<' '<<b<<' '<<c;
    return 0;
    }


Measured memory_bytes: 3644
a,b,c,d=map(int,input().split())
if a*c>a*d:
    if b*c>b*d:
        if a*c>b*c:
            print(a*c)
        else:
            print(b*c)
    else:
        if a*c>b*d:
            print(a*c)
        else:
            print(b*d)
else:
    if b*c>b*d:
        if a*d>b*c:
            print(a*d)
        else:
            print(b*c)
    else:
        if a*d>b*d:
            print(a*d)
        else:
            print(b*d)

Measured memory_bytes: 9232
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func inputIntSlice(size int) []int {
	slice := make([]int, size)
	for i := range slice {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	r, g, b, n := nextInt(), nextInt(), nextInt(), nextInt()
	ans := 0
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			if n >= (r*i+g*j) && (n-(r*i+g*j))%b == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
N, M = map(int, input().split())
drink = []
for _ in range(N):
    A, B = map(int, input().split())
    drink.append([A, B])

drink = sorted(drink)
money = 0
for a, b in drink:
    if b > M:
        money += a * M
        M = 0
    else:
        money += a * b
        M -= b
print(money)

Measured memory_bytes: 20832
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  loop(i,1,10)loop(j,1,10)cout<<i<<"x"<<j<<"="<<i*j<<endl;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<int, int>
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int a, p; cin >> a >> p;
	cout << ( a * 3 + p ) / 2 << endl;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int solve(int n, int k) {
    if (n == 1) return 0;
    return (solve(n-1, k) + k) % n;
}

int main() {
    int n, m, k;
    while (cin >> n >> k >> m, n) {
        cout << (solve(n-1, k) + m) % n + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3384
fn main() {
    proconio::input! {
        s: proconio::marker::Bytes,
    }
    let n=s.len();
    let f=|j: usize, k: usize| {
        for i in 0..k-j {
            if s[i+j]!=s[k-i-1] {
                return false;
            }
        }
        true
    };
    println!("{}",if f(0,n) && f(0,(n-1)/2) && f((n+3)/2-1,n) {"Yes"} else {"No"});
}

Measured memory_bytes: 2160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

ll N, A, B;
vector<ll> X;
vector<ll> D;
int main(void) {
    cin >> N >> A >> B;
    X = vector<ll>(N);
    for (ll i = 0; i < N; i++) {
        cin >> X[i];
    }

    if (A >= B) {
        cout << B * (N - 1) << endl;
        return 0;
    }

    D = vector<ll>(N);
    D[0] = 0;
    for (ll i = 1; i < N; i++) {
        D[i] = min((X[i] - X[i - 1]) * A, B);
    }

    ll ans = 0;
    for (auto d : D) {
        ans += d;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
import numpy as np

n = int(input())
sum = 0
arr = []
for i in range(n):
    arr.append(int(input()))
sum = np.sum(arr)



flag = False
arr.sort()
sub = sum
for i in range(n):
    if arr[i] % 10 != 0:
        sub = arr[i]
        break

if sum % 10 != 0:
    print(sum)
else:
    print(sum-sub)


Measured memory_bytes: 12500
#include <stdio.h>

int main(){

    int X = 0;
    int Y = 0;
    int sum = 0;
    
    scanf("%d %d", &X, &Y);

    if (X == 1){
        sum = sum + 300000;
    } else if (X == 2) {
        sum = sum + 200000;
    } else if (X == 3) {
        sum = sum + 100000;
    } 
    if (Y == 1){
        sum = sum + 300000;
    } else if (Y == 2) {
        sum = sum + 200000;
    } else if (Y == 3) {
        sum = sum + 100000;
    } 
    if (X == 1 && Y == 1){
        sum = sum + 400000;
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class12
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = x.OrderBy(y => y).ToArray();
            int point = (a[N / 2] + a[N / 2 - 1]) / 2;

            for(int i = 0; i < N; i++)
            {
                if (x[i] <= point)
                    Console.WriteLine(a[N / 2]);
                else
                    Console.WriteLine(a[N / 2-1]);
            }
        }
    }
}


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

class SuffixArray {
  int N;
  std::string str;
  std::vector<int> rank;
  std::vector<int> sa;
  std::vector<int> lcp;
  struct Comp {
    int N;
    int k;
    std::vector<int>* rank;
    bool operator()(int i, int j){
      if((*rank)[i] != (*rank)[j]) return (*rank)[i] < (*rank)[j];
      int ri = (i+k <= N ? (*rank)[i+k] : -1);
      int rj = (j+k <= N ? (*rank)[j+k] : -1);
      return ri < rj;
    }
  };
public:
  SuffixArray(std::string str):str(str),N(str.length()),sa(N+1),rank(N+1),lcp(N+1){}
  //O(N log^2 N)
  void build_sa(){
    std::vector<int> tmp(N+1);
    for(int i=0; i<=N; i++){
      sa[i] = i;
      rank[i] = (i < N ? str[i] : -1);
    }
    Comp comp;
    comp.N = N;
    comp.rank = &rank;
    for(int k=1; k<=N; k*=2){
      comp.k = k;
      std::sort(sa.begin(), sa.end(), comp);
      tmp[sa[0]] = 0;
      for(int i=1; i<=N; i++){
        tmp[sa[i]] = tmp[sa[i-1]] + (comp(sa[i-1], sa[i]) ? 1 : 0);
      }
      for(int i=0; i<=N; i++){
        rank[i] = tmp[i];
      }
    }
  }
  std::vector<int> get_sa(){
    return sa;
  }
  //O(N)
  void build_lcp(){
    for(int i=0; i<=N; i++) rank[sa[i]] = i;
    int h = 0;
    lcp[0] = 0;
    for(int i=0; i<N; i++){
      int j = sa[rank[i]-1];
      if(h>0) h--;
      for(; j+h<N && i+h<N; h++){
        if(str[j+h] != str[i+h]) break;
      }
      lcp[rank[i]-1] = h;
    }
  }
  std::vector<int> get_lcp(){
    return lcp;
  }
  //O(|T|+|S|)
  bool contain(const std::string& query){
    int a=0, b=N;
    while(b-a>1){
      int c=(a+b)/2;
      if(str.compare(sa[c], query.length(), query) < 0) a = c;
      else b = c;
    }
    return str.compare(sa[b], query.length(), query) == 0;
  }
};


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

  SuffixArray sa(S);
  sa.build_sa();
  sa.build_lcp();
  vector<int> satable = sa.get_sa();
  vector<int> lcptable = sa.get_lcp();

  int ret = 0;
  REP(i,1,satable.size()-1){
    int mx = lcptable[i];
    REP(j,i+1,satable.size()){
      int x = satable[i];
      int y = satable[j];
      int cmnl = lcptable[j-1];
      if(mx > cmnl) break;
      
      //cout << S.substr(satable[i]) << " " << S.substr(satable[j]) << " " << x << " " << y << " " << cmnl << endl;
      if(x+mx<=y || y+mx<=x){
        ret = max(ret, mx);
      }
    }
  }

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


Measured memory_bytes: 512
n = int(input())
nums = sorted([int(i) for i in input().split()])
# n = 3
# nums = [1, 1, 3]

median = nums[n//2]
mean = sum(nums) // n

ans = 10 ** 10
for diff in range(min(median, mean), max(median, mean)+2):
    diff_sum = 0
    for num in nums:
        diff_sum += (num - diff) ** 2
    ans = min(ans, diff_sum)

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++){
        if(i%2==0){
            a/=2;
            b+=a;
        }else{
            b/=2;
            a+=b;
        }
    }
    cout<<a<<' '<<b<<endl;
    return 0;
}

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

public class Main {
    // TODO solve
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        final int r = scanner.nextInt();

        final int[] toVisit = new int[r];
        for (int i = 0; i < r; i++) {
            toVisit[i] = scanner.nextInt() - 1;
        }

        final int[][] graph = new int[n][n];
        for (int i = 0; i < graph.length; i++) {
            Arrays.fill(graph[i], Integer.MAX_VALUE / 2);
            graph[i][i] = 0;
        }

        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt() - 1;
            final int b = scanner.nextInt() - 1;
            final int c = scanner.nextInt();

            graph[a][b] = c;
            graph[b][a] = c;
        }

        warshallFloyd(graph);

        for (int i = 0; i < toVisit.length; i++) {
            final boolean[] isVisited = new boolean[r];
            isVisited[i] = true;
            permutation(toVisit, isVisited, toVisit[i], graph, 1, 0);
        }
        System.out.println(answer);
    }

    static int answer = Integer.MAX_VALUE;

    private static void permutation(final int[] toVisit, final boolean[] isVisited, final int current, final int[][] graph, final int index, final int sum) {
        if (index == isVisited.length) {
            answer = Math.min(answer, sum);
            return;
        }

        for (int i = 0; i < isVisited.length; i++) {
            if (isVisited[i]) {
                continue;
            }

            isVisited[i] = true;
            permutation(toVisit, isVisited, toVisit[i], graph, index + 1, sum + graph[current][toVisit[i]]);
            isVisited[i] = false;
        }
    }

    private static void warshallFloyd(final int[][] graph) {
        for (int k = 0; k < graph.length; k++) {
            for (int i = 0; i < graph.length; i++) {
                for (int j = 0; j < graph.length; j++) {
                    graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]);
                }
            }
        }
    }
}


Measured memory_bytes: 48620
import math


n, a, b = map(int, input().split())
MOD = 10**9 + 7

sum = pow(2, n, MOD) - 1

num_1 = 1
num_2 = 1

for i in range(1, a+1):
    num_1 = num_1 * (n-a+i) % MOD

for j in range(1, b+1):
    num_2 = num_2 * (n-b+j) % MOD

gyakugen_a = pow(math.factorial(a), MOD-2, MOD)
gyakugen_b = pow(math.factorial(b), MOD-2, MOD)

num_1 *= gyakugen_a
num_2 *= gyakugen_b

print((sum - num_1 - num_2)%MOD)




Measured memory_bytes: 5444
#include<stdio.h>
#define N 25
#define NIL -1
 
struct Node {
  int parent;
  int left;
  int right;
};
struct Node T[N];
int cnt,x,y;
 
int depth(int nodeid) {
 
 if(T[nodeid].parent == NIL) {
    return 0;
  }
 else {
      cnt++;
      depth(T[nodeid].parent);
    }
 return  cnt;  
}
 
int height(int nodeid) {
  int x=0,y=0;
  if(T[nodeid].left != NIL)
    x = height(T[nodeid].left) + 1;
   
  if(T[nodeid].right != NIL)
    y = height(T[nodeid].right) + 1;
   
  if(x < y) return y;
   
  else return x; 
   
}
 
int sibling(int nodeid) {
  if(T[nodeid].parent == NIL)
    return NIL;
 
 else  if(T[T[nodeid].parent].left == nodeid)
    return T[T[nodeid].parent].right;
 
 else return T[T[nodeid].parent].left;
 
}        
 
int degree(int nodeid) {
  if(T[nodeid].left == NIL && T[nodeid].right == NIL)
    return 0;
  else if(T[nodeid].left != NIL && T[nodeid].right != NIL)
    return 2;
  else return 1;
}
 
int main(void) {
   
  int i,j,n,m,l,newnode,left,right;
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++)
    T[i].parent = T[i].left = T[i].right = NIL; 
   
  for(i=0;i<n;i++) {
    scanf("%d%d%d",&newnode,&m,&l);
 
    T[m].parent = newnode;
    T[l].parent = newnode;  
    T[newnode].left = m;    
    T[newnode].right = l;  
  
  }   
    for(i=0;i<n;i++) { 
      cnt = 0;
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,T[i].parent,sibling(i),degree(i),depth(i),height(i));
       
      if(T[i].parent == NIL) {
    printf(" root\n");
      }
      else if (T[i].left == NIL && T[i].right == NIL) {
    printf(" leaf\n");
      }  
      else  {
    printf(" internal node\n");
      }   
    }
    return 0;    
 
}  

Measured memory_bytes: 612
n, m = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
mod = 1000000007
xtot = 0
ytot = 0
for i in range(n):
	xtot += (2*i-n+1)*x[i]
	xtot %= mod
for i in range(m):
	ytot += (2*i-m+1)*y[i]
	ytot %= mod
print(int((xtot*ytot)%mod))

Measured memory_bytes: 19580
## atcoder problem 5 ever

try:
    import sys, r_std
    sys.stdin = open('inp.txt')
except:
    pass

MOD = 10**9 + 7
def solve(A, n, k):
    ## get comb dic
    dic = {}
    if k>n:
        return 0
    for i in range(k-2):
        dic[i] = 0

    dic[k-2] = 1
    for i in range(k-1, n-1):
        dic[i] = (dic[i-1] * i * pow(i-k+2, MOD-2, MOD)) % MOD

    cumm = {}
    cumm[0] = dic[0]
    for i in range(1,n-1):
        cumm[i] = cumm[i-1] + dic[i]

    ans = 0
    A.sort()
    for i in range(1, n+1):
        mul = cumm.get(i-2, 0) - cumm.get(n-i-1, 0)
        #print(mul, mul*A[i-1])
        ans = (ans + A[i-1]*mul) %MOD

    print(ans)
n, k = map(int, input().split())
arr = list(map(int, input().split()))

solve(arr, n, k)


Measured memory_bytes: 35656
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn search(ABCD: &Vec<(usize, usize, i64, i64)>, N: usize, mi: i64, mx: i64, A: &mut Vec<i64>) -> i64 {
    if A.len() == N {
        let mut ret: i64 = 0;
        for &(a, b, c, d) in ABCD {
            if A[b] - A[a] == c {
                ret += d;
            }
        }
        return ret;
    }

    let mut ret: i64 = 0;

    for a in mi..mx {
        A.push(a);
        ret = max(ret, search(ABCD, N, max(a, mi), mx, A));
        A.pop();
    }
    return ret;
}

fn main() {
    input! {
        N: usize,
        M: i64,
        Q: usize,
        ABCD: [(Usize1, Usize1, i64, i64); Q],
    }

    let mut A = vec![];
    println!("{}", search(&ABCD, N, 1, M + 1, &mut A));
}


Measured memory_bytes: 2152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    ll X;
    cin >> N >> X;
    vector<ll> AL(N + 1), PA(N + 1);
    AL[0] = PA[0] = 1;
    REP(i, 0, N) {
        AL[i + 1] = 2 * AL[i] + 3;
        PA[i + 1] = 2 * PA[i] + 1;
    }
    function<ll(int, ll)> rec = [&](int n, ll x) {
        if (n == 0) {
            return 1LL;
        }
        if (x == 1) {
            return 0LL;
        }
        if (x <= AL[n - 1] + 2) {
            return rec(n - 1, x - 1) + (x == AL[n - 1] + 2);
        }
        return rec(n - 1, x - AL[n - 1] - 2) + PA[n - 1] + 1;
    };

    cout << rec(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL dp[101010][4];
int a[101010], b[101010], c[101010];

int main(){
    INIT;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i] >> b[i] >> c[i];
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(void)
{
    int n;
    float a;
    scanf("%d",&n);
    if(n%2==0) printf("%.6f",1/2.0);
    else printf("%.6f",(n+1)/2.0/n);
    return 0;
}





Measured memory_bytes: 760
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int n; string s; CI n >> s;
	int white = 0, black = 0,ans=1000000;
	string tmp = s;
	int ans2 = 0, ans3 = 0;

	REP(i, n) {
		if (s[i] == '.')white++;
	}

	REP(i, n) {
		if (s[i] == '#')black++;
		if (s[i] == '.')white--;
		ans = min(ans, black + white);
	}

	for (int i = n - 1; i > 0; i--) {
		if (s[i] == '.' and s[i - 1] == '#') {
			ans3++;
			s[i - 1] = '.';
		}
	}
	s = tmp;
	REP(i, n) {
		if (s[i] == '#' and s[i + 1] == '.') {
			ans2++;
			s[i + 1] = '#';
		}
	}

	CO min(ans, min(ans2,ans3)) EN;

	return 0;
}


Measured memory_bytes: 772
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <functional>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::map< long int,std::vector<long int>, std::greater<long int> > jobs;
    long int A,B;
    for(int i=0; i<N; ++i){
        std::cin >> A >> B;
        if(jobs.find(B)==jobs.end()){
            jobs[B] = std::vector<long int>{A};
            continue;
        }
        jobs[B].emplace_back(A);
    }

    std::priority_queue<long int> queue;
    auto jobsIter = jobs.begin();
    long int t = (*jobsIter).first;
    for(auto A : (*jobsIter).second){
        queue.push(A);
    }
    ++jobsIter;
    while(!queue.empty()){
        t -= queue.top();
        queue.pop();
        if(jobsIter != jobs.end()){
            while((*jobsIter).first>=t && jobsIter != jobs.end()){
                for(auto A : (*jobsIter).second){
                    queue.push(A);
                }
                ++jobsIter;
            }
            if(queue.empty()){
                t = (*jobsIter).first;
                for(auto A : (*jobsIter).second){
                    queue.push(A);
                }
                ++jobsIter;
            }
        }
    }
    if(t>=0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 23540
#include<iostream>
#include<algorithm>
using namespace std;
int main(int argc,char *argv[]){
int n,m,x,y;
while(cin >> n >> m >> x >> y){
int i;
int a[110],b[110];
for(i = 0;i < n;i++){
cin >> a[i];
}
for(i = 0;i<m;i++){
cin >> b[i];
}
sort(a,a+n);
sort(b,b+m);

int flag = 0;
if(x < y){
for(i = x + 1;i<y;i++){
if(i <= b[0]&&i>a[n - 1]){
flag =1;
}
}
}
else{
for(i = y + 1;i<=x;i++){
if(i <=a[0]&&i>b[n - 1]){
flag=1;
}
}
}
if(flag){
cout << "No War"<< endl;
}
else{
cout << "War" << endl;
}
}
return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2 * 1000 * 100 + 47;
LL A[MAX];
LL B[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    int n; 
    cin >> n;
    FOR(i, 0, n) {
        cin >> A[i] >> B[i];
    }

    sort(A, A + n);
    sort(B, B + n);
    LL res = -1;
    if (n % 2) {
        res = B[n / 2] - A[n / 2] + 1;
    }
    else {
        res = (B[n / 2 - 1] + B[n / 2]) - (A[n / 2 - 1] + A[n / 2]) + 1;
    }

    cout << res << endl;
}

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

int main() {
  int A, B, i, x = 0;
  cin >> A >> B;
  i = A;
 
  while(i <= B) {
    int a, b, c, d, e;
    a = i / 10000;
    b = i % 10000 / 1000;
    c = i % 1000 / 100;
    d = i % 100 / 10;
    e = i % 10;
    
    if(a == e && b == d){
      x += 1;
    }
    i++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
ll k,a,b;
vector<int> l,r;
vector<P> pa;
int main() {
	cin>>k>>a>>b;
	if(b-a<=2)cout<<k+1<<endl;
	else{
		if(a>k)cout<<k+1<<endl;
		else {
			ll ans=a+((k-a+1)/2)*(b-a);
			if((k-a+1)%2==1)++ans;
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=0, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a>>m>>b;
  /*ll ar[n];
  rep(i,0,n){ cin>>ar[i];k+=ar[i];}
  m=abs(k-ar[0]);
  rep(i,0,n)
  {
    b+=ar[i];
    ll z=k-b;
    m=min(m,abs(z-b));*/
 double z=((double)(n)*(double)(a))/(double)(2);
 cout<<z<<" ";
 if(2*m==n && 2*b==a) cout<<1;
 else cout<<0;
  //k=min(n+a,min(n+b,a+b));
 // cout<<m;
  /*if(n<a) cout<<0;
  else cout<<10;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

map <string, int> p;
int main()
{
	int n,m;
	string s[150],t[150];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		p[s[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>t[i];
		p[t[i]]--;
	}
	int max=0;
	for(int i=0;i<n;i++)
	{
		if(p[s[i]]>max) max=p[s[i]];
	}
	cout<<max<<endl;
	return 0;
}

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

void solve(long long N, std::vector<long long> A){
	vector<pair<long long, long long> > B(N);
	int i;
	for(i=0;i<N;i++){
		B[i].first = A[i];
		B[i].second = i+1;
	}

	sort(B.begin(),B.end());
	for(i=0;i<N;i++){
		cout << B[i].second;
		if(i!=N-1){
			cout << " ";
		}
	}
	cout << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;
class Main {
          
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
              
        // TODO Auto-generated method stub
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int x = 0;
              
        if(a > b){
            x = a;
            a = b;
            b = x;
            }
        if(b > c){
            x = b;
            b = c;
            c = x;
            }
        if(a > b){
            x = a;
            a = b;
            b = x;
            }
            System.out.println(a+" "+b+" "+c);
    }
      
}

Measured memory_bytes: 26236