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

struct edge{
	int to, cost;
	edge(){}
	edge(int to_, int cost_){
		to = to_; cost = cost_;
	}
};

const int MAX_V = 401;
vector<edge> G[MAX_V];
int d[MAX_V];

int solve(int v){
	if( v == 0 ) return 0;
	if( d[v] != -1 ) return d[v];
	int res = 0;
	for(int i = 0; i < G[v].size(); i++){
		int to = G[v][i].to;
		int cost = solve(to) + G[v][i].cost;
		res = max(res, cost);
	}
	return d[v] = res;
}

void add_edge(int u, int v, int cost){
	G[v].push_back(edge(u, cost));
}

int main(){
	fill(d, d + MAX_V, -1);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		add_edge(a, b, c);
	}
	cout << solve(n-1) << endl;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>

using LL = long long;
const int MOD = (int)1e9 + 7;

const int kN = 1000000 + 5;

int row[kN], col[kN];
int n, m;

int main() {
  scanf("%d%d", &n, &m);
  std::set<int> set;
  for (int i = 1; i <= n; ++ i) {
    int x;
    scanf("%d", &x);
    if (row[x] || set.count(x)) {
      return puts("0"), 0;
    }
    row[x] = i;
    set.emplace(x);
  }
  set.clear();
  for (int i = 1; i <= m; ++ i) {
    int x;
    scanf("%d", &x);
    if (col[x] || set.count(x)) {
      return puts("0"), 0;
    }
    col[x] = i;
    set.emplace(x);
  }
  int r = 0, c = 0;
  int result = 1;
  for (int v = n * m; v >= 1; -- v) {
    if (row[v] && col[v]) {
      ++ r, ++ c;
    } else if (row[v]) {
      result = result * 1LL * c % MOD;
      ++ r;
    } else if (col[v]) {
      result = result * 1LL * r % MOD;
      ++ c;
    } else {
      int w = std::max(r * c - (n * m - v), 0);
      result = result * 1LL * w % MOD;
    }
    // printf("v = %d, result = %d, r = %d, c = %d\n", v, result, r, c);
  }
  printf("%d\n", result);
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	ll dp[n + 1][3] = {0};

	rep(i, 1, n + 1)
		rep(j, 0, 3)
			cin >> dp[i][j];

	rep(i, 1, n + 1)
	{
		dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]);
		// cout << dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}

	cout << max({dp[n][0], dp[n][1], dp[n][2]});


	return 0;
}







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

int h, w;
int a[80][80];

bool dp[80][80][12800];

int main() {
	cin >> h >> w;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			int b;
			cin >> b;
			a[i][j] = abs(a[i][j] - b);;
		}
	}
	dp[0][0][a[0][0]] = true;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			for(int k = 0; k < 12800; k++) {
				if (!dp[i][j][k]) continue;
				if (i < h - 1) {
					int t1 = k+a[i+1][j];
					int t2 = abs(k-a[i+1][j]);
					dp[i+1][j][t1] = true;
					dp[i+1][j][t2] = true;
				}
				if (j < w - 1) {
					int t1 = k+a[i][j+1];
					int t2 = abs(k-a[i][j+1]);
					dp[i][j+1][t1] = true;
					dp[i][j+1][t2] = true;
				}
			}
		}
	}
	auto& rs = dp[h-1][w-1];
	int ans = 0;
	while(!rs[ans]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 79360
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
N, D = map(int, input().split())		# 5 7 2

A=[]

for _ in range(N):
	a =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
	A.append(a)


def calc(X,Y):
	a = 0
	for k in range(D):
		a += (X[k]-Y[k])**2
	
	a = a**(1/2)
	return (a == int(a))
	

ans=0
for i in range(N-1):
	for j in range(i+1,N):
		X = A[i]
		Y = A[j]
		
		if calc(X,Y):
			ans +=1
			#p("i,j", i,j)

print(ans)


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


int main(){
	ll N,K;
	cin >> N >> K;
	
	ll d[10];
	for(ll i=0;i<K;i++){
		cin >> d[i];
		}
		
    ll ans = N;
    for(ll i=N;i<=N*10;i++){
    	ll temp = i;
    	ll cnt = 0;
    	while(temp > 0){
    		ll num = temp%10;
    		for(ll k = 0; k<K;k++){
    			if(num == d[k]) cnt +=1;
    			}
    		temp/=10;
    	}
    	if(cnt == 0){
    		ans = i;
    		break;
    	}
    }
	
	cout << ans << endl;
	
	return 0;
	}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

void merge_sort(int *t1, int left, int right){    //アドレスが渡される
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        merge_sort(t1,left,left+n2-1);
        merge_sort(t1,left+n2,right);

        int t2[n2];
        int t3[n3];
        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
        }

        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                k++;
            }
        }
    }
}


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *d=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&d[i]);
  }

  merge_sort(d, 0, N-1);

  // rep(i,N){
  //   printf("d[%d]=%d\n", i, d[i]);
  // }

  int middle=N/2-1;

  int ans=d[middle+1]-d[middle];

  printf("%d\n", ans);


  return 0;
}


