akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

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

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

    def union(self, x, y):
        x = self.root(x)
        y = self.root(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 size(self, x):
        return -self.parents[self.root(x)]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def members(self, x):  # 計算量n
        root = self.root(x)
        return [i for i in range(self.n) if self.root(i) == root]

    def all_roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.all_roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.all_roots()}

    def __str__(self):
        return ''.join('{}: {}'.format(r, self.members(r)) for r in self.all_roots())

uf = UnionFind(n)

# uf.membersは呼ぶたびに計算量nかかるので，何度も呼ぶ場合は下の配列を使おう
# members = [set() for i in range(n)]
# for i in range(n):
#     r = uf.root(i)
#     members[r].add(i)
ab = [tuple(map(int,input().split())) for i in range(m)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    uf.union(a,b)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)







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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll cnt0 = 0;
  ll cnt1 = 0;
  for (ll i = 0; i < (ll)S.size(); i++) {
    if (S.at(i) == '0') cnt0++;
    else cnt1++;
  }
  cout << min(cnt0, cnt1) * 2 << endl;


  return 0;
}



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

using namespace std;

int main()
{
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;
	
	if(max((y + r), H) > H || max((x + r), W) > W || x < 0 || y < 0){
		
		cout << "No" << endl;
	}
	else{
	
	    cout << "Yes" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() 
{ 
    fastio
    ll a, b;
    cin>>a>>b;
    cout<<a*b<<endl;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.size() < 2 || s.size() % 2 !=0){
        cout << "No" <<endl;
        return 0;
    }
    for(int i = 0;i < s.size();i++){
        if((i % 2 == 0 && s[i] != 'h')||(i % 2 == 1 && s[i] != 'i')){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
    std::string s;
    int q;
    std::cin >> s >> q;

    bool rev = false;
    std::string left, right;
    while (q--) {
        int t;
        std::cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            std::cin >> f >> c;
            
            if ((f == 1 && !rev) || (f == 2 && rev)) {
                left += c;
            } else {
                right += c;
            }
        }
    }

    auto reverse = [](std::string str) {
        std::reverse(str.begin(), str.end());
        return str;
    };
    if (!rev) {
        std::cout << reverse(left) + s + right << std::endl;
    } else {
        std::cout << reverse(right) + reverse(s) + left << std::endl;
    }

    return 0;
}


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

using ll = long long;

void Main()
{
    ll n, a, b;
    std::cin >> n >> a >> b;

    if (a == 0)
    {
        cout << "0";
        return;
    }

    if (b == 0)
    {
        cout << n;
        return;
    }

    ll ans = n / (a + b) * a;
    ans += min(n % (a + b), a);

    cout << ans;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll INF = 1e8, SZ = 1e5 + 10;

ll n;
vector<vector<ll>> gr;
bool used[SZ];

bool fl = true;

ll bst(vector<ll> &vec, int ln) {
	int l = -1, r = vec.size() - 1;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		vector<ll> vec2 = vec;
		vec2.erase(vec2.begin() + mid);
		ll maxS = 0;
		for (int i = 0; i < vec2.size(); i++) {
			ll rv = vec2.size() - i - 1;
			if (i == rv) {
				maxS = max(maxS, vec2[i]);
			}
			else {
				maxS = max(maxS, vec2[i] + vec2[rv] - 1);
			}
		}
		if (maxS > ln) {
			l = mid;
		}
		else {
			r = mid;
		}
	}

	return vec[r];
}

ll dp(int v, int l) {
	used[v] = 1;

	vector<ll> vals;
	for (auto to : gr[v]) {
		if (!used[to]) {
			vals.push_back(dp(to, l) + 1);
			if (vals.back() > l) fl = false;
		}
	}

	if (gr[v].size() == 1 && vals.size() == 1) {
		if (vals[0] > l) {
			fl = false;
		}
		return 0;
	}
	if (gr[v].size() == 1) return 1;
	if (gr[v].size() == 2) return vals[0];

	sort(vals.begin(), vals.end());
	if (gr[v].size() % 2 == 1) {
		ll maxS = 0;
		for (int i = 0; i < vals.size(); i++) {
			ll rv = vals.size() - i - 1;
			if (i == rv) {
				maxS = max(maxS, vals[i]);
			}
			else {
				maxS = max(maxS, vals[i] + vals[rv] - 1);
			}
		}

		if (maxS <= l) return 1ll;
		if (vals.back() > l) {
			fl = false;
		}
		vals.pop_back();
	}

	for (int i = 0; i < vals.size() - 1; i++) {
		ll rev = vals.size() - 2 - i;
		if (i == rev && vals[i] > l) {
			fl = false;
		}
		if (i != rev && vals[i] + vals[rev] - 1 > l) {
			fl = false;
		}
	}

	if (!fl) return 0;

	return bst(vals, l);
}

bool fl2 = true;
bool check(int l) {
	fl = true;
	fl2 = true;

	if (l == 2) {
		cout << "";
	}
	for (int i = 0; i < n; i++) used[i] = 0;
	for (int i = 0; i < n; i++) {
		if (gr[i].size() == 1) {
			dp(i, l);
			break;
		}
	}
	fl2 = fl;
	
	fl = true;
	for (int i = 0; i < n; i++) used[i] = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (gr[i].size() == 1) {
			dp(i, l);
			break;
		}
	}

	return max(fl, fl2);
}

int main() {
	fastInp;

	cin >> n;

	gr.resize(n);
	for (int i = 0; i < n - 1; i++) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}

	ll cnt = 0;

	for (int i = 0; i < n; i++) {
		if (gr[i].size() > 2) cnt += (gr[i].size() - 3) / 2 + 1;
	}

	cout << cnt + 1 << " ";

	int l = 0, r = INF;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		if (check(mid)) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	cout << r - 1;

	return 0;
}

