akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
 
#define ll long long

#define start long long t;cin>>t;while(t--)
#define in(x) cin >> x
#define in2(x, y) cin >> x >> y
#define in3(x, y, z) cin >> x >> y >> z
#define in4(x, y, z, o) cin >> x >> y >> z >> o
#define biggestFactor (n)      for (ll j = 2; j <= sqrt(n); j++){if (n % j == 0){cout << n / j << "\n";break;}}
                               //First find smallest factor and then divide that factor and the answer itself is biggest factor
                          
using namespace std;


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >>arr[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n - 1; i++)
    {
        if (arr[i] > arr[i + 1])
        {
            ans += abs(arr[i] - arr[i + 1]);
            arr[i + 1] = arr[i];
        }
    }
    cout << ans << "\n";
    	return 0;
}

Measured memory_bytes: 5188
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, M, A, B;
char X[1001][1001];

void puta(int x, int y) {
    --A;
    X[x][y] = '<';
    X[x][y + 1] = '>';
}

void putb(int x, int y) {
    --B;
    X[x][y] = '^';
    X[x + 1][y] = 'v';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    cin >> N >> M >> A >> B;

    MEM(X, '.');

    if (M % 2)for (int i = 0; i < N - 1 && B>0; i += 2)
        putb(i, 0);
    if (N % 2)for (int j = M % 2; j < M - 1 && A>0; j += 2)
        puta(0, j);

    for (int i = N % 2; i < N - 1; i += 2)for (int j = M - 2; j >= 0; j -= 2) {
        if (A >= 2) {
            for (int k = 0; k < 2 && A>0; ++k)
                puta(i + k, j);
        } else if (B >= 2) {
            for (int k = 0; k < 2 && B>0; ++k)
                putb(i, j + k);
        } else if (A == 1 && B == 1 && N%2 && M%2 && i==N-2&&j==1) {
            puta(i + 1, j - 1);
            putb(i, j + 1);
        } else if (A == 1) {
            puta(i, j);
        } else if (B == 1) {
            putb(i, j);
        }
    }

    if (A == 0 && B == 0) {
        cout << "YES" << endl;
        rep(i, N) {
            rep(j, M)cout << X[i][j];
            cout << endl;
        }
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int b[12];
double p[12];
double q[12];
double PI=acos(-1.0);
int main(){
	int x,y;
	int a;
	scanf("%d%d%d",&a,&x,&y);
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
		p[i]=PI*100*b[i];
	}
	int at=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<b[i]*10000;j++){
			double t=100.0-(sin(PI*at/500000)*x+cos(PI*at/500000)*y);
			q[i]+=PI*t/10000;
			at++;
		}
	//	printf("%f\n",q[i]);
	}
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",(int)(q[i]/p[i]*100));
	}
	printf("\n");
}

Measured memory_bytes: 1036
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

nn = []
n = []
for a, b in zip(A, B):
    d = a - b
    if d == 0:
        continue
    if d > 0:
        nn.append(d)
    else:
        n.append(-d)

ans = len(n)

if ans == 0:
    print(ans)
    exit()

s = sum(n)

if s > sum(nn):
    print(-1)
    exit()

t = 0
for v in sorted(nn, reverse=True):
    t += v
    ans += 1
    if t >= s:
        break
print(ans)


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

int main(){
  int h,l;
  cin>>h>>l;
  if(h+l==0){cout<<0<<endl;}
  if(h+l>0){cout<<1<<endl;}
  if(h+l<0){cout<<-1<<endl;}
  return 0;
}



Measured memory_bytes: 3080
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)+[(0,0)]
b=Counter(v[::-2]).most_common(2)+[(0,0)]
#most_common()の引数は頻度が高い数を何番目まで表示するか
#[(0,0)]を追加しないとvがすべて同じ場合範囲外指定してしまう
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Measured memory_bytes: 15588
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>

int n;
std::vector<std::pair<double, double>> pts;

