akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define EPS 0.000000001
using namespace std;


struct Info{
	int x;
	long double h;
};

long double calc(long double tmp_x,long double tmp_distance){
	return sqrt(tmp_x*tmp_x + (tmp_distance/(2*tmp_x))*(tmp_distance/(2*tmp_x)));
}

int main(){

	double distance;
	int N,bounce_limit;

	scanf("%lf %d %d",&distance,&N,&bounce_limit);

	Info info[N];

	for(int i = 0; i < N ;i++){
		cin >> info[i].x >> info[i].h;
	}

	long double tmp_distance;

	long double ans = 1000000.0;
	long double left,right,m,tmp_x,max_x,tmp_y,tmp_dist,tmp_h;

	bool FLG;

	for(int b_count = 1; b_count <= bounce_limit+1; b_count++){

		tmp_distance = (double)distance/b_count;

		left = 0.0,right = DBL_MAX,m = (left+right)/2;

		while(left <= right){

			tmp_x = m;
			tmp_y = tmp_distance/(2*tmp_x);

			FLG = true;

			for(int i = 0; i < N; i++){
				tmp_dist = info[i].x;

				while(tmp_dist >= tmp_distance)tmp_dist -= tmp_distance;

				tmp_h = (tmp_y/tmp_x)*tmp_dist-1.0/(2*tmp_x*tmp_x)*(tmp_dist*tmp_dist);

				if(info[i].h > tmp_h){
					FLG = false;
					break;
				}
			}
			if(FLG){
				left = m+EPS;
			}else{
				max_x = m;
				right = m-EPS;
			}
			m = (left+right)/2;
		}

		ans = min(ans,calc(max_x,tmp_distance));

		left = 0.0,right = max_x;

		while(true){
			if(right-left < EPS){
				ans = min(ans,calc((right-left)/2,tmp_distance));
				break;
			}

			long double mid1 = left + (right-left)/3;
			long double mid2 = left + (right-left)/3*2;

			long double v_1 = calc(mid1,tmp_distance);
			long double v_2 = calc(mid2,tmp_distance);

			ans = min(ans,min(v_1,v_2));

			if(v_1 < v_2){
				right = mid2-EPS;
			}else{
				left = mid1+EPS;
			}
		}
	}

	printf("%.12Lf\n",ans);

	return 0;
}

Measured memory_bytes: 3244
#!/usr/bin/env python

import sys
import heapq

n,m= [ int(x) for x in sys.stdin.readline().split() ]
baito=[ [] for _ in range(m) ]
for _ in range(n):
    ai,bi = [ int(x) for x in sys.stdin.readline().split() ]
    ai-=1
    if ai<m: baito[ai].append(-bi)
#
tot=0
cur=[]
for i in range(m):
    ref= baito[i]
    if ref: heapq.heapify(ref)
    while ref: heapq.heappush(cur,heapq.heappop(ref))
    #
    if not cur: continue
    tot+= heapq.heappop(cur)
#
print( -tot )


Measured memory_bytes: 17608
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>

using namespace std;
#define INF 0x3f3f3f3f

const int maxn = 8 + 2;
int len[maxn], vis[maxn];
int n, goal[3], better, sum[3], comp[3];
int back1[maxn], back2[maxn];
bool addVis(int u, int p) {
    int i = 0, cnt = 0, tol = 0;
    while (p > 0) {
        if (p & 1) {
            vis[i]++;
            cnt++;
            tol += len[i];
        }
        p >>= 1;
        if (vis[i] > 1) return false;
        i++;
    }
    comp[u] = cnt;
    sum[u] = tol;
    return true;
}

int main() {
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < 3; i++)
            scanf("%d", &goal[i]);
        for (int i = 0; i < n; i++) {
            scanf("%d", &len[i]);
        }
        better = INF;
        for (int i = 1; i < (1 << n); i++) {
            memset(vis, 0, sizeof(vis));
            if (!addVis(0, i)) continue;
            memcpy(back1, vis, sizeof(vis));
            for (int j = 1; j < (1 << n); j++) {
                memcpy(vis, back1, sizeof(vis));
                if (!addVis(1, j)) continue;
                memcpy(back2, vis, sizeof(vis));
                for (int k = 1; k < (1 << n); k++) {
                    memcpy(vis, back2, sizeof(vis));
                    if (!addVis(2, k)) continue;
                    int tol = 0;
                    for (int x = 0; x < 3; x++) {
                        tol += (comp[x] - 1) * 10;
                        tol += fabs(sum[x] - goal[x]);
                    }
                    better = min(better, tol);
                }
            }
        }
        printf("%d\n", better);
    }
    return 0;
}



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

const int INF = (1<<29);
const int dy[4] = {-1,0,1,0};
const int dx[4] = {0,1,0,-1};
int h,w;

