akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n, x;

    cin >> n >> x;

    int l = 0;
    int d = 0;
    int cnt = 0;
    for ( int i = 0; i <= n; i++ ) {
        cin >> l;
        if ( d <= x ) {
            cnt++;
        }
        d += l;
    } 

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())

if N < 105:
    print(0)
    exit()
elif N == 105:
    print(1)
    exit()

ans = 1
for n in range(107, N+1, 2):
    if len(make_divisors(n)) == 8:
        ans += 1

print(ans)


Measured memory_bytes: 3188
a,b,c,x,y=map(int,input().split())
ans=0
if a>c*2 and b>c*2:
  ans+=max(x,y)*2*c
elif a>c*2:
  if x>y:
    ans+=2*c*x
  else:
    ans+=2*c*x+(y-x)*b
elif b>c*2:
  if x>y:
    ans+=2*c*y+(x-y)*a
  else:
    ans+=2*c*y
elif a+b>c*2:
  if x>y:
    ans+=2*c*y+(x-y)*a
  else:
    ans+=2*c*x+(y-x)*b
else:
  ans+=a*x+b*y
print(ans)

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

int main(){
  int L, R, d, n;
  cin >> L >> R >> d;
  if(L % d == 0){
    n = R / d - L / d + 1;
  }else{
  n = R / d - L / d ;
  }
  cout << n << endl;
  
}

Measured memory_bytes: 3640
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a >>b;

	c = a * 100 + b * 1800;

	d = 1;

	for (int i = 0; i < b; i++) {
		d *= 2;
	}

	cout << c*d << endl;


	return 0;

}


Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

static const double pi = 3.14159265358979323846264338327950288;

int main(void){
	long double a, b, h, m; cin >> a >> b >> h >> m;
	long double aa = (60.0*h+m) / (60*12) * 2*pi;
	long double bb = m / 60.0 * 2*pi;
	long double ang = abs(aa-bb);
	//if(ang >= pi) ang -= pi;
	long double ans = sqrt((a*a)+(b*b) - 2*a*b*cos(ang));
	printf("%.50Lf", ans);
	return 0;
}

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline


from collections import deque
h, w = map(int, input().split())
a, b = map(int, input().split())
c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = [list(input()) for i in range(h)]
now = 0
dd = [(-1, 0), (1, 0), (0, 1), (0, -1)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            de = deque([(i, j)])
            s[i][j] = now
            while de:
                x, y = de.popleft()
                for p, q in dd:
                    if 0 <= x + p < h and 0 <= y + q < w and s[x + p][y + q] == ".":
                        s[x + p][y + q] = now
                        de.append((x + p, y + q))
            now += 1
st = s[a][b]
en = s[c][d]
es = [set() for i in range(now)]
for i in range(h):
    for j in range(w):
        if s[i][j] != "#":
            for p in range(-2, 3):
                for q in range(-2, 3):
                    if 0 <= i + p < h and 0 <= j + q < w and s[i + p][j + q] != "#":
                        es[s[i][j]].add(s[i + p][j + q])
                        es[s[i + p][j + q]].add(s[i][j])
from heapq import heappush, heapify, heappop


def dijkstra(s):
    INF = 1 << 32
    d = [INF] * now  # 頂点sからの最短距離
    v = -1
    que = [(0, s)]
    heapify(que)
    d[s] = 0
    while que:
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for e in es[v]:
            if d[e] > d[v] + 1:
                d[e] = d[v] + 1
                heappush(que, (d[e], e))
    return d[en] if d[en] < INF else -1


print(dijkstra(st))


Measured memory_bytes: 187836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  string Sd,T;
  cin >> Sd >> T;

  reverse(Sd.begin(), Sd.end());
  reverse(T.begin(), T.end());

  bool ok = false;
  string ans;
  string horn = "";
  for (int i = 0; i + T.size() <= Sd.size(); i++) {
    string head = Sd.substr(i, T.size());
    for (int j = 0; j < head.size(); j++) {
      if (head[j] == '?') head[j] = T[j];
    }
 
    if (head == T) {
      ok = true;
      string horn = Sd.substr(0, i);
      string tail = Sd.substr(i + T.size());
      for (int k = 0; k < tail.size(); k++) {
	if (tail[k] == '?') tail[k] = 'a';
      }
      for (int k = 0; k < horn.size(); k++){
	if (horn[k] == '?') horn[k] = 'a';
      }
      head = horn + head;
      reverse(head.begin(), head.end());
      reverse(tail.begin(), tail.end());
      ans = tail + head;
      break;
    }
  }

  if (ok){
    cout << ans << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> b;
    vector<int> ope;
    rep(i, N) {
        int num; cin >> num;
        num--;
        b.push_back(num);
    }
    while(b.size()) {
        int i = 0;
        rep(j, b.size()) {
            if(b[j] == j) i = j;
        }
        if(b[i] != i) {
            cout << -1 << endl;
            return 0;
        }
        ope.push_back(i);
        b.erase(b.begin() + i);
    }
    reverse(ope.begin(), ope.end());
    for(auto& e: ope) cout << e + 1 << endl;



    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MOD = 1000000007;
const int MAX_N = 60;
int N;
std::string S1, S2;

int main(int argc, char **argv) {
    std::cin >> N;
    std::cin >> S1;
    std::cin >> S2;

    int128_t ret = 0;
    if (S1[0] == S2[0]) {
        ret = 3;
    } else {
        ret = 6;
    }

    for (int i = 1; i < N; i++) {
        if (S1[i] == S1[i-1]) {
            continue;
        } else if (S1[i] == S2[i]) {
            if (S1[i-1] == S2[i-1]) {
                ret = (ret * 2) % MOD;
            } else {
                continue;
            }
        } else {
            if (S1[i-1] == S2[i-1]) {
                ret = (ret * 2) % MOD;
            } else {
                ret = (ret * 3) % MOD;
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def dist(x, y):
    assert 0 <= y <= x
    return min(y, x - y)

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    ai = sorted(ai)

    x = ai[-1]
    y = ai[0]
    for i in range(n - 1):
        if dist(x, ai[i]) > dist(x, y):
            y = ai[i]

    print("%d %d" % (x, y))

main()


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 200100;

int n, m;

int p[M];

void ini() {
  iota(p, p + M, 0);
}

int get(int x) {
  return p[x] = p[x] == x ? x : get(p[x]);
}

void uni(int x, int y) {
  x = get(x);
  y = get(y);
  p[x] = y;
}

void read() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int x;
      cin >> x;
      uni(i, n + x);
    }
  }

  for (int i = 0; i < n; ++i)
    if (get(i) != get(0)) {
      cout << "NO\n";
      exit(0);
    }
  cout << "YES\n";
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  ini();
  read();

}



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

#define ll long long
#define ull unsigned long long

using namespace std;

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

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

	int a0;
	cin >> a0;
	int val = a0;
	int MAX = val;
	for (int ii = 1; ii < N; ++ii){
		int a;
		cin >> a;
		MAX = max(MAX, a);
		val = gcd(val, a);
	}

	if ((K % val == 0) && (K <= MAX)){
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;		
	}


	return 0;
}


Measured memory_bytes: 256
class node:
    def __init__(self):
        self.parent = None
        self.left = None
        self.right = None
        self.key = None
        
class btree:
    def __init__(self):
        self.root = None
        
    def insert(self, v):
        y = None
        x = self.root
        z = node()
        z.key = v
        
        while x is not None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    
    def find(self, v):
        x = self.root
        z = node()
        z.key = v
        
        find_flg = 0
        while x is not None:
            if x.key == z.key:
                find_flg = 1
                break

            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        
        if find_flg:
            print('yes')
        else:
            print('no')
    

    def print_tree(self):
        def inorder(nd):
            if nd.left is not None:
                inorder(nd.left)
            print(' %i'%nd.key, end='')
            if nd.right is not None:
                inorder(nd.right)
        
        def preorder(nd):
            print(' %i'%nd.key, end='')
            if nd.left is not None:
                preorder(nd.left)
            if nd.right is not None:
                preorder(nd.right)
                
        inorder(self.root)
        print()
        preorder(self.root)
        print()
        
n = int(input())

bt = btree()

for i in range(n):
    inp = input()
    if inp.split()[0]=='insert':
        bt.insert(int(inp.split()[1]))
    elif inp.split()[0]=='find':
        bt.find(int(inp.split()[1]))
    else:
        bt.print_tree()
        


Measured memory_bytes: 85232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> pos;
int main(){
  ll n;
  cin>>n;
  ll ps=1;
  ll ren=0;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(ren%2==1){
      ren++;
      a=pos[i-1]+1;
    }
    else{
      a=min(ps,a);
      if(i>0){
        if(a==pos[i-1]+1) ren++;
      }
      else ren=0;
    }
    pos.push_back(a);
    ps=a+2;
  }
  ll ans=1,cnt=0;
  ren=0;
  ll mod=1e9+7;
  for(ll i=0;i<n;i++){
    cnt++;
    if(pos[i]-pos[i-1]==1){
      ren++;
      if(ren%2==1){
        ans*=cnt;
        cnt--;
        ans%=mod;
      }
    }
    else ren=0;
  }
  for(ll i=cnt;i>=1;i--){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<stdlib.h>
#define max(x,y) (x<y)?(y):(x)
#define INF 1000000
int N,M;
int s[INF];
int check(int X){
    int res=0;
    int L=1;
    int p=0;
    int index=0;
    if(L+X<=s[0]) return INF;
    while(L+X <= s[N-1]){
        //倒す敵を決定 L+X>s[i]かつmin(abs(L-s[i])
        int diff=INF;
        for(int i=p;i<N;i++){
            if(L+X>s[i]&&diff>abs(L-s[i])){
                diff=abs(L-s[i]);
                index=i;
            }
            else if(L+X<=s[i]) break;
        }p=index;
        L+=max(1,X-diff);
        res++;
    }
    return res+1;
}
int solve(){
    int left=s[0];
    int right=s[N-1];
    int mid;
    while(right-left>1){
        mid=(left+right)/2;
        int tmp=check(mid);
        if(tmp>=M){
            left=mid;
        }
        else{
            right=mid;
        }
    }
    if(check(left)>=M) return left;
    else return -1;
}
int main(void){
    while(1){
        scanf("%d%d",&N,&M);
        if(N+M==0) break;
        for(int i=0;i<N;i++) scanf("%d",&s[i]);
        printf("%d\n",solve());
    }
}



Measured memory_bytes: 2124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
long long computeComb(long long n) {
	return n * (n - 1) / 2;
}
 
 
int main() {
	long long N;
	cin >> N;
 
	long long* count = new long long[N + 1]();
	long long* A = new long long[N];
 
	for (int i = 0; i < N; i++) {
		cin >> A[i];
 
 
		count[A[i]]++;
	}
 
	long long sum = 0;
	for (int i = 0; i < N + 1; i++) {
			sum += computeComb(count[i]);
		
	}
 
	for (int i = 0; i < N; i++) {
		cout << sum - count[A[i]] + 1 << "\n";
	}
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long a;
    long min = 1000000;
    long max = -1000000;
    long long sum = 0;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a;
        if(a < min) min = a;
        if(a > max) max = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
int N;
int deg[100001];
int par[100001];
int sib[100001];
int Depth(int);
int Height(int);
int main() {
  int j,i;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    par[i] = -1;
    sib[i] = -1;
    deg[i] = 0;
  }
  for(i = 0; i < N; i++) {
    int id, lef, rig;
    scanf("%d %d %d", &id, &lef, &rig);
    if(lef != -1) {
      par[lef] = id;
      sib[lef] = rig;
      deg[id]++;
    }
    if(rig != -1) {
      par[rig] = id;
      sib[rig] = lef;
      deg[id]++;
    }
  }
  for(i = 0; i < N; ++i) {
    int depth = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, par[i], sib[i], deg[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(deg[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}
int Depth(int i) {
  if(par[i] == -1) return 0;
  return Depth(par[i]) + 1;
}
int Height(int i) {
  int j, h;
  h = 0;
  for(j = 0; j < N; ++j) {
    if(par[j] == i) {
      int tmp = Height(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}



Measured memory_bytes: 2100
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef priority_queue<int> PQI;
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"a == b"<<endl;
    }
    else if(a<b){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a > b"<<endl;
    }
    
}


Measured memory_bytes: 3128
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] c = new char[H][W];

		for (int i = 0; i < H;  i++){
				c[i] = sc.next().toCharArray();

		}


		for (int i = 0; i < W + 2 ;i++) {

				System.out.print("#");


		}
		System.out.println("");

//		for (int i = 1; i < H -1 ;i++) {
//			for (int j = 0; j < W + 2;j++) {
//				System.out.print("#");
//			}
//			System.out.println("");
//		}


		for (int i = 0; i < H;i++) {
			System.out.print("#");
			for (int j = 0; j < W; j++) {
			System.out.print(c[i][j]);
			}
			System.out.println("#");
		}
		for (int i = 0; i < W + 2 ;i++) {

				System.out.print("#");

		}

		System.out.println("");

	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    string S;
    cin >> S;
    cout << S[0] << S.size()-2 << S[S.size()-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int c[50] = {};
    int v[50] = {};
    int n = 0;

    cin >> n;

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

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

    int sum = 0;

    for(int i = 0; i < n; i++) {
        int value = v[i] - c[i];
        if(value > 0) sum += value;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll x,y;
    cin>>x>>y;
    if(y>=x*2 && y<=x*4 && y%2==0)
    cout<<"Yes";
    else
    cout<<"No";

    return 0;
}


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

const int MOD = (int)1e9+7;

int N;
string s;
bool check(string aa){
	for(int i=1;i<N;i++){
		if(aa.at(i)=='S'){
			if(s.at(i)=='o')	aa+=aa.at(i-1);
			else if(s.at(i)=='x' && aa.at(i-1)=='S')	aa+='W';
			else if(s.at(i)=='x' && aa.at(i-1)=='W')	aa+='S';
		}
		else if(aa.at(i)=='W'){
			if(s.at(i)=='x')	aa+=aa.at(i-1);
			else if(s.at(i)=='o' && aa.at(i-1)=='S')	aa+='W';
			else if(s.at(i)=='o' && aa.at(i-1)=='W')	aa+='S';
		}
	}

	bool ans=false;
	if(aa.at(0)==aa.at(N)){
		if(s.at(0)=='o'){
			if(aa.at(0)=='S' && aa.at(N-1)==aa.at(1))	ans=true;
			else if(aa.at(0)=='W' && aa.at(N-1)!=aa.at(1))	ans=true;
		}
		else if(s.at(0)=='x'){
			if(aa.at(0)=='S' && aa.at(N-1)!=aa.at(1))	ans=true;
			else if(aa.at(0)=='W' && aa.at(N-1)==aa.at(1))	ans=true;
		}
	}

	if(ans){
		for(int i=0;i<N;i++)	cout << aa.at(i);
		cout << endl;
		return true;
	}
	return false;
}

int main(){
	cin >> N >> s;
		
	if(!check("SS")){
		if(!check("WW")){
			if(!check("SW")){
				if(!check("WS")){
					cout << -1 << endl;
				}
			}
		}
	}
	
	return 0;
}


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

typedef long double ld;
typedef long long ll;

const int inf = 1e9 + 1;
const ld pi = acos(-1);

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cout << setprecision(20);
    ld a, b, v;
    cin >> a >> b >> v;
    if ((a * a * b) > 2 * v) {
        //   cout << "kek";
        ld x = (2 * v) / (a * b);
        cout << (pi / 2 - atan(x / b)) * 180 / pi;
    } else {
        //    cout << "lol";
        ld v1 = a * a * b - v;
        ld x = (2 * v1) / (a * a);
   //     cout << x << endl;
        cout << atan(x / a) * 180 / pi;
    }
    //    int n;
//    ll k;
//    cin >> n >> k;
//    vector<ll> a(n);
//    for (int i = 0; i < n; i++) {
//        cin >> a[i];
//    }
//    vector<ll> b(n);
//    for (int j = 0; j < n; j++) {
//        cin >> b[j];
//    }
//    sort(a.begin(), a.end());
//    sort(b.begin(), b.end());
//    ll ans = 0;
//
////    for (int i = 0; i < n; i++) {
////        cout << a[i] << " ";
////    }
////    cout << endl;
////    for (int j = 0; j < n; j++) {
////        cout << b[j] << " ";
////    }
////    cout << endl;
//    set<pair<ll,int>> x;
//    for (int i = 0; i < n; i++) {
//        if (k >= a[i]) {
//            k -= a[i];
//        } else {
//            ans += (a[i] - k) * b[n - 1 - i];
//            k = 0;
//        }
//        cout << ans << " ";
//    }
//    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long int i, j, k, n;
    long int cnt;
    long int cnt_2 = 0;
    long int r_cnt = 0;
    long int g_cnt = 0;
    long int b_cnt = 0;
    char s[4001];
    scanf("%ld", &n);
    scanf("%s", s);

    for(i=0; i<n; i++)
    {
        if(s[i] == 'R') r_cnt++;
        else if(s[i] == 'G') g_cnt++;
        else if(s[i] == 'B') b_cnt++;
    }
    cnt = r_cnt * g_cnt * b_cnt;
    for(i=1; i<=n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            k = 2 * j - i;
            if(k > n) continue;
            if(s[i-1] == s[j-1]) continue;
            if(s[i-1] == s[k-1]) continue;
            if(s[j-1] == s[k-1]) continue;
            cnt_2++;
        }
    }
    printf("%ld\n", cnt - cnt_2);

    return 0;
}



Measured memory_bytes: 1732
import math
N,D = map(int,input().split())
ten = [list(map(int,input().split())) for i in range(N)]
s = 0
for i in range(N):
    if math.sqrt((ten[i][0])**2 + (ten[i][1])**2) <= D:
        s += 1
print(s)

Measured memory_bytes: 45456
n=int(input())
a=list(map(int,input().split()))

b=list(map(int,input().split()))

l=0
for i in range(n):
  if b[i]<=a[i]:
    l+=b[i]
    b[i]=0
  else:
    l+=a[i]
    b[i]=b[i]-a[i]
  
  if b[i]<=a[i+1]:
    l+=b[i]
    a[i+1]=a[i+1]-b[i]
  else:
    l+=a[i+1]
    a[i+1]=0

print(l)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define PI 3.1415926535897932384626
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

const int MAX=1e6+1;
int cnt[MAX];
bool vis[MAX];

int main() {
	io();
	
	int n;
	cin>>n;
	for(int i=0;i<n;i++) {
		int a; cin>>a;
		cnt[a]++;
	}
	int ans=0;
	for(int i=1;i<=MAX;i++) {
		if(vis[i] || cnt[i]==0) continue;
		if(cnt[i]==1) ans++;
		for(int j=i;j<=MAX;j+=i)
			vis[j]=true;
	}
	cout<<ans;
	return 0;
}


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

int main(){
    int x,n;

    cin >>x>>n;
    
    
    if(n==0){
        cout  << x << endl;
        
        return 0;
    }
    
    int p[n];
    
    int min = 2000;
    int tmp;
    int ans;
    bool flag = true;
    
    
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    
    for(int j= -100;j<=200;j++){
        for(int i=0;i<n;i++){
            if(j == p[i]){
                //cout << "nise j " << j << endl;
                flag = false;
            }
        }
        
        if(flag == true){
            tmp = abs(x - j);
        
            if(tmp < min){
                min = tmp;
                ans = j;
                //cout << "tochu min " << min << " Tochu j " << j << endl;
            }
        }
        
        flag = true;
        
    }
    
    cout <<  ans << endl;
    
}

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

int main() {
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    
    int x1[n]={};
    int y1[m]={};
    for(int i=0;i<n;i++){
        cin >> x1[i];
    }
    for(int i=0;i<m;i++){
        cin >> y1[i];
    }

    for(int z=x+1;z<y+1;z++){
        bool flag = true;

        for(int i=0;i<n;i++){
            if(x1[i]>=z) flag = false;
        }
        for(int i=0;i<m;i++){
            if(y1[i]<z) flag = false;
        }
        if(flag){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;

using namespace std;

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

  priority_queue<ld, vector<ld>, less<ld> > pq;
  int n, m; cin >> n >> m;
  for(int i = 0 ; i < n ; ++i) {
    int a; cin >> a; pq.push(a);
  }
  while(m--) {
    ld a = pq.top(); pq.pop(); pq.push(a / 2);
  }
  ll ans = 0;
  while(!pq.empty()) {
    ll x = floor(pq.top()); pq.pop();
    ans += x;
  }
  cout << ans << '\n';
}


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

int main(){
    int H,W, M;
    cin >> H >> W >> M;
    int bomb_H[H+1], bomb_W[W+1];
    int h,w;
    vector<pair<int,int> > posi;
    int i,j,k;
    fill(bomb_H,bomb_H+H+1,0);
    fill(bomb_W,bomb_W+W+1,0);
    for(i=0; i<M; i++){
        cin >> h >> w;
        bomb_H[h]++;
        bomb_W[w]++;
        posi.push_back(make_pair(h,w));
    }
    sort(posi.begin(),posi.end());
    int h_MAX=0,w_MAX=0;
    for(i=1; i<=H; i++){
        if(h_MAX<bomb_H[i]){
            h_MAX=bomb_H[i];
        }
    }
    for(j=1; j<=W; j++){
        if(w_MAX<bomb_W[j]){
            w_MAX=bomb_W[j];
        }
    }
    vector<int> vec_H, vec_W;
    for(i=1; i<=H; i++){
        if(h_MAX==bomb_H[i]){
            vec_H.push_back(i);
        }
    }
    for(j=1; j<=W; j++){
        if(w_MAX==bomb_W[j]){
            vec_W.push_back(j);
        }
    }
    long long dabu=0;
    for(k=0; k<posi.size(); k++){
        h = posi[k].first;
        w = posi[k].second;
        if(h>vec_H[vec_H.size()-1]) continue;
        if(w>vec_W[vec_W.size()-1]) continue;
        i = lower_bound(vec_H.begin(),vec_H.end(),h)-vec_H.begin();
        j = lower_bound(vec_W.begin(),vec_W.end(),w)-vec_W.begin();
        if(h==vec_H[i]&&w==vec_W[j]){
            dabu++;
        }
    }
    long long H_size, W_size;
    H_size=vec_H.size();
    W_size=vec_W.size();
    if(dabu==H_size*W_size){
        cout << h_MAX+w_MAX-1 << endl;
    }else{
        cout << h_MAX+w_MAX << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 12392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n;
    cin >> n;
    unordered_map<string, int> w;
    char last;
    bool ok = true;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(i > 0 && (w[s] == 1 || s[0] != last))
            ok = false;
        w[s] = 1;
        last = s.back();
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac[p-1] == 1:
    continue
  if s == 'AC':
    ac[p-1] = 1
  if s == 'WA':
    wa[p-1] += 1

result = [x * y for x, y in zip(ac, wa)]
AC = sum(ac)
WA = sum(result)

print(AC, WA)

Measured memory_bytes: 5528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
 
int main()
{
  ll n;
  cin>>n;
  ll lim=26;
  int m=-1;
  for (int i = 1; i <= 20; ++i)
  {
    if(n<=lim) 
    {
      m=i;
      break;
    }
    lim+=pow(26,i+1);
  }
  string ans="";
  for (int i = m-1; i >= 0; --i)
  {
    if(n/(ll)pow(26,i)==0)
    {
      (*ans.rbegin())--;
      n+=pow(26,i+1);
      i++;
      continue;
    }
    if(n/(ll)pow(26,i)>26)
    {
      ans+='z';
      n-=(ll)pow(26,i)*26;
      continue;
    }
    ans+='a'+(n/pow(26,i)-1);
    n%=(ll)pow(26,i);
  }
  for (int i = ans.size()-1; i >=0; --i)
  {
    if(ans[i]=='a'-1)
    {
      ans[i-1]-=1;
      ans[i]='z';
    }
  }
 
  cout<<ans<<endl;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  int ans(INFint);
  for (int i(0);i<3;i++){
    int tmp(0);
    for (int j(0);j<3;j++){
      if (i == j) continue;
      tmp += abs(A[i] - A[j]);
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}




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

int main() {
	string s, ns;
	int n;
	cin >> n;
	cin >> s;
	
	if(s.length()>n) {
		ns = s.substr(0, n);
		cout << ns << "..." << '\n';
	} else {cout << s << "\n";}
	return 0;
}



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


vector<int> e[100000];
bool used[100000];
set<int> st;
vector<int> v;
int n,m,p[100000];

void dfs(int pos){
  used[pos]=1;
  st.insert(pos);
  v.push_back(p[pos]);
  for(int i=0;i<e[pos].size();i++)
    if(!used[e[pos][i]])dfs(e[pos][i]);
}

signed main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>p[i],p[i]--;
  int x[100000],y[100000];

  for(int i=0;i<m;i++){
    cin>>x[i]>>y[i];
    x[i]--,y[i]--;
    e[x[i]].push_back(y[i]);
    e[y[i]].push_back(x[i]);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(!used[i]){
      dfs(i);
      for(int j=0;j<v.size();j++)if(st.count(v[j]))ans++;
      st.clear();
      v.clear();
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15604
#include<iostream>
#include<string>
using namespace std;
int a;
string s[10000];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == "E869120") {
			a++;
		}
	}
	cout << a << endl;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	long long  arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	long long sumarr[n];
	sumarr[0] = arr[0];
	for(int i=1;i<n;i++){
		sumarr[i] = arr[i] + sumarr[i-1];
	}
	long long sum = 0;
	for(int i=0;i<n;i++){
		sum = (sum%(long long)((1e9)+7) + ((arr[i]%(long long)((1e9)+7))*((sumarr[n-1] - sumarr[i])%(long long)((1e9)+7)))%(long long)((1e9)+7))%(long long)((1e9)+7);
	}
	cout << sum << endl;
}


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

int main() {
    long long N;
    cin >> N;
    vector<long long> H(N);
    vector<long long> H2(N);
    string flag = "True";
    for(long long i = 0LL; i < N; i++){
        cin >> H[i];
        //copy(H.begin(), H.end(), H2.begin());
    }
    for(int i = N - 1; i >= 0; i--){
        if(H[i]-H[i-1] < 0){
            // sort(H.begin(),H.begin()+i,greater<long long>());
            // if(H[0] - H2[i] > 1 ){
            //     flag = "false";
            //     break;
            // }

            for(int j = i - 1; j >= 0; j--){
                if(H[j]-H[i] > 1){
                    flag = "false";
                    break;
                }
            }
        }
    }
if(flag =="false"){
    cout << "No" << endl;
} else {
    cout << "Yes" << endl;
} 

}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for (int i=0;i<s.length()/2;i++) {
			if (s.charAt(i)!=s.charAt(s.length()-1-i)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/c.in", "r", stdin);
//  freopen("../IO/c.out", "w", stdout);
#else
//  std::ios_base::sync_with_stdio(false);
//  std::cin.tie(nullptr);
//  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int P = 1'000'000'007;
int64_t qpow(int64_t a, int64_t b) {
  int64_t res = 1;
  for (; b; b >>= 1, (a *= a) %= P) if (b & 1) (res *= a) %= P;
  return res;
}
void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  out << ((qpow(10, n) - 2 * qpow(9, n) + qpow(8, n)) % P + P) % P << '\n';
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;

int main(){
  int n;cin >> n;
  min_priority_queue<int> ms;
  for(int i=0;i<n;i++){
    int d;
    cin >> d;
    ms.push(d);
  }
  int res = 0;
  int di = 0;
  for(int i=0;i<n;i++){
    auto v = ms.top();ms.pop();
    if(di < v) {
      di = v;
      res++;
    }
  }
   cout << res << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		line.split.map!(to!int).reduce!("a+b").writeln;
	}
}

Measured memory_bytes: 1052
N, K = map(int, input().split())
mod = 10**9+7

cnt = [0] * (K+1)
ans = 0
for i in range(1, K+1):
    f = i - cnt[i]
    ans = (ans + f * pow(K//i, N, mod)) % mod
    for j in range(2*i, K+1, i):
        cnt[j] += f
print(ans)



Measured memory_bytes: 68756
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back
#define pf push_front
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n%2==0) cout << n/2 << endl;
    else cout << n/2+1 << endl;
    
    
    return 0;
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  ll mini = 1e18, maxi = 0;
  REP(i, m) {
    ll l, r;
    cin >> l >> r;
    mini = min(mini, r);
    maxi = max(maxi, l);
  }
  cout << max(0LL, mini - maxi + 1) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    #define mp make_pair
    #define pb push_back
    #define lb lower_bound
    #define up upper_bound
    #define vll vector<ll>
    #define G vector<vll >
    #define F first
    #define S second
    #define pll pair<ll,ll>
    #define FOR1(i,a) for(i=0;i<=a;i++)
    #define FOR2(i,a,b) for(i=a;i<=b;i++)
    #define endl '\n'
    #define clr(a) memset(a,0,sizeof(a))
    #define all(x) x.begin(),x.end()
    #define rll read_ll();
    #ifndef ONLINE_JUDGE
    #define gc getchar
    #define pc putchar
    #else
    #define gc getchar_unlocked
    #define pc putchar_unlocked
    #endif
    typedef long long ll;
    ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}
     
    int main()
    {
    	ll n,t,i;
    	n=rll t=rll
    	vll a(n);
    	FOR1(i,n-1)
    	{
    		cin>>a[i];
    	}
    	// ll endtime=a[0]+t;
    	ll runtime=0,endtime=0;
    	// bool flag;
    	FOR2(i,0,n-1)
    	{
    		// cout<<runtime<<" "<<endtime<<endl;
    		// flag=false;
    		if(a[i]<=endtime)
    		{
    			endtime=a[i]+t;
    			runtime+=((i>0)?(a[i]-a[i-1]):t);
    		}
    		else
    		{
    			runtime+=t;
    			endtime=a[i]+t-1;
    		}
    	}
    	// cout<<runtime<<" ";
    	// cout<<endtime;
    	cout<<runtime;
    	
    	return 0;
    }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int32_t main()
{
	BOOST
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
	cout << "OUTPUT \n";
#endif
	int t; //cin >> t;
	t = 1;
	while (t--)
	{
		int  n;
		cin >> n;
		int a[n];
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		int ans = 0;
		for (int i = 1; i < n; i++)
		{
			if (a[i] < a[i - 1])
			{
				ans += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
		cout<<ans<<"\n";
	}
	return 0;

}

Measured memory_bytes: 5244
#include <stdio.h>
int main(){
    int N,A,B;
    scanf("%d¥n", &N);
    if(N==1){
        printf("Hello World\n");
    }
    else{
        scanf("%d¥n", &A);
        scanf("%d¥n", &B);
        printf("%d", A+B);
    }
    return 0;
}


Measured memory_bytes: 128
N = gets.to_i
A0 = gets.split.map(&:to_i)
A1 = gets.split.map(&:to_i)
max = 0

0.upto(N - 1) do |i|
  tmp = 0
  0.upto(i) {|j| tmp += A0[j] }
  i.upto(N - 1) {|j| tmp += A1[j] }
  max = tmp if max < tmp
end

puts max

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

int n, m;
typedef pair<int, int> P;
vector<P> v;

bool comp(P a, P b)
{
	return a.second < b.second;
}

int main()
{
	int ans = 0;

	cin >> n >> m;
	v.resize(m);
	for ( int i = 0; i < m; i++ ) {
		cin >> v[i].first >> v[i].second;
	}

	sort( v.begin(), v.end(), comp );
	int endtime = 0;
	for ( int i = 0; i < m; i++ ) {
		if( v[i].first >= endtime ) {
			endtime = v[i].second;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int n, a, b;
    int min, g, i;
    
    cin >> n;
    cin >> a;
    cin >> b;

    min = n * a;

    if(min < b){
        cout << min;
    }else{
        cout << b;
    }

    return 0;

}

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

typedef long long ll;

const int maxn = 2e5 + 5;
const ll INF = 1e18;
int N, h[maxn], a[maxn];
ll tree[4 * maxn];

void update(int l, int r, int ql, int qr, ll val, int node) {
    if (ql > qr) {
        return;
    }
    if (ql > r || qr < l) {
        return;
    }
    if (ql <= l && qr >= r) {
        tree[node] = val;
        return;
    }
    int mid = l + (r - l) / 2;
    update(l, mid, ql, qr, val, 2 * node);
    update(mid + 1, r, ql, qr, val, 2 * node + 1);
    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

ll query(int l, int r, int ql, int qr, int node) {
    if (ql > qr) {
        return 0;
    }
    if (ql > r || qr < l) {
        return 0;
    }
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    int mid = l + (r - l) / 2;
    return max(query(l, mid, ql, qr, 2 * node), query(mid + 1, r, ql, qr, 2 * node + 1));
}

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    ll answer = 0;
    for (int i = 0; i < N; i++) {
        ll temp = query(1, N, 1, h[i] - 1, 1) + a[i];
        answer = max(answer, temp);
        update(1, N, h[i], h[i], temp, 1);
    }
    cout << answer;

    return 0;
}

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

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	int A, B; cin >> A >> B;
	cout << 6 - A - B << endl;
}

Measured memory_bytes: 256
import math
l=int(input())
n=math.floor(math.log2(l))
edge=[]
for i in range(n):
    edge.append((i+1,i+2,0))
    edge.append((i+1,i+2,2**i))
i=n-1
while l>2**n:
    m=l-2**i
    if m>=2**n:
        edge.append((i+1,n+1,m))
        l=m
    i-=1
print(n+1,len(edge))
for a,b,c in edge:
    print(a,b,c)


Measured memory_bytes: 3316
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S, T = S_MAP()
b = []
for i in range(N):
  a = S[i] + T[i]
  b.append(a)
b = "".join(b)
print(b)

Measured memory_bytes: 5260
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

bool f(string a, string b){
    if(a.size() > b.size()) return true;
    else if(a.size() < b.size()) return false;
    else {
        REP(i, a.size()){
            if(a[i] == b[i]) continue;

            if((int)(a[i] - '0') > (int)(b[i] - '0')) return true;
            else return false;
        }
    }
    return true;
}

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

    int hon[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    bool use[9] = {false};

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    REP(i, m) cin >> a[i];
    REP(i, m) use[a[i]-1] = true;

    string dp[10005];
    bool ok[10005] = {false};
    dp[0] = ""; ok[0] = true;
    REP(i, n+1){
        REP(j, 9) if(use[j]){
            if(i-hon[j] >= 0 && ok[i-hon[j]]){
                char cur = (char)('0' + j+1);
                string curstr = cur + dp[i-hon[j]];
                if(f(curstr, dp[i])){
                    dp[i] = curstr;
                    ok[i] = true;
                }
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 32512