double dist(std::pair<double, double> a, std::pair<double, double> b) {
    return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

int main() {
    std::cin >> n;
    pts.resize(n);
    for (auto& p: pts) {
        std::cin >> p.first >> p.second;
    }

    std::vector<int> perm;
    for (int i = 1; i <= n; i++) {
        perm.push_back(i);
    }

    double total_dist = 0, ways = 0;
    do {
        ways += 1;
        for (int i = 1; i < (int)perm.size(); i++) {
            total_dist += dist(pts[perm[i] - 1], pts[perm[i - 1] - 1]);
        }
    } while (std::next_permutation(perm.begin(), perm.end()));

    std::cout << std::fixed << std::setprecision(9) << total_dist / ways << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if(n == 0) {
				break;
			}
			int [] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = scan.nextInt();
			}
			int min = Integer.MAX_VALUE;
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(i != j) {
						int k = Math.abs(a[i] - a[j]);
						min = Math.min(min, k);
					}
				}
			}
			System.out.println(min);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 46936
// date: July 27 2020

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pii;


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    cout << ((n % 1000 != 0) ? 1000 - (n % 1000) : 0);
    return 0;
}


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

int main()
{
    int n;
    scanf("%d", &n);

    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);

    vector<int> out;
    for (int i = n; i > 0; --i)
    {
        for (int j = 2 * i; j <= n; j += i)
            a[i] ^= a[j];
        if (a[i]) out.push_back(i);
    }

    printf("%d\n", (int)out.size());
    reverse(out.begin(), out.end());
    for (int i : out)
        printf("%d ", i);
}


Measured memory_bytes: 2424
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>b)
        for(int i=0;i<a;i++){
           // cout<<b*pow(10,i)<<endl;
            ans+=b*pow(10,i);
           // cout<<ans<<endl<<endl;
        }
    else
        for(int i=0;i<b;i++){
            //cout<<a*pow(10,i)<<endl;
            ans+=a*pow(10,i);
            //cout<<ans<<endl<<endl;
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import qualified Data.IntMap.Strict as M
import           Data.List

main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve as

solve :: [Int] -> Int
solve = M.foldl' (+) 0
    . fmap (\x -> x * (x - 1) `div` 2)
    . foldl' (\mp x -> M.insertWith (+) x 1 mp) (M.singleton 0 0)
    . scanl' (+) 0


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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B == C + D) {
		cout << "Balanced";
	}
	else if (A + B > C + D) {
		cout << "Left";
	}
	else { cout << "Right"; }
	return 0;
}

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

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int main(){
	stack<int> st;
	int n;
	while(cin >> n){
		if(n==0){
			cout << st.top() << endl;
			st.pop();
		}
		else st.push(n);
	}
	return 0;
}

Measured memory_bytes: 1200
N = int(input())
SAC = 0
SWA = 0
STLE = 0
SRE = 0
for i in range(N):
  tmp = input()
  if tmp == 'AC':
    SAC += 1
  elif tmp == 'WA':
    SWA += 1
  elif tmp == 'TLE':
    STLE += 1
  elif tmp == 'RE':
    SRE += 1