Measured memory_bytes: 22340
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 107;
int n, a[N], ans[N];

int main() {
	rd(n), rda(a, n);
	for (int i = n; i; i--) {
		int p = 0;
		for (int j = i; j && !p; j--)
			if (a[j] == j) p = j;
		if (!p) return prints("-1"), 0;
		ans[i] = p;
		for (int j = p; j < i; j++) a[j] = a[j+1];
	}
	for (int i = 1; i <= n; i++) print(ans[i]);
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    ll A,B,N;
    ll max=0;
    cin >> A >> B >> N;
    //A = 1<<6, B = 1<<12 , N<<12;
    if(B > N){
        long double a = (A*N)/B;
        ll tmp = ll(a);
        cout << tmp << endl;
        return 0;
    }else{
        N = B - 1;
        long double a = (A*N)/B, b = N/B;
        ll tmp = ll(a) - A * ll(b);
        cout << tmp << endl;
        return 0;
    }
    
}

Measured memory_bytes: 3632
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll n, d, x, tmp;
  cin >> n >> d >> x;

  d--;
  ll consumption = 0;
  REP(i, n) {
    cin >> tmp;
    consumption += d / tmp + 1;
  }

  cout << x + consumption << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int []a=new int [10];
	static int []b=new int [10];
	public static void main(String[]args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int nn=in.nextInt();
		if(n*500>=nn)
			System.out.println("Yes\r\n" + 
					"");
		else
			System.out.println("No\r\n" + 
					"");
	}
}


Measured memory_bytes: 23124
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		PrintWriter out =new PrintWriter(System.out);
		ArrayList<Integer> List =new ArrayList<Integer>();
		ArrayList<Integer> temp=new ArrayList<Integer>();
		while(sc.hasNext()){
			int ans=0;
			char []tmp=sc.nextLine().toCharArray();
			for(int i=0;i<10;i++){
				List.add(Integer.parseInt(""+tmp[i]));
			}
			for(int n=0;n<10;n++){
				for(int i=1;i<List.size();i++){
					temp.add((List.get(i)+List.get(i-1))%10);
				}
				List.clear();
				for(int a:temp){
					List.add(a);
					ans=a;
				}
				temp.clear();
			}
			out.println(ans);

		}
		out.flush();
	}
}

Measured memory_bytes: 17192
#include <stdio.h>