Measured memory_bytes: 896
#include<bits//stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int x=a.size();
	for(int i=0;i<x;i++){
		if(a.size()==2){
			cout<<a<<endl;
		}
		else{
			cout<<a[2]<<a[1]<<a[0]<<endl;
		}
		return 0;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        //int c=sc.nextInt();
        int x1=a+b;
        int x2=a-b;
        int x3=a*b;
        System.out.println(Math.max(Math.max(x1,x2),x3));

    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;

long double pi = 3.14159265358979;

long double x[2],y[2];

long double dist(){
    return sqrt((x[0]-x[1])*(x[0]-x[1]) + (y[1]-y[0])*(y[1]-y[0]));
}

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

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

Measured memory_bytes: 3696
n=int(input())

n0=n
k=1
for i in range(6):
    if n0<10 :
        break
    n0//=10
    k+=1
if k==1 :
    ans = n%10
else:
    ans = 9
    if k>=3 :
        ans += min(900,n-99)
        if k>=5 :
            ans += min(90000,n-9999)
print(ans)




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

int main() {
   ll n;
   cin>>n;
   
   ll arr[n];
   map<ll,ll> m;
   ll sum = 0;
   for(int i = 0;i<n;i++){
   cin>>arr[i];
   m[arr[i]]++;
   sum += arr[i];
   }
   
   ll queries;
   cin>>queries;
   while(queries--)
   {
       ll b,c;
       cin>>b>>c;
       if(m.find(b)==m.end())
       {
           cout<<sum<<"\n";
       }
       else
       {
           // now we have to check that the element exist in the map or not..
           sum = sum - m[b]*b + m[b]*c;
           ll temp = m[b];
           m.erase(b);
           m[c] = m[c] + temp;
           cout<<sum<<"\n";
           
       }
       
   }
  
    
	return 0;
}

Measured memory_bytes: 8308
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    # これ追加
    def count_group(self):
        return len({self.find(x) for x in range(n)})

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

cnt = 0
# 自分以外の道を全て繋いで一つのグループになるか（自分を繋がなくてもグループが一つにまとまるか）
# を調べる
for i in range(m):
    # UnionFindをm回生成する
    U = UnionFind(n)
    # 自分以外の道を全てunionしていく
    for j in range(m):
        if i == j:
            continue
        a, b = lista[j]
        U.union(a - 1, b - 1)
    # 繋ぎ終わったら全体でグループが１つにまとまっているか調べる
    if U.count_group() > 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 42480
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

using CC = pair<ll, ll>;

template<typename T>
constexpr T divide_floor(T a, T b)
{
	T remainder = a % b;
	return (a - remainder) / b;
}

int main()
{
	int N, Q;
	string S;
	cin >> N >> Q >> S;

	vector<int> dp(N, 0);
	char prev = S[0];
	rep_init(i, 1, N)
	{
		dp[i] = dp[i-1];
		if (prev == 'A' && S[i] == 'C')
		{
			++dp[i];
		}

		prev = S[i];
	}

	rep(i, Q)
	{
		int l, r;
		cin >> l >> r;
		--l; --r;

		cout << dp[r] - dp[l] << endl;
	}

	return 0;
}

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

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int f[10001];
        memset(f, 0, sizeof(f));
        for (int i = 1; i <= 1000; ++i)
        {
            for (int j = 1; j <= 1000; ++j)
            {
                for (int k = 1; k <= 1000; ++k)
                {
                    int p = i * i + j * j + k * k + i * j + j * k + k * i;
                    if (p <= 10000)
                        f[p]++;
                }
            }
        }
        for (int i = 1; i <= n; ++i)
            cout << f[i] << "\n";
    }
}

