akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int[] n = Read.Ints();
        Array.Sort(n);
        Console.WriteLine(n[n.Length-1]-n[0]);
        Console.ReadLine();
    }
    public static Boolean uso() { return false; }
    public static int gcd(int a, int b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static int lcm(int a, int b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int n, m;
map<int, pii> mp;

class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return true;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return false;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    vector<int> v[n];
    rep(i, m) { int a, b; cin >> a >> b; a--; b--; mp[i] = {a, b}; }
    int ans = 0;
    rep(i, m) {
        UnionFind uni(n);
        rep(j, m) {
            if (i == j) continue;
            uni.connect(mp[j].F, mp[j].S);
        }
        if (uni.size(0) != n) ans++;
    }
    out(ans);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		pair[] ar=new pair[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=new pair(scan.nextInt(),scan.nextInt());
		}
		Arrays.sort(ar,new compare());
		int curtime=0;
		for(int i=0;i<n;i++)
		{
			curtime+=ar[i].a;
			if(curtime>ar[i].b)
			{
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}
class pair{
	int a;int b;
	pair(int x,int y)
	{
		a=x;
		b=y;
	}
}
class compare implements Comparator<pair>
{

	@Override
	public int compare(pair o1, pair o2) {
		if(o1.b>o2.b)
		{
			return 1;
		}else if(o2.b>o1.b)
		{
			return -1;
		}else {
			return 0;
		}
	}
	
}

Measured memory_bytes: 105340
// ARC103F.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

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

int n, siz[MAX_N], id[MAX_N], fa[MAX_N], head[MAX_N], current;
ll D[MAX_N];
set<ll> st[2];
map<ll, int> mp;

struct edge
{
    int to, nxt;
} edges[MAX_N << 1];

void addpath(int src, int dst)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    head[src] = current++;
}

ll dfs(int u, int up)
{
    ll ret = 0;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].to != up)
            ret += dfs(edges[i].to, u) + siz[edges[i].to];
    return ret;
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &D[i]), mp[D[i]] = i, siz[i] = 1, id[i] = i;
    sort(id + 1, id + 1 + n, [](const int &rhs1, const int &rhs2) { return D[rhs1] > D[rhs2]; });
    for (int i = 1; i < n; i++)
    {
        int u = id[i];
        ll transfer = D[u] - (n - siz[u]) + siz[u];
        if (mp.count(transfer) == 0)
            puts("-1"), exit(0);
        fa[u] = mp[transfer], siz[fa[u]] += siz[u], addpath(fa[u], u), addpath(u, fa[u]);
    }
    if (dfs(id[n], 0) == D[id[n]])
    {
        for (int i = 1; i <= n; i++)
            if (fa[i] != 0)
                printf("%d %d\n", i, fa[i]);
    }
    else
        puts("-1");
    return 0;
}

Measured memory_bytes: 13952
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
from collections import Counter
def main():
    s = Counter(IS())
    print(700+s['o']*100)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << max({a+b,a-b,a*b}) << endl;

}


Measured memory_bytes: 256
N = int(input())
P = []
indexls = [0]*N
for i in range(N):
    tmp = int(input())
    P.append(tmp)
    indexls[tmp-1] = i
maxlen = 1
tmplen = 1
for i in range(1,N):
    if indexls[i] > indexls[i-1]:
        tmplen += 1
        maxlen = max(maxlen,tmplen)
    else:
        tmplen = 1
print(N-maxlen)

Measured memory_bytes: 19004
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

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

for(;a>=b;k--){
  b*=2;
}
for(;b>=c;k--){
  c*=2;
}
if(k>=0){
  std::cout << "Yes";
}else{
  std::cout << "No";
}
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#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 H,W,N; cin >> H >> W >> N;
  map<pair<ll,ll>,ll> cnt;
  REP(i,N){
    ll a,b; cin >> a >> b;
    REP(i,3) REP(j,3) cnt[{a-i,b-j}]++;
  }
  vector<ll> ans(10,0);
  FOREACH(p,cnt){
    ll x = p.first.first, y = p.first.second, c = p.second;
    if(1<=x && x<=H-2 && 1<=y && y<=W-2) ans[c]++;
  }
  ans[0] = (H-2)*(W-2);
  FOR(i,1,10) ans[0] -= ans[i];
  REP(i,10) cout << ans[i] << endl;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