int
main(int argc, char argv[])
{
  int K, ans;
  scanf("%d", &K);
  
  if(K % 2 == 1){
   ans = (K / 2) * (K / 2 + 1);
  }
  else{
   ans = (K / 2) * (K / 2);
  }
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdio>
#include <ctype.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#define INF 0x3fffffff
#define DEBUG 1
#define MAXSIZE 100005
using namespace std;
typedef long long LL;

map<int, bool> mapp;
int main() {
	int n;
	scanf("%d", &n);
	int num = 0;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		if (mapp.count(a) == 0 || mapp[a] == false) {
			num++;
			mapp[a] = true;
		}
		else {
			num--;
			mapp[a] = false;
		}
	}
	printf("%d", num);
	printf("\n");
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	ll H, W; cin >> H >> W;
	if(W % 3 == 0 || H % 3 == 0){
		printf("0\n");
		return 0;
	}

	// if(H > W) swap(H, W);
	ll ans = INFF;
	if(H % 2 == 1 && W % 2 == 1){
		ll h1 = H / 2;
		ll h2 = H - h1;
		ll w1 = W / 2;
		ll w2 = W - w1;
		
		ll sum1 = h1 * w2;
		ll sum2 = h1 * w1;
		ll sum3 = h2 * w2;
		ll sum4 = h2 * w1;
		ll ma1 = max(sum3, max(sum1 + sum2, sum4));
		ll mi1 = min(sum3, min(sum1 + sum2, sum4));
		ll ma2 = max(sum3, max(sum1, sum2 + sum4));
		ll mi2 = min(sum3, min(sum1, sum2 + sum4));
		chmin(ans, abs(ma1  - mi1));
		chmin(ans, abs(ma2 - mi2));
		// printf("%lld\n", ans);
	}else if(H % 2 == 0 && W % 2 == 0){
		// printf("k\n");
		// ll ans = INFF;
		ll sum = H * W;
		// printf("H %lld %lld\n", H, W);
		for (int i = 0; i <= W; ++i){
			ll d = H * i;
			ll d1 = (sum - d) / 2;
			chmin(ans, abs((d1 - d)));
		}
		swap(H, W);
		for (int i = 0; i <= W; ++i){
			ll d = H * i;
			ll d1 = (sum - d) / 2;
			chmin(ans, abs((d1 - d)));
		}
		// printf("%lld\n", ans);
	}else if(H % 2 == 0 || W % 2 == 0){

		if(H % 2) swap(H, W);
		// ll ans = INFF;
		ll sum = H * W;
		for (int i = 0; i <= W; ++i){
			ll d = H * i;
			ll d1 = (sum - d) / 2;
			chmin(ans, abs((d1 - d)));
		}

		swap(H, W);
		for (int i = 0; i <= W; ++i){
			ll d1 = H * i;
			ll w = W - i;
			ll d2 = w * (H / 2);
			ll d3 = w * (H / 2 + 1);
			ll ma = max(d1, max(d2, d3));
			ll mi = min(d1, min(d2, d3));
			chmin(ans, abs(ma - mi));
		}
		// printf("%lld\n", ans);
	}
	// printf("k\n");

	if(H % 3 == 1 || W % 3 == 1){
		if(H % 3 != 1) swap(H, W);
		ll h1 = H / 3;
		ll h2 = H - h1 * 2;
		chmin(ans, abs(W * h2 - W * h1));
	}
	if(H % 3 == 2 || W % 3 == 2){
		if(H % 3 != 2) swap(H, W);
		ll h1 = H / 3;
		ll h2 = (H - h1) / 2;
		chmin(ans, abs(W * h2 - W * h1));
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
    long long a, b, c, m, n;
    cin >> a >> b >> c >> m >> n;
    n *= 4;
    if(2 * a < b)
	b = 2 * a;
    if(2 * b < c)
	c = 2 * b;
    if(2 * c < m)
	m = 2 * c;
    long long ans = 0;
    ans += (n / 8) * m;
    n %= 8;
    ans += (n / 4) * c;
    n %= 4;
    ans += (n / 2) * b;
    n %= 2;
    ans += n * a;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


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


        for(int i=1;i<=n;++i){
            int x=i;
            if (x%3==0){
                cout << " " <<i;
            }
            else while (x>0){
                if(x%10==3){
                    cout << " "<<i;
                    break;
                }
                x/=10;
            }


            }




    cout << endl;
    return 0;

}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

int sod(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int _find(int n,int l,int r){
    int ans=0;
    for(int i=1;i<=n;i++){
        int s=sod(i);
        if(s>=l && s<=r){
            ans+=i;
        }
    }
    return ans;
}
void solve(){
    
    int n,l,r;
    cin>>n>>l>>r;
    
    cout<<_find(n,l,r);
}



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

Measured memory_bytes: 3652
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List

main = do
    [_,c,k] <- map read . words <$> getLine
    ts <- map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents
    print $ solve c k ts

solve :: Int -> Int -> [Int] -> Int
solve c k = f 0 . sort
    where
        c' = c-1 -- first passanger always inside
        f :: Int -> [Int] -> Int
        f acc [] = acc
        f acc (t:ts) = let packAsMany = dropWhileNoLonger c' (<= t+k)
                            in f (acc+1) (packAsMany ts)

dropWhileNoLonger :: Int -> (a -> Bool) -> [a] -> [a]
dropWhileNoLonger _ _ [] = []
dropWhileNoLonger !l f list@(x:xs)
    | l <= 0    = list
    | otherwise = if f x then dropWhileNoLonger (pred l) f xs
                         else list


Measured memory_bytes: 16764
#include <stdio.h>
 
int main(void) {
  int A, B, K;
  int i;
  
  scanf("%d %d %d", &A, &B, &K);
  for(i = A; i <= B; i++) {
    if(i <= A + K - 1 || B - K + 1 <= i) printf("%d\n", i);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n, m;
  while(cin >> n >> m, n && m) {
    i64 ns = 0;
    i64 ms = 0;
    vector<i64> N(n), M(m);
    rep(i,0,n) {
      cin >> N[i];
      ns += N[i];
    }
    rep(i,0,m) {
      cin >> M[i];
      ms += M[i];
    }
    i64 ans = 1e18;
    i64 an, am;
    rep(i,0,n) rep(j,0,m) {
      if(ns + 2 * M[j] == ms + 2 * N[i]) {
        i64 tmp = ans;
        ans = min(ans, N[i] + M[j]);
        if(ans < tmp)
        {
          an = N[i];
          am = M[j];
        }
      }
    }

    if(ans == 1e18) cout << -1 << endl;
    else cout << an << " " << am << endl;
  }
}



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

void fnInput(vector<int>& rvnMtrx)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMtrx.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; ++i)
    cin >> rvnMtrx[i] >> rvnMtrx[i + 1];
}

int fnMtrxChainMultpl(vector<vector<int>>& rvvnDetDP, const vector<int>& cnrvnMtrx)
{
  const int nMAXSIZ = cnrvnMtrx.size() - 1;
  for (int i = 1; i <= nMAXSIZ; ++i)  rvvnDetDP[i][i] = 0;

  for (int nDif = 1; nDif <= nMAXSIZ - 1; ++nDif)
    for (int nRow = 1; nRow <= nMAXSIZ - nDif; ++nRow)
    {
      int nCol = nRow + nDif;
      for (int nx = nRow; nx <= nCol - 1; ++nx)
        rvvnDetDP[nRow][nCol] =
          min(rvvnDetDP[nRow][nCol],
              rvvnDetDP[nRow][nx] + rvvnDetDP[nx + 1][nCol] 
                                  + cnrvnMtrx[nRow - 1] * cnrvnMtrx[nx] * cnrvnMtrx[nCol]);
    }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnDetDP; 
  vector<int> vnMtrx;

  fnInput(vnMtrx);
  vvnDetDP.resize(vnMtrx.size(), vector<int>(vnMtrx.size(), INT_MAX));

  fnMtrxChainMultpl(vvnDetDP, vnMtrx);
  cout << vvnDetDP[1][vnMtrx.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	for (int i = 0;i < k;i++) {
		if (a >= b) {
			b *= 2;
		}
		else if (b >= c) {
			c *= 2;
		}
	}

	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	int n, m;
	n = min(a, b);
	n = min(n, c);
	n = min(n, d);
	n = min(n, e);
	m = max(a, b);
	m = max(m, c);
	m = max(m, d);
	m = max(m, e);
	if (m - n <= k)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
}

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

int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int sum = x;
    for(int j=0;j<n;j++){
        for(int k=0;k<100;k++){
            if(k*a[j]+1 <= d){sum++;}
            else break;
        }
    }

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a.sort(reverse = True)
ans = 1
for i in range(N):
    ans *= a[i]
    if ans > 10**18:
        print('-1')
        break
else:
    print(ans)

Measured memory_bytes: 21712
"use strict"
function main(arg) {
    let K = Number(arg.trim().split("\n")[0])
    let tmp = arg.trim().split("\n")[1].split(" ").map(Number)
    let A = tmp[0]
    let B = tmp[1]
    for (let i = A; i <= B; i++) {
        if (i % K === 0) {
            console.log('OK')
            return
        }
    }
    console.log('NG')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "\t\t" << #y << ": " << y << endl;
#define debugv(v, n) cerr << #v << " : " << " "; for(int i = 0; i < n; i++) cerr << "\t" << #v << "[" <<  i <<  "]" <<  " : " << v[i] << "\n"; cerr << endl;
#define sep() cerr << "--------------------" << endl;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	return 0;
}

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

int main(void) {
  double N, K, exp = 0;
  cin >> N >> K;
  while (true) {
    if (pow(K, exp) > N) {
      cout << exp << endl;
      return 0;
    }
    exp++;
  }
}


Measured memory_bytes: 256
from collections import deque

def n_bfs(S,W,H):
    dx=(-1,0,1,0)
    dy=(0,1,0,-1)
    queue=deque([[0,0]])
    d=[[0]*W for _ in range(H)]
    d[0][0]=1
    while queue:
        x,y=queue.popleft()
        for n in range(4):
            nx,ny=x+dx[n],y+dy[n]
            if 0<=nx<=W-1 and 0<=ny<=H-1 and S[ny][nx]=="." and d[ny][nx]==0:
                queue.append([nx,ny])
                d[ny][nx]=d[y][x]+1
    return d[-1][-1]

def n_main():
    H,W=map(int,input().strip().split())
    S=[list(input()) for _ in range(H)]
    ans=n_bfs(S,W,H)
    num_dot=sum(s.count(".") for s in S)
    
    return num_dot-ans if ans!=0 else -1

if __name__=="__main__":
    print(n_main())

Measured memory_bytes: 3316
N, K = map(int, input().split())
Hs = [0] * N
for i in range(N):
    Hs[i] = int(input())

Hs.sort()

ans = 10 ** 9

for i in range(N - K + 1):
    # print((Hs[K - 1 + i], Hs[i]))
    delta = Hs[K - 1 + i] - Hs[i]
    if delta < ans:
        ans = delta

print(ans)


Measured memory_bytes: 7472
#include <chrono>
#include <iostream>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

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

  int ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
X=tuple(map(int,input().split()))
k=B//A
a=0
for i in range(N-1):
    if X[i+1]-X[i]>k:
        a+=B
    else:
        a+=(X[i+1]-X[i])*A
print(a)

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

int main()
{
    int i,j=0,ara[15],min=99999,num;
    char s[15];
    gets(s);

    for(i=0;i<strlen(s)-2;i++)
    {
        num=((s[i]-'0')*100)+((s[i+1]-'0')*10)+(s[i+2]-'0');
        ara[j]=abs(753-num);
        j++;

    }

    for(i=0;i<j;i++)
    {
        if(ara[i]<=min)min=ara[i];
    }
    printf("%d",min);



}


Measured memory_bytes: 128
const MOD: u64=1000000007;
fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };
    let mut g=vec![vec![];n];
    for _ in 1..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let ab: Vec<_>=s.split_whitespace().map(|x|x.parse::<usize>().unwrap()-1).collect();
        g[ab[0]].push(ab[1]);
        g[ab[1]].push(ab[0]);
    };
    let mut s=vec![1;n];
    c(0, 0, &g, &mut s);
    let mut r=vec![0;n];
    let m=(2..n as u64).fold(1, |a,b|a*b%MOD);
    r[0]=m*inv(s[1..n].iter().fold(1, |a,b|a*b%MOD))%MOD;
    f(0, 0, &g, &s, n as u64, &mut r);
    for a in r {
        println!("{}",a);
    }
}
fn c(v: usize, p: usize, g: &Vec<Vec<usize>>, s: &mut Vec<u64>) {
    for &u in &g[v] { if u!=p {
        c(u, v, g, s);
        s[v]+=s[u];
    }}
}
fn f(v: usize, p: usize, g: &Vec<Vec<usize>>, s: & Vec<u64>, n: u64, r: &mut Vec<u64>) {
    for &u in &g[v] { if u!=p {
        r[u]=r[v]*s[u]%MOD*inv(n-s[u])%MOD;
        f(u, v, g, s, n, r);
    }}
}
fn inv(mut x: u64) -> u64 {
    let mut y=1;
    let mut n=MOD-2;
    while n>0 {
        if (n&1)==1 {
            y=y*x%MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    y
}

Measured memory_bytes: 24700
#include<stdio.h>

int main(){
	int i, j, k, S[10000], T[500], n, q, c = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &T[i]);
	}
	for (j = 0; j < q; j++) {
		for (i = 0; i < n; i++) {
			if (T[j] == S[i]) {
				c += 1;
				T[j] = -1;
			}
		}
	}
	printf("%d\n", c);
	return 0;
}