Measured memory_bytes: 3684
A, B, C, X = [int(input()) for _ in range(4)]

ans = 0
for a in range(A + 1):  # 1からAまで　0は考慮しない
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + c * 50 == X:
                ans += 1
print(ans)

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

int main()
{
    long long int n,ac=0,wa=0,tle=0,re=0,i=0;
    char s[7],a[]="AC",b[]="WA",t[]="TLE",r[]="RE";
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",s);
        if(strcmp(s,a)==0)
        {
            ac++;
        }
      if(strcmp(s,b)==0)
        {
            wa++;
        }

         if(strcmp(s,t)==0)
        {
            tle++;
        }

         if(strcmp(s,r)==0)
        {
            re++;
        }


    }
    printf("AC x %lld\nWA x %lld\nTLE x %lld\nRE x %lld\n",ac,wa,tle,re);
    return 0;
}


Measured memory_bytes: 3816
n = int(input())
l = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
full = n // len(l)
part = n % len(l)

out = sum(l) * full + 15 * 8 * (full * (full - 1))//2
for i in range(part):
    if l[i] > 0:
        out += l[i] + 15 * full
print(out)


Measured memory_bytes: 61912
import java.util.*;

public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();

        int[][] X = new int[N][D];

        for(int i = 0;i<N;i++){
            for(int j=0;j<D;j++){
                X[i][j] = sc.nextInt();
            }
        }

        int ans = 0;
        for(int i=0;i<N;i++){
            for(int j= i+1;j<N;j++){
                double powDistance =0;
                for(int k=0;k<D;k++){
                    powDistance += Math.pow((X[i][k] - X[j][k]),2);
                }
                double distance = Math.sqrt(powDistance);

                if(distance == Math.ceil(distance)){
                    ans++;
                }

            }
        }
        System.out.println(ans);



    }



}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
bool f(vector<int> &A, int x) {
  int l = -1, r = A.size();
  while (r - l > 1) {
    int mid = l + (r - l) / 2;
    if (x <= A[mid]) {
      r = mid;
    } else {
      l = mid;
    }
  }
  int mid = 1 + l + (r - l) / 2;
  if (A[mid] == x) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int n, q;
  cin >> n;
  vector<int> A(n);
  REP(i, n) cin >> A[i];
  cin >> q;
  int ans = 0;
  REP(i, q) {
    int b;
    cin >> b;
    if (f(A, b)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
int prime(int e);

int main(void)
{
    int sum = 0;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int E;
        int judge = 0;
        scanf("%d", &E);
        judge = prime(E);
        if(judge == 1) sum++;
    }
    printf("%d\n", sum);
    return 0;
}

int prime(int e)
{
    int flag = 0;
    for(int j = 2; j <= sqrt(e); j++)
    {
        int r = e % j;
        if(r == 0)
        { flag = 1; break; }
    }
    if(flag == 0) return 1;
    else return 0;
}


Measured memory_bytes: 2136
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;


int main() {
	ll n,sum = 0;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum = sum + i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var h = int.Parse(spl[2]);
        var m = int.Parse(spl[3]);

        double min = h*60 + m;

        double hh = (min % (12 * 60.0)) / (12 * 60.0) * 360 * Math.PI / 180.0;
        double mm = (min % 60.0) / 60.0 * 360 * Math.PI / 180.0;
        
        var hx = Math.Cos(hh) * a;
        var hy = Math.Sin(hh) * a;

        var mx = Math.Cos(mm) * b;
        var my = Math.Sin(mm) * b;

        //Debug.WriteLine($"{hx}:{hy} {mx}:{my}");

        var x = (hx - mx);
        var y = (hy - my);

        var ret = Math.Sqrt(x*x + y*y);
        return ret;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27840
# -*- coding: utf-8 -*-
import math
# スペース区切りの整数の入力
n,k = map(int, raw_input().split())

ll = map(int, raw_input().split())

if n<= k:
	print 1
else:
	print int(math.ceil(float(n-k)/float(k-1))+1)

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

struct node{
  int key;
  struct node *p;
  struct node *left;
  struct node *right;
};
typedef struct node *Node;

Node root,NIL;
int max;

void insert(int k){
  int T;
  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x->left;
  }
  else{
    x = x->right;
  }
}

z->p = y;
if ( y == NIL ){
  root = z;
}
else{
  if (z->key < y->key) {
    y->left = z;
  }
  else{
    y->right = z;
  }
}
}

void in(Node n){
  if (n == NIL) return;
  in(n->left);
  printf(" %d", n->key);
  in(n->right);
}

void out(Node n){
  if (n == NIL) return;
  printf(" %d", n->key);
  out(n->left);
  out(n->right);
}

int main(){
  int l, i, s;
  char M[20];
  scanf("%d",&l);
  max = 0;
  for (i=0 ; i<l ; i++){
    scanf("%s", M);
    if (strcmp(M,"insert") == 0){
      scanf("%d",&s);
      insert(s);
    }
    else if (strcmp(M,"print") == 0){
      in(root);
      printf("\n");
      out(root);
      printf("\n");
    }
  }

  return 0;
}



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

const int INF = 1e9;

int number(char c)
{
    if (c == '*')
    {
        return -1;
    }
    else if (c == '+')
    {
        return -2;
    }
    else
    {
        return c - '0';
    }
}

pair<int,int> parse(string s){
    int cnt = 0;
    char c;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] =='.')cnt++;
        else{
            c = s[i];
        }
    }
    return make_pair(number(c),cnt);
}