int res=1e9,sum[15];
char s[15][1005];
bool flag[1010]; 
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cin>>s[i][j];
	}
	for(int i=0;i<(1<<(n-1));i++)
	{
		int cnt=0;
		vector<int>v;
		for(int j=1;j<n;j++)
		{
			int x=j-1;
			if((i>>x)&1==1)
				v.push_back(j);			
		}
		cnt=v.size();
		v.push_back(n);
		bool ok1=true;
		memset(flag,false,sizeof(flag));
		for(int j=0;j<15;j++)
			sum[j]=0;
		for(int j=0;j<m;j++)
		{
			for(int t=0;t<v.size();t++)
			{
				int a,b;
				if(t==0)
				{
					a=0;
					b=v[t]-1;
				}
				else
				{
					a=v[t-1];
					b=v[t]-1;
				}
				for(int x=a;x<=b;x++)
				{
					if(s[x][j]=='1')
						sum[t]++;
				}
			}
			bool ok2=false;
			for(int t=0;t<v.size();t++)
			{
				if(sum[t]>k)
				{
					ok2=true;
					break;
				}
			}
			if(ok2)
			{
				if(j==0)
				{
					ok1=false;
					break;
				}
				else
				{
					cnt++;
					for(int t=0;t<v.size();t++)
					{
						sum[t]=0;
						int a,b;
						if(t==0)
						{
							a=0;
							b=v[t]-1;
						}
						else
						{
							a=v[t-1];
							b=v[t]-1;
						}
						for(int x=a;x<=b;x++)
						{
							if(s[x][j]=='1')
								sum[t]++;
						}
						if(sum[t]>k)
						{
							ok1=false;
							break;
						}
					}
				}
			}
		}
		for(int j=0;j<m;j++)
		{
			if(flag[j])
				cnt++;
		}
		if(ok1==true)
			res=min(res,cnt);
	}
	cout<<res;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main(){
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	int sum=0;
	for (int i=1;i<n;i++)
		sum+=a[i];
	if (a[n]<sum) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> A(n, vector<ll>(m));
    vector<vector<ll>> B(l, vector<ll>(m)); // Transpose
    vector<vector<ll>> C(n, vector<ll>(l, 0));
    rep(i, n) rep(j, m) cin >> A[i][j];
    rep(j, m) rep(k, l) cin >> B[k][j];

    rep(i, n) rep(k, l) rep(j, m) C[i][k] += A[i][j] * B[k][j];

    rep(i, n) rep(k, l) {
        cout << C[i][k];
        if(k < l - 1)
            cout << " ";
        else
            cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3256
#include <stdio.h>
#include <stdlib.h>
#define N 200000
#define M 10*10*10*10*10*10*10*10*10
int max(int x,int y);
int min(int x,int y);
int main(){
  int i,j,n;
  int R[N];
  int minv;
  int maxv;
  scanf("%d",&n);
  if(n < 2 || n > N) exit(1);
  for(i=0;i<=n-1;i++){
    scanf("%d",&R[i]);
    if(R[i] < 1 || R[i] > M) exit(2);
  }
  minv = R[0];
  maxv = R[1]-R[0];
  for(j=1;j<=n-1;j++){
    maxv = max(maxv,R[j]-minv);
    minv = min(minv,R[j]);
  }
  printf("%d\n",maxv);
  return 0;
}

int max(int x,int y){
  if(x>y) return x;
  else return y;
}

int min(int x,int y){
  if(x<y) return x;
  else return y;
}



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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

vector<string> ans;
string s;

void addSubstr(int n, char c)
{
	FOR(i,0,n){
		if(s[i] == c){
			int l = min(5, n - i)+1;
			FOR(j,1,l){
				ans.pb(s.substr(i, j));
			}
		}
	}
}

int main()
{
	cin >> s;
	int k;
	cin >> k;
	char least = 'z';
	int n = s.size();
	FOR(i,0,n){
		if(least > s[i])least = s[i];
	}
	while(least <= 'z'){
		addSubstr(n,least);
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)), ans.end());
		if((int)ans.size() >= k)break;
		least++;
	}
/*	FOR(i,0,(int)ans.size())cout << ans[i] << " ";
	cout << endl;*/
	ANS(ans[k-1]);
	return 0;
}


Measured memory_bytes: 1660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<int> C,S,F;
int N;


int ch(int p,int t)
{
	//if(DP[t][p]!=-1)return DP[t][p];
	if(p+1==N-1)return t+C[p];

	if(S[p+1]>=t+C[p])
		return ch(p+1,S[p+1]);
	else
		return ch(p+1,(((t+C[p])/F[p+1]+((t+C[p])%F[p+1]?1:0))*F[p+1]));
}