print("AC x " + str(SAC))
print("WA x "+ str(SWA))
print("TLE x "+str(STLE))
print("RE x "+str(SRE))


Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n,k; cin >> n >> k;
    int cnt[n];
    rep(i,n) cnt[i] = 0;
    rep(i,k){
        int d; cin >> d;
        rep(j,d){
            int a; cin>> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    rep(i,n) if(cnt[i] == 0) ans++;
    cout << ans ;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
#define prev prev228
#define all(x) (x).begin(), (x).end()

long long n;

int ask(long long x)
{
    cout << "? " << x << endl;
    string s;
    cin >> s;
    return (s == "Y");
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long l = 1e11 - 1, r = 1e12 - 1;
    while (l + 1 < r)
    {
        long long m = (l + r) / 2;
        if (ask(m)) r = m;
        else l = m;
    }
    while (r % 10 == 0) r /= 10;
    long long k = r;
    vector<int> digits;
    while (k > 0)
    {
        digits.push_back(k % 10);
        k /= 10;
    }
    sort(all(digits));
    if (digits[0] != 9)
    {
        while (1)
        {
            if (ask(r + 1))
            {
                cout << "! " << r;
                return 0;
            }
            r = 10 * r;
        }
    }
    else
    {
        while (1)
        {
            if (ask(r + 1))
            {
                cout << "! " << r / 10;
                return 0;
            }
            r = 10 * r;
        }
    }
}


Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll INF=1000000000000000;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
	ll n,w;
	cin>>n>>w;
	ll W[n+1],P[n+1];
	for(ll i=1;i<=n;i++)
	{
		cin>>W[i]>>P[i];
	}
	ll dp[w+1];
	for(ll i=0;i<=w;i++)
		dp[i]=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=w;j>=W[i];j--)
		{
			dp[j]=max(dp[j],dp[j-W[i]]+P[i]);
		}
	}
	cout<<dp[w]<<endl;
}

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

