akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    if(s=="ABC")cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3624
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#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 LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {

	while (1) {
		int n;
		int t[17][17];
		int dp[1 << 16];

		cin >> n;
		if (n == 0) {
			break;
		}
		
		FOR(i, 1, n) {
			FOR(j, 0, n) {
				cin >> t[i][j];
			}
		}
		
		FOR(i, 0, (1 << 16) - 1) {
			dp[i] = INF;
		}

		dp[0] = 0;

		FOR(i, 0, (1 << n) - 1) {
			FOR(j, 0, n-1) {
				if (!(i&(1 << j))) {
					int v;
					v = t[j + 1][0];
					
					FOR(k, 0, n - 1) {
						if (i & (1 << k)) {
							v = min(v, t[j + 1][k + 1]);
						}
					}
					dp[i + (1 << j)] = min(dp[i] + v, dp[i + (1 << j)]);
				}
			}
		}

		cout << dp[(1 << n) - 1] << endl;

	}

	

	return 0;
}


Measured memory_bytes: 3336
n = int(input())
a = [int(i) for i in input().split()]
a_2 = [abs(a[i]) for i in range(n)]
a.sort()

if a[0] >= 0:
    print([sum(a_2) -2, sum(a_2)][a[0] == 0])
    aa = a[0]
    for i in range(n-1):
        if i == 0:
            print(aa, a[i + 1])
            aa = aa - a[i + 1]
        elif i == n - 2:
            print(a[i + 1], aa)
        else:
            print(aa, a[i+1])
            aa = aa - a[i + 1]

elif a[-1] <= 0:

    print([sum(a_2) -2, sum(a_2)][a[-1] == 0])
    a.reverse()
    if a[-1] == 0:
        a = [a[-1]] + a[0:]
    aa = a[0]
    for i in range(n-1):
        if i == 0:
            print(aa, a[i + 1])
            aa = aa - a[i + 1]
        elif i == n - 2:
            print(aa, a[i + 1])
        else:
            print(aa, a[i+1])
            aa = aa - a[i + 1]

else:
    print(sum(a_2))
    minus = []
    plus = []
    for i in range(n):
        if a[i] < 0:
            minus.append(a[i])
        else:
            plus.append(a[i])
    minus2 = minus.pop()
    plus2 = plus.pop()
    for i in range(len(minus)):
        print(plus2 ,minus[i])
        plus2 -= minus[i]
    for i in range(len(plus)):
        print(minus2, plus[i])
        minus2 -= plus[i]
    print(plus2, minus2)



Measured memory_bytes: 14260
s=input()
t=input()
n=len(s)
k=len(t)
c=n
for i in range(n-k+1):
  c1=0
  for j in range(i,i+k):
    if(s[j]!=t[j-i]):
      c1+=1
  c=min(c,c1)
print(c)

Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

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

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


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

	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			if ((i < d) ^ (j < c)) { cout << 1; }
			else { cout << 0; }
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


n,m,x,y = map(int, input().split())

# 空白区切りの数列をリストに代入
xx = [int(i) for i in input().split()]
yy = [int(i) for i in input().split()]

for i in range(n):
    x = max(x,xx[i])
for i in range(m):
    y = min(y,yy[i])
if x < y:
    print('No War')
else:
    print('War')



Measured memory_bytes: 22052
#include<stdio.h>
#include<math.h>

int main() {
	int n;
	scanf("%d", &n);
	int x;
	int f = 0;
	int so = 0, sg = 0;
	while (n) {
		f = 0;
		scanf("%d", &x);
		if (x % 2 == 0) {
			so++;
			if (x % 3 == 0 || x % 5 == 0)
				sg++;
		}
		n--;
	}
	if (so == sg) {
		printf("APPROVED");
	}
	else
		printf("DENIED");
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))
flag = True
for i in range(N):
  if a[i]%2 ==0:
    if a[i]%3==0 or a[i]%5==0:
      flag = True
    else:
      flag = False
      break
      
      
if flag == True:
  print('APPROVED')
else:
  print('DENIED') 