int calc(int op,vector<int> nums){
    if(op==-1){
        int ret = 1;
        for(int x:nums){
            ret *= x;
        }
        return ret;
    }
    else
    {
        int ret = 0;
        for(int x:nums){
            ret += x;
        }
        return ret;
    }
}



int main(){
    int N;
    while(cin >> N,N){
        vector<string> s(N);
        for (int i = 0; i < N; i++)            
        {
            cin >> s[i];
        }
        vector<pair<int,int>> p(N);
        for(int i=0;i<N;i++)p[i] = parse(s[i]);
        p.push_back(make_pair(-INF, 0));
        stack<pair<int, int>> st;
        int level = 0;
        for (int i = 0; i <= N; i++)
        {
            while(level>p[i].second){
                vector<int> nums;
                int c;
                while (1)
                {
                    auto x = st.top();
                    st.pop();
                    c = x.first;
                    int l = x.second;
                    if(c<0)break;
                    else
                        nums.push_back(c);
                }
                int num = calc(c,nums);
                // cerr << "nums---" << endl;
                // for (int x : nums)
                //     cerr << x << endl;
                // cerr << "----" << endl;
                // cerr << num << endl;
                st.push(make_pair(num, level));
                level--;
            }
            if(p[i].first!=-INF)st.push(p[i]);
            level = p[i].second;
        }
        int pp = st.top().first;
        cout << pp << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int H,W;
int h1[2009],h2[2009];

int main(){
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0;i<H;i++)cin >> S[i];
  int ans=1;
  for(int i=0;i<W;i++){h1[i]=-1; h2[i]=H;}
  for(int i=0;i<H;i++){
    //最初はマス外に障害物があるとする
    int w1=-1,w2=W;
    for(int c=0;c<W;c++){if(S[i][c]=='#'){w2=c; break;}}
    for(int j=0;j<W;j++){
      if(i==0){
        for(int b=0;b<H;b++){if(S[b][j]=='#'){h2[j]=b; break;}}
      }
      //障害物だったら端を更新して中断
      if(S[i][j]=='#'){w1=j; h1[j]=i; continue;}
      if(j>=w2){
        w2=W;
        for(int c=j+1;c<W;c++){if(S[i][c]=='#'){w2=c; break;}}
      }
      if(i>=h2[j]){
        h2[j]=H;
        for(int b=i+1;b<H;b++){if(S[b][j]=='#'){h2[j]=b; break;}}
      }
      ans=max(ans,h2[j]-h1[j]+w2-w1-3);
      //if(ans==4){cout << i << " " << j << " " << h2[j] << " " << h1[j] << " " << w2 << " " << w1 << endl; return 0;}
      //if(ans==H+W-1){cout << ans << endl; return 0;}
    }
  }
  cout << ans << endl;
}

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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	int n,x=0,count=0;
	cin>>n;
	int arr[n];
	for (int i=0;i<n;++i)cin>>arr[i];
	x=arr[0];
	for (int i=1;i<n;++i){
		if (max(x,arr[i])<=x){
			count+=x-arr[i];
			arr[i]=x;
		}
		else{
			x = max(x,arr[i]);
		}
	}
	cout<<count;


}


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