int main() {
    ll N, K;
    cin >> N >> K;

    ll ans;

    if (K % 2 == 1) {
        ll num = N / K;
        ans = num * num * num;
    } else {
        ll num =  N / K;
        ans = num * num * num;

        ll num2 = (N + K/2) / K;
        ans += num2 * num2 * num2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}


// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main(){
    int ans=0;
    string S;
    cin >> S;

    for(int i=0; i<S.length(); i++){
        int temp=0;
        int j=i;
        while(S[j]=='A'||S[j]=='T'||S[j]=='G'||S[j]=='C'){
            j++;
             temp++;
        }
        ans=max(temp,ans);
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())

ary = [[-1] * N for i in range(N)]
for i in range(N):
    for j in range(int(input())):
        x, y = map(int, input().split())
        ary[i][x - 1] = y

ret = 0
for a in range(2 ** N):
    flg = True
    for i in range(N):
        if (a >> i & 1) == 1:
            for j in range(N):
                if ary[i][j] == -1:
                    continue
                if (a >> j & 1) != ary[i][j]:
                    flg = False
                    break

    if flg:
        n = sum([a >> i & 1 for i in range(N)])
        ret = max(ret, n)

print(ret)


Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void){
    int a, b, c;
 
    scanf("%d%d%d", &a, &b, &c);
 
    if(a*b*c == 5*5*7 && a+b+c == 17 && a*b+b*c+c*a == 95){
        printf("YES");
        return 0;
    }
    printf("NO");
 
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

int main(){

    std::string s;
    std::cin >> s;

    std::string output;

    int i, len;
    i = 0;
    len = s.length();

    while (i < len)
    {   
        while (s[i] == 'B')
        {
            if (i == 0)
                s.erase(i,1);
            else
            {
                s.erase(i-1,2);
                --i;
            }
        }
        len = s.length();
        i++;
    }   
    
    std::cout << s << std::endl;
    return 0;
}


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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

inline Point curr(const Polygon &p, const int &i) { return p[i % p.size()]; }

inline Point next(const Polygon &p, const int &i) {
    return p[(i + 1) % p.size()];
}

inline Point prev(const Polygon &p, const int &i) {
    return p[(i + p.size() - 1) % p.size()];
}

struct Circle {
    Point p;
    double r;
    Circle(Point p = Point(), double r = 0) : p(p), r(r) {}
};

int intersectCC(Circle a, Circle b) {
    double dsq = norm(a.p - b.p);
    double rs = (a.r + b.r) * (a.r + b.r);
    double rd = (a.r - b.r) * (a.r - b.r);
    if (sgn(dsq - rs) == 1) // 重なっていない
        return 4;
    else if (sgn(rs - dsq) == 0)
        return 3;
    else if (sgn(rs - dsq) > 0 && sgn(dsq - rd) > 0)
        return 2;
    else if (sgn(dsq - rd) == 0)
        return 1;
    else
        return 0;
}

int main(){
    double c1x, c1y, c1r, c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;
    cout << intersectCC(Circle(Point(c1x, c1y), c1r), Circle(Point(c2x, c2y), c2r)) << endl;

    return 0;
}



Measured memory_bytes: 3280
#include <stdio.h>

int main(){

  int a,b;
  char ch;

  while(1){
    scanf("%d %c %d",&a, &ch, &b);
    if ( ch == '?' ) break;
    if( ch =='+'){
      printf("%d\n",a+b);
    } if( ch =='-'){
      printf("%d\n",a-b);
    } if( ch =='*'){
      printf("%d\n",a*b);
    } if( ch =='/'){
      printf("%d\n",a/b);
    }
  }
  return 0;
}

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

void up_down(int w) {
  for(int i=0;i<w+2;i++){
    cout<<'#';
  }
  cout<<endl;
}

int main() {
  int h, w;
  cin>>h>>w;
  up_down(w);
  for(int i=0;i<h;i++){
    string s;
    cin>>s;
    cout<<'#'<<s<<'#'<<endl;
  }
  up_down(w);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M;
    cin >> N >> M;
    int l[N], r[N];
    rep(i, N) cin >> l[i] >> r[i];
    int ans[M+1], query[M+2];
    fill(ans, ans+M+1, 0);
    fill(query, query+M+2, 0);
    rep(i, N){
        //未チェックの中で最小のもの
        int j = 1;
        //m:=チェックした中で最小のもの
        int m = M+1;
        while(j < m){
            int L = (l[i]+j-1)/j, R = r[i]/j;
            if(L <= R) ans[j]++;
            chmin(R, m-1);
            chmax(L, j+1);
            if(R >= L) query[L]++, query[R+1]--;
            m = L, j++;
        }
    }
    int sum = 0;
    rep2(i, 1, M){
        sum += query[i];
        cout << ans[i]+sum << endl;
    }
}

Measured memory_bytes: 4096
#include<stdio.h>
 
int main(void)
{
  int A,B,c;
  
  scanf("%d %d",&A,&B);

  c = A+B;
  if(c<A-B)
  	c = A-B;
  if(c<A*B)
  	c = A*B;

  printf("%d",c);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 2000005;
const int MOD = 998244353 ;




void solve(){
    int x, y;
    cin>>x>>y;
    if((y > (4*x)) || (y < (2*x))){cout<<"No";return ;}
    if(y%2){
        cout<<"No";
    }
    else cout<<"Yes";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

vector<pair<int, int>> graph[1000009];
ll dist[1000009];
bool used[1000009];

void DFS(int start) {
	used[start] = 1;
	for (auto v : graph[start]) {
		if (!used[v.first]) {
			dist[v.first] = dist[start] + v.second;
			DFS(v.first);
		}
	}
}

int main() {
	ll n, q, k, a, b, c;
	cin>>n;
	for (int i = 0; i < n - 1; i++) {
		cin>>a>>b>>c;
		graph[a].push_back(pair<int, int>(b, c));
		graph[b].push_back(pair<int, int>(a, c));
	}
	cin>>q>>k;
	DFS(k);
	while (q--) {
		int x, y;
		cin>>x>>y;
		cout<<dist[x] + dist[y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	ll ans=1000;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1]){
			ll op = ans/a[i-1];
			ll cur = ans%a[i-1];
			ans = cur+op*a[i];
		}
	}
	cout<<ans;


    return 0;
}


Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int ds = in.nextInt();
            int[] H = new int[ds];
            int[] res = new int[ds];
            for (int i = 0; i < ds; i++) H[i] = in.nextInt();
            for (int i = H.length - 2; i >= 0; i--) {
                int v1 = (i < H.length - 1) ? Math.abs(H[i] - H[i + 1]) + res[i + 1] : Integer.MAX_VALUE / 2;
                int v2 = (i < H.length - 2) ? Math.abs(H[i] - H[i + 2]) + res[i + 2] : Integer.MAX_VALUE / 2;
                res[i] = Math.min(v1, v2);
            }
            out.println(res[0]);
        }

    }
}



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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
string s;
int k,ans=0;
signed main(){
    cin>>s>>k;
    int l=s.size();
    bool same=true;
    rep(i,l-1){
        if(s[i]!=s[i+1])same=false;
    }
    if(same){
        int length=l*k;
        cout<<length/2<<endl;
        return 0;
    }
    if(s[0]==s[l-1]){
        int b=1,e=1;
        for(int i=0;i<l;i++){
            if(s[i]!=s[i+1])break;
            else b++;
        }
        for(int i=l-1;i>=0;i--){
            if(s[i]!=s[i-1])break;
            else e++;
        }
        int sum=b+e;
        ans+=(b/2)+(e/2);
        sum/=2;
        ans+=sum*(k-1);
        s=s.substr(b,l-e);
        l-=b+e;
    }
    rep(i,l-1){
        if(s[i]==s[i+1]){
            ans+=k;
            i++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int a[100000];

int main(){
	int N;
  	map<int, int> mp;
  	int ans = 0;
  
  	cin >> N; 
  
  	for(int i = 0; i < N; i++){
      cin >> a[i];
    }

   	for(int i = 0; i < N; i++){
      mp[a[i]] += 1;
    }

	for(auto x : mp){
      if( x.first < x.second ){
        ans += x.second - x.first;    
      }
      else if( x.first > x.second ){
        ans += x.second;    
      }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,K;
    cin>>N>>K;
    long long stone[N];
    long long dp[N+1];
    for(int i=0;i<N;++i){
        cin>>stone[i];
        dp[i]=1000000002;
    }

    dp[0]=0;
    for(int i=0;i<N;++i){
        for(int j=1;j<=K;++j){
          if(i+j<N) dp[i+j]=min(dp[i+j],dp[i]+llabs(stone[i]-stone[i+j]));
        }

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

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, M; cin >> N >> M;
	vector<PLL>a(M);
	FOR(i, 0, M) {
		cin >> a[i].first >> a[i].second;
	}
	sort(ALL(a), [](const PLL&a, const PLL&b) {
		if (a.second != b.second) {
			return a.second < b.second;
		}
		else {
			return a.first > b.first;
		}
	});
	LL s = 0; LL ans = 0;
	FOR(i, 0, M) {
		if (s <= a[i].first) {
			s = a[i].second;
			ans++;
		}
	}

	std::cout << ans << endl;

	return 0;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
	else if ((A + B) == (C + D)){
      cout << "Balanced" << endl;
    }
	else {
      cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b=mii()

for i in range(1,10001):
    c=floor(i*0.08)
    d=floor(i*0.10)

    if c==a and d==b:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    char a;
    cin >> a;
    cout << char(a + 1) << endl;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

sums = 0.0
for perm in list(itertools.permutations(list(range(N)))):
    bef = perm[0]
    for i in perm[1:]:
        itoj = math.sqrt((xy[bef][0] - xy[i][0])**2 + (xy[bef][1] - xy[i][1])**2)
        sums += itoj
print(sums/math.factorial(N))

Measured memory_bytes: 7972
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template <class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    lint x;
    cin >> x;

    lint ans = 0;
    ans += x / 11;

    if (x % 11 == 0)
    {
        cout << 2*ans << endl;
    }
    else if (x % 11 <= 6)
    {
        cout << 2*ans + 1 << endl;
    }
    else 
    {
        cout << 2*ans + 2 << endl;
    }

    return 0;
}


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

int main() {
	int D, C[26];
	cin >> D;
	for (int i = 0; i < 26; i++) cin >> C[i];
	vector<int> L(26, -1);
	vector<vector<int> > S(D, vector<int>(26));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) cin >> S[i][j];
	}
	for (int i = 0; i < D; i++) {
		long long MAX = -1000000000000000, ID = -1;
		for (int j = 0; j < 26; j++) {
			if (MAX < S[i][j] + C[j] * 8 * (i - L[j])) MAX = S[i][j] + 8 * C[j] * (i - L[j]), ID = j;
		}
		L[ID] = i;
		cout << ID + 1 << endl;
	}
}

Measured memory_bytes: 3688
import java.text.DecimalFormat;
import java.util.Scanner;

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

		double a = ((double)L) / 3.0;
		DecimalFormat df = new DecimalFormat("0.000000000000");
		System.out.println(df.format(a * a * a));
	}
}


Measured memory_bytes: 21588
#include <stdio.h>

int area[24][24];
int dirx[] = {-1, 0, 1, 0};
int diry[] = {0, 1, 0, -1};

void search(int x, int y)
{
	int i, nx, ny;
	area[y][x] = 0;
	
	for (i = 0; i < 4; i++){
		nx = x + dirx[i];
		ny = y + diry[i];
		if (nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && area[ny][nx])search(nx, ny);
	}
}

int main(void)
{
	int i, j;
	char S[24];
	int count;
	
	while (1){
		count = 0;
		for (i = 0; i < 12; i++){
			if (scanf("%s", S) == EOF) return 0;
			for(j = 0; j < 12; j++) area[i][j] = S[j] - '0';
		}
		
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				if (area[i][j]){
					search(j, i);
					count++;
				}
			}
		}
		
		printf("%d\n", count);
	}
}