int main()
{
	scanf("%d",&N);
	for(int i=0;i<N-1;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		C.push_back(a);
		S.push_back(b);
		F.push_back(c);
	}
	for(int i=0;i<N;i++)
	{
		if(i==N-1)puts("0");
		else printf("%d\n",ch(i,S[i]));
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; ll A[301];
//---------------------------------------------------------------------------------------------------
ll dp[51][2][2];
ll opt(ll A0, ll A1, ll other) {
	rep(d, 0, 51) rep(debt, 0, 2) rep(prof, 0, 2) dp[d][debt][prof] = infl;
	dp[0][0][0] = 0;

	rep(d, 0, 50) rep(debt, 0, 2) rep(prof, 0, 2) {
		ll a0 = ((A0 & (1LL << d)) != 0);
		ll a1 = ((A1 & (1LL << d)) != 0);
		ll b = ((other & (1LL << d)) != 0);

		int debt2 = 0, prof2 = 0;
		if (debt) a0--;
		if (a0 < 0) a0 = 1, debt2 = 1;
		if (prof) a1++;
		if (a1 == 2) a1 = 0, prof2 = 1;

		
		/*int debt2 = 0;
		if (debt == 0) {
			// 借金無
		}
		else {
			// 借金してる
			if (a0 == 0) {
				// でもお金ないし、借金連鎖
				debt2 = 1;
				a0 = 1;
			}
			else {
				a0 = 0;
			}
		}

		int prof2 = 0;
		if (prof == 0) {
			// 利益無し
		}
		else {
			// 利益あり
			if (a1 == 1) {
				// でも既にあるから、利益連鎖
				prof2 = 1;
				a1 = 0;
			}
			else {
				a1 = 1;
			}
		}*/

		// 何もしない
		if ((a0 ^ a1) == b) chmin(dp[d + 1][debt2][prof2], dp[d][debt][prof]);

		// 1つ渡す
		a0--;
		if (a0 < 0) debt2 = 1, a0 = 1;
		a1++;
		if (a1 == 2) prof2 = 1, a1 = 0;

		if ((a0 ^ a1) == b) chmin(dp[d + 1][debt2][prof2], dp[d][debt][prof] + (1LL << d));
	}

	//rep(d, 0, 5) rep(de, 0, 2) rep(pr, 0, 2) printf("dp[%d][%d][%d] = %lld\n", d, de, pr, dp[d][de][pr]);

	ll ans = dp[50][0][0];
	if (ans == infl) ans = -1;
	if (ans == A0) ans = -1;
	return ans;
}
//---------------------------------------------------------------------------------------------------
ll naive(ll A0, ll A1, ll other) {	
	rep(move, 0, A0) if ((other ^ (A0 - move) ^ (A1 + move)) == 0) return move;
	return -1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	ll other = 0;
	rep(i, 2, N) other ^= A[i];

	//cout << naive(A[0], A[1], other) << endl;
	cout << opt(A[0], A[1], other) << endl;
}







Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  if (A < 10 and B < 10) cout << A * B << endl;
  else cout << -1 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b;
	cin >> a >> b;
	cout << (a*b % 2 == 1 ? "Yes" : "No") << '\n';
}


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

int main() {
  while (true) {
    string s;
    cin >> s;
    int a = 0, b = 0;
    if (s == "") break;
    for (int i = 0; i < s.size() - 2; i++) {
      if (s.at(i) == 'J' && s.at(i + 1) == 'O' && s.at(i + 2) == 'I') a++;
      if (s.at(i) == 'I' && s.at(i + 1) == 'O' && s.at(i + 2) == 'I') b++;
    }
    cout << a << endl;
    cout << b << endl;
  }
}


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

int main() {
	long double N;
	cin >> N; 
	for (long double i = 1; i <= 3500; i += 1) {
		for (long double j = 1; j <= 3500; j += 1) {
			long double w = (N * i * j)/(4 * i * j - N * i - N * j);
			if (w > 0.0 && w < 3500.0 && floor(w) == w) {
				cout << fixed << setprecision(0) << i << " " << j << " " << w << " \n";
				return 0;
			}
		}
	}
}


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

int n, m, q;
int ans = 0;
std::vector<int> a, b, c, d;
void dfs(std::vector<int> A){
    if(A.size() == n+1){
	int tmp = 0;
	for(int i = 0; i < q; i++){
	    if(A[b[i]] - A[a[i]] == c[i]){
		tmp += d[i];
	    }
	}
	ans = std::max(ans, tmp);
	return;
    }

    A.push_back(A.back());

    while(A.back() <= m){
	dfs(A);
	A.back()++;
    }


}

int main(void){
    std::cin >> n >> m >> q;
    a = b = c = d = std::vector<int>(q);
    for(int i = 0; i < q; i++){
	std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(std::vector<int>(1, 1));

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 3508
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <pii, vpi, greater<pii>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a, n, m, d;
vpi v;

void solve()
{
     cin >> n >> d >> a;
     for (int i = 0; i < n; i++)
     {
          int x, y; cin >> x >> y;
          v.pb({x, y});
     }
     sort(all(v));

     int bomb = 0, p = 0;
     que_min q;
     for (int i = 0; i < n; i++)
     {
          while (sz(q) && q.top().F < v[i].F)
          {
               p -= q.top().S;
               q.pop();
          }
          int dd = 0;

          if (v[i].S > p)
          {
               int x = v[i].S - p;
               int div = (x + a - 1) / a;
               p += div * a;
               dd = div * a;
               bomb += div;
               q.push({v[i].F + 2 * d, dd});
          }
     }
     cout << bomb;

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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



using namespace std;


main()
{
    string s, s1, s2 = "";
    s1 = "AKIHABARA";
    cin >> s;
    if (s[0] != 'A')
        s = 'A' + s;
    for (int i = 0; i < s.size(); i++)
    {
        s2 = s2 + s[i];
        if (s[i] != 'A' && (s[i + 1] == 'K' || s[i + 1] == 'B' || s[i + 1] == 'R'))
             s2 = s2 + 'A';
    }
    if (s2.back() != 'A')
        s2 += 'A';
    if (s2 == s1)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}




Measured memory_bytes: 256
#include <iostream>
#define MAX_ROW 1000000000
#define MAX_COL 1000000000
using namespace std;


int main()
{
    long N,M;
    cin  >> N >> M;
    if((N == 1) || (M == 1))
    {
        if(N > M){ cout << (N - 2) << endl; }
        else if(M > N){ cout << (M - 2) << endl;}
        else{ cout << 1 << endl; }
    }
    else if ((N == 2) || (M == 2))
    {
        cout << 0 << endl;
    }
    else
    {
        cout << (M * N) - (2 * (M + N) -4) << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    long long N; scanf("%lld", &N);
    if(N == ((long long)1e18) - 1){
        printf("%lld %lld\n%lld %lld\n%lld %lld\n", (long long)1e9, (long long)1, (long long)1, (long long)1e9, (long long)0, (long long)0);
    }
    else if(N == ((long long)1e18)){
        printf("%lld %lld\n%lld %lld\n%lld %lld\n", (long long)1e9, (long long)0, (long long)0, (long long)1e9, (long long)0, (long long)0);
    }
    else{
        long long a = N / ((long long)(1e9) - 1);
        N -= a * ((long long)(1e9) - 1);
        printf("%lld %lld\n%lld %lld\n%lld %lld\n", a, (long long)0, N, (long long)1e9, (long long)0, (long long)1);
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

def solve():
    N, K = list(map(int, input().split()))

    ans = 0
    for i in range(1, N+1):
        if i >= K:
            ans += (1/N)
            continue
        # a*2^n >= K より
        # n >= log2(K/a)
        n = math.ceil(math.log2(K/i))
        ans += (1/N) * (1/2)**n

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
import java.util.*;


		       public class Main {

		           public static void main(String args[])  {
		        	   Scanner sc =new Scanner(System.in);
		        	   int lifeA = sc.nextInt();
		        	   int attackA = sc.nextInt();
		        	   int lifeB = sc.nextInt();
		        	   int attackB = sc.nextInt();	
                      while(lifeA>0 && lifeB>0) {
                    	  if(lifeA>0) {
                    		  lifeB -= attackA;
                    	  }
                    	  if(lifeB>0){
                    		  lifeA -=attackB;
                    	  }

                      }
                      if(lifeA <lifeB) {
                    	  System.out.println("No");
                      }else {
                    	  System.out.println("Yes");
                      }

		           }
		       }




Measured memory_bytes: 35732
def get_score(s, t):
    for i in range(len(s)):
        s = s[-1:] + s[:len(s) - 1]
        if s == t:
            return True
    return False


a = input()
b = input()

r = 'Yes' if get_score(a, b) else 'No'
print(r)


Measured memory_bytes: 2940
//?????????????????????
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(void){
    int n, q, t;
    string name;
    //?¨????????????????????????? queue????????????
    queue<pair<string, int> > Q;     //?????????????????\???
    
    cin >> n >> q;
    
    //????????????????????????????????\???????????????????????????
    for(int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    
    pair<string, int> u;
    int elaps = 0, a;
    
    //?¶£?????¬????????§???
    while(!Q.empty()){
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if(u.second > 0){
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4408
from collections import deque


n=int(input())
num=deque()
inst=[]*2
for i in range(n):
    inst=input().split()
    if inst[0]=="insert":
        num.appendleft(inst[1])
    elif inst[0]=="deleteFirst":
        num.popleft()
    elif inst[0]=="deleteLast":
        num.pop()
    elif inst[0]=="delete":
        try:
            num.remove(inst[1])
        except:
            pass

print(" ".join(num))


Measured memory_bytes: 69732
import sys
from operator import or_
sys.setrecursionlimit(10 ** 7)

# AC
# Python3 (3.4.3) 696 ms
# PyPy3 (2.4.0) 1572 ms


class SegmentTree:
    """
    引数：
        N: 処理する区間の長さ
        operator: モノイド演算 (max, min, __add__,ラムダ式,関数定義など)
        UNIT: 単位元
        a: 長さNの配列 a で初期化（a を与えない場合、単位元で初期化）
    注意: 内部的には 1-indexed
    """

    def __init__(self, N, operator, unit, a=None):
        self.op = operator
        self.UNIT = unit

        self.N0 = 2**(N-1).bit_length()
        self.tree = [self.UNIT]*(2*self.N0)
        if a != None:
            self.tree[self.N0:self.N0+N] = a[:]
            for k in range(self.N0-1, 0, -1):
                self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])

    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0
        self.tree[k] = x
        k //= 2
        while k:
            self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])
            k //= 2

    # 区間[l,r)をopでまとめる
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = self.UNIT
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(self.tree[R], s)
            if L & 1:
                s = self.op(s, self.tree[L])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def get(self, k):  # k番目の値を取得。query[k,k]と同じ
        return self.tree[k + self.N0]

    def all(self):
        return self.tree[1]


N = int(input())
S = input()
S = [1 << (ord(x) - 97) for x in S]

seg = SegmentTree(N, or_, 0, S)

Q = int(input())

ans = []
for _ in range(Q):
    q, a, b = input().split()

    if q == '1':
        b = 1 << (ord(b) - 97)
        seg.update(int(a) - 1, b)
    else:
        r = seg.query(int(a) - 1, int(b))
        cnt = 0

        for i in range(26):
            if r & (1 << i):
                cnt += 1

        ans.append(str(cnt))


print("\n".join(ans))


Measured memory_bytes: 78780
import math

a, b = map(int, input().split())
i = -1
atax = -1
btax = -1
while not ((atax == a and btax == b) or (btax > 100)):
    i += 1
    atax = math.floor(i * 0.08)
    btax = math.floor(i * 0.1)
if btax > 100:
    print(-1)
else:
    print(i)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;


string st;
int a;

int plmi();

int num() {
	int n = 0;
	while (1) {
		if (isdigit(st[a])) {
			n *= 10;
			n += st[a] - '0';
			a++;
		}
		else {
			return n;
		}
	}
}

int siki() {
	int n;
	if (st[a] == '(') {
		a++;
		n=plmi();
		a++;
	}
	else {
		n = num();
	}
	return n;
}

int evdi() {
	int n = siki();
	while (1) {
		if (st[a] == '*') {
			a++;
			n *= siki();
		}
		else if (st[a] == '/') {
			a++;
			n /= siki();
		}
		else {
			break;
		}
	}
	return n;
}

int plmi() {
	int n=evdi();
	while (1) {
		if (st[a] == '+') {
			a++;
			n += evdi();
		}
		else if (st[a] == '-') {
			a++;
			n -= evdi();
		}
		else {
			break;
		}
	}
	
	return n;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> st;
		a = 0;
		int ans=plmi();
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n;cin >> n;
	
	vector<ll> v(n);
	ll sum = 0;
	
	REP(i,n)
	{
		cin >> v[i];
		sum += v[i];
	}
	
	bitset<4000000> dp;
	dp[0] = 1;
	
	REP(i,n)dp |= dp << v[i];
	
	REP(i,4000000)
	{
		if(dp[i]&&i>=sum-(sum/2))
		{
			cout << i << endl;
			return 0;
		}
	}	
	
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
X = [tuple(map(int, input().split())) for _ in range(N)]

if N % 2 == 0:
    n0 = N // 2 - 1
    n1 = n0 + 1
else:
    n0 = (N + 1) // 2 - 1
    n1 = n0

# Aの順
X.sort()
l0 = X[n0][0]
l1 = X[n1][0]
Ls, Lt = divmod(l0 + l1, 2)

# Bの順
X.sort(key=lambda x: x[1])
r0 = X[n0][1]
r1 = X[n1][1]
Rs, Rt = divmod(r0 + r1, 2)

e = 2 if N % 2 == 0 else 1
d = (Rs * e) - (Ls * e) + 1
cnt = d
cnt -= (Lt == 1)
cnt += (Rt == 1)
print(cnt)


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vull vector<ull>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define reset(x,y) memset(x,y,sizeof x);
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";
ll n,k;
vvll a;

ll add(ll a, ll b) {
	ll ret=(a+b)%mod;
	while(ret<0) ret+=mod;
	return ret%mod;
}

vector<vll> mul(vector<vll> a, vector<vll> b) {
	vvll ret(a.size(),vll(b[0].size(),0));
	for(int i = 0; i < a.size(); i++) {
		for(int j = 0; j < b[0].size(); j++) {
			ret[i][j] = 0;
			for(int k = 0; k < b.size(); k++) {
				ret[i][j] = add(ret[i][j],a[i][k]*b[k][j]%mod);
			}
		}
	}
	return ret;
}

vvll modexp(ll exp) {
	vector<vll> tmp = a;
	vvll ret;
	ret.resize(n,vll(n));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ret[i][j] = (i==j);
		}
	}
	while(exp > 0) {
		if(exp&1)
			ret = mul(ret,tmp);
		tmp = mul(tmp,tmp);
		exp>>=1;
	}
	return ret;
}

int main() {
//	IOS
	cin >> n >> k;
	a.resize(n,vll(n));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(i!=j)
				swap(a[i][j],a[j][i]);//transpos
		}
	}
//	testing
	vvll pkt=modexp(k);
	vvll vec(n,vll(1,1));
	vec=mul(pkt,vec);
	ll res = 0;
//	for(int i = 0; i < n; i++) {
//		for(int j = 0; j < n; j++) {
//			cout<<pkt[i][j]<<(j+1==n?'\n':' ');
//		}
//	}
//	testing
	for(int i = 0; i < n; i++) {
		res=(res+vec[i][0])%mod;
//		cout<<vec[i][0]<<endl;
	}
	cout<<res<<endl;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!p)
#define until(p) while(!p)

using ll = long long;
using P = std::tuple<int,int>;

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

int counter[1000], counter2[1000];

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        fill(counter2, counter2+1000, 0);
        
        string S;
        std::cin >> S;

        for(char& c : S){
            ++counter2[c];
        }

        for(int j='a';j<='z';++j){
            if(i == 0){
                counter[j] = counter2[j];
            }else{
                counter[j] = min(counter[j], counter2[j]);
            }
        }
    }

    for(int i='a';i<='z';++i){
        if(counter[i] == 0){continue;}

        std::cout << std::string(counter[i], (char)i);
    }

    std::cout << std::endl;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i]= map(int, input().split())
links = [[] for _ in range(N + 1)]
for i in range(len(A)):
    links[A[i]].append(B[i])
    links[B[i]].append(A[i])
    
#print(links)
result = [-1] * (N + 1)
q = deque([1])
#print(q)
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
            #print(q)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

Measured memory_bytes: 45208
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<u64>();
    let s = v[0] + v[1];
    if s & 0x1 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", s / 2);
    }
}