int main() {

	long int S, T;
	int digit = 1;
	vector<int> vnumbers;
	int number;
	const int  N = 753;
	int min = 999;
	int number_made;
	int difference;

	cin >> S;
	
	T = S;

	while (T >= 10) {
		number = T % 10;
		vnumbers.push_back(number);
		T /= 10;
		digit++;
	}

	number = T % 10;
	vnumbers.push_back(number);

	reverse(vnumbers.begin(), vnumbers.end());

	for (int i = 0; i < vnumbers.size() - 2; i++) {
		number_made = 100 * vnumbers.at(i) + 10 * vnumbers.at(i + 1) + vnumbers.at(i + 2);
		difference = abs(number_made - N);
		if (difference < min) {
			min = difference;
		}
	}

	cout << min << endl;

	
	return 0;

}


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

using namespace std;

const int N = 2010;
const int NN = 2010;

unsigned long long one = 1;
unsigned long long g[N][NN];
unsigned long long was[NN];

bool alive[N];
bool can_put[N];

int a[N];
int x[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (__gcd(a[i], a[j]) > 1) {
        g[i][j >> 6] |= (one << (j & 63));
        g[j][i >> 6] |= (one << (i & 63));
      }
    }
  }
  int nn = ((n - 1) >> 6) + 1;
  for (int i = 0; i < n; i++) {
    alive[i] = true;
    can_put[i] = true;
  }
  for (int it = 0; it < n; it++) {
    for (int i = 0; i < nn; i++) {
      was[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      if (!alive[i]) {
        was[i >> 6] |= (one << (i & 63));
      }
    }
    int best = -1;
    for (int i = 0; i < n; i++) {
      if (was[i >> 6] & (one << (i & 63))) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = i;
      was[i >> 6] |= (one << (i & 63));
      while (b < e) {
        for (int j = 0; j < nn; j++) {
          if ((g[x[b]][j] & was[j]) != g[x[b]][j]) {
            for (int u = j * 64; u < (j + 1) * 64; u++) {
              if (g[x[b]][u >> 6] & (one << (u & 63))) {
                if (!(was[u >> 6] & (one << (u & 63)))) {
                  was[u >> 6] |= (one << (u & 63));
                  x[e++] = u;
                }
              }
            }
          }
        }
        b++;
      }
      int cur = -1;
      for (int j = 0; j < e; j++) {
        if (!can_put[x[j]]) {
          continue;
        }
        if (cur == -1 || a[x[j]] < a[cur]) {
          cur = x[j];
        }
      }
      if (best == -1 || (cur != -1 && a[cur] > a[best])) {
        best = cur;
      }
    }
    if (it > 0) putchar(' ');
    printf("%d", a[best]);
    alive[best] = false;
    for (int i = 0; i < n; i++) {
      if (!alive[i]) {
        continue;
      }
      if (g[best][i >> 6] & (one << (i & 63))) {
        can_put[i] = true;
      } else {
        if (a[best] < a[i]) {
          can_put[i] = false;
        }
      }
    }
  }
  printf("\n");
  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	long long sum = 0;
	for(int b=k+1;b<=n;b++) {
		sum += (n / b) * (b - k);
		if(n % b >= k) sum += n % b - k + 1;
	}
	if(k == 0) sum -= n;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,K,S; cin >> N >> K >> S;
    if(K == N){
        REP(i,N){
            cout << S << " ";
        }
        cout << endl;
        return 0;
    }
    if(K == 0){
        if(S == int(1e9)){
            REP(i,N){
                cout << 1 << " ";
            }
            cout << endl;
        }else{
            REP(i,N){
                cout << S+1 << " ";
            }
            cout << endl;

        }
        return 0;
    }

    if(S == 1){
        REP(i,K){
            cout << 1 << " ";
        }
        REP(i,N-K) cout << 2 << " ";
        cout << endl;
        return 0;
    }

    cout << 1 << " ";
    REP(i,K){
        if(i%2 == 0) cout << S-1 << " ";
        else cout << 1 << " ";
    }
    REP(i,N-K-1){
        if(S == int(1e9)) cout << 2 << " ";
        else cout << int(1e9) << " ";
    }
    cout << endl;

}