class state{
public:
  int y,x, up,n,e, cost;
};

bool check(int y, int x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return true;
}

int main(){
  while(cin >> h >> w && (h|w)){
    int a[11][11],b[11][11][6][6][6],gx,gy,ans=INF;
    state u,v;
    queue<state> Q;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> a[i][j];
        for(int k=0;k<6;k++) for(int l=0;l<36;l++) b[i][j][k][l/6][l%6] = INF;
      }
    }
    cin >> u.y >> u.x >> gy >> gx;
    b[u.y][u.x][0][4][2] = 0;
    u.up = 1;
    u.n = 5;
    u.e = 3;
    u.cost = 0;
    Q.push(u);

    while(!Q.empty()){
      u = Q.front();
      Q.pop();

      if(u.y == gy && u.x == gx){
        ans = min(ans,u.cost);
        continue;
      }

      for(int i=0;i<4;i++){
        v = u;
        v.y += dy[i];
        v.x += dx[i];
        if(!check(v.y,v.x)) continue;
        if(i == 0){
          v.up = 7 - u.n;
          v.n = u.up;
        } else if(i == 1){
          v.up = 7 - u.e;
          v.e = u.up;
        } else if(i == 2){
          v.up = u.n;
          v.n = 7 - u.up;
        } else if(i == 3){
          v.up = u.e;
          v.e = 7 - u.up;
        }
        v.cost += a[v.y][v.x] * (7 - v.up);
        if(b[v.y][v.x][v.up-1][v.n-1][v.e-1] > v.cost){
          b[v.y][v.x][v.up-1][v.n-1][v.e-1] = v.cost;
          Q.push(v);
        }
      }
    }
    cout << ans << endl;
  }
}

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define FI first
#define SE second

int main(){
    int N, P;
    cin >> N >> P;
    int ki = 0;
    for(int i = 0;i < N;i++){
        int test;
        cin >> test;
        if(test % 2 == 1){
            ki++;
        }
    }
    if(ki == 0){
        if(P == 1){
            cout << 0 << endl;
            ED
        }
        else{
            cout << long(pow(2,N)) << endl;
            ED
        }
    }
    cout << long(pow(2,N-1)) << endl;
}

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

struct Edge {
    const unsigned int from;
    const unsigned int to;
    const int cost;

    Edge(unsigned int from, unsigned int to, int cost) : from(from), to(to), cost(cost) {}

    bool operator<(const Edge& edge) const {
        return this->cost < edge.cost;
    }
    bool operator>(const Edge& edge) const {
        return this->cost > edge.cost;
    }
};


/**
 * startから他のすべてのnodeへの最短距離(到達できないnodeはINT_MAX)をもとめる
 * 負の閉路がある場合は空を返す
 * O(|V||E|)
 */
std::vector<int> bellman_ford(const int start, const int num_node, const std::vector<Edge> &edges) {
    std::vector<int> distance(num_node, INT_MAX);
    distance[start] = 0;
    std::vector<unsigned int> prev(num_node, -1);

    int i;
    for (i = 0; i < num_node; ++i) {
        bool update = false;
        for (const auto &e : edges) {
            unsigned int from = e.from, to = e.to;
            int cost = e.cost;
            if (distance.at(from) != INT_MAX and distance.at(to) > distance.at(from) + cost) {
                distance.at(to) = distance.at(from) + cost;
                prev.at(to) = from;
                update = true;
            }
        }
        if (not update) { break; }
    }

    if (i == num_node) {
        return {};
    }
    else {
        return distance;
    }
}

using namespace std;