Measured memory_bytes: 4352
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>

    using namespace std ;

    int main(){
      int N,L;
      cin>>N>>L;
      if(L<=0&&abs(L)<=N-1)cout<<L*N+(N*(N-1))/2<<endl;
      if(L<=0&&abs(L)>N-1)cout<<(L-1)*(N-1)+(N*(N-1))/2<<endl;
      if(L>0)cout<<L*(N-1)+(N*(N-1))/2<<endl;
      return 0;
    }

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

// ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++; // counting divisors
//bool isPrime(ll n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	int n, k; cin >> n >> k;

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

	cout << cnt << "\n";


}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
const ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
// lcm = (a*b)/gcd(a,b)
//freopen("input.txt" ,"r",stdin );
//freopen("output.txt","w",stdout);
int n;
vector<int>a,b,c;
int memo[100005][4];
int fun(int idx,int prev)
{
	if (idx ==n)
		return 0;
	int &ret = memo[idx][prev];
	if (~ret)
		return ret;
    if(prev==0)
        return ret=max(fun(idx+1,1)+b[idx],fun(idx+1,2)+c[idx]);
    else if(prev==1)
        return ret=max(fun(idx+1,0)+a[idx],fun(idx+1,2)+c[idx]);
    else if(prev==2)
        return ret=max(fun(idx+1,0)+a[idx],fun(idx+1,1)+b[idx]);
    else
        return ret=max(fun(idx+1,0)+a[idx],max(fun(idx+1,1)+b[idx],fun(idx+1,2)+c[idx]));
}
void fast();
int main()
{
    fast();
    cin>>n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    memset(memo,-1,sizeof memo);
    loop(n)cin>>a[i]>>b[i]>>c[i];
    cout<<fun(0,3);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 7680
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;
	in(n);
	LL ec = 0, vc = 0;
	vector<bool> vis(n+1, false);
	for(int i=0;i<n-1;i++) {
		int x, y;
		in2(x, y);
		if(!vis[x]) vc += 1L * x * (n-x+1);
		if(!vis[y]) vc += 1L * y * (n-y+1);
		vis[x] = true;vis[y] = true;
		ec += (1L * min(x, y) * (n - max(x, y)+1));
	}
	cout<<(n == 1 ? 1 : vc-ec)<<en;
}

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


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>