Measured memory_bytes: 1280
N = int(input())
C = [0, 0, 0, 0]
for i in range(N):
    S = input()
    if S == 'AC':
        C[0] += 1
    elif S == 'WA':
        C[1] += 1
    elif S == 'TLE':
        C[2] += 1
    elif S == 'RE':
        C[3] += 1

s = "AC x " + str(C[0]) + "\nWA x " + str(C[1]) + "\nTLE x " + str(C[2]) + "\nRE x " + str(C[3])
print(s)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    string s;
    cin>>s;
    int ans=700;
    for(int i=0;i<3;i++){
        if(s[i]=='o')ans+=100;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x, y;
  scanf("%d %d", &x, &y);
  if(x > y) {
    printf("a > b\n");
  }else if(x < y){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 300010;
const int MAXM = 110;
const int MAXK = 510;

string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    int lef = (s[0] - '0') * 10 + s[1] - '0';
    int rig = (s[2] - '0') * 10 + s[3] - '0';
    bool mmyy = false, yymm = false;

    if (lef <= 12 && lef > 0) mmyy = true;
    if (rig <= 12 && rig > 0) yymm = true;

    if (mmyy && yymm) cout << "AMBIGUOUS";
    else if (mmyy) cout << "MMYY";
    else if (yymm) cout << "YYMM";
    else cout << "NA";
    return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int n, k;
int a[100];
vector<vector<int> > result(100010, vector<int>(2, INIT));

bool canTaroWin(int rest, bool isTaroTurn) {
	if (result[rest][isTaroTurn] != INIT) {
		return (result[rest][isTaroTurn] == 1);
	}
	if (isTaroTurn) {
		result[rest][isTaroTurn] = 0;
		for (int i = 0; i < n; i++) {
			if (rest >= a[i] && canTaroWin(rest - a[i], false))
				result[rest][isTaroTurn] = 1;
		}
	} else {
		result[rest][isTaroTurn] = 1;
		for (int i = 0; i < n; i++) {
			if (rest >= a[i] && !canTaroWin(rest - a[i], true))
				result[rest][isTaroTurn] = 0;
		}
	}
	return (result[rest][isTaroTurn] == 1);
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (canTaroWin(k, true)) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)



int main() {
	int a, b;
	char c;
	cin >> a >> c >> b;
	if (c == '+')
		cout << a + b;
	else
		cout << a - b;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
   int key;
   Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }

    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }

    printf("\n");
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();

    for (i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') { insert(key); np++; size++; }
        if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();
    return 0;
}

Measured memory_bytes: 32216
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	vector<int> dp(H + 1, inf);
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= H; ++j) {
			int tar = min(j + A[i], H);
			dp[tar] = min(dp[tar], dp[j] + B[i]);
		}
	}
	cout << dp[H] << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m = read();
    let mut x: Vec<i64> = (0..m).map(|_| read()).collect();

    x.sort();

    let mut ans = x[m-1] - x[0];

    let mut distance: Vec<i64> = x[..].windows(2).map(|x| x[1] - x[0]).collect();
    distance.sort_by(|x,y| y.cmp(x));

    if m < n { 
        ans = 0;
    }else{
        for i in 0..n-1 {
            ans -= distance[i];
        }
    }
    
    println!("{}", ans);
    //println!("{:?}", distance);
}