Measured memory_bytes: 544
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f;
    scanf("%d%d",&a,&b);

    d=(a+b);
    e=(a-b);
    f=(a*b);
    if(d>e && d>f) {c=d;}
    if(e>d && e>f) {c=e;}
    if(f>d && f>e) {c=f;}
    printf("%d",c);

    return 0;
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    if(n == 1){
        cout<<abs(a[0])<<endl;
        return 0;
    }

    ll ans = INF;
    for(ll i=0;i<n-k+1;++i){
        ll index = i + k - 1;
        ans = min(ans, min(abs(a[i]) + abs(a[i] - a[index]), abs(a[index]) + abs(a[i] - a[index])));
    }
    ans = max(ans, (ll)0);
    cout<<ans<<endl;

    return 0;
}

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

int s[2],ii[2],jj[2];
bool f[2];

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N,D[2]; cin>>N>>D[0]>>D[1];
  rep(i,2){
    while(D[i]%4==0){
      D[i]/=4;
      s[i]++;
    }
  }
  vector<pair<int,int>> V;
  rep(i,2*N){
    rep(k,2) ii[k]=(i>>s[k]);
    rep(j,2*N){
      rep(k,2) jj[k]=(j>>s[k]);
      rep(k,2){
        f[k]=(D[k]%2==1) ? ((ii[k]+jj[k])%2==0) : (ii[k]%2==0) ;
      }
      if(f[0]&&f[1]) V.push_back({i,j});
    }
  }
  rep(i,N*N) cout<<V[i].first<<" "<<V[i].second<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