using namespace std;
const int MAXN = 2010 , MOD = 924844033;
int g[MAXN][MAXN][3];
int f[MAXN][MAXN];
int fac[MAXN] , ifac[MAXN] , ans[MAXN];
int rk[MAXN];
int n , k;

int C(int a , int b){
	return 1ll * fac[a] * ifac[a - b] % MOD * ifac[b] % MOD;
}

int main(){
	cin >> n >> k;
	k <<= 1;
	fac[0] = fac[1] = 1;
	for(int i = 2 ; i <= n ; ++ i)
		fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[0] = ifac[1] = 1;
	for(int i = 2 ; i <= n ; ++ i)
		ifac[i] = MOD - 1ll * ifac[MOD % i] * (MOD / i) % MOD;
	for(int i = 2 ; i <= n ; ++ i)
		ifac[i] = 1ll * ifac[i - 1] * ifac[i] % MOD;
	int now = 1;
	for(int i = 1 ; i <= n ; ++ i){
		rk[i] = now;
		now += k;
		if(now > n){
			now %= k;
			now ++;
		}
	}
	g[0][0][0] = 1;
	f[0][0] = 1;
	k >>= 1;
	for(int i = 1 ; i <= n ; ++ i){
		if(rk[i] <= 2 * k){
			for(int j = 0 ; j <= i ; ++ j){
				g[i][j][0] = f[i - 1][j];
				if(j && rk[i] - k > 0) g[i][j][1] = f[i - 1][j - 1];
				if(j && rk[i] + k <= n) g[i][j][2] = f[i - 1][j - 1];
			}
			for(int j = 0 ; j <= i ; ++ j)
				for(int t = 0 ; t < 3 ; ++ t)
					f[i][j] = (f[i][j] + g[i][j][t]) % MOD;
		}
		else{
			for(int j = 0 ; j <= i ; ++ j){
				g[i][j][0] = f[i - 1][j];
				if(j) g[i][j][1] = (g[i - 1][j - 1][0] + g[i - 1][j - 1][1]) % MOD;
				if(j && rk[i] + k <= n) g[i][j][2] = f[i - 1][j - 1];
			}
			for(int j = 0 ; j <= i ; ++ j)
				for(int t = 0 ; t < 3 ; ++ t)
					f[i][j] = (f[i][j] + g[i][j][t]) % MOD;
		}
	}
	now = 1;
	for(int i = n ; i >= 0 ; -- i){
		ans[i] = 1ll * f[n][i] * now % MOD;
		now = 1ll * now * (n - i + 1) % MOD;
	}
	for(int i = n - 1 ; i >= 0 ; -- i)
		for(int j = i + 1 ; j <= n ; ++ j)
			ans[i] = (ans[i] + MOD - 1ll * ans[j] * C(j , i) % MOD) % MOD;
	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 62336
<?php
$num=trim(fgets(STDIN));
$number=trim(fgets(STDIN));
$number=explode(" ",$number);
asort($number);
$arrs=array_keys($number);
$answer="";
foreach($arrs as $arr){
  	$arr=intval($arr);
	$answer.=strval($arr+1)." ";
}
echo $answer;

Measured memory_bytes: 36568
N = gets.chomp.to_i
B = gets.chomp.split.map(&:to_i)

# p N
# p B

Res = []
Erased = Array.new(N, false)  # erased flag

def solve
  0.upto(N-1).each do
    last_k = -1
    last_i = -1

    k = 0  # k: the index without erased one
    0.upto(N-1).each do |i|  # i: the index with erased one
      next if (Erased[i]) # skip erased one
      
      if (B[i] == k + 1)
        last_k = k
        last_i = i
      end
      
      k += 1
    end
    
    # Now, last_k is the largetst k
    if last_k == -1  # No one found
      p -1
      return
    end
    
    Erased[last_i] = true
    Res << last_k
  end
  
  Res.reverse.each do |e|
    p e + 1  # 1-indexed
  end
end

solve

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

#define int long long
const long long INF = 1LL << 61;

struct sol {
	long long x, cost;
	long long c;

	sol(long long xx, long long cc, long long C) {
		x = xx;
		cost = cc;
		c = C;
	}

	long long getCost(long long y) {
		long long d = y - x;
		return d * d + cost + c;
	}

	long long time(sol sol2) {
		long long l = sol2.x;
		long long r = sol2.x;

		while (getCost(r) < sol2.getCost(r))
		{
			l = r + 1;
			r *= 2;
		}

		long long ans = r;


		while (l <= r) {
			long long mid = l + (r - l) / 2;
			if (getCost(mid) >= sol2.getCost(mid)) {
				ans = mid;
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		return ans;
	}
};

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long c;
	cin >> n >> c;

	vector<long long> heights;
	for (int i = 0; i < n; i++) {
		long long h;
		cin >> h;
		heights.push_back(h);
	}

	vector<long long> dp(n, INF);
	dp[0] = 0LL;
	deque<sol> all;
	
	all.push_back({ heights[0], 0, c });
	for (int i = 1; i < n; i++) {
		while (all.size() >= 2 && all[0].getCost(heights[i]) >= all[1].getCost(heights[i])) {
			all.pop_front();
		}
		dp[i] = all[0].getCost(heights[i]);
		sol add(heights[i], dp[i], c);
		while (true) {
			if (all.size() < 2) {
				break;
			}

			if (all[all.size() - 2].time(all[all.size() - 1]) < all[all.size() - 2].time(add)) {
				break;
			}

			if (all[all.size() - 2].time(all[all.size() - 1]) == all[all.size() - 2].time(add)) {
				long long tm = all[all.size() - 2].time(all[all.size() - 1]);
				if (all[all.size() - 1].getCost(tm) < add.getCost(tm)) {
					break;
				}
			}
			all.pop_back();
		}
		all.push_back(add);

	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 9480
# tameshi 
n = input()
lis = []
ans = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:ans += 1
  
print ' '.join( map(str, reversed(lis[ans:])) )

Measured memory_bytes: 61524
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let d: i32 = input();

    let d = 2 * d + 1;
    println!("{}", (n + d - 1) / d);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define rep(a,b,c) for(int a=(int)b;a<(int)c;a++)
#define repe(a,b,c) for(int a=(int)b;a<=(int)c;a++)
#define repk(a,b,c,k) for(int a=(int)b;a<(int)c;a+=(int)k)
#define comeback std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define ful(a) a.begin(),a.end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
using namespace std;
int em(int x,int n)
{
    if(n==0)
    return 1;
    else if(n%2==0)
    return em((x%mod*x%mod)%mod,n/2);
    else
    return (x%mod*em((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int dp[3001][3001];
int a[3001];
int fun(int lo,int hi){
	if(lo==hi)
		return a[lo];
	if(dp[lo][hi]!=-1)
		return dp[lo][hi];
	int ans=0;
	ans=max(a[lo]-fun(lo+1,hi),a[hi]-fun(lo,hi-1));
	return dp[lo][hi]=ans;
}
signed main()
{
	comeback
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif*/
		int n,m,i,j,k,l;
		cin>>n;
		//int a[n+1];
		repe(i,1,n)
		cin>>a[i];
		memset(dp,-1,sizeof(dp));
		cout<<fun(1,n);
}

Measured memory_bytes: 70912
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int R = sc.nextInt();
		System.out.println(R + (100 * Math.max(10 - N, 0)));
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 22732