Measured memory_bytes: 6396
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Data.Bool
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [defT,atkT,defA,atkA] = takahashi <= aoki
  where
    takahashi = steps atkT defA
    aoki = steps atkA defT

    steps atk = length . L.unfoldr (\v -> if v <= 0 then Nothing else Just (v, v-atk))

output :: _ -> IO ()
output = print . bool No Yes

data YesNo = Yes | No
  deriving Show

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    vector<pair<int, int> > AB(N);
    for (auto & ab : AB) cin >> ab.first >> ab.second;
    auto dp = vector<int>(H+1, INT32_MAX);
    dp[H] = 0;
    for (int i = H; i > 0; --i) {
        for (const auto & ab : AB) {
            if (dp[i] == INT32_MAX) continue;
            dp[max(i-ab.first, 0)] = min(dp[max(i-ab.first, 0)], dp[i]+ab.second);
        }
    }
    printf("%d\n", dp[0]);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a_li = list(map(int,input().split()))
a_min = min(a_li)
a_max = max(a_li)
a_average = round(sum(a_li)/n)
ans1 = 0
ans2 = 0
ans3 = 0
for i in range(n):
    ans1 += (a_min-a_li[i])**2
    ans2 += (a_max-a_li[i])**2
    ans3 += (a_average-a_li[i])**2
print(min(ans1,ans2,ans3))

Measured memory_bytes: 61892
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l;
    string s;
    cin>>s;
    if(s.size()%2)
                return no,0;
    bool ok=1,ishi=1;
    for(i=0; i<s.length()-1; i+=2)
    {
        if(s[i]=='h'&&s[i+1]=='i');
        else return no,0;
    }
    if(ishi)
            return yes,0;


    return 0;
}





Measured memory_bytes: 3544
#include <cstdio>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

int h, w, s;
int u[32][32];
int a[33][33];
P dp[33][33][33][33];

void integrate(){
	rep(i, h + 1){
		fill_n(a[i], w + 1, 0);
	}
	rep(i, h){
		rep(j, w){
			a[i + 1][j + 1] = u[i][j];
		}
	}
	rep(i, h){
		rep(j, w + 1){
			a[i + 1][j] += a[i][j];
		}
	}
	rep(i, h + 1){
		rep(j, w){
			a[i][j + 1] += a[i][j];
		}
	}
}

int area(int s, int t, int u, int v){
	return a[u][v] - a[s][v] - a[u][t] + a[s][t];
}

void init(){
	rep(i, h + 1){
		rep(j, w + 1){
			rep(k, h + 1){
				fill_n(dp[i][j][k], w + 1, P(0, 0));
			}
		}
	}
}

P& ap(int a, int b, int c, int d){
	return dp[a][b][c][d];
}

int& af(int a, int b, int c, int d){
	return ap(a, b, c, d).first;
}

P unite(const P& p, const P& q){
	return P(p.first + q.first, min(p.second, q.second));
}