int a, b, c, d, e, k;

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

    cin >> a >> b >> c >> d >> e >> k;

    if (e - a <= k)
    {
        cout << "Yay!\n";
    }
    else
    {
        cout << ":(\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  vector<ll> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  repp(i, 2, N) { L[i] = L[i - 1] + L[i - 2]; }
  cout << L[N] << endl;
}

Measured memory_bytes: 256
N,_=gets.split(" ").map{|i| i.to_i}
A=gets.split(" ").map{|i| i.to_i}
B=gets.split(" ").map{|i| i.to_i}
Asum = A.inject{|sum,a| sum+a}
Bsum = B.inject{|sum,b| sum+b}
if (Asum < Bsum)
	puts -1
	exit 0
end
AminB = Array.new(N) { |i| 0 }
for i in 0..(N-1)
	AminB[i] = A[i] - B[i]
end
AminB_positive_sorted = AminB.reject{|n| n < 0}.sort{|n,m| n <=> m}
maxdif = Asum - Bsum
i = 0
cnt = 0
# p AminB_positive_sorted
# p maxdif
while(maxdif >= 0 && i <= AminB_positive_sorted.size-1)
	if(AminB_positive_sorted[i] <= maxdif)
		maxdif -= AminB_positive_sorted[i]
		cnt += 1
		i += 1
	else
		puts N-cnt
		exit 0
	end