Measured memory_bytes: 1992
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for _ in range(m):
  a,b=map(int,input().split())
  if ans[a-1]:
    if h[a-1]<=h[b-1]:
      ans[a-1]=0
  if ans[b-1]:
    if h[b-1]<=h[a-1]:
      ans[b-1]=0
print(ans.count(1))

Measured memory_bytes: 84940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  private static final long M = 1_000_000_007;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].neighbors.add(nodes[b]);
      nodes[b].neighbors.add(nodes[a]);
    }

    long[] count = dfs(nodes[0]);
    System.out.println((count[0] + count[1]) % M);
  }

  private static long[] dfs(Node node) {
    node.visited = true;
    long[] count = new long[] {1, 1};
    for (Node n : node.neighbors) {
      if (!n.visited) {
        long[] c = dfs(n);
        count[0] *= (c[0] + c[1]) % M;
        count[0] %= M;
        count[1] *= c[0];
        count[1] %= M;
      }
    }
    return count;
  }

  private static class Node {
    final List<Node> neighbors = new ArrayList<>();
    boolean visited;
  }
}


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

ll memo[64][64];
ll ncr(ll n , ll r){
	if(memo[n][r])return memo[n][r];
	long long ans = 1;
	int d[64] = {0};
	for(int i = 1 ; i <= r ; i++) d[i] = 1;
	for(int i = 0 ; i < r  ; i++){
		ans *= n-i;
		for(int j = 1 ; j <= r ; j++)
			if(d[j] && ans % j == 0){
				ans /= j;
				d[j] = 0;
			}
	}
	return memo[n][r] = ans;
}