Measured memory_bytes: 9180
#define rep(i,n) for (int i=0;i<(n);i++)
#define repr(i,n) for (int i=(n)-1;i>=0;i--)
#define rep2(i,s,n) for (int i=(s);i<(n);i++)
#define rep2r(i,s,n) for (int i=(n)-1;i>=(s);i--)

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vd vector<double>
#define vc vector<char>
#define cd complex<double>
#define vcd vector<cd>

#define all(a) (a).begin(),(a).end()
#define range(a,i) (a).begin(),(a).begin()+i
#define repv(itr,v) for(auto itr=(v).begin();itr!=(v).end();itr++)

#define sint(a) int a; scanf("%d",&a);
#define sint2(a,b) int a,b; scanf("%d %d",&a,&b);
#define sint3(a,b,c) int a,b,c; scanf("%d %d %d",&a,&b,&c);
#define sint4(a,b,c,d) int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d);
#define sint5(a,b,c,d,e) int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
#define sll(a) ll a; scanf("%lld",&a);
#define sll2(a,b) ll a,b; scanf("%lld %lld",&a,&b);
#define sll3(a,b,c) ll a,b,c; scanf("%lld %lld %lld",&a,&b,&c);
#define sll4(a,b,c,d) ll a,b,c,d; scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
#define sll5(a,b,c,d,e) ll a,b,c,d,e; scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e);
#define svi(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define svll(v,n) vector<ll> v(n); rep(i,n) scanf("%lld", &v[i]);
#define sdouble(x) double x; scanf("%lf",&x);
#define svd(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define schar(x) char x; scanf(" %c", &x);
#define sstring(x) string x; cin >> x;

#define pint(a) printf("%d\n",a);
#define pint2(a,b) printf("%d %d\n",a,b);
#define pint3(a,b,c) printf("%d %d %d\n",a,b,c);

#define pll(a) printf("%lld\n",a);
#define pll2(a,b) printf("%lld %lld\n",a,b);
#define pll3(a,b,c) printf("%lld %lld %lld\n",a,b,c);

#define printvi(v) printf("[ ");repv(itr,v) printf("%d ",*itr);printf("]\n");
#define printvll(v) printf("[ ");repv(itr,v) printf("%lld ",*itr);printf("]\n");

#define ceili(x,y) (x)%(y)?(x)/(y)+1:(x)/(y)

#define MOD 1000000007

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#else
#pragma GCC diagnostic ignored "-Wunused-result"
#endif

#ifdef _MSC_VER
#define DEBUG
#endif

#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex>

using namespace std;