end
if(i == AminB_positive_sorted.size)
		puts N-cnt
		exit 0
end
puts N





Measured memory_bytes: 17596
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container, std.typecons;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto eij = new DList!edge[](n);

  foreach (_1; n.iota) {
    auto rd = readln.splitter;
    auto i = rd.front.to!size_t; rd.popFront;
    auto k = rd.front.to!size_t; rd.popFront;
    foreach (_2; k.iota) {
      auto v = rd.front.to!size_t; rd.popFront;
      auto c = rd.front.to!int; rd.popFront;
      eij[i].insertBack(edge(v, c));
    }
  }

  auto wi = dijkstra(n, eij, 0);
  foreach (i, w; wi)
    writefln("%d %d", i, w);
}

alias Tuple!(size_t, "v", int, "w") edge;

int[] dijkstra(size_t n, DList!edge[] eij, size_t s)
{
  auto wi = new int[](n);
  wi[] = -1;

  auto bi = new edge[](1_000_000);
  bi[0] = edge(s, 0);
  auto hi = bi.heapify!("a.w > b.w")(1);
  while (!hi.empty) {
    auto es = hi.front; hi.removeFront;
    if (wi[es.v] >= 0) continue;
    wi[es.v] = es.w;

    foreach (et; eij[es.v]) {
      if (wi[et.v] >= 0) continue;
      wi[et.v] = min(wi[et.v], es.w + et.w);
      hi.insert(edge(et.v, es.w + et.w));
    }
  }

  return wi;
}

Measured memory_bytes: 37532
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(n int) int {
	if n < 0 {
		n = -n
	}
	return n
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	X := make([]int, n)
	Y := make([]int, n)
	H := make([]int, n)

	for i := 0; i < n; i++ {
		X[i] = nextInt()
		Y[i] = nextInt()
		H[i] = nextInt()
	}

	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			var h int
			max := 1000 * 1000 * 1000 * 2
			var invalid bool
			for i := 0; i < n; i++ {
				if h == 0 {
					if H[i] == 0 {
						sum := abs(x-X[i]) + abs(y-Y[i])
						if sum < max {
							max = sum
						}
					} else {
						h = abs(x-X[i]) + abs(y-Y[i]) + H[i]
						if h > max {
							invalid = true
							break
						}
					}
				} else {
					if H[i] == 0 {
						if h-(abs(x-X[i])+abs(y-Y[i])) > 0 {
							invalid = true
							break
						}
					} else {
						if H[i] != h-(abs(x-X[i])+abs(y-Y[i])) {
							invalid = true
							break
						}
					}
				}
			}

			if invalid {
				continue
			}
			if h == 0 {
				h = 1
			}
			fmt.Printf("%v %v %v\n", x, y, h)
			return
		}
	}
}


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

int main() {
	int h,w;cin>>h>>w;
	int hi=-1,wi=-1;
	bool found = false;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			string s;cin>>s;
			if(s=="snuke"){
				hi=i;
				wi=j;
				found = true;
				break;
			}
		}
		if(found)break;
	}
	cout << (char)('A' + wi) << hi+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

constexpr int mod = 1000000007;
int t;

