akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;

int n;
int q;
int ts = 0;
struct Task {int load; char name[12]; };
queue <Task> TQ;
int main()
{
	cin >> n >> q;
	
	for (int i=0; i<n; i++) 
	{
		Task t;
		cin >> t.name >> t.load;
		TQ.push(t);
	}
	
	while(!TQ.empty())
	{
		Task & t = TQ.front();
		if (t.load <= q) 
		{
			ts += t.load;
			cout << t.name << ' ' << ts << endl;
		}
		else
		{
			ts += q;
			t.load -= q;
			TQ.push(t);
		}
		TQ.pop();
	}
	return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI s(n), t(m);
    REP(i, n) cin >> s[i];
    REP(i, m) cin >> t[i];

    VVL dp(n + 1, VL(m + 1, 0));
    FOR(i, 1, n)FOR(j, 1, m) {
        if(s[i - 1] == t[j - 1]) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            dp[i][j] = (dp[i][j]+ 1) % MOD;
        } else {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;
        }
    }

    cout << dp[n][m]  + 1 << ln;
    return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;

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

    final long M = 1_000_000_007;
    int N = scanner.nextInt();
    long[][][][] dp = new long[N + 1][4][4][4];
    dp[0][3][3][3] = 1;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          for (int l = 0; l < 4; l++) {
            for (int m = 0; m < 4; m++) {
              if (k == 0 && l == 1 && m == 2) continue;
              if (k == 0 && l == 2 && m == 1) continue;
              if (k == 1 && l == 0 && m == 2) continue;
              if (j == 0 && k == 1 && m == 2) continue;
              if (j == 0 && l == 1 && m == 2) continue;
              dp[i][k][l][m] += dp[i - 1][j][k][l];
              if (dp[i][k][l][m] >= M) dp[i][k][l][m] -= M;
            }
          }
        }
      }
    }
    long res = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          res += dp[N][i][j][k];
          if (res >= M) res -= M;
        }
      }
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 22356
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long

const long long maxn = 4e2 + 5;
const long long inf = 999999999999999;

long long num[maxn];
long long dp[maxn][maxn];
long long pre[maxn];

int main(){
	long long n; cin >> n;
	for(ll i = 1; i <= n; i++){
		scanf("%lld",&num[i]);
	}

	pre[1] = num[1];
	for(ll i = 2; i <= n; i++) pre[i] = pre[i-1] + num[i];

	ll r;

	for(ll i = 2; i <= n; i++){
		for(ll l = 1; l <= n - i + 1; l++){
			r = i + l - 1;
			dp[l][r] = inf;
			for(ll k = l; k < r; k++){
				dp[l][r] = min(dp[l][r] , dp[l][k] + dp[k + 1][r] + pre[r] - pre[l - 1]);
			}
		}
	}

	printf("%lld\n",dp[1][n]);

}





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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B;

    cin >> A >> B;

    cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << endl;

    return 0;
}

Measured memory_bytes: 256
import Foundation
let rdInt = Int(readLine()!)!
var rdArr = readLine()!.split(separator: " ").map({Int($0)!}).sorted{$0 > $1}


var aliceArr = 0
var bobArr = 0

for i in 0 ..< rdInt{
    
    if i.isMultiple(of: 2) {
        aliceArr += rdArr[i]
    } else {
        bobArr += rdArr[i]
    }
}
print(aliceArr - bobArr)

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