string f(ll n,ll bit,ll m){
	if(bit == 0) return string(n,'0');
	ll cur = 0;
	for(int i = bit ; i <= n ; i++){
		ll next = cur+ncr(i-1,bit-1);
		if(m <= next && m >= cur+1) return f(i-1,bit-1,m-cur) + "1" + string(n-i,'0');
		cur = next;
	}
}
int main(){
	ll n,m;
	while(cin >> n >> m && (n||m) ){
		int bit = n;
		ll cur = 0;
		for(int i = 0 ; i <= n ; i++){
			ll next = cur + ncr(n,i);
			if(m <= next && m >= cur+1){ bit = i; break;}
			cur = next;
		}
		m -= cur;
		if(bit == 0) cout << string(n,'0') << endl;
		else{
			string r = f(n,bit,m);
			for(int i = 0 ; i < r.size() ; i++) cout << r[r.size()-1-i];
			cout << endl;
		}
	}
}

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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int n;
deque<int> deq;

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

	cin >> n;
	for (int i=0;i<n;i++) {
		int a;cin >> a;
		if (i%2) deq.push_back(a);
		else deq.push_front(a);
	}

	if (n%2) {
		for (int i=0;i<n;i++) {
			if (i) cout << ' ';
			cout << deq[i];
		}
	}
	else {
		for (int i=n-1;i>=0;i--) {
			cout << deq[i];
			if (i) cout << ' ';
		}
	}
	cout << endl;
}