P dfs(int a, int b, int c, int d){
	if(af(a, b, c, d)){
		return ap(a, b, c, d);
	}

	if(c - a == 1 && d - b == 1){
		return P(1, u[a][b] - s);
	}

	P p(1, area(a, b, c, d) - s);
	for(int i = a + 1; i < c; ++i){
		if(area(a, b, i, d) < s || area(i, b, c, d) < s){
			continue;
		}
		P x = dfs(a, b, i, d);
		P y = dfs(i, b, c, d);
		P z = unite(x, y);
		p = max(z, p);
	}
	for(int i = b + 1; i < d; ++i){
		if(area(a, b, c, i) < s || area(a, i, c, d) < s){
			continue;
		}
		P x = dfs(a, b, c, i);
		P y = dfs(a, i, c, d);
		P z = unite(x, y);
		p = max(z, p);
	}
	return ap(a, b, c, d) = p;
}

int main(){
	while(scanf("%d%d%d", &h, &w, &s), h){
		rep(i, h){
			rep(j, w){
				scanf("%d", &u[i][j]);
			}
		}
		integrate();
		s = area(0, 0, h, w) - s;
		init();
		P p = dfs(0, 0, h, w);
		printf("%d %d\n", p.first, p.second);
	}
	return 0;
}

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

int main() {
	long int N;
	cin >> N;
	vector<long long int> h(N), a;
	for(int i = 0; i < N; ++i){
		cin >> h[i];
	}
	int judge = 0;
	int count = 0;
	long int max_h = h[0];
	for(int i = 0; i < N; ++i){
			if(h[i] > max_h){
					max_h = h[i];
			}else if(max_h - h[i] >= 2){
					judge = 1;
					break;
			}
	}
	if(judge == 0){
			cout << "Yes" << endl;
	} else {
			cout << "No" << endl;
	}
}
					
	


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll a,b,c,k;
cin >> a >> b >> c >> k;
ll cnt = 0;
while (a >= b) {
    cnt++;
    b *= 2;
}
while(b>=c){
    cnt++;
    c *= 2;
}
cout << (cnt <= k ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
main(){
    int i = 1;
    while(1){
        int Case;
        scanf("%d",&Case);
        if (Case > 0){
            printf("Case %d: %d\n",i,Case);
            i++;
        }
        else{
            break;
        }
    
    }
    return 0;
}


Measured memory_bytes: 2024
n=gets.to_i
s={}
m=0
for i in 0...n do
    key=gets.chomp
    if s[key]==nil
        s[key]=1
    else
        s[key]+=1
        m=(s[key]>m)?s[key]:m
    end
end
s.delete_if {|k,v|v<m}
s1=s.sort{|a,b| a[0]<=>b[0]}
s1.each do |t|
    puts t[0]
end


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    int ans = 0;
    vector<int> nums_a(n);
    rep(i, n) cin >> nums_a[i];
    rep(i, n){
        int tmp;
        cin >> tmp;
        nums_a[i] -= tmp;
        if(nums_a[i] > 0) ans += nums_a[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}

static void ABC103D_IsLandsWar();

#if 1
int main()
{
	ABC103D_IsLandsWar();
	fflush(stdout);
	return 0;
}
#endif

class ABC103D_Data {
public:
	int left = 0;
	int right = 0;
	static bool asc_left(const ABC103D_Data& a, const ABC103D_Data& b) {
		return a.left < b.left;
	}
};
static void ABC103D_IsLandsWar()
{
	int N, M;
	get2int(N, M);

	std::vector<ABC103D_Data> battle(M);
	for (int i = 0; i < M; i++) {
		get2int(battle[i].left, battle[i].right);
	}
	
	std::sort(battle.begin(), battle.end(), ABC103D_Data::asc_left);
	
	int ans = 0;
	int left = N + 1, right = -1;
	for (int i = 0; i < M; i++) {
		if (battle[i].left >= right) {
			left = battle[i].left;
			right = battle[i].right;
			ans++;
		}
		else if (battle[i].right < right) {
			right = battle[i].right;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1152