akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string t = "AKIHABARA";
    string::iterator itr = s.begin();
    bool ok = true;
    rep(i, t.size()) {
        if(itr == s.end() and i != t.size()-1) {
            ok = false;
            break;
        }
        if(t[i] != 'A') {
            if(*itr != t[i]) {
                ok = false;
                break;
            }
            itr++;
        }
        else {
            if(*itr == 'A') {
                itr++;
            }
        }
    }
    if(itr != s.end()) ok = false;

    cout << (ok?"YES":"NO") << endl;
}


Measured memory_bytes: 3628
H, W, D = map(int, input().split())
position = {}

for i in range(H):
    row = list(map(int, input().split()))
    for j, value in enumerate(row):
        position[value] = (i, j)

costs = {i: 0 for i in range(1, D+1)}
for i in range(1, D+1):
    current = i + D
    while current <= H*W:
        costs[current] = costs[current-D] + abs(position[current][0] - position[current-D][0]) + abs(position[current][1] - position[current-D][1])
        current += D

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    MP = costs[R] - costs[L]
    print(MP)

Measured memory_bytes: 35984
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  cout << n*n*n << endl;
  return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int k, n;
	cin >> k >> n;
	
	if(n <= 500 * k) cout << "Yes";
	else cout << "No";

	return 0;
}

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