int main(void) {
    int V, E, r;
    cin >> V >> E >> r;


    vector<Edge> edges;
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        edges.emplace_back(Edge(s, t, d));
    }

    auto distance = bellman_ford(r, V, edges);
    if (distance.empty()) {
        cout << "NEGATIVE CYCLE" << endl;
    }
    else {
        for (int i = 0; i < distance.size(); ++i) {
            if (distance[i] == INT_MAX) {
                cout << "INF" << endl;
            }
            else {
                cout << distance[i] << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3104
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static char[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力



		long A = sc.nextLong();
		long B = sc.nextLong();
		int C = sc.nextInt();
		int D = sc.nextInt();

		long key = lcm(C, D);
//		System.out.println(key);
		long ans = 0;
		
		ans += (B/C - A/C) + (B/D - A/D) - (B/key - A/key);
//		System.out.println((B/C - A/C)+1);
//
//		System.out.println((B/D - A/D) + 1);
//		System.out.println((B/key - A/key)+1);


		if(A%C == 0){
			ans++;
		}
		if(A%D == 0){
			ans++;
		}
		if(A%key == 0){
			ans--;
		}
		System.out.println(B-A+1-ans);
		
		

	}

	static int rsearch(int y,int x){

		int count = 0;
		while(x < map[0].length && map[y][x] != '#'){
			count++;
			x++;
		}
		return count;	

	}

	static int csearch(int y,int x){

		int count = 0;
		while(y < map.length && map[y][x] != '#'){
			count++;
			y++;
		}
		return count;	
	}


	static boolean checkswitch(int bit,int[] k,ArrayList<ArrayList<Integer>> list,int[] p,int m){

		//		System.out.println("bit " + bit);

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

			ArrayList<Integer> sub = list.get(i);
			int onnum = 0;						//onの数
			for(int j = 0;j < sub.size();j++){
				//				System.out.println("sub "+ sub.get(j));
				if((bit & (1 << sub.get(j))) != 0){				//目的のスイッチがついているか
					onnum++;
					//					System.out.println("on  ");
				}

			}
			if(onnum % 2 != p[i]){				//一個でも電球がつかなかったらout
				return false;
			}

		}


		return true;

	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  otherpair.end - end;
	}
}




Measured memory_bytes: 21972
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 5e5 + 5;

int n, Q, D;
int d[maxn];

int f[maxn];
lli g[maxn];

void read_input()
{
    cin >> n >> D;
    for(int i = 1; i <= n; ++i)
        cin >> d[i];
}

void solve()
{
    f[0] = D;
    for(int i = 1; i <= n; ++i)
    {
        int nxt = abs(f[i - 1] - d[i]);
        f[i] = min(f[i - 1], nxt);
    }
    g[n + 1] = 1;
    for(int i = n; i > 0; --i)
        g[i] = (d[i] >= 2 * g[i + 1] ? g[i + 1] : g[i + 1] + d[i]);
    cin >> Q;
    for(; Q > 0; --Q)
    {
        int i;
        cin >> i;
        cout << (g[i + 1] <= f[i - 1] ? "YES\n" : "NO\n");
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i = 0;i<n;i++)
#define ll long long
int solve(int key){
	if(key>=1800 && key<=1999) return 1;
	if(key>=1600 && key<=1799) return 2;
	if(key>=1400 && key<=1599) return 3;
	if(key>=1200 && key<=1399) return 4;
	if(key>=1000 && key<=1199) return 5;
	if(key>=800 && key<=999) return 6;
	if(key>=600 && key<=799) return 7;
	if(key>=400 && key<=599) return 8;
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;

	int op = 0;

	while(b<=a){
		b = b*2;
		op++;
	}

	while(c<=b){
		c = c*2;
		op++;
	}

	if(op<=k){
		cout<<"Yes";
	}
	else cout<<"No";
	

}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

int t;

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif
    int n,m;
    int s[10],c[10];
    int num[10];
    memset(num,-1,sizeof(num));
    cin>>n>>m;
    bool flag = true;
    rep(i,0,m) {
        cin>>s[i]>>c[i];
        if(num[s[i]]!=-1 && num[s[i]] !=c[i]) {
            flag = false;
        }
        num[s[i]] = c[i];
    }
    if(!flag) cout<<-1<<endl;
    else {
        if(num[1]==0&&n==1) cout<<0<<endl;
        else if(num[1]==-1&&n==1) cout<<0<<endl;
        else {
            if(num[1]==0) cout<<-1<<endl;
            else {
                rep(i,1,n+1) {
                    if(i==1&&num[i]==-1) cout<<1;
                    else cout<<(num[i]==-1?0:num[i]);
                }
                cout<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 2 != 0 && b % 2 != 0)
    {
        cout << "Odd";
    }
    else
    {
        cout << "Even";
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    int len = s.size();

    ll ans = 0;
    for (int bit = 0; bit < (1 << len - 1); bit++) {
        ll n = s[0] - '0';
        for (int i = 0; i < len - 1; i++) {
            if (bit & (1 << i)) {
                ans += n;
                n = 0;
            }
            n = n * 10 + s[i+1] - '0';
        }
        ans += n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  long long H[100000];
  cin >> N;
  rep(i, N) {
    cin >> H[i];
  }
  long long key = H[0];
  long long count = 0;
  long long a[100000];
  a[0] = 0;
  rep(i, N-1) {
    if(H[i+1] <= key) {
      count++;
      a[i+1] = count;
    } else {
      count = 0;
      a[i+1] = count;
    }
    key = H[i+1];
  }
  long long ans = 0;
  rep(i, N) {
    ans = max(ans, a[i]);
    // cout << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

struct VectorItem
{
  uint64_t i, len;
  VectorItem(uint64_t i, uint64_t len) : i(i), len(len) { }
  bool operator<(const VectorItem &rhs) const { return len < rhs.len; }
  uint64_t operator+(const VectorItem &rhs) const { return len + rhs.len; }
};

int main()
{
  uint64_t N;
  cin >> N;
  
  vector<VectorItem> L;
  for (uint64_t n = 0; n < N; ++n) {
    uint64_t len;
    cin >> len;
    
    L.emplace_back(n, len);
  }
  sort(L.begin(), L.end());
  
  uint64_t T = 0;
  for (uint64_t n = 0; n < N; ++n) {
    for (uint64_t m = n + 1; m < N; ++m) {
      uint64_t max_len = L[n] + L[m];
      
      auto begin_itr = L.begin();
      advance(begin_itr, m + 1);
      
      auto end_itr = lower_bound(begin_itr, L.end(), VectorItem(-1, max_len));
      
      T += distance(begin_itr, end_itr);
    }
  }
  cout << T << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split(' '))
A_ls = [0] + list(map(int, input().split(' ')))
B_ls = [0] + list(map(int, input().split(' ')))

for i in range(1, N+1):
    A_ls[i] += A_ls[i - 1]

for i in range(1, M+1):
    B_ls[i] += B_ls[i - 1]

a_cnt, b_cnt, rst = 0, M, 0
while a_cnt < N + 1:
    if A_ls[a_cnt] > K:
        break
    while A_ls[a_cnt] + B_ls[b_cnt] > K and b_cnt > 0:
        b_cnt -= 1
    rst = max(rst, a_cnt + b_cnt)
    a_cnt += 1
print(rst)

Measured memory_bytes: 39912
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
multiset<int> mp;
multiset<int> ::iterator it;
int main(){
	int n,m;
	cin>>n;
	for(register int x,i=1;i<=n;i++)scanf("%d",&x),mp.insert(x);
	cin>>m;
	for(register int x,i=1;i<=m;i++){
		scanf("%d",&x);
		if(mp.count(x)){
			it=mp.find(x);
			mp.erase(it);
		}else{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>

int main(){
	long long x;
	scanf("%lld", &x);

	long long cnt=0;

    cnt += (x/11)*2;
    x %= 11;

    if(x==0) printf("%lld\n", cnt);
    else if(x<=6) printf("%lld\n", cnt+1);
    else printf("%lld\n", cnt+2);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define pb push_back
#define f first
#define s second
#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i<= n; i++)
#define MOD 1000000007
const int MAX = 2123;
ll n, k;
ll cnt;
ll a, b;
bool ok;
ll ans;
set<ll> num;
map<ll, ll> fre;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ok = false;
	cin >> n >> k;
	for(ll i = 0; i < n; i++){
		cin >> a >> b;
		fre[a] += b;
	}
	cnt = 0;
	for(auto x : fre){
		cnt += x.second;
		/*cout << x.first << " " << cnt << endl;*/
		if(cnt >= k){
			ans = x.first;
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[55];

int main(){
    ll k;
    cin >> k;
    rep(i, 50) a[i] = 49 + (k / 50);
    rep(i, k%50){
        rep(j, 50){
            if (i == j) a[j] += 50;
            else a[j]--;
        }
    }

    cout << 50 << endl;
    rep(i, 50) cout << a[i] << " ";
    cout << endl;

    return 0;
}

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

int main() {
    int r, g, b;
    std::cin >> r >> g >> b;

    if ((100 * r + 10 * g + b) % 4 == 0) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }

    return 0;
}


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

int main(void){
  int N;
  cin >> N;
  vector<long> s;
  long long sum = 0;
  long a;
  for (int i = 0; i<N; i++){
  	cin >> a;
    s.push_back(a);
    sum += a;
  }
  sort(s.begin(), s.end());
  if (sum %10 !=0) {cout << sum << endl;return 0;}
  for (int i = 0; i<N; i++){
    //cout << "i:" << i << endl;
   	if (s[i] % 10 != 0) {sum -= s[i]; break;}
    if (i == N-1) {sum = 0; break;}
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323
//void quick(int *,long long,long long);

int main(){
     
	float a;
	while(scanf("%f",&a)!=EOF){
		if(a<=48.00)
			printf("light fly\n");
		else if(a<=51.00)
			printf("fly\n");
		else if(a<=54.00)
			printf("bantam\n");
		else if(a<=57.00)
			printf("feather\n");
		else if(a<=60.00)
			printf("light\n");
		else if(a<=64.00)
			printf("light welter\n");
		else if(a<=69.00)
			printf("welter\n");
		else if(a<=75.00)
			printf("light middle\n");
		else if(a<=81.00)
			printf("middle\n");
		else if(a<=91.00)
			printf("light heavy\n");
		else
			printf("heavy\n");
	}
	return 0;
}

Measured memory_bytes: 604
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var v = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
        Array.Sort(v);
        for (int i = 0; i < N - 1; i++){
            v[i + 1] = (v[i] + v[i + 1]) / 2;}
        double answer = v[^1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27292
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, vector<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int f(int d, int c) {
  if (d == 0) return c - 1;
  if (c == 1) return 0;
  return (c * d - 1) / 9 + c - 1;
}
int g(string s) {
  int ret = 0;
  while (sz(s) > 1) {
    int idx = 0;
    int t = s[idx] + s[idx + 1] - '0' * 2;
    string next = s.substr(0, idx);
    next += to_string(t);
    next += s.substr(idx + 2);
    s = next;
    ret++;
  }
  return ret;
}
signed main() {
  int M;
  cin >> M;
  int p = -1;
  int ans = 0;
  rep(i, 0, M) {
    int d, c;
    cin >> d >> c;
    ans += f(d, c);

    int x = (d * c) % 9;
    if (d == 0)
      x = 0;
    else if (x == 0)
      x = 9;

    if (p == -1)
      p = x;
    else {
      ans += (p + x - 1) / 9 + 1;
      int np = (p * 10 + x) % 9;
      if (p * 10 + x == 0)
        np = 0;
      else if (np == 0)
        np = 9;
      p = np;
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



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

int main(){
  int x, n; cin >> x >> n;
  unordered_set<int> s;
  for(int i=0; i<n; i++){
    int tmp; cin >> tmp;
    s.insert(tmp);
  }
  if(s.count(x) == 0){
    cout << x << "\n";
    return 0;
  }
  int left = x-1;
  int right = x+1;
  while(true){
    if(s.count(left)==0){
      cout << left << "\n";
      break;
    }else if(s.count(right)==0){
      cout << right << "\n";
      break;
    }
    left--;
    right++;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define templ template<typename T>
	#define sz 5050
	typedef long long ll;
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
}
using namespace my_std;

int n;
ll A,B;
int pos[sz];

ll dp[sz][sz],mn[sz][sz];

int main()
{
	read(n,A,B);
	int x;
	rep(i,1,n) read(x),pos[x]=i;
	memset(dp,0x3f,sizeof(dp));memset(mn,0x3f,sizeof(mn));
	rep(i,0,n) dp[0][i]=mn[0][i]=0;
	rep(i,1,n) rep(j,0,n)
	{
		if (pos[i]==j) dp[i][j]=min(mn[i-1][j-1],dp[i-1][j]+A);
		else if (pos[i]>j) dp[i][j]=mn[i-1][j]+B;
		else dp[i][j]=mn[i-1][j]+A;
		mn[i][j]=min(dp[i][j],j?mn[i][j-1]:ll(1e15));
	}
	cout<<mn[n][n];
	return 0;
}

Measured memory_bytes: 398848
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL gcd(LL a,LL b)
{
    if(a&&b)while((a%=b)&&(b%=a));
    return a+b;
}
struct frac
{
    LL x;
    LL y;
    frac operator - (const frac& p)const
    {
        LL u=x*p.y-y*p.x,v=y*p.y,t=gcd(u,v);
        frac ans;
        ans.x=u/t;ans.y=v/t;
        return ans;
    }
    bool operator <= (const frac& p)const{return x*p.y<=y*p.x;}
};
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=3500;i++)
    {
        frac ans,t;
        ans.x=4;ans.y=n;
        t.x=1;t.y=i;
        if(ans<=t)continue;
        ans=ans-t;
        for(int j=i;j<=3500;j++)
        {
            frac tmp;
            tmp.x=1;
            tmp.y=j;
            if(ans<=tmp)continue;
            ans=ans-tmp;
            if(ans.x==1)
            {
                cout<<i<<" "<<j<<" "<<ans.y<<endl;
                return 0;
            }
        }
    }
return 0;
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> drink(n);
  rep(i,n) {
    ll a, b;
    cin >> a >> b;
    drink[i] = make_pair(a, b);
  }
  sort(drink.begin(), drink.end());

  ll ans = 0;
  rep(i,n) {
    if (m >= drink[i].second) {
      m -= drink[i].second;
      ans += drink[i].first*drink[i].second;
    } else {
      ans += drink[i].first*m;
      m = 0;
    }
    if (m == 0) break;
  }
  cout << ans << endl;
  return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll a, b;
    cin >> a >> b;
    ll y = max(0ll, b-a);
    ll x = y/(a-1) + bool(y%(a-1)) + 1;
    if (b == 1)
        x = 0;
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=15;
int n,m,sum,ans;
int map[maxn+8][maxn+8],tmp[maxn*maxn+8];
int g[(1<<maxn)+8],f[(1<<maxn)+8][maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int main()
{
    n=read(),m=read();
    for (int i=1;i<=m;i++)
	{
	    int u=read(),v=read(),w=read();
	    map[u][v]=map[v][u]=w;
	    sum+=w;
	}
    //for (int i=1;i<=m;i++) printf("%d ",tmp[i]);puts("");
    for (int sta=1;sta<1<<n;sta++)
	{
	    int x;
	    for (int i=1;i<=n;i++) if (sta&(1<<(i-1))) {x=i;break;}
	    g[sta]=g[sta^(1<<(x-1))];
	    for (int i=1;i<=n;i++)
		if (sta&(1<<(i-1)))
		    g[sta]+=map[x][i];
	}
    memset(f,128,sizeof(f));
    for (int sta=0;sta<1<<(n-2);sta++)
	{
	    f[(sta<<1)^1][1]=g[(sta<<1)^1];
	    if (map[1][n])
		ans=max(ans,f[(sta<<1)^1][1]+g[((1<<n)-1)^((sta<<1)^1)]+map[1][n]);
	}
    for (int sta=0;sta<1<<(n-2);sta++)
	for (int i=1;i<n-1;i++)
	    if (sta&(1<<(i-1)))
		{
		    if (map[1][i+1]) f[(sta<<1)^1][i+1]=g[(sta<<1)]+map[1][i+1];
		    for (int s=sta^(1<<(i-1));s;s=(sta^(1<<(i-1)))&(s-1))
			for (int j=1;j<n;j++)
			    if (((s<<1)^1)&(1<<(j-1)))
				if (map[i+1][j])
				    f[(sta<<1)^1][i+1]=max(f[(sta<<1)^1][i+1],f[(s<<1)^1][j]+map[i+1][j]+g[(sta^s)<<1]);
		    if (map[i+1][n]) ans=max(ans,f[(sta<<1)^1][i+1]+g[((1<<n)-1)^((sta<<1)^1)]+map[i+1][n]);
		}
    /* for (int sta=0;sta<1<<(n-2);sta++)
	for (int i=1;i<n;i++)
	    if (((sta<<1)^1)&(1<<(i-1)))
	    if (f[(sta<<1)^1][i]==f[0][0]) printf("Error:%d %d\n",sta,i);*/
    printf("%d\n",sum-ans);
    return 0;
}
	


Measured memory_bytes: 3328
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
ans = 0
for i in range(N):
    a, b = ISI()
    ans += b - a + 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    cout << pow(N,3) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

flg = 0 # 1 increase -1 decrease
prev = -1

cnt = 0
for a in A:
  if flg == 0 and prev==-1:
    prev = a
    cnt += 1
  elif flg==0 and not prev==-1:
    if a > prev:
      flg = 1
      prev = a
    elif a < prev:
      flg = -1
      prev = a
  elif flg == 1:
    if a < prev:
      flg = 0
      prev = a
      cnt +=1
    else:
      prev = a
  elif flg == -1:
    if a > prev:
      flg = 0
      prev = a
      cnt +=1
    else:
      prev = a
  #print(a, flg, prev, cnt)
print(cnt)      

Measured memory_bytes: 14436
#include <iostream>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	int h[n+1];
	int A[m+1];
	int B[m+1];
	int log[n+1];
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
		log[i] = i;
	}
	for (int i = 1; i <= m; i++)
	{
		cin >> A[i] >> B[i];
		if (h[A[i]] <= h[B[i]])
			log[A[i]] = 0;
		if (h[B[i]] <= h[A[i]])
			log[B[i]] = 0;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		if (log[i] != 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0 ; i < n ; i++) cin >> a[i];
	int x = 0;
	while(true){
		int f = 0;
		for(int i = 0 ; i < n ; i++){
			int w = 0;
			if( x and a[i] == 0 ) continue;
			for(int j = i ; j < n ; j++){
				w = w * 10 + a[j];
				if( w > x ) break;
				if( w == x ){
					f = 1;
					break;
				}
			}
		}
		if(!f) break;
		x++;
	}
	cout << x << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define all(n)	n.begin(),n.end()
#define each(i,n) for(auto &i : n)

const int INF = 1e9;

signed main() {
	double d;
	cin >> d;

	double ld = int(d);
	double ans = max(d * sqrt(2.0l), ld + 1.0l);
	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 3268
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, ans;
  cin >> a >> b;
  for (int i = 1; i <= 3; i++) {
    if (a != i && b != i) {
      ans = i;
      break;
    }
  }

  cout << ans << '\n';
  return 0;
}

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

bool isSq(int a){
    bool ans = false;
    if(a < 0) ans = false;
    else {
        int i = 0;
        while(i * i <= a){
            if(i * i == a) ans = true;
            i++;
        }
    }
    return ans;
}

int dis(vector<vector<int>> x, int a, int b){
    int ans = 0;
    for(int i = 0; i < x[0].size(); i++){
        ans += (x[a][i] - x[b][i]) * (x[a][i] - x[b][i]);
    }
    return ans;
}

int main(void){
    int n, d, ans = 0;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }

    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            if(isSq(dis(x, i, j))) ans++;
        }
    }

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

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

int main(){
    int N,a[300000];
    cin>>N;
    string S;
    cin>>S;

    a[0]=(S[0]=='E');
    for(int i=1;i<N;i++){
        a[i]=a[i-1]+(S[i]=='E');
    }

    int MIN=a[N-1]-a[0];
    for(int i=1;i<N;i++){
        int cnt=0;
        cnt+=i-a[i-1];
        cnt+=a[N-1]-a[i];
        MIN=min(MIN,cnt);
    }
    cout<<MIN<<endl;

    return 0;
}

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

using ll = long long;

const int N = 100005;

struct BIT{
    int d[2 * N];
    void i(){ fill(d + 1, d + 2 * N, 0); }
    void u(int x){ for(; x < 2 * N; x += x & -x) d[x]++; }
    int g(int x){ int r = 0; for(; x; x &= x - 1) r += d[x]; return r; }
} B;

int n, a[N];
ll t;

int f(int x){
    ll r = 0;
    B.i();
    B.u(N);
    for(int i = 0, j = N; i < n; i++){
        j += (a[i] <= x ? 1 : -1);
        r += B.g(j - 1);
        B.u(j);
    }
    return (r > t / 2);
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    t = 1LL * n * (n + 1) / 2;
    int s = *min_element(a, a + n), e = *max_element(a, a + n);
    while(s < e){
        int m = (s + e) / 2;
        if(f(m)) e = m;
        else s = m + 1;
    }
    printf("%d\n", s);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint p(n);
    REP(i, n) { cin >> p[i]; }
    int cnt = 0;
    FOR(i, 1, n - 1)
    {
        if ((p[i-1] < p[i] && p[i+1] > p[i]) || (p[i-1] > p[i] && p[i+1] < p[i])){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	long N=sc.nextLong();
	long min=N;
	for(long i=(long) Math.floor(Math.sqrt(N));i>=1;i--) {
		if(N%i==0) {
			min=i+N/i-2;
			break;
		}
	}
	System.out.println(min);
}
}

Measured memory_bytes: 23636
#整数の入力
N = int(input())

#複数の入力
input_list = input().split( )

counter = 0

for i in range(N):
  if(int(input_list[i])%2==0):
    if((int(input_list[i])%3==0)or(int(input_list[i])%5==0)):
      counter = counter + 1
  else:
    counter = counter + 1
if(counter == N):
  print("APPROVED")
else:
  print("DENIED")



Measured memory_bytes: 3060
n, m = map(int, input().split())
node = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    node[a].append(b)
    node[b].append(a)

q = int(input())
node_color = [0 for _ in range(n + 1)]
vdc = [list(map(int, input().split())) for _ in range(q)]

vdc = vdc[::-1]
painted = set()
visited = [[0] * 11 for _ in range(n + 1)]


def dfs(now, dist, color):
    if dist < 0:
        return
    if visited[now][dist]:
        return

    visited[now][dist] += 1
    if not node_color[now]:
        node_color[now] = color

    for x in node[now]:
        dfs(x, dist - 1, color)


for i in vdc:
    v, d, c = i
    dfs(v, d, c)

for m in range(n):
    print(node_color[m + 1])


Measured memory_bytes: 64224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int col[105];
int main(){
	cin>>n;
	if(n%2 == 1){
		col[n] = 0;
		for(int i=1;i<n-i;i++){
			col[i] = i;
			col[n-i] = i;
		}
	}
	else{
		for(int i=1;i<n+1-i;i++){
			col[i] = i;
			col[n+1-i] = i;
		}
	}
	vector<P>edge;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(col[i] != col[j]) edge.pb(P(i,j));
		}
	}
	cout << edge.size() << endl;
	for(int i=0;i<edge.size();i++){
		cout << edge[i].fi << " " << edge[i].sc << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[105];
bool k=true;
int main(void){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                k=false;
            }
        }
    }
    if(k){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
    
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double l = M * 6;
    double h = H * 30 + (M * 6) / 12;
//    print(l, h);
//    print(H * 30 + 30 * (M * 6) / 360);
//    print(l - h);
    double ans = A * A + B * B - 2 * A * B * cos(abs(l - h) * M_PI / 180);
    // ans = A * A + B * B - 2 * A * B * cos(abs(85) * M_PI / 180);
    cout << sqrt(ans) << '\n';
}

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


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

#define ll long long
using namespace std;
void solve()
{
	ll A,V,B,W,T;
	cin>>A>>V>>B>>W>>T;
	ll D = abs(A-B);
	ll Vel = V-W;
	if (D<=Vel*T)
		cout<<"YES"<<endl;
	else
	{
		cout<<"NO"<<endl;
	}
	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//int T;
    //cin>>T;
    //while(T--)
        solve();

	return 0;
}

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

int main()
{
    int N, X;
    cin >> N >> X;
    int p = 0;
    int pp = 0;

int count = 1;
    for(int i = 0; i < N; i++) {
        cin >> p;
        pp += p;

        if(pp <= X) {
            count++;
        }
    }

     cout << count << endl;

    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
    }
    in(n);
    in(k);
    ll a[n + 90];
    ll s[n + 90];
    mem(s, 0);
    ll pdt = 1;
    fw(i, 1, n + 1)
    {
        cin >> a[i];
    }
    fw(i, k + 1, n + 1)
    {
        if (a[i] > a[i - k])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6740
#include <cstdio>

const int INF = 0x3f3f3f3f;

int n, t;

int main() {
    int res = INF;
    scanf("%d%d", &n, &t);
    for (int i = 0; i < n; i++) {
        int c, s;
        scanf("%d%d", &c, &s);
        if (s <= t && c < res) {
            res = c;
        }
    }
    if (res == INF) {
        printf("TLE\n");
    } else {
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 128
function main()
  
  S = split(chomp(readline()),"")
  
  Q = parse(Int,readline())
  
  count = 0
  
  for i in 1:Q
    T = split(chomp(readline())," ")
    if T[1] == "1"
      count += 1
    elseif T[2] == "1"
      if count % 2 == 0
        unshift!(S,T[3])
      else
        push!(S,T[3])
      end
    else
      if count % 2 == 0
        push!(S,T[3])
      else
        unshift!(S,T[3])
      end
    end
  end
  
  if count % 2 == 1
    S = reverse(S)
  end
  
  println(join(S))
  
end

main()

Measured memory_bytes: 174000
fun main(args: Array<String>){
    val (l, r) = readLine()!!.split(" ").map { it.toInt() }
    val a = l % 2019
    val b = r % 2019
    var min = 2019
    if (r - l > 2019) min = 0
    if (a < b) {
        for (i in a until b+1) {
            if (b - a == 1) {
                min = a * b % 2019
                break
            }
            for (j in i + 1 until b+1) {
                val x = i * j
                val modX = x % 2019
                if (min > modX) min = modX
            }
        }
    } else {
        for (i in b until a+1) {
            if (a - b == 1) {
                min = a * b % 2019
                break
            }
            for (j in i + 1 until a+1) {
                val x = i * j
                val modX = x % 2019
                if (min > modX) min = modX
            }
        }
    }
    println(min)
}

Measured memory_bytes: 36084
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int 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;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int x = a * 60 + b, y = c * 60 + d;
    cout << y - x - e << endl;

    return 0;
}


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

int main()
{
  string S;
  cin >> S;
  char now = S[0];
  int cnt = 0;
  for (int i = 1; i < S.size(); i++)
  {
    if (S[i] != S[i - 1])
    {
      cnt++;
      now = S[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s1, s2, s3;

	cin >> s1 >> s2 >> s3;

	transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
	transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
	transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

	cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
local n=io.read("*n")
local a={}
local suma=0
local sumaeven=0
for i=1,n do
    a[i]=io.read("*n")
    suma=suma+a[i]
    if i%2==0 then
        sumaeven=sumaeven+a[i]
    end
end

local x={suma-2*sumaeven}
for i=1,n-1 do
    x[i+1]=2*a[i]-x[i]
end
print(table.concat(x," "))

Measured memory_bytes: 8880
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;

int main()
{
    string s,t;
    cin>>s>>t;
    ll tl = t.length();
    ll sl = s.length();
    ll flag=0;
    for(ll i=0;i<sl;i++){
        if(t[i]!=s[i]){
            flag=1;
            break;
        }
    }
    if(flag==1){
        cout<<"No"<<endl;
    }
else{
    cout<<"Yes"<<endl;
}
    return 0;
}


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

int main()
{
    long long int n,sum=0,ans=0,maxi=0,mini=INT_MAX;
    cin>>n;
    long long int a[n+1];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        maxi=max(maxi,a[i]);
    }
    for(int j=0; j<=maxi; j++)
    {
        ans=0;
        for(int i=0; i<n; i++)
        {
            ans+=((a[i]-j)*(a[i]-j));
        }
        mini=min(mini,ans);
    }
    cout<<mini<<endl;
    return 0;
}


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

using namespace std;

long long h[1000000],n,a;
long long sum;
bool cmp(int x,int y){
    return x>y;
}

int main (){
    cin>>a>>n;
    for (int i=1;i<=a;i++) cin>>h[i];
    sort(h+1,h+a+1,cmp);
    if (n>a){
        cout<<0;
        return 0;
    }
    if (n==0){
        for (int i=1;i<=a;i++) sum+=h[i];
    }
    else{
        for (int i=n+1;i<=a;i++) sum+=h[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1792