Measured memory_bytes: 3072
def main():

    s = input()
    t = input()
    m, n = len(s), len(t)
    dp = [[0 for _ in range(n+1)] for _ in range(m+1)]

    for i in range(m):
        for j in range(n):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    i, j = m, n
    ans = ""
    while i > 0 and j > 0:
        if s[i-1] == t[j-1]:
            ans += s[i-1]
            i -= 1
            j -= 1
        elif dp[i][j-1] > dp[i-1][j]:
            j -= 1
        else:
            i -= 1
    return ans[::-1]


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 119900
#include<stdio.h>

int main()
{
	int n,a[105],i,x=0;
    	for(i=1;i<=100;i++)a[i]=0;
    	while(scanf("%d",&n)!=EOF){
        	a[n]++;
        	if(a[n]>x)x=a[n];
    	}
    	for(i=0;i<100;i++)if(a[i]==x)printf("%d\n",i);
    	return 0;
}
	


Measured memory_bytes: 2040
#include <stdio.h>

int main()
{
int A[100][100]={0};
int B[100];
int c[100];
int i,n,m,k,p,q,r;

scanf(" %d %d",&n,&m);
for(i = 0; i < n; i++)
{
	for(k = 0;k <m; k++)
	{
		scanf(" %d",&A[i][k]);
	}
}

for(k = 0;k < m;k++)
{
	scanf(" %d",&B[k]);
}
for(p = 0;p < n;p++)
{
	c[p]=0;
	for(q = 0;q < m;q++)
	{
		c[p]+=A[p][q]*B[q];
	}
	printf("%d\n",c[p]);
}
return 0;
}