int main(){
	int H,W;
	cin >> H >> W;
	while(H != 0 || W != 0){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}


Measured memory_bytes: 3072
n, m = map(int, input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = []

for i in range(n):
    a[i] = list(map(int, input().split()))

for i in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    print(s)



Measured memory_bytes: 6024
N, M, Q = map(int, input().split())
L = []
for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    ai -= 1
    bi -= 1
    L.append((ai, bi, ci, di))


def dfs(A):
    if len(A) == N:
        r = 0
        for Li in L:
            if A[Li[1]] - A[Li[0]] == Li[2]:
                r += Li[3]
        return r
    r = 0
    for i in range(A[-1], M + 1):
        r = max(r, dfs(A + [i]))
    return r


print(dfs([1]))


Measured memory_bytes: 9220
<?php

fscanf(STDIN, "%d %d %d %d", $n, $m, $x, $y);
$x_arr = explode(' ', trim(fgets(STDIN)));
$y_arr = explode(' ', trim(fgets(STDIN)));

$x_arr[] = $x;
$y_arr[] = $y;

$max_x = max($x_arr);
$min_y = min($y_arr);

echo $max_x < $min_y ? 'No War' : 'War';


Measured memory_bytes: 4604
N, M = map(int, input().split())

roads = [[] for _ in range(N)]
for _ in range(M):
    _from, _to = map(int, input().split())
    roads[_from-1].append(_to-1)
    roads[_to-1].append(_from-1)

visited = [False] * N
ans = [None] * N
visited[0] = True
prevs = [0]
for _ in range(N):
    next_prevs = []
    for prev in prevs:
        for to in roads[prev]:
            if not visited[to]:
                visited[to] = True
                ans[to] = prev
                next_prevs.append(to)
    prevs = next_prevs

if not all(visited):
    print("No")
    exit(0)
print("Yes")
for i in range(1, N):
    print(ans[i]+1)


Measured memory_bytes: 34808
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int i;
	char s[111111];
	cin >> s;
	if (s[0] == s[1]) {
		cout << "1 2" << endl;
		return 0;
	}
	for (i = 2; s[i] != '\0'; i++) {
		if (s[i] == s[i - 1] || s[i] == s[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){

    string a;
    cin>>a;

    if(a=="SSS"){
        cout<<0<<endl;
    }else if(a=="SSR" || a=="SRS" || a=="RSS" || a=="RSR"){
        cout<<1<<endl;
    }else if(a=="RRR"){
        cout<<3<<endl;
    }else{
        cout<<2<<endl;
    }


    return 0;
}

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

bool isIn(int x, int y, int x_max, int x_min, int y_max, int y_min){
	if(x<=x_max && x>=x_min){
		if(y<=y_max && y>=y_min){
			return true;
		}
	}
	return false;
}

int main(){

	int x,y;
	cin >> x >> y;

	long int count = 0;
	int x_min=0, x_max=0, y_min=0, y_max=0;
	int f_n2=1, f_n1=1, f=1;
	if( isIn(x,y,x_max,x_min,y_max,y_min) ){cout << 1 << endl; return 0;};

	//n=1
	++count;
	x_max = 1;
	if (isIn(x,y,x_max,x_min,y_max,y_min)){cout << count%3 + 1 << endl; return 0;}	

	while(true){
		++count;
		f_n2 = f_n1;
		f_n1 = f;
		f = f_n2 + f_n1;

		if(count%4==2){y_max += f;}
		else if(count%4==3){x_min -= f;}
		else if(count%4==0){y_min -= f;}
		else {x_max += f;}
		if(isIn(x,y,x_max,x_min,y_max,y_min)){cout << count%3+1 << endl; break;}
	}

	return 0;
}



Measured memory_bytes: 3092
H,W,K = [int(x) for x in input().split()]
dp=[[0]*W for _ in range(H+1)]
dp[0][0]=1
for i in range(H):
  for j in range(W):
    for bit in range(1<<(W-1)):
      flag = 1
      for k in range(W-2):
        if (bit&1<<k) and (bit&1<<k+1):
          flag = 0
      if flag!=1:
        continue
      nj = j
      if (bit&1<<j):
        nj = 1+j
      if j>0 and (bit&1<<(j-1)):
        nj = j-1
      dp[i+1][nj] +=dp[i][j]
      dp[i+1][nj] %=(10**9+7)
print(dp[H][K-1])

Measured memory_bytes: 44652
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int p, q, r;
  scan(p, q, r);
  int ans = min(p + q, q + r);
  ans = min(ans, r + p);
  print(ans);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  string S; cin >> S;
  vector<char> op(3);
  vector<int> a(4);
  int sum;
  
  rep(i,4){
    a[i] = S[i] - '0';
  }
  
  for(int bit =0; bit <(1 << 3); bit++){
    sum = a[0];
    
    rep(i,3){
      if(bit &(1 << i)){
        sum += a[i+1];
        op[i] = '+';
      }
      else{
        sum -= a[i+1];
        op[i] = '-';
      }
    }
    if(sum == 7){
      break;
    }
  }
  cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
}

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

int main(void)
{
	int n, i;
	double x[101],y[101],d;
	double Dxy,Dxy2,Dxy3,Dxyp;	
	
	scanf( "%d", &n );
	
	for( i=0; i<n; i++ ) {
		scanf( "%lf", &x[i]);
	}
	for( i=0; i<n; i++ ) {
		scanf( "%lf", &y[i]);
	}

	
	Dxy=Dxy2=Dxy3=Dxyp=0;
	for( i=0; i<n; i++ ) {
		d = fabs( x[i]-y[i] );
		
		Dxy += d;
		Dxy2 += pow( d, 2 );
		Dxy3 += pow( d, 3 );
		if( Dxyp < d ) {
			Dxyp = d;
		}
	}
	
	printf( "%lf\n%lf\n%lf\n%lf\n", Dxy,sqrt(Dxy2),cbrt(Dxy3),Dxyp );
	
	return 0;
}


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

int main ()
{
	long long a, b, c;
	// c - a - b > 0 e 4ab > (c - a - b)^2
	cin >> a >> b >> c;
	if(c - a - b > 0 and 4 * a * b < (c - a - b) * (c - a - b))
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
#define pb push_back


int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    int arr[m];
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(n-sum>=0) cout << n-sum;
    else cout<<-1;
    return 0;
                                                     

  
}

Measured memory_bytes: 3692
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, M, K = Scanner.map_int()
    A = Scanner.map_int()
    B = Scanner.map_int()
    time = 0
    ans = 0
    for a in A:
        if time + a > K:
            break
        time += a
        ans += 1
    x = ans
    j = 0
    while time <= K and j < M:
        if time + B[j] > K:
            break
        time += B[j]
        j += 1
        ans += 1
    tmp = ans
    for i in reversed(range(x)):
        time -= A[i]
        tmp -= 1
        while time <= K and j < M:
            if time + B[j] > K:
                break
            time += B[j]
            j += 1
            tmp += 1
        ans = max(ans, tmp)
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

string S, T;
int A, B;
string U;

int main(){
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if(S == U) cout << A - 1 << " ";
  else cout << A << " ";
  if(T == U) cout << B - 1 << endl;
  else cout << B << endl;

  return 0;
}



    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int m, n, y; cin >> m >> n >> y;
  cout << m * n / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int t[150];
signed main(){
    int n,m,sum = 0;
    cin >> n;
    reps(i,n){
        cin >> t[i];
        sum += t[i];
    }   
    cin >> m;
    int p,x;
    rep(i,m){
        cin >> p >> x;
        cout << sum + (x - t[p]) << '\n';
    }   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    VEC(int) pos(5);
    READVEC(pos);
    int K;
    cin >> K;
    int bad = 0;
    FOR(i, 0, 5)
        FOR(j, i + 1, 5)
            if (pos[j] - pos[i] > K)
                bad = 1;

    cout << (bad ? ":(" : "Yay!") << endl;
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int _=1e5+5;
const int mod=1e9+7;
#define ll long long
inline int read()
{
	char ch='!';int z=1,num=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')z=-1,ch=getchar();
	while(ch<='9'&&ch>='0')num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
	return z*num;
}
ll n,a[_],jjc[_];
ll ksm(ll a,ll b){ll r=1;for(;b;b>>=1,a=a*a%mod)if(b&1)r=a*r%mod;return r;}
int main()
{
	n=read();ll tmp=1;
	for(int i=1;i<=n;++i)
		a[i]=read(),tmp=tmp*i%mod;
	for(int i=1;i<=n;++i)
		jjc[i]=(jjc[i-1]+tmp*ksm(i,mod-2))%mod;
	ll Ans=0;
	for(int i=1;i<=n;++i)
		(Ans+=(jjc[i]+jjc[n-i+1]-tmp)%mod*a[i]%mod)%=mod;
	(Ans+=mod)%=mod;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = 1;
    ll hhh = b - a;
    if (hhh <= 2 || k <= (a - 1))
    {
        ans += k;
    }
    else
    {
        ans += (a - 1);
        k -= (a - 1);
        ans += (k / 2) * hhh;
        ans += k % 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3", "3 5 -1" ].parse.expand.solve == "12\n8\n10" );
	assert( [ "5", "1 1 1 2 0" ].parse.expand.solve == "4\n4\n4\n2\n4" );
	assert( [ "6", "-679 -2409 -3258 3095 -3291 -4462" ].parse.expand.solve == "21630\n21630\n19932\n8924\n21630\n19288" );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	// 出発地点と帰着地点として座標0を足す
	as = [ 0L ] ~ as ~ [ 0L ];
	
	// 普通に全部回ったときの金額を出す
	auto f = 0L;
	foreach( i; 1 .. as.length )
	{
		f += ( as[ i ] - as[ i - 1 ] ).abs;
	}
	
	// 1 .. n のどれかをスキップした時の金額を出す
	auto ss = new long[ as.length - 2 ];
	foreach( i; 1 .. as.length - 1 )
	{
		if( ( as[ i - 1 ] <= as[ i ] && as[ i ] <= as[ i + 1 ] ) ||
		    ( as[ i + 1 ] <= as[ i ] && as[ i ] <= as[ i - 1 ] ) )
		{
			// 通過なら金額減らない
			ss[ i - 1 ] = f;
		}
		else
		{
			// 折り返しているなら往復分の金額が減る
			auto dl = ( as[ i - 1 ] - as[ i ] ).abs;
			auto dr = ( as[ i ] - as[ i + 1 ] ).abs;
			ss[ i - 1 ] = f - 2 * min( dl, dr );
		}
	}
	
	return ss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 13320
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n; 

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  ll ans=0;

  vector<int> q(n);
  rep(i,n){
    cin>>q[i];
    ans+=max(0,p[i]-q[i]);
  }

  cout << ans << endl;
}

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

int main(void) {
	const char *SEP = " ";
	int i, k;
	char input_str[12 * 200000];
	char *num_str;

	fgets(input_str, sizeof(input_str), stdin);
	num_str = strtok(input_str, SEP);
	k = atoi(num_str);

	for ( i = 0; i < k; i++ ) {
		printf("ACL");
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
        using namespace std;
    	typedef long long int ll; 
         
        int main() {
          int n;
          cin >> n; 
          vector<int> a(n+1);
          vector<int> b(n+1);
          for(int i=1; i<=n; i++){
            cin>> a.at(i); 
          }
          int x=n;
            for(int i = n; i >=1 ; i--){
              int S = a.at(i);
              for(int j = i; j<=n ; j+=i ){
                S+= b.at(j);
              }//jのループ終わり
              b.at(i) = S%2; 
            }//iのループ終わり
          
          int M=0; 
          for(int i=1; i<=n; i++){
           if( b.at(i) == 1){
             M++; 
           }
          }
          
          cout<< M << endl; 
          for(int i=1; i<=n; i++){
           if( b.at(i) == 1){
             cout<< i <<" "; 
           }
          }
        }

Measured memory_bytes: 2432
#!/usr/bin/env python
# coding: utf-8


def main():
    n, m = list(map(int, input().split()))
    if n >= m:
        print(0)
        return
    xs = list(map(int, input().split()))
    sort_xs = sorted(xs)

    diff_xs = []
    for i in range(m-1):
        diff_xs.append(sort_xs[i+1] - sort_xs[i])
    sort_diff_xs = sorted(diff_xs)
    print(sum(sort_diff_xs[:m-n]))


if __name__ == '__main__':
    main()


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

class MainClass
{
    static void Main()
    {
        string S = ReadLine();
        int ans = 0;
        int count = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'R')
            {
                count++;
                ans = Max(count, ans);
            }
            else
            {
                count = 0;
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 25952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int x = int.Parse(str[0]);
        int a = int.Parse(str[1]);
        int b = int.Parse(str[2]);

        if(b - a <= 0){
            Console.WriteLine("delicious");
        }else if(b - a <= x){
            Console.WriteLine("safe");
        }else{
            Console.WriteLine("dangerous");
        }
    }
}



Measured memory_bytes: 11092
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma GCC optimize ("O3")
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

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

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    intt x, y;
    cin >> x >> y;
    intt cur = x, res = 0;
    while (cur <= y) {
        res++;
        cur *= 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
constexpr int IINF = numeric_limits<int>::max();
constexpr long LINF = numeric_limits<long>::max();
constexpr int MOD = (int)1e9 + 7;
// constexpr int MOD = 998244353;

int main()
{
    int k;
    cin >> k;
    int ans = 0;
    for (size_t i = 1; i <= k; i++) {
        for (size_t j = 1; j <= k; j++) {
            for (size_t l = 1; l <= k; l++) {
                ans += gcd(i, gcd(j, l));
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3596
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
    [n] <- getIntList
    xl <- getIntList
    let p = properFraction $ (fromIntegral . sum) xl / fromIntegral n
    let consL = consumptionSum (fst p) xl
    let consR = consumptionSum (fst p + 1) xl
    putStrLn . show $ if consL < consR then consL else consR

consumptionSum :: (Integral a) => a -> [a] -> a
consumptionSum p = sum . map (\x -> (x-p)^2)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

Measured memory_bytes: 508
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>

using namespace std; using ll=long long; const int INF=1e2; using P=pair<int,int>;
bool cmp(string s1, string s2) {
  if (s1 == "") return true;
  if (s1.size() != s2.size()) return s1.size() > s2.size();
  return s1 > s2;
}
bool cmp(P p1, P p2) {
  
}
int main() {
  string s; cin>>s; int n=s.size();
  int nx[n+1][26]; fill(nx[0], nx[n+1], n+1);
  for(int i=0;i<n;i++) {
    nx[i][s[i]-'a'] = i+1;
  }
  for(int j=0;j<26;j++) {
    for(int i=n-2;i>=0;i--) {
      nx[i][j] = min(nx[i][j],nx[i+1][j]);
    }
  }
  //for(int i=0;i<n;i++) cout<<nx[i]['b'-'a']<<" "; cout<<endl;

  string t[n+2];
  for(int i=0;i<=n;i++) {
    for(int j=0;j<26;j++) {
      int id = nx[i][j];
      if (cmp(t[id], t[i]+(char)('a'+j))) t[id] = t[i]+(char)('a'+j);
    }
    t[i].clear(); t[i].shrink_to_fit();
  }
  /*
  for(int i=0;i<=n+1;i++) {
    cout<<t[i]<<" ";
  } cout<<endl;*/
  cout<<t[n+1]<<endl;
}


Measured memory_bytes: 34216
//ABC 077 B - Around Square
#include <iostream>
#include <cmath>
using namespace std;

bool isSquareNumber(int n){
  if(sqrt(n) == static_cast<int>(sqrt(n))){
    // n is Square number
    return true;
  }
  return false;
}

int main(void){
  //input 
  int N; cin >> N;
  bool hasFoundSquareNumber = false;
  int i;

  for(i=N ; i>0 ; i--){
    if(isSquareNumber(i) == true){
      hasFoundSquareNumber = true;
      break;
    }
  }

  if(true == hasFoundSquareNumber){
    cout << i << endl;
  }
  return 0;
}


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

int main() {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = w * h / 2.0;

  printf("%f ", ans);
  cout << (w / 2.0 == x && h / 2.0 == y ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

unsigned long long hiku(unsigned long long a, unsigned long long b) {
	return a > b ? a - b : b - a;
}


int main() {
	unsigned long long  k;
	int a, b, c;

	cin >> a >> b >> c;
	cin >> k;

	if (k%2 == 0) {
		if (hiku(a, b) > pow(10, 18)) {
			cout << "Unfair";
			return 0;
		}
		cout << a - b;
	}
	else {
		if (hiku(a, b) > pow(10, 18)) {
			cout << "Unfair";
			return 0;
		}
		cout << b - a;
	}
	return 0;
}

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

using namespace std;
#define lint long long


int main() {
    int X[3][3];
    
    cin >> X[0][0] >> X[0][1] >> X[1][1];
    
    X[0][2] = 3 * X[1][1] - X[0][0] - X[0][1];
    X[2][2] = 3 * X[1][1] - X[0][0] - X[1][1];
    X[1][2] = 3 * X[1][1] - X[0][2] - X[2][2];
    X[1][0] = 3 * X[1][1] - X[1][1] - X[1][2];
    X[2][0] = 3 * X[1][1] - X[0][2] - X[1][1];
    X[2][1] = 3 * X[1][1] - X[0][1] - X[1][1];
    
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cout << X[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int X; cin >> X;
  cout << 10 - X/200 << endl;
  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;

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

  int cnt[1000] = {0};
  for (int i = 0; i < m; i++){
    int b;
    cin >> b;
    for (int j = 0; j < n; j++){
      if (a[j] <= b){
        cnt[j]++;
        break;
      }
    }
  }

  pair<int, int> maxa;
  for (int i = 0; i < n; i++){
    if (maxa.first < cnt[i]){
      maxa.first = cnt[i];
      maxa.second = i;
    }
  }

  cout << maxa.second + 1 << endl;
}

Measured memory_bytes: 3088
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();


        int[] A = new int[N];
        for (int i = 0;i < K; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int nsunuke = sc.nextInt() - 1;
                A[nsunuke] = 1;
            }
        }

        int count = 0;
        for (int i = 0;i < N; i++) {
            if(A[i] != 1) {
                count++;
            }
        }
        System.out.println(count);
    }
}

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

typedef long long ll;


int main()
{
	ll n;

	cin >> n;

	vector<ll> v(n);

	for(ll i = 0; i < n; i++)
		cin >> v[i];
	
	ll ans = 0;
	ll m = v[0];

	for(ll i = 1; i < n; i++){
		if(v[i] < m){
			ans += m - v[i];
		}
		m = max(m, v[i]);
	}

	cout << ans << "\n";

}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)1e3+5;
const int MOD=(int)1e9+7;

int n,m,a,b,c,q;
vi V;
int dp[N][N];
bool sciana[N][N];
string A;

void wczytaj(){
	cin>>n>>m;
	for (int i=1; i<=n; ++i){
		cin>>A;
		for (int j=0; j<m; ++j){
			if (A[j]=='.')
				sciana[i][j+1]=1;
		}
	}
}

void solve(){
	dp[1][1]=1;
	for (int i=1; i<=n; ++i){
		for (int j=1; j<=m; ++j){
			if (sciana[i-1][j])
				dp[i][j]+=dp[i-1][j];
			if (sciana[i][j-1])
				dp[i][j]+=dp[i][j-1];
			if (dp[i][j]>MOD)
				dp[i][j]-=MOD;
		}
	}
	cout<<dp[n][m]<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		solve();
	}
}

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

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(c)              (c).begin(),(c).end()

int main()
{
    int n;cin>>n;
    vector<pair<ll,ll>> v;
    rep(i,0,n)
    {
        ll a,b;cin>>a>>b;
        v.push_back({b,a});
    }
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=v[i].second;
        if(sum<=v[i].first)
            continue;
        else
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 6384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#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 repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int B[1000000];
int A[1000000];

vector<pair<int, int>> v;

signed main() {
	int N, M, C;
	cin >> N >> M;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end());
	int ans = 0;
	
	rep(i,N) {
		if (M <= v[i].second) {
			ans += v[i].first * M;
			M = 0;
			break;
		}
		else {
			ans += v[i].first * v[i].second;
			M -= v[i].second;
		}
	}
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 2420
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


N, T = LI()
C = []
for _ in range(N):
    c, t = LI()
    if t <= T:
        C.append(c)

if C:
    print(min(C))
else:
    print('TLE')


Measured memory_bytes: 5416
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int m,a[6],s,g,n[330],d[330];
vector<int> G[330];

int main(){
  scanf("%d",&m);
  rep(i,6)scanf("%d",a+i);
  scanf("%d%d",&s,&g); s--; g--;
  rep(i,m)scanf("%d",n+i);

  rep(i,m)rep(j,6){
    int k = -1;
    rep(t,2){
      int nxt = i+k*a[j];
      if(0<=nxt && nxt<m){
	nxt += n[nxt];
	G[nxt].push_back(i);
      }
      k*=-1;
    }
  }
  
  memset(d,-1,sizeof(d));
  d[g] = 0;
  queue<int> q;
  q.push(g);

  while(q.size()){
    int cur = q.front(); q.pop();
    rep(i,G[cur].size()){
      int nxt = G[cur][i];
      if(d[nxt]<0){
	d[nxt] = d[cur]+1;
	q.push(nxt);
      }
    }
  }

  while(true){
    int dice;
    scanf("%d",&dice); dice--;
    
    int res = 0, pos = s, k=-1;
    rep(t,2){
      int nxt = s + k*a[dice];
      if(0<=nxt && nxt<m){
	nxt += n[nxt];
	if(d[nxt]>=0 && d[pos]>d[nxt]){
	  pos = nxt; res = k;
	}
      }
      k*=-1;
    } 

    printf("%d\n",res); fflush(stdout);
    s = pos;
    if(s == g)return 0;
  }
}

Measured memory_bytes: 1304
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    vector<int> ans(n);
    int INF = 1 << 29;
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    for (int i = 0; i < m; ++i) cin >> c[i] >> d[i];
    for (int i = 0; i < n; ++i) {
        int min = INF;
        for (int j = 0; j < m; ++j) {
            int t = (abs(a[i]-c[j]) + abs(b[i]-d[j]));
            if (t < min) {
                min = t;
                ans[i] = j+1;
            }
        }
    }
    for (int i = 0; i < n; ++i) cout << ans[i] << std::endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	sqrtN := int(math.Sqrt(float64(N)))

	min := N
	for i := 1; i <= sqrtN; i++ {
		if N % i != 0 {
			continue
		}

		num := i + (N/i) - 2
		if num < min {
			min = num
		}
	}

	fmt.Println(min)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}


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

int main(){
  long long h,w,ans=1e18,yoko,tate;
  cin>>h>>w;
  yoko=w/2;
  tate=h/2;
  if(h==3||w==3){
    cout<<0<<endl;
    return 0;
  }
  for(int i=1;i<h-1;i++){
    long long tate1=(h-i)/2;
    ans=min(ans,max({i*w,tate1*w,(h-tate1-i)*w})-min({i*w,tate1*w,(h-tate1-i)*w}));
  }
  for(int i=1;i<w-1;i++){
    long long yoko1=(w-i)/2;
    ans=min(ans,max({i*h,yoko1*h,(w-yoko1-i)*h})-min({i*h,yoko1*h,(w-yoko1-i)*h}));
  }
  for(int i=1;i<h;i++){
    ans=min(ans,max({i*w,(h-i)*yoko,(h-i)*(w-yoko)})-min({i*w,(h-i)*yoko,(h-i)*(w-yoko)}));
  }
  for(int i=1;i<w;i++){
    ans=min(ans,max({i*h,(w-i)*tate,(w-i)*(h-tate)})-min({i*h,(w-i)*tate,(w-i)*(h-tate)}));
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
 
        if(N%2==0){                
			System.out.println("0.5");
		}else{
			System.out.println((double)(N/2+1)/N);
    }
    }
}


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

int main() {

  double N = 0;
  double K = 0;

  int ans = 0;

  cin >> N >> K;

  for (int i = 0; pow(K, i) <= N; i++) {
    ans = i;
  }

  cout << ans + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll mod = 1e9 + 7;
    int N, K, a, b;
    cin >> N >> K;
    unordered_map<int, vector<int>> e;
    for(int i = 0; i < N-1; i++) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    unordered_set<int> visit;
    ll ans = K;
    visit.insert(1);
    vector<int> dq = {1};
    unordered_map<int, int> colored;
    while (!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            colored[node] = (node == 1) ? 1 : 2;
            for(int neibor: e[node]) {
                if (visit.count(neibor) == 0) {
                    // ans *= bfs2(neibor, node, visit, e, K);
                    ans *= (K - colored[node]);
                    ans %= mod;
                    colored[node] += 1;
                    visit.insert(neibor);
                    new_dq.push_back(neibor);
                }
            }
        }
        dq.swap(new_dq);
    }
    cout << ans << endl;
    return 0;
}



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

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

int main() { 
  int h, w;
  cin >> h >> w;
  vector<vector<char> > A(h, vector<char>(w));
  queue<P> que;
  bool visited = false;
  P startp;
  rep(i,h)rep(j,w) {
    cin >> A[i][j];
    if (A[i][j] == '#') {
      que.push(P(i,j));
      if (!visited) {
        startp = P(i,j);
        visited = true;
      }
    }
  }
  ll ans = 0;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    if (p == startp) {
      visited = false;
      ans++;
    }
    rep(i,4) {
      int y = p.first + dy[i];
      int x = p.second + dx[i];
      if (x < 0 || y < 0 || x >= w || y >= h) continue;
      if (A[y][x] == '.') {
        A[y][x] = '#';
        que.push(P(y,x));
        if (!visited) {
          startp = P(y,x);
          visited = true;
        }
      }
    }
  }
  ans--;
  cout << ans << endl;
}


Measured memory_bytes: 9488