int binom(int n, int k){
  long long int r = 1;
  for(int i = 0; i < k; i++){
    r = r * (n-i) % mod;
    while(r % (i+1)) r += mod;
    r = r / (i+1);
  }
  return r % mod;
}


/*
[x^N] 1 / [(1-x)^16(1+x)^5]
[x^N] 1 / [(1-x)^11(1-x^2)^5]
[x^N] (1+x)^11 / (1-x^2)^16
*/

int main(){
  scanf("%d", &t);
  while(t--){
    int n;
    scanf("%d", &n);
    if(n < 5){
      puts("0");
      continue;
    }
    n -= 5;
    long long int r = 0;
    for(int i = n/2; 2*i >= n-11; --i){
      r = (r + (long long) binom(i+15, 15) * binom(11, n-2*i)) % mod;
    }
    printf("%lld\n", r);
  }

  return 0;
}


Measured memory_bytes: 1736
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean A = false;
		for(int i=0; i<N; i++) {
			String C = sc.next();
			if(C.contains("Y")) {
				A = true; 
				break;
			}
		}
		System.out.println(A ? "Four" : "Three");
	}
}

Measured memory_bytes: 35860
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string str;
    cin >> str;
    int K;
    cin >> K;
    for(int i=0; i<str.size()-1; i++)
    {
        if(str[i] == 'a') continue;
        int tmp = 26 - (str[i] - 'a');
        if(K >= tmp){
            str[i] = 'a';
            K -= tmp;
        }
        if(K == 0) break;
    }
    str[str.size()-1] = (str[str.size()-1] - 'a' + K) % 26 + 'a';
    cout << str << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    M += H * 60;
    double theta = M * (11.0 / (12.0 * 60.0)) * (2.0 * M_PI);
    cout << fixprec(14) << sqrt(A * A + B * B - 2.0 * A * B * cos(theta)) << endl;
    return 0;
}

Measured memory_bytes: 4216
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll> & v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


bool a[100010];
string gcs(string s, string t) {

	ll high = min(s.size(), t.size());
	ll low = 0;
	ll mid = -1;
	for (size_t i = 0; i < 20; i++)
	{
		mid = (high + low) / 2;
		string st = s.substr(0, mid);
		string tt = t.substr(0, mid);
		if (st == tt) {
			low = mid;
		}
		else high = mid;

		if (s.size() <= mid || t.size() <= mid) continue;
		st = s.substr(0, mid + 1);
		tt = t.substr(0, mid + 1);
		if (st == tt) {
			low = mid + 1;
			mid = mid + 1;
		}
	}
	return s.substr(0, mid);
}

ll dp[100010][6];
int pi[100010][6];
ll dist[7][7];

ll calc(ll now, ll b, int c, int p, int v) {

	if (b < 0) return INF;
	ll dis = now - b - 1LL;

	ll val = dp[b][p] + max(dis, dist[p][c]);
	if (v > val) {
		val = min(val, calc(now, pi[b][p], c, p, val));
	}
	return val;
}

struct bridge {
	int l, r;
};
bridge bs[100010];
bool cm(bridge& left, bridge& right) {
	return left.r < right.r;
}
void solv() {
	int n, m;
	cin >> n >> m;
	for (size_t i = 0; i < m; i++)
	{
		cin >> bs[i].l >> bs[i].r;
	}
	sort(bs, bs + m, cm);
	int tail = 0;
	int res = 0;
	for (size_t i = 0; i < m; i++)
	{
		if (tail <= bs[i].l) {
			res++;
			tail = bs[i].r;
		}

	}

	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  int N,a,b,c;
  cin >>N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
  SORT(v);
  cout << v[N/2]-v[N/2-1];
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define endl '\n'
#define ll long long

using namespace std;

int arr[101];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, d;
	int num;
	int ans = 0;
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			cin >> num;
			arr[num]++;
		}
	}

	for (int j = 1; j <= n; j++)
		if (!arr[j]) ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644