Measured memory_bytes: 648
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	int cnt=0;
	REP(i,1,n) {
		int l,r;
		cin>>l>>r;
		cnt+=r-l+1;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	map<string, int> s;

	int n; cin >> n;
	for (string x; n--; s[x]++) {
		cin >> x;
		//cout << "s[x]: " << s[x] << ", string: " << x;
	}

	int m; cin >> m;
	for (string x; m--; s[x]--) cin >> x;

	int res = 0;
	for (auto & e : s) res = max(res, e.second);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

ll dp[1001][4100] = {0};
//----------------------------------------------------------------
signed main(){

	ll n,m;
	cin >> n >> m;
	
	rep(i,m+1)rep(j,(1LL<<n))dp[i][j] = INF;
	dp[0][0] = 0;

	rep(i,m){
		ll a,b;
		cin >> a >> b;
		vll c(b);
		rep(j,b)cin >> c[j];
		// cerr << "kagi == " << i << endl;
		// cerr <<a <<" " << b << endl;
		// for(auto x:c)cerr << x << " ";cerr << endl;

		rep(j,(1LL<<n)){
			//not use
			dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
			//use
			ll next_j = j;
			for(auto x:c)next_j |= (1LL<<(x-1));
			dp[i+1][next_j] = min(dp[i+1][next_j],dp[i][j]+a);
		}
	}


	if(dp[m][(1LL<<n)-1] == INF)cout << -1 << endl;
	else cout << dp[m][(1LL<<n)-1] << endl;

	
    

	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc142.contest.atcoder.jp/tasks/abc142_b

Measured memory_bytes: 32256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define ll long long
ll n,k,ans;
int main(){
	//File();
	scanf("%lld%lld",&n,&k);
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	REP(i,k+1,n){
		ans+=n/i*(i-k);
		if(n%i)ans+=(n%i-k+1)>=0 ? n%i-k+1 : 0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, k;
pair<int, int> a[maxn];
void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
		//if (h[i] >= k)++h[0];
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
		cout << a[i].second << " ";
	//cout << h[0] << endl;
	//cout << 1.0 * (a + 1 >> 1) / (a) << endl;
}
int main() {
	solve();

	return 0;
}

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

int N;
long long int num[5] = {};

main()
{
    cin >> N;
    string name;
    for (int i = 0; i < N; i++) {
        cin >> name;
        switch (name[0]) {
            case 'M':
                num[0]++;
                break;
            case 'A':
                num[1]++;
                break;
            case 'R':
                num[2]++;
                break;
            case 'C':
                num[3]++;
                break;
            case 'H':
                num[4]++;
                break;
            default:
                break;
        }
    }

    long long int ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += num[i] * num[j] * num[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,t;
  cin >> n >> t;
  ll ans = 0, c = 0;
  rep(i,n){
    ll a;
    cin >> a;
    if(a<c) ans -= c-a;
    ans += t;
    c = a+t;
  }
  cout << ans << endl;
}


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

int main()
{
    string s;
    int ans=0;
    cin>>s;
    for(int i=0;i<s.length();++i)
    {
        if(s[i]=='+')
        ans++;
        else
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
S=int(input())
ans=int(0)
iqs=[1]
for i in range(1,S):
  iqs.append(i*iqs[-1])
#print(iqs)
for i in range(1,S//3+1):
        raw=S-i*3
    #(i-1)とrawの重複組み合わせ
        ans+=iqs[raw+i-1]//iqs[i-1]//iqs[raw]
        ans=ans%(10**9+7)
print(ans)

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

ans = 0
smallest = 10 ** 9 + 1
nega = 0
for i in range(len(A)):
  if A[i] < 0:
    nega ^= 1
    A[i] *= -1
  ans += A[i]
  if A[i] < smallest:
    smallest = A[i]
  
if nega:
  ans -= smallest * 2
  
print(ans)

Measured memory_bytes: 20000
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a;
	map<int,int> num;
	for(int i=0;i<n;i++){
		cin >> a;
		num[a]++;
	}
	int ans=0;
	for(auto p: num){
		int x=p.first;
		int m=p.second;
		if(m<x) ans+=m;
		else ans+=m-x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4736
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string result;
	int diff_y = ty - sy;
	int diff_x = tx - sx;

	result += string(diff_y, 'U');
	result += string(diff_x, 'R');

	result += string(diff_y, 'D');
	result += string(diff_x, 'L');

	result += 'L';
	result += string(diff_y + 1, 'U');
	result += string(diff_x + 1, 'R');
	result += 'D';

	result += 'R';
	result += string(diff_y + 1, 'D');
	result += string(diff_x + 1, 'L');
	result += 'U';

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(abs(a-x)>abs(b-x)){
		printf("B\n");
	}else{
		printf("A\n");
	}
	return 0;
}


Measured memory_bytes: 128
s=list(input().split())
n=int(s[0])
l=int(s[1])
cost=[]
time=[]

for i in range(n):
  li=list(input().split())
  if int(li[1])<=l:
    cost.append(int(li[0]))
    time.append(int(li[1]))
if len(cost)==0:
  print('TLE')
else:
  print(min(cost))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

ll n,c,v[100009],x[100009],sum1[100009],sum2[100009],a[100009],b[100009];

int main(){
    cin>>n>>c;
    FOR(i,1,n+1){
        cin>>x[i]>>v[i];
        sum1[i]=sum1[i-1]+v[i];
        a[i]=max(a[i-1],sum1[i]-x[i]);
    }x[n+1]=c;
    for(ll i=n;i;i--){
        sum2[i]=sum2[i+1]+v[i];
        b[i]=max(b[i+1],sum2[i]-c+x[i]);
    }
    ll ans=0;
    rep(i,n+1){
        ans=max(ans,sum1[i]-2*x[i]+b[i+1]);
    }
    for(ll i=n+1;i;i--){
        ans=max(ans,sum2[i]-2*(c-x[i])+a[i-1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	char a;
	cin >> a;
	if(a >= 'a') cout << "a\n";
	else cout << "A\n";
}

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

using namespace std;
int main()
{
    long long x,y;
    cin >> x >> y;
    if(x>=y&&x%y==0) printf("-1\n");
    else
    {
        if((x*2)%y!=0) printf("%lld\n",x*2);
        else if((x*3)%y!=0) printf("%lld\n",x*3);
        else printf("-1\n");
    }
    return 0;
}


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

int calc(int year, int month, int day) {
  int res = 0;
  for (int y = 1; y < year; ++y) {
    if (y % 3 == 0) res += 200;
    else res += 195;
  }
  for (int m = 1; m < month; ++m) {
    if (m % 2 == 0 && year % 3 != 0) res += 19;
    else res += 20;
  }
  res += day;
  return res;
}

int main() {
  int n;
  cin >> n;
  
  int Mil = calc(1000, 1, 1);
  for (int i = 0; i < n; ++i) {
    int y, m, d;
    cin >> y >> m >> d;
    int cal = calc(y, m, d);
    cout << Mil - cal << endl;
  }
}


Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int a, b, c;
  int xs[3];
  for (int i = 0; i < 3; i++) {
    cin >> xs[i];
  }
  sort(xs, xs + 3);
  cout << xs[0] << " " << xs[1] << " " << xs[2] << endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
 
const string YES = "Yes";
const string NO = "No";
 
void solve(){
 
}
 
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
        sum += v.at(i);
    }
    sort(v.rbegin(), v.rend());
    cerr << v.at(M-1) * 4*M << endl;
    if(v.at(M-1) * 4*M >= sum){
        cout << "Yes" << endl;
    } else { 
        cout << "No" << endl;
    }
 
         
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
	int n,m;
	cin >> n >> m;
	int a=1;
	while(a*(n-1)+1<m){
		a++;
	}
	if(m==1)
	cout << 0 << endl;
	else
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n, d;
    cin >> n >> d;
    int ans = d * 2 + 1;
    if (n % ans == 0) {
        cout << n / ans << endl;
    } else
        cout << n / ans + 1 << endl;
}

Measured memory_bytes: 256