ll inv(ll n) {
	ll r = 1;
	ll k = MOD - 2;
	for (; k > 0; k >>= 1) {
		if (k & 1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}

int main(int argc, char** argv) {
	sll(n);
	map<ll, ll> m;
	ll a = 0;
	ll p = 0;
	rep(i, n + 1) {
		scanf("%lld", &a);
		if (m.find(a) == m.end()) {
			m[a] = i;
		}
		else {
			p = m[a] + (n - i);
			break;
		}
	}
	ll b = n + 1, c = 1, d = 1, e = 1;
	rep(i, n + 1) {
		pll((b * c % MOD - d * e % MOD + MOD) % MOD);
		b = b * (n - i) % MOD;
		c = c * inv(i + 2) % MOD;
		if (i <= p) {
			d = d * (p - i) % MOD;
			e = e * inv(i + 1) % MOD;
		}
	}
	return 0;
}


Measured memory_bytes: 7424
n = int(input())
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    high = n-1
    low = j+1
    ab = l[i] + l[j]
    if l[j+1] >= ab:
      continue
    while high - low > 1:
      mid = (high+low)//2
      if l[mid] < ab:
        low = mid
      else:
        high = mid
    if l[high] < ab:
      s += high - j
    else:
      s += low - j
print(s)

Measured memory_bytes: 43372
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate nPm
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    vector<int> v1 = {5, 5, 7};
    vector<int> v2(3);
    rep(i, 3) cin >> v2[i];
    sort(ALL(v2));
    string ans = (v1.size() == v2.size() && equal(v1.cbegin(), v1.cend(), v2.cbegin())) ? "YES" : "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var y1 = int.Parse(line[0]);
        var m1 = int.Parse(line[1]);
        var d1 = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var y2 = int.Parse(line[0]);
        var m2 = int.Parse(line[1]);
        var d2 = int.Parse(line[2]);
        var a1 = getAge(y1, m1, d1);
        var b1 = getAge(y2, m2, d2);
        var ans = -1;
        for (int i = 0; i < a1.Count(); i++)
            ans = Max(ans, Abs(a1[i] - b1[i]));
        Console.WriteLine(ans);
    }
    public static List<int> getAge(int y, int m, int d)
    {
        var yyyy = 2996;
        var ans = new List<int>();
        var bd = new DateTime(y, m, d);
        var mo = new int[] { 1, 3, 5, 7, 8, 10, 12 };
        foreach (var x in mo)
        {
            for (int i = 1; i <= 31; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        var mo2 = new int[] { 4, 6, 9, 11 };
        foreach (var x in mo2)
        {
            for (int i = 1; i <= 30; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        for (int i = 1; i <= 29; i++)
        {
            var now = new DateTime(yyyy, 2, i);
            var age = now.Year - bd.Year;
            if (bd > now.AddYears(-age)) age--;
            ans.Add(age);
        }
        return ans;
    }
}



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

public class Main {
	static class T implements Comparable<T>{
		int id;
		double t;
		public T(int id, double t) {
			this.id = id;
			this.t = t;
		}
		public int compareTo(T o) {
			return t-o.t<0?-1:o.t-t<0?1:0;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		T[][] r = new T[3][8];
		for(int i=0;i<3;i++){
			for(int j=0;j<8;j++)r[i][j]=new T(sc.nextInt(),sc.nextDouble());
			Arrays.sort(r[i]);
		}
		T[] t = new T[6];
		int x = 0;
		for(int i=0;i<3;i++){
			System.out.printf("%d %.2f\n", r[i][0].id, r[i][0].t);
			System.out.printf("%d %.2f\n", r[i][1].id, r[i][1].t);
			t[x++] = r[i][2];
			t[x++] = r[i][3];
		}
		Arrays.sort(t);
		System.out.printf("%d %.2f\n", t[0].id, t[0].t);
		System.out.printf("%d %.2f\n", t[1].id, t[1].t);
	}
}

Measured memory_bytes: 20272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	int num = 0;
	while (1) {
		num += a;
		if (num % b == c) {
			cout << "YES" << endl;
			break;
		}
		if (num % b == 0) {
			cout << "NO" << endl;
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int fact(long long int n);

int main()
{
    long long int n,m;
    cin >> n >> m;
    if(n == m)
    {
        cout << ((fact(n) % (1000000000 + 7)) * (fact(m) % (1000000000 + 7)) * (2 % (1000000000 + 7))) % (1000000000 + 7)  << endl;
    }
    else if(n == m+1 || n == m-1)
    {

        cout << ((fact(n) % (1000000000 + 7)) * (fact(m) % (1000000000 + 7))) % (1000000000 + 7) << endl;
    }
    else if(n > m || n < m)
    {
        cout << 0 << endl;
    }
}

long long int fact(long long int n)
{
    long long int ans = 1;
    for(long long int i=1;i < n+1;i ++)
    {
        ans = (ans * i)% (1000000000 + 7);
    }

    return ans;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    K = int(input())
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


if __name__ == '__main__':
    main()


Measured memory_bytes: 68736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int x; cin >> x;
    if (x < 600) cout << 8 << endl;
    else if (x < 800) cout << 7 << endl;
    else if (x < 1000) cout << 6 << endl;
    else if (x < 1200) cout << 5 << endl;
    else if (x < 1400) cout << 4 << endl;
    else if (x < 1600) cout << 3 << endl;
    else if (x < 1800) cout << 2 << endl;
    else if (x < 2000) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3608
import Data.Char

solvea :: (Int,Int) -> Int
solvea (a,b) = min a b

solveb ::(Int,Int) -> Int -> (Int,Int)
solveb (a,b) p = (solvea (a+p, b+p), solvea(a+11-p, b+9-p))


{-
example :: (Int,Int) -> Int
example (a,b) = fst (a,b)
-}
--solvec:: string -> Int

solvec xs = foldr (\x (a,b)-> solveb (a,b) $ ssolvec $ x) (0,10) xs
ssolvec::Char -> Int
ssolvec x = digitToInt x

solved = solvea . solvec



--examplec::[Int] -> Int
-- examplec xs = foldr (\x (a,b) -> solveb(a,b) x) (0,10) xs
-- examplecc xs = foldl (\(a,b) x -> solveb(a,b) x) (0,10) xs

main = do
    x <- getLine--xはstring
    -- print $ digitToInt $ head x
    -- print $ examplec [3,6]
    -- print $ examplecc [3,6]
    -- print $ solvec "36"
    -- print $ solved "36"
    print $ solved x
    -- print $ snd f
    -- where f = solveb (2,4) 5

Measured memory_bytes: 199036
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        PriorityQueue<Pair> que = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            que.add(new Pair(in.ni(), in.ni()));
        }
        PriorityQueue<Integer> que2 = new PriorityQueue<>();
        long ans = 0;
        for (int i = 1; i <= m; i++) {
            while(!que.isEmpty()&&que.peek().a<=i) que2.add(-que.poll().b);
            if(!que2.isEmpty()) ans -= que2.poll();
        }
        out.println(ans);
    }
    public static class Pair implements Comparable<Pair>{
        int a, b;
        public Pair(int x, int y){
            this.a = x; this.b = y;
        }
        @Override
        public int compareTo(Pair o) {
            return Integer.compare(a,o.a);
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 44888
H1, M1, H2, M2, K = ARGF.gets.chomp.split.collect {|el| el.to_i}

ss = H1 * 60 + M1
ee = H2 * 60 + M2

ans = ee - K - ss

if ans < 0
  ans += 24 * 60
end

puts ans


Measured memory_bytes: 14408
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


template<class T>
vec<T> makeVec(const int n1, const T initValue) {
  return vec<T>(n1, initValue);
}


#define FOR(i, n) for (int i = 0; i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto p = next_vec<double>(in, n);
  vec<double> dp(n + 1), nx(n + 1);
  dp[0] = 1.0;
  FOR(i, n) {

    FOR(j, i + 1) {

      if (dp[j] > 0.0) {

        nx[j + 1] += dp[j] * p[i];
        nx[j] += dp[j] * (1. - p[i]);

      }

    }

    dp = nx;
    nx = makeVec<double>(n + 1, 0);
  }
  double res = 0;
  FOR(i, n + 1) {
    int o = n - i;
    if (i > o) {
      res += dp[i];
    }
  }
  out << fixed << setprecision(15) << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
ll N, M;
bool prm[100010];
ll cmb[31];

ll exp(ll c, ll x){
    if(x == 1) return c;
    ll e = exp(c, x / 2) % mod;
    e = e * e % mod;
    if(x % 2 == 1) e = e * c % mod;
    return e;
}

void culc(){
    cmb[0] = 1;
    for(int i = 1; i <= 30; i++){
        cmb[i] = (cmb[i - 1] * (N + i - 1)) % mod;
        cmb[i] = cmb[i] * exp(i, mod - 2) % mod;
    }
}

int main(){

    cin >> N >> M;

    culc();
    int s_M = sqrt(M);

    for(int i = 2; i <= s_M; i++){
        prm[i] = true;
    }
    ll ans = 1;
    for(int i = 2; i <=  s_M; i++){
        if(!prm[i]) continue;
        for(int j = i; j <= s_M; j += i){
            prm[j] = false;
        }
        ll cnt = 0;
        while(M % i == 0){
            M /= i;
            cnt++;
        }
        ans = ans * cmb[cnt] % mod;
    }
    if(M != 1) ans = ans * cmb[1] % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
 
	public class Main{
	  public static void main(String[] args) {
		  
		  Scanner scanner = new Scanner(System.in);
		  
		    String S = scanner.next();
	 		String T = scanner.next();
	 		
		  if (T.length() == S.length()+1 && T.indexOf(S) == 0) {
			  System.out.println("Yes");
		  }
		  else{
			  System.out.println("No");
		  }
		  scanner.close();
	}
}

Measured memory_bytes: 26936
package main

import (
	"fmt"
)

func main() {
	var a string
	fmt.Scan(&a)

	weathers := []string{"Sunny", "Cloudy", "Rainy"}

	num := 0
	if a == "Sunny" {
		num = 0
	} else if a == "Cloudy" {
		num = 1
	} else {
		num = 2
	}
	res := num + 1
	if res == 3 {
		res = 0
	}

	fmt.Println(weathers[res])
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
  int x,y,ama,cha;
  
  scanf("%d %d",&x,&y);

  if(y<x)
    {
      cha=x;
      x=y;
      y=cha;
    }
  
  ama=x%y;
  while(ama!=0)
    {
      x=y;
      y=ama;
      ama=x%y;
    }
  printf("%d\n",y);


  return 0;
}























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

int main() {
  int H;
  int W;
  cin >> H;
  cin >> W;
  
  for (int i = 0; i < W+2; i++){
    cout << "#";
  }
  cout << endl;
  for (int j = 0; j < H; j++){
    string S;
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  for (int k = 0; k < W+2; k++){ 
    cout << "#";
  }
  cout << endl;
}

      

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

using namespace std;

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

const int N = 1e5 + 5;

int n;

int main() {

	scanf("%d", &n);

	int res = 1;

	int lastx = 0, lasty = 0;

	for(int i = 1; i <= n; i++) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		res &= abs(y-lastx)+abs(z-lasty)<=x;
		lastx=y;
		lasty=z;
		x = abs(x);
		y = abs(y);
		z = abs(z);
		x&=1;
		y&=1;
		z&=1;
		res &= !(x^y^z);
	}

	puts(res ? "Yes" : "No");

    return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define pb push_back
#define f(n) for(ll i=0;i<n;i++)
#define ina for(ll i=0;i<n;i++)cin>>a[i];
#define all(v) v.begin(),v.end()
#define YES printf("YES\n")
#define NO printf("NO\n")
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//long long bigmod/* (a^p)%m */ ( long long a, long long p, long long m ){long long res = 1;long long x = a;while ( p ){if ( p & 1 ){res = ( res * x ) % m;}x = ( x * x ) % m;p = p >> 1;}return res;}
//ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; }
//call manipulated_seive(N) and get prime in prime vector
//const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
//ll phi[5000001];bool mark[5000001];void sievephi(ll n){ll i,j;for(ll i=1;i<=n;i++) phi[i]=i;mark[1]=true;for(ll i=2;i<=n;i++)if(!mark[i]){for(ll j=i;j<=n;j+=i){mark[j]=true;phi[j]=phi[j]/i*(i-1);}}}

/*speedup
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
// vule geli coilbi na dada cout << fixed << setprecision(6) << pi <<" "<<npi<<endl;
//Pattern? OEIS
// prime factorize?? think about 2


vector<int>v;
int a[200003];

int main()
{
    fastio;

       ll n;
       cin>>n;
       ll ans=n+1;
       for(ll i=1;i*i<=n;i++)
       {
           if(n%i==0)
           {
               v.pb(n/i);
               v.pb(i);
               ans= min(ans, i+n/i);
           }
       }
       cout<<ans-2LL<<endl;


    return 0;
}




Measured memory_bytes: 3628
w, h, n = map(int, input().split(' '))
x_axis = [0, w]
y_axis = [0, h]
for i in range(n):
    x, y, a = map(int, input().split(' '))
    if a == 1:
        x_axis[0] = max(x,x_axis[0])
    elif a == 2:
        x_axis[1] = min(x, x_axis[1])
    elif a == 3:
        y_axis[0] = max(y,y_axis[0])
    else:
        y_axis[1] = min(y, y_axis[1])
if x_axis[1]-x_axis[0] > 0 and y_axis[1]-y_axis[0] > 0:
    ans = (x_axis[1]-x_axis[0])*(y_axis[1]-y_axis[0])
else:
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem0212 : Highway Express Bus **/
struct edge{
	int from, to, cost;
	edge(int f, int t, int c):from(f), to(t), cost(c){}
	edge(){}
};
vector<edge> G;

int main()
{
	int C, N, M, S, D;
	while (cin>>C>>N>>M>>S>>D, C) {
		S--, D--;
		G.clear();
		
		rep(i, M) {
			int a, b, f;
			cin>>a>>b>>f;
			a--, b--;
			G.push_back(edge(a, b, f));
			G.push_back(edge(b, a, f));
		}
		
		int d[100][11];
		fill(d[0], d[0]+100*11, INF);
		for (int i=0; i<=C; i++) d[S][i]=0;
		
		while (true) {
			bool update=false;
			
			for (int i=0; i<G.size(); i++) {
				edge e = G[i];
				for (int j=0; j<=C; j++) {
					if (d[e.to][j] > d[e.from][j] + e.cost) {
						d[e.to][j] = d[e.from][j] + e.cost;
						update = true;
					}
					
					
					if (j+1<=C) {
						if (d[e.to][j+1] > d[e.from][j]+e.cost/2) {
							d[e.to][j+1] = d[e.from][j]+e.cost/2;
							update = true;
						}
					}
				}
			}
			
			if (!update) break;
		}
		
		int ans = INF;
		for (int i=0; i<=C; i++) {
			ans = min(ans, d[D][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1224
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    int n, m, x, c[12], a[12][12];
    cin >> n >> m >> x;
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }
    
    const int max = 12 * pow(10, 5) + 1;
    int res = max;
    rep(comb_, pow(2, n))
    {
        int sum = 0, comb = comb_;
        int und[12] = {0};
        rep(i, n)
        {
            if(comb & 1)
            {
                sum += c[i];
                rep(j, m)
                {
                    und[j] += a[i][j];
                }
            }
            comb >>= 1;
        }
        bool isAble = true;
        rep(i, m)
        {
            if (und[i] < x) isAble = false;
        }
        if (isAble) res = min(res, sum);
    }
    if (res == max) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 4040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  Int X = lin();
  Int Y = lin();
  if (X % Y == 0) {
    puts("-1");
  } else {
    printf("%lld\n", X);
  }
  return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL n,m;cin>>n>>m;

    LL work=0;

    REP(i,m){
        LL a;cin>>a;
        work+=a;
    }
    if(work>n){
        cout<<-1<<endl;
        return;
    }
    cout<<(n-work)<<endl;
    
	return;
}

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

Measured memory_bytes: 3664
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
long long K, arr [200010], lo = 1, hi = MOD-7, ret;

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> K; for(int i = 0; i < N; i++) cin >> arr[i];
    while(lo <= hi){
        long long mid = (lo+hi)/2;
        long long cnt = 0;
        for(int i = 0; i < N; i++) cnt += (arr[i]+mid-1)/mid-1;
        if(cnt <= K){
            hi = mid-1;
            ret = mid;
        }
        else lo = mid+1;
    }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

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


int main(){
  int a,b,c,d, l, r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  
  if (l > r){
    cout << "Left" << endl;
  }
  else if(l < r){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	long long m,n,ans;
	scanf("%lld %lld",&m,&n);
	if(m>=2)
		m-=2;
	if(n>=2)
		n-=2;
	ans=m*n;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

ll a, lg = 17, o=0;
vec<ll> m, c;
vec<vec<ll>> n;

ll mx(ll l, ll r){
    ll u = c[r-l+1], d = 1<<u;
    return max(n[u][l], n[u][r-d+1]);
}

ll findl(ll p, ll x){
    ll l = -1, r = p+1;
    for(; l+1!=r;){
        ll md = (l+r)/2;
        if(mx(md, p)<x) r = md;
        else l = md;
    }
    return l;
}

ll findr(ll p, ll x){
    ll l = p-1, r = a;
    for(; l+1!=r;){
        ll md = (l+r)/2;
        if(mx(p, md)<x) l = md;
        else r = md;
    }
    return r;
}

int main(){
    fast;
    c = vec<ll>(300000);
    for(int q=2; q<300000; q++) c[q] = 2<<c[q-1] > q ? c[q-1] : c[q-1]+1;
    cin>>a;
    n = vec<vec<ll>>(lg, vec<ll>(a));
    m = vec<ll>(a);
    for(int q=0; q<a; q++) cin>>m[q], n[0][q] = m[q];
    for(int q=1; q<lg; q++) for(int w=0; w+(1<<q)<=a; w++) n[q][w] = max(n[q-1][w], n[q-1][w+(1<<q-1)]);
    deque<pll> d;
    vec<ll> nl(a, -1), nr(a, -1);
    for(int q=0; q<a; q++){
        for(; d.size() && d.back().F<m[q];) nr[d.back().S] = q, d.pop_back();
        d.pb({m[q], q});
    }
    d.clear();
    for(int q=a-1; q>=0; q--){
        for(; d.size() && d.back().F<m[q];) nl[d.back().S] = q, d.pop_back();
        d.pb({m[q], q});
    }
    for(ll q=0; q<a; q++){
        ll pl = nl[q];
        ll pr = nr[q];
        ll cur = 0;
        if(pl!=-1){
            ll k = findl(pl-1, m[q]);
            cur+=(pl-k)*(pr==-1 ? a-q : pr-q);
        }
        if(pr!=-1){
            ll t = findr(pr+1, m[q]);
            cur+=(t-pr)*(pl==-1 ? q+1 : q-pl);
        }
        o+=cur*m[q];
    }
    cout<<o;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class T>
class PriorityQueue{
    vector<deque<T>>dat;
    vector<int32_t>count;
    int32_t num;
public:
    PriorityQueue():num(0){}
    void add(const T &x){
        dat.push_back({x});
        count.push_back(1);
        num++;
        while(dat.size()>1&&count[dat.size()-2]==count[dat.size()-1]){
            auto x=dat[dat.size()-2];
            auto y=dat[dat.size()-1];
            int z=count[dat.size()-1]*2;
            dat.pop_back();count.pop_back();
            dat.pop_back();count.pop_back();
            dat.push_back(deque<T>(x.size()+y.size()));
            count.push_back(z);
            merge(x.begin(),x.end(),y.begin(),y.end(),dat.back().begin());
        }
    }
    T getMin(){
        int32_t cur=0;
        while(cur<dat.size()&&dat[cur].size()==0)cur++;
        assert(cur!=dat.size());
        T res=dat[cur][0];
        for(int32_t i=cur+1;i<dat.size();i++){
            if(dat[i].size())res=min(res,dat[i][0]);
        }
        return res;
    }
    T getMax(){
        int32_t cur=0;
        while(cur<dat.size()&&dat[cur].size()==0)cur++;
        assert(cur!=dat.size());
        T res=dat[cur].back();
        for(int32_t i=cur+1;i<dat.size();i++){
            if(dat[i].size())res=max(res,dat[i].back());
        }
        return res;
    }
    void removeMin(){
        T val=getMin();
        num--;
        for(int32_t i=0;i<dat.size();i++){
            if(dat[i].size()&&dat[i][0]==val){
                dat[i].pop_front();
                return;
            }
        }
    }
    void removeMax(){
        T val=getMax();
        num--;
        for(int32_t i=0;i<dat.size();i++){
            if(dat[i].size()&&dat[i].back()==val){
                dat[i].pop_back();
                return;
            }
        }
    }
    inline int32_t size(){
        return num;
    }
};

signed main(){
    int N,M,r;
    cin>>N>>M>>r;
    vector<vector<pint>>G(N);
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].pb({b,c});
    }

    vint dist(N,INT_MAX);
    dist[r]=0;
    PriorityQueue<pint>que;
    que.add({0,r});
    while(que.size()){
        auto p=que.getMin();
        que.removeMin();
        if(dist[p.se]<p.fi)continue;
        for(auto &e:G[p.se]){
            if(dist[e.fi]<=p.fi+e.se)continue;
            dist[e.fi]=p.fi+e.se;
            que.add({dist[e.fi],e.fi});
        }
    }

    rep(i,N){
        if(dist[i]==INT_MAX)puts("INF");
        else printf("%lld\n",dist[i]);
    }
    return 0;
}

Measured memory_bytes: 19292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    
    int n;
    ll c;
    cin >> n >> c;
    
    vector<pair<ll, ll> > v(n);
    rep(i, n) cin >> v[i].F >> v[i].S;
    
    ll f[n + 1];
    f[0] = 0;
    rep(i, n) {
        f[i + 1] = f[i] + v[i].S - v[i].F;
        if (i) f[i + 1] += v[i - 1].F;
    }
    // rep(i, n + 1) cout << f[i] << " "; cout << endl;
    ll g[n + 1];
    g[0] = 0;
    rep3(i, 1, n + 1) {
        g[i] = max(g[i - 1], f[i]);
    }
    // rep(i, n + 1) cout << g[i] << " "; cout << endl;
    
    
    ll f2[n + 1];
    f2[0] = 0;
    rep(i, n) {
        f2[i + 1] = f2[i] + v[i].S - 2 * v[i].F;
        if (i) f2[i + 1] += 2 * v[i - 1].F;
    }
    ll g2[n + 1];
    g2[0] = 0;
    rep3(i, 1, n + 1) {
        g2[i] = max(g2[i - 1], f2[i]);
    }
    // rep(i, n + 1) cout << g2[i] << " "; cout << endl << endl;
    
    
    ll ans = g[n]; // すべて選べる
    ll anti = 0;
    for (int i = n - 1; i >= 0; --i) { // どこまで反時計
        
        anti += v[i].S;
        anti -= c - v[i].F;
        
        // cout << i << " " << v[i].F << " " << v[i].S << " " << anti << endl;
        chmax(ans, anti + g[i] - (c - v[i].F));
        chmax(ans, anti + g2[i]);
        // cout << ans << endl;
        anti += c - v[i].F;
    }
    cout << ans << endl;
}


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

int main() {
	int n;
	cin>>n;
	if(n%10==3)
	{
		cout<<"bon"<<endl;
	}
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
    {
    	cout<<"pon"<<endl;
    }
    else
    {
    	cout<<"hon"<<endl;
    }
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  string s;
  cin>>s;
  if((s[0]-('0'))*10+(s[1]-'0')>12||(s[0]-('0'))*10+(s[1]-'0')==0){
    if((s[2]-('0'))*10+(s[3]-'0')>12||(s[2]-('0'))*10+(s[3]-'0')==0)op("NA")
    else op("YYMM");
  } else if((s[2]-('0'))*10+(s[3]-'0')>12||(s[2]-('0'))*10+(s[3]-'0')==0){
    op("MMYY");
  }else op("AMBIGUOUS")
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &x : a) cin >> x;

    sort(a.begin(), a.end(), greater<int>());
    int Alice = 0, Bob = 0;
    for (size_t i = 0; i < a.size(); ++(++i)) Alice += a[i];
    for (size_t i = 1; i < a.size(); ++(++i)) Bob += a[i];

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
PROGRAM Battle
      IMPLICIT NONE
      integer :: a,b,c,d
      
      read*,a,b,c,d
      
      do while( .true. )
        a = a - d
        c = c - b
        
        if( c<=0 )then
          print*,'Yes';stop
        end if
        
        if( a<=0 )then
          print*,'No';stop
        end if
      end do
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 2840
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    vector<int> a(n),b(n);
    for(i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];

    }
    sort(b.begin(),b.end());
    int m1,m2;
    m1=b[n-1];
    m2=b[n-2];

    for(i=0;i<n;i++){
        if(a[i]==m1)
            cout<<m2<<'\n';
        else cout<<m1<<'\n';
    }


    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll inf = 1e9;
const int maxn = 4010;

int n, cnt[5][maxn];
char s[maxn];

int main(void) {
    fastio;
    cin >> n >> s + 1;
    for(int i = 1; i <= n; ++i) {
        if(s[i] == 'R') s[i] = 1;
        else if(s[i] == 'G') s[i] = 2;
        else if(s[i] == 'B') s[i] = 3;
        for(int j = 1; j <= 3; ++j) cnt[j][i] = cnt[j][i - 1];
        ++cnt[s[i]][i];
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i) for(int j = i + 1; j <= n; ++j) if(s[j] != s[i]) {
        int t = 6 - s[i] - s[j];
        ans += cnt[t][n] - cnt[t][j - 1];
        if(s[j + j - i] == t)   --ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3708