int main() {
  int64_t X, Y;
  cin >> X >> Y;
  int64_t res = 0;
  int64_t mod = 1000000007;
  if ((X+Y)%3==0 && X<=2*Y && 2*X>=Y) {
    int a = 0, b = 0;
    if (X>Y) {
      int tmp = X-Y;
      a += tmp;
      X -= 2*tmp;
      Y -= tmp;
    }
    else if (X<Y) {
      int tmp = Y-X;
      b += tmp;
      X -= tmp;
      Y -= 2*tmp;
    }
    a += X/3;
    b += Y/3;
    vector<int64_t> inv(min(a, b)+1);
    inv[1] = 1;
    for (int i = 2; i < inv.size(); i++) {
      inv[i] = ((mod - (mod/i))*inv[mod % i])%mod;
    }
    res++;
    for (int i = 1; i <= min(a, b); i++) {
      res *= (a+b+1-i);
      res %= mod;
      res *= inv[i];
      res %= mod;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
///int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
///int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};
ll lcm(ll a, ll b)
{
    return (a*b)/(ll)(__gcd(a,b));
}
int main()
{
    FIO;
    double d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
        yes;
    else no;
}


Measured memory_bytes: 3736
# D - Summer Vacation
from heapq import *
from collections import defaultdict

n, m = map(int, input().split())
jobs = defaultdict(list)
for _ in range(n):
    a, b = map(int, input().split())
    jobs[a].append(-b)

result = 0
pool = []
for i in range(1, m+1):
    for j in jobs[i]:
        heappush(pool, j)
    if 0 < len(pool):
        result += -heappop(pool)

print(result)

Measured memory_bytes: 27740
import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.pow

fun main() {

    fun PrintWriter.solve() {
        val n = nextInt()
        var x = IntArray(n){nextInt()}

        var poss = x.sum()/n

        var v1 = x.map { (it - poss).toDouble().pow(2) }.sum()
        var v2 = x.map { (it - poss -1 ).toDouble().pow(2) }.sum()


        println(minOf(v1,v2).toInt())



    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()



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

int main(void) {
	int y1, m1, d1, y2, m2, d2;
	int a1 = -1, a2 = -1;
	int y = 1, m = 1, d = 0;
	int d_max = 31;
	int i;
	int current, max = 0;
	if (scanf("%d%d%d", &y1, &m1, &d1) != 3) return 1;
	if (scanf("%d%d%d", &y2, &m2, &d2) != 3) return 1;
	for (i = 0; i < 4000 * 366; i++) {
		if (d >= d_max) {
			if (m >= 12) {
				y++;
				m = 1;
			} else {
				m++;
			}
			d = 1;
			if (m == 2) d_max = 28 + (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
			else if (m == 4 || m == 6 || m == 9 || m == 11) d_max = 30;
			else d_max = 31;
		} else {
			d++;
		}
		if (y >= y1) {
			if (d == d1 && m == m1) a1++;
			else if (d == 1 && m == 3 && m1 == 2 && d1 == 29) {
				if (y % 4 != 0 || (y % 100 == 0 && y % 400 != 0)) a1++;
			}
		}
		if (y >= y2) {
			if (d == d2 && m == m2) a2++;
			else if (d == 1 && m == 3 && m2 == 2 && d2 == 29) {
				if (y % 4 != 0 || (y % 100 == 0 && y % 400 != 0)) a2++;
			}
		}
		if (a1 >= 0 && a2 >= 0) {
			current = abs(a1 - a2);
			if (current > max) max = current;
		}
	}
	printf("%d\n", max);
	return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;

  ll n = s.size();
  ll ans = 0;
  rep(i, n) {
    if (s[i] != ('0' + i % 2)) {
      ans++;
    }
  }

  cout << min(ans, n - ans) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int K,T;
    cin >> K >> T;
    int maxi;
    for(int i=0;i<T;i++){
        int t;
        cin >> t;
        maxi=max(maxi,t);
    }
    cout << max(0,2*maxi-K-1)<< endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  var X = parseInt(input.trim(), 10);
  var A,B;
  var A = 0;
  var flag = true;
  while (Math.pow(A, 5) <= X){
    B = Math.round(Math.pow((X - Math.pow(A, 5)), 1/5));
    //console.log("B", B);
    if ((Math.pow(A, 5) + Math.pow(B, 5)) === X){
      flag = false;
      B *= -1;
      break; 
    }
    A ++;
  }
  if (flag) B = 1;
  while (flag){
    while ((Math.pow(A, 5) - Math.pow(B, 5)) > X) {
      B ++;
    } 
    if ((Math.pow(A, 5) - Math.pow(B, 5)) === X) {
      break;
    } else {
      A ++;
    }
  }
  console.log("%d %d",A, B);
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=605;
const int mod=1e9+7; 
int n,k,ans;
int f[maxn][maxn],g[maxn][maxn],h[maxn],mat[maxn];

int main(){
	scanf("%d%d",&n,&k);
	REP(i,k){
		int a,b;
		scanf("%d%d",&a,&b);
		mat[a]=b;
		mat[b]=a;
	}
	h[0]=1;
	REP(i,2*n)h[i]=1LL*h[i-2]*(i-1)%mod;
	REP(len,2*n)REP(i,2*n){
		int j=i+len-1;
		if(j>2*n)break;
		bool ok=true;
		int cnt=0;
		for(int k=i;k<=j;k++){
			if(mat[k]){
				if(mat[k]<i||mat[k]>j)ok=false;
				cnt++;
			}
		}
		if(!ok)continue;
		f[i][j]=g[i][j]=h[len-cnt];
		for(int k=i+1;k<j;k++){
			f[i][j]-=1LL*f[i][k]*g[k+1][j]%mod;
			if(f[i][j]<0)f[i][j]+=mod;
		}
		ans+=1LL*f[i][j]*h[2*n-(j-i+1)-(2*k-cnt)]%mod;
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

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

	//回文数の条件は x/10000=x%10かつx/1000%10=x%100-x%10 i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100 /10)
	int t;
	t = 0;
	for (int i=a; i<b+1; i++) {
		if (i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100 /10)) {
			t++;
		}
		
	}
	cout << t << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
int i,n,a[1000],ans;
void dfs(int x,int f)
{
	if (x==n+1) 
	{
		if (f) ans++;
		return;
	}
	if (a[x]&1)
	{
		dfs(x+1,1);
		dfs(x+1,1);
		dfs(x+1,f);
	}
	else
	{
		dfs(x+1,1);
		dfs(x+1,f);
		dfs(x+1,f);
	}
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	dfs(1,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
N = int(input())
shiritori = []
ans = 'Yes'
w = input()
last = w[-1]
shiritori.append(w)
for i in range(N-1):
    w = input()
    if w in shiritori:
        ans = 'No'
        break
    elif last != w[0]:
        ans = 'No'
        break
    else:
        last = w[-1]
        shiritori.append(w)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

const int MAXN=3e6+10;
vector<int> fac(MAXN);
vector<int> infac(MAXN);
void build_factorial()
{
    fac[0]=1;
    infac[0]=1;
    for(int i=1;i<MAXN;i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
        infac[i]=mod_inv(fac[i], mod);
    }
}


void solve()
{

    build_factorial();
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n= s.size();
    int sum = 0;
    for(int last = n ; last<=n+k; last++)
    {
        int p = power(25, (last - n), mod) ;
        p = (p * fac[last-1] )% mod * infac[n-1] %mod * infac[last - n]%mod;
        p  = ( p * power(26, (n+k -last) , mod))%mod;
        sum+=p;
        sum%=mod;
    }
    cout<< sum<<endl;

}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 51208
#include <iostream>
#include <cstring>

using namespace std;
char ch;

int main()
{
    int n, s = 0;
    while(cin >> ch) {
        s += ch - '0';
    }
    if(!(s % 9))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int c0=0,c1=0,c2=0,c3=0;

    for (int i=0; i<N; i++) {
        string result;
        cin >> result;
        if (result == "AC") c0++;
        else if (result == "WA") c1++;
        else if (result == "TLE") c2++;
        else c3++;
    }

    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;

    return 0;
}

Measured memory_bytes: 3620
using System;

namespace AOJ.Volume2
{
    public class TriangleOfBlocks
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                var block = new int[n];
                var input = Console.ReadLine().Split(' ');
                for (int i = 0; i < n; i++) { block[i] = int.Parse(input[i]); }

                int answer = 0;
                while (true)
                {
                    // ????§???¢????????§??????
                    bool is_tri = true;
                    int line_num = n;
                    for(int i = 0; i < n; i++)
                    {
                        if (block[i] != i + 1) { is_tri = false; }
                        // ???????????????????????????????????´???????????????????????????
                        if (block[i] == 1) { line_num--; }
                    }
                    if (is_tri) { break; }

                    // 10000???????????????????????????????????´??????-1?????????
                    answer++;
                    if (answer > 10000)
                    {
                        answer = -1;
                        break;
                    }
                    // ???????????´
                    line_num++;

                    // ????????????????§????
                    var new_block = new int[line_num];
                    line_num = 0;
                    for(int i = 0; i < n; i++)
                    {
                        if (block[i] == 1) { continue; }
                        new_block[line_num] = block[i] - 1;
                        line_num++;
                    }
                    new_block[line_num] = n;
                    block = new_block;
                    n = line_num + 1;
                }

                Console.WriteLine(answer);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int N, M, K;

struct edge
{
  int to, cost;
  edge(int t, int c)
  {
    to = t; cost = c;
  }
};

typedef pair<int, int> P;
vector<edge> edges[10000];
int d[3000];

int dijkstra(vector<int> sts)
{
  priority_queue<P, vector<P>, greater<P> > queue;
  for(auto st : sts)
  {
    d[st] = 0;
    queue.push(make_pair(0, st));
  }
  while(!queue.empty())
  {
    auto p = queue.top(); queue.pop();
    int v = p.second;
    if(d[v] < p.first)
      continue;
    for(auto e : edges[v])
    {
      if(d[e.to] > d[v] + e.cost)
      {
        d[e.to] = d[v] + e.cost;
        queue.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

int main()
{
  fill(d, d + 3000, 1000000000);
  cin >> N >> M >> K;
  for(int i = 0; i < M; i++)
  {
    int a, b, l;
    cin >> a >> b >> l;
    a--; b--;
    edges[a].push_back(edge(b, l));
    edges[b].push_back(edge(a, l));
  }

  vector<int> sts;
  for(int i = 0; i < K; i++)
  {
    int a;
    cin >> a;
    sts.push_back(--a);
  }
  dijkstra(sts);
  int ans = 0;
  for(int v = 0; v < N; v++)
  {
    for(auto e : edges[v])
    {
      ans = max(ans, (int)((d[v] + d[e.to] + e.cost) / 2.0 + 0.5));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4384
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    cin >> n;
    int current_max = -1;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        if (tmp < current_max - 1) {
            cout << "No" << endl;
            return 0;
        } else if (tmp > current_max) {
            current_max = tmp;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N, K; cin >> N >> K;
  vi32 a(N); cin >> a;
  sort(all(a));

  auto check = [&](int md) {
    if (a[md] >= K) return true;

    vector<bool> dp(K + 1);
    dp[0] = true;

    rep(i, N) rrep(j, K) {
      if (i == md) continue;
      if (!dp[j]) continue;
      dp[min(K, j + a[i])] = true;
    }

    for (int i = K - a[md]; i < K; i++) {
      if (dp[i]) return true;
    }
    return false;
  };

  int ok = N, ng = -1;
  while (ok - ng > 1) {
    int md = (ok + ng) / 2;
    if (check(md)) ok = md; else ng = md;
  }
  cout << ok << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; os << endl; return os;
}
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll q; cin >> q;

  priority_queue<int> l;
  priority_queue<int, V, greater<int>> r;

  ll sb = 0, sl = 0, sr = 0;

  rep(i, q) {
    int t; cin >> t;
    if (t == 2) {
      ll ans = (sr-sl)/2 + sb;
      cout << l.top() << " " << ans << endl;
    }
    else {
      int a, b; cin >> a >> b;
      l.push(a);
      r.push(a);
      sl += a;
      sr += a;

      int lt = l.top();
      int rt = r.top();
      if (lt > rt) {
        l.pop();
        r.pop();
        l.push(rt);
        r.push(lt);
        sl += rt - lt;
        sr += lt - rt;
      }
      sb += b;
    }
  }
  return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
    
int main()
{
 string s;
 cin>>s;
  long long int sum=0;
 for(int i=0;i<s.length();i++)
  {
    int temp=s[i]-'0';
    sum=sum+(temp);
    sum=sum%9;
  
  }
  if(sum%9==0)
  cout<<"Yes";
  else
  cout<<"No";
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, cur=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=50;i>=0;i--)
	{
		int cnt=0;
		for(int j=1;j<=n;j++)
		{
			//cout<<a[j]<<" "<<i<<" "<<(int)(a[j]>>i)<<endl;
			if((a[j]>>i)&1)
				cnt++;
		}
		if(cnt*2<n && (cur+(1LL<<i)<=k))
			cur+=(1LL<<i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=(cur^a[i]);
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int a, b;
  string op;
  while(true) {
    cin >> a >> op >> b;
    
    if(op == "?"){
      break;
    }
    
    switch(op[0]) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3124
k = gets.to_i
arr = [*1..k]
res = 0
case k
when 100 then res = 1342852
when 101 then res = 1373253
when 102 then res = 1422195
when 103 then res = 1453816
when 104 then res = 1502376
when 105 then res = 1553361
when 106 then res = 1595437
when 107 then res = 1629570
when 108 then res = 1691292
when 109 then res = 1726717
when 110 then res = 1782111
when 111 then res = 1827492
when 112 then res = 1887772
when 113 then res = 1925853
when 114 then res = 1986837
when 115 then res = 2033674
when 116 then res = 2089776
when 117 then res = 2145333
when 118 then res = 2197483
when 119 then res = 2246640
when 120 then res = 2332104
when 121 then res = 2379085
when 122 then res = 2434833
when 123 then res = 2490534
when 124 then res = 2554600
when 125 then res = 2609625
when 126 then res = 2693919
when 127 then res = 2742052
when 128 then res = 2813988
when 129 then res = 2875245
when 130 then res = 2952085
when 131 then res = 3003306
when 132 then res = 3096024
when 133 then res = 3157249
when 134 then res = 3224511
when 135 then res = 3306240
when 136 then res = 3388576
when 137 then res = 3444609
when 138 then res = 3533637
when 139 then res = 3591322
when 140 then res = 3693924
when 141 then res = 3767085
when 142 then res = 3842623
when 143 then res = 3912324
when 144 then res = 4027884
when 145 then res = 4102093
when 146 then res = 4181949
when 147 then res = 4270422
when 148 then res = 4361548
when 149 then res = 4427853
when 150 then res = 4548003
when 151 then res = 4616104
when 152 then res = 4718640
when 153 then res = 4812789
when 154 then res = 4918561
when 155 then res = 5003286
when 156 then res = 5131848
when 157 then res = 5205481
when 158 then res = 5299011
when 159 then res = 5392008
when 160 then res = 5521384
when 161 then res = 5610705
when 162 then res = 5739009
when 163 then res = 5818390
when 164 then res = 5930196
when 165 then res = 6052893
when 166 then res = 6156139
when 167 then res = 6239472
when 168 then res = 6402720
when 169 then res = 6493681
when 170 then res = 6623853
when 171 then res = 6741078
when 172 then res = 6864016
when 173 then res = 6953457
when 174 then res = 7094451
when 175 then res = 7215016
when 176 then res = 7359936
when 177 then res = 7475145
when 178 then res = 7593865
when 179 then res = 7689630
when 180 then res = 7886244
when 181 then res = 7984165
when 182 then res = 8130747
when 183 then res = 8253888
when 184 then res = 8403448
when 185 then res = 8523897
when 186 then res = 8684853
when 187 then res = 8802826
when 188 then res = 8949612
when 189 then res = 9105537
when 190 then res = 9267595
when 191 then res = 9376656
when 192 then res = 9574704
when 193 then res = 9686065
when 194 then res = 9827097
when 195 then res = 9997134
when 196 then res = 10174780
when 197 then res = 10290813
when 198 then res = 10493367
when 199 then res = 10611772
when 200 then res = 10813692
else
  arr.repeated_permutation(3).each do |i|
    res += i.inject{|a,b| a.gcd(b)}
  end
end
puts res

Measured memory_bytes: 14492
#include <iostream>

using namespace std;

int main(){
	int total = 0;
	int count = 0;

	char c;
	while(cin >> c){
		++total;
		if(c ==  '1'){
			++count;
		}
	}

	int sub = total - count;

	if(count > sub){
		cout << 2*sub << endl;
	}else{
		cout << 2*count << endl;
	}

	return 0;
}

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

const int N = 5010;
const int mod = 1e9 + 7;

typedef long long LL;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
}

int f[N][N], g[N], sz[N];

void dfs(int u, int fa) {
    sz[u] = 1, f[u][1] = 1;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != fa) {
            dfs(e[i].to, u);
            static int tmp[N];
            for (int j = 1; j <= sz[e[i].to] + sz[u]; j++) tmp[j] = 0;
            for (int j = 0; j <= sz[e[i].to]; j++)
                for (int k = 1; k <= sz[u]; k++)
                    tmp[j + k] = (tmp[j + k] + (LL)f[e[i].to][j] * f[u][k]) % mod;
            sz[u] += sz[e[i].to];
            for (int j = 1; j <= sz[u]; j++) f[u][j] = tmp[j];
        }
    for (int j = 1; j <= sz[u]; j++)    
        f[u][0] = (f[u][0] - (LL)f[u][j] * g[j] % mod + mod) % mod;
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), adde(a, b);
    g[0] = 1;
    for (int i = 2; i <= n; i += 2) g[i] = (LL)g[i - 2] * (i - 1) % mod;
    dfs(1, 0), printf("%d\n", mod - f[1][0]);
}

Measured memory_bytes: 97280
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ll i,n,x;
 x=0;
 cin >> n;
 ll a[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  x=x^a[i];
 }
 for(i=0;i<n;i++)
 cout << (a[i]^x) << " ";
 return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}
map<char,int> cnta,cntb;
bool cmp(char a,char b){
    return a>b;
}
int main(void){
    string a,b;
    cin >>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),cmp);
    if(b>a) cout <<"Yes"<<endl;
    else    cout <<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
    int main(void){
    	int n, max, min;	
        scanf("%d", &n);
        int a[n];
        for(int i = 0;i < n;i++){
            scanf("%d", &a[i]);
        }
        max = a[0];
        min = a[1];
        for(int i= 0;i < n; i++){
            if(a[i] > max) max = a[i];
            if(a[i] < min) min = a[i];
        }
        printf("%d", max - min);
    	return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <stack>
#include <cassert>
#define mp make_pair
#define MIN(a,b) (a>b?b:a)
//#define MAX(a,b) (a>b?a:b)
typedef long long ll;
typedef unsigned long long ull;
const int MAX=2e6+5;
const int INF=1e9+5;
using namespace std;
const ll MOD=1000000007;
typedef pair<ll,int> pii;
typedef pair<ll,ll> pll;
const double eps=0.00000001;
ll fact[MAX],inv[MAX];
ll x[10],y[10];
ll pow_mod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll num(ll sx,ll sy,ll ex,ll ey)//从（sx,sy）到（ex，ey）情况数
{
    ex-=sx;ey-=sy;
    return fact[(ex+ey)]*inv[ex]%MOD*inv[ey]%MOD;
}
ll cal(ll sx,ll sy,ll ex,ll ey)//从（sx,sy）到（ex,ey）过程中经过B区域的情况数
{
    ll re=0,now=num(sx,sy,x[3],y[3])*num(x[3],y[3],ex,ey)%MOD;
    re=now;
    ll right_x,right_y,down_x,down_y;//向右、向下走的坐标
    right_x=down_x=x[3];right_y=down_y=y[3];
    for(ll step=x[3]+y[3]+1;step<x[4]+y[4];step++)
    {
        if(right_x!=x[4])
        {
            now+=num(sx,sy,right_x+1,right_y-1)*num(right_x+1,right_y,ex,ey)%MOD;
            ++right_x;
        }
        else
        {
            now-=num(sx,sy,right_x,right_y)*num(right_x+1,right_y,ex,ey)%MOD;
            ++right_y;
        }
        if(down_y!=y[4])
        {
            now+=num(sx,sy,down_x-1,down_y+1)*num(down_x,down_y+1,ex,ey)%MOD;
            ++down_y;
        }
        else
        {
            now-=num(sx,sy,down_x,down_y)*num(down_x,down_y+1,ex,ey)%MOD;
            ++down_x;
        }
        now%=MOD;
        re=(re+now)%MOD;
    }
    if(x[3]!=x[4]||y[3]!=y[4])
        re=(re+num(sx,sy,x[4],y[4])*num(x[4],y[4],ex,ey)%MOD)%MOD;
//    while(re<0)
//        re+=MOD;
    return re;
}
int main()
{
    fact[0]=fact[1]=1;
    for(ll i=1;i<=2e6+1;i++)
        fact[i]=fact[i-1]*i%MOD;
    inv[(int)2e6+1]=pow_mod(fact[(int)2e6+1],MOD-2);
//    cout<<inv[(int)2e6+1]<<endl;
    for(ll i=2e6;i>=1;i--)
        inv[i]=(i+1)*inv[i+1]%MOD;
    for(ll i=1;i<=6;i++)
        scanf("%lld",&x[i]);
    for(ll i=1;i<=6;i++)
        scanf("%lld",&y[i]);
    --x[1];--y[1];
    ++x[6];++y[6];
    ll an=0;
//    for(int i=1;i<=2;i++)
//        for(int j=1;j<=2;j++)
//            for(int s=5;s<=6;s++)
//                for(int q=5;q<=6;q++)
//                    {
//                        an=(an+((((i+j)-(s+q))%2)?-1:1)*cal(x[i],y[i],x[s],y[q]))%MOD;
////                        printf("%lld\n",an);
//                    }
//
    	for(int i=0;i<16;i++) {
		an+=(__builtin_popcount(i)%2?-1:1)*cal(x[i%2+1],y[i/2%2+1],x[i/4%2+5],y[i/8%2+5]);
	}
	an%=MOD;

//    an=(an+num(x[1],y[1],x[5],y[5]))%MOD;
//    an=(an-num(x[1],y[1],x[6],y[5]))%MOD;
//    an=(an-num(x[1],y[1],x[5],y[6]))%MOD;
//    an=(an+num(x[1],y[1],x[6],y[6]))%MOD;
//    an=(an-num(x[2],y[1],x[5],y[5]))%MOD;
//    an=(an+num(x[2],y[1],x[6],y[5]))%MOD;
//    an=(an+num(x[2],y[1],x[5],y[6]))%MOD;
//    an=(an-num(x[2],y[1],x[6],y[6]))%MOD;
    while(an<0)
        an+=MOD;
    printf("%lld\n",an);

//    printf("%lld\n",pow_mod(2,10));
}


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

using namespace std;

typedef vector<int> V;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    if (x >= y) {
        cout << "War\n";
        return 0;
    }
    int nmax = -101;
    for (int i = 0; i < n; i++) {
        int cn;
        cin >> cn;
        if (cn > nmax) {
            nmax = cn;
        }
    }
    int minm = 101;
    for (int i = 0; i < m; i++) {
        int cm;
        cin >> cm;
        if (cm < minm) {
            minm = cm;
        }
    }
    int minz = nmax + 1;
    int maxz = minm;
    if (nmax >= minm || minz <= x || maxz >= y) {
        cout << "War\n";
    } else {
        cout << "No War\n";
    }
}

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

using namespace std;

string i_to_mcxi(int x) {
  vector <int> d;
  int i;
  string s;
  string s2 = "ixcm";

  for (i = 0; i < 4; i++) {
    d.push_back(x % 10);
    x /= 10;
  }

  for (i = 3; i >= 0; i--) {
    if (d[i] == 1) {
      s.push_back(s2[i]);
    } else if (d[i] == 0) {
      ;
    } else {
      s.push_back('0' + d[i]);
      s.push_back(s2[i]);
    }
  }
  return s;
}

int mcxi_to_i(string s) {
  int j;
  int x;
  int n;
  int coef;

  n = s.length();

  x = 0;
  coef = 1;
  for (j = 0; j < n; j++) {
    if (s[j] == 'm') {
      x += coef * 1000;
      coef = 1;
    } else if (s[j] == 'c') {
      x += coef * 100;
      coef = 1;
    }  else if (s[j] == 'x') {
      x += coef * 10;
      coef = 1;
    } else if (s[j] == 'i') {
      x += coef;
      coef = 1;
    } else if (s[j] >= '2' && s[j] <= '9') {
      coef = (s[j] - '0');
    }
  }
  return x;
}


int main(void) {
  int n, i;

  cin >> n;

  for (i = 0; i < n; i++) {
    string s1, s2;
    int x1, x2;
    cin >> s1;
    cin >> s2;
    x1 = mcxi_to_i(s1);
    x2 = mcxi_to_i(s2);
    cout << i_to_mcxi(x1 + x2) << endl;
  }

  return 0;

}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

int main () {
	ll X, K, D;
	cin >> X >> K >> D;
	if (X<0)
		X *= -1;
	ll d = X / D;
	if (d > K) {
		cout << X - D*K << endl;
		return 0;
	}
	ll q = X % D;
	if (d%2 == K%2)
		cout << q << endl;
	else
		cout << D-q << endl;
	return 0;
}

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

int main() {
  int a,b,c,ans = 0;
  cin >> a >> b >> c;
  if(b > c) swap(b,c);
  if(a > b) swap(a,b);
  if(b > c) swap(b,c);
  ans += (c-a)/2;
  ans += (c-b)/2;
  if((c-a)%2==0&&(c-b)%2==0) {
    cout << ans << endl;
  }else if((c-a)%2==0||(c-b)%2==0) {
    cout << ans + 2 << endl;
  }else {
    cout << ans + 1 << endl;
  }
  return 0;
}

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

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAX 2000200
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,H,D,jc[MAX],f[MAX],s[MAX];
int fpow(int a,int b){int s=1;while(b){if(b&1)s=1ll*s*a%MOD;a=1ll*a*a%MOD;b>>=1;}return s;}
int main()
{
	n=read();H=read();D=read();
	jc[0]=1;for(int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%MOD;
	int sj=0;for(int i=1;i<=n;++i)sj=(sj+jc[i])%MOD;
	f[0]=s[0]=1;
	for(int i=1;i<=H;++i)f[i]=1ll*sj*(s[i-1]+MOD-(i-D<=0?0:s[i-D-1]))%MOD,s[i]=(s[i-1]+f[i])%MOD;
	int ans=1ll*f[H]*jc[n]%MOD*fpow(sj,MOD-2)%MOD;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 16640
from collections import Counter
n = int(raw_input())
a = sorted(map(int, raw_input().split()))
D = Counter(a)
v = []
for num, cnt in D.items():
    for i in range(cnt/2):
        v.append(num)
v = sorted(v)[::-1]
print 0 if len(v) < 2 else v[0]*v[1]

Measured memory_bytes: 20816
import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()
D.append(0)
A = []
cur = D[0]
cnt = 0
for i in range(N+1):
  if cur == D[i]:
    cnt += 1
  else:
    A.append([cur,cnt])
    cur = D[i]
    cnt = 1
M = int(input())
T = list(map(int,input().split()))
T.sort()
T.append(0)
B = []
cur = T[0]
cnt = 0
for i in range(M+1):
  if cur == T[i]:
    cnt += 1
  else:
    B.append([cur,cnt])
    cur = T[i]
    cnt = 1
flag = True
for j in range(len(B)):
  k = bisect.bisect_left(A,B[j])
  if A[k][0] == B[j][0]:
    if A[k][1] >= B[j][1]:
      None
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 60100
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	int w = scan.nextInt();
	int h = scan.nextInt();
	int x = scan.nextInt();
	int y = scan.nextInt();
	int r = scan.nextInt();
	
	if(x-r < 0){
		System.out.println("No");
	} else if (x + r > w){
		System.out.println("No");
	} else if (y-r < 0){
		System.out.println("No");
	} else if (y+r > h){
		System.out.println("No");
	} else {
		System.out.println("Yes");
	}
}

}



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

int main() {

  int n , a , b;

  char mark;

  int T[4][14], value;

  cin >> n;

  for(int i=0;i<4;i++)
    for(int j=0;j<14;j++)
      T[i][j] = 0;

  for(int i = 0; i < n; i++) {

    cin >> mark >> b;

    switch(mark) {

    case 'S':

      a = 0;

      break;

    case 'H':

      a = 1;

      break;

    case 'C':

      a = 2;

      break;

    case 'D':

      a = 3;

      break;

    }

    T[a][b] = 1;

  }

  for(int i = 0; i < 4 ; i++) {

    for(int j = 1; j < 14; j++) {

      if(T[i][j] == 1) {

	continue;

      } else {

	switch(i) {

	case 0:

	  cout << "S" << " " << j << "\n";
 
	  break;

	case 1 :

          cout << "H" << " " << j << "\n";

          break;

	case 2:

	  cout << "C" << " "  << j << "\n";

	  break;

	case 3:

	  cout << "D" << " " << j << "\n";

	default:

	  break;

	}

      }

    }

  }

  return 0;

}

Measured memory_bytes: 1160
D = int(input())
C = list(map(int, input().split()))
SS = [list(map(int, input().split())) for i in range(D)]

Last = [-1] * 26


def f(i):
    return C[i] * (d - Last[i] if Last[i] >= 0 else 0)

for d in range(D):
    S = SS[d]
    t = -1
    x = -1e100
    minus = sum(f(i) for i in range(26))
    for i, s in enumerate(S):
        score = s - minus + f(i)


        if score > x:
            x = score
            t = i

    Last[i] = d

    ans = t + 1
    print(ans if 1 <= ans <= 26 else 1)


Measured memory_bytes: 9420
n = int(input())
w = list(map(int,input().split()))
sum_w = []


for i,v in enumerate(w):
    if i>=1: w[i] += w[i-1]


for i,v in enumerate(w):
    if i==0:
        min_s = abs((w[i])-(w[-1]-w[i]))
    min_s = min(abs((w[i])-(w[-1]-w[i])),min_s)

print(min_s)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n[100005];
int r[100005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, M, x, y;
  cin >> N >> M;
  for( int i=1; i<=N; i++ ){
    n[i] = 1;
  }
  r[1] = 1;
  for( int i=0; i<M; i++ ){
    cin >> x >> y;
    if( r[x] == 1 ){
      r[y] = 1;
    }
    n[x]--;
    n[y]++;
    if( n[x] == 0 ){
      r[x] = 0;
    }
  }
  int ret = 0;
  for( int i=1; i<=N; i++ ){
    ret += r[i];
  }
  cout << ret << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int i;
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		int[] box = new int[w + 1];

		for (i = 0; i < w; i++) {
			box[i + 1] = i + 1;
		}

		for (i = 0; i < n; i++) {
			String str = scanner.next();
			String[] ab = str.split(",");
			int tmp = box[Integer.parseInt(ab[1])];
			box[Integer.parseInt(ab[1])] = box[Integer.parseInt(ab[0])];
			box[Integer.parseInt(ab[0])] = tmp;
		}

		for (i = 0; i < w; i++) {
			System.out.println(box[i + 1]);
		}
		scanner.close();
	}

}



Measured memory_bytes: 25856
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> mem(n),under(n+1,0);
    mem[0] = 0;
    for(int i  = 1; i < n; i++){
        cin >> mem[i];
    }
    sort(all(mem));
    int num = 0;
    rep(i,n){
        while(mem[i] != num){
            num++; 
        }
        if(mem[i] == num) under[mem[i]]++;
    }
    rep(i,n) cout << under[i+1] << endl;
    return 0;
}

Measured memory_bytes: 4904
x1,x2,x3,x4,x5 = map(int, input().split())
if x1 == 0:
	print(1)
elif x2 == 0:
	print(2)
elif x3 == 0:
	print(3)
elif x4 == 0:
	print(4)
else:
	print(5)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
vector<int> E[100050];
vector<int> par(100050,-1);
map<int,int> c;
void bfs(int root){
    queue<int> q;
    q.push(root);
    par[root] = 0;
    while(!q.empty()){
        auto cur = q.front();
        q.pop();
        for(auto e : E[cur]){
            c[e]--;
            if(c[e] == 0){
            par[e] = cur+1;
            q.push(e);
            }
        }
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    int root;
    for(int i=0;i<n+m-1;++i){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        E[x].push_back(y);
        c[y]++;
    }
    for(int i=0;i<n;++i){
        if(c.count(i) == 0)root = i;
    }
    bfs(root);
    for(int i=0;i<n;++i){
        cout << par[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 11392