akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,i,x,y,z;
	for(i=1;i<=3;i++) {
		scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
		x=d-a;
		if((e-b)>0) {
			y=e-b;
		}
		else {
			x=x-1;
			e=e+60;
			y=e-b;
		}
		if((f-c)>0) {
			z=f-c;
		}
		else {
			y=y-1;
			f=f+60;
			z=f-c;
		}
		if(z>=60) {
			y=y+1;
			z=z-60;
		}
		if(y>=60) {
			x=x+1;
			y=y-60;
		}
		printf("%d %d %d\n",x,y,z);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
  
int popStack(stack<int>* stk){
    int ret = stk->top();
    stk->pop();
    return ret;
}
  
  
int main(){
    string s;
    getline(cin,s);
    stack<int> stk;
    for(int i = 0; i < s.size();i++){
        if(s[i] != ' '){
            if('0' <= s[i] && s[i] <= '9'){
                int val = s[i] - '0';
                i++;
                while(s[i] != ' '){
                    val *= 10;
                    val += s[i] - '0';
                    i++;
                }
                stk.push(val);
            }else{
                int val;
                switch(s[i]){
                    case '+':
                        val = popStack(&stk) + popStack(&stk);      
                        break;
                    case '-':
                        val = popStack(&stk);
                        val = popStack(&stk) - val;
                        break;
                    case '*':
                        val = popStack(&stk) * popStack(&stk);
                        break;
                    case '/':
                        val = popStack(&stk);
                        val = popStack(&stk) / val;
                        break;
                }
                stk.push(val);
            }
        }
    }
    cout << stk.top() << endl;
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    ll ans = 0;
    vector<bool> win(N, false);
    rep(i, 0, N) {
        if (i < K) {
            if (T[i] == 'r') {
                ans += P;
            }
            else if (T[i] == 's') {
                ans += R;
            }
            else {
                ans += S;
            }
            win[i] = true;
        }
        else {
            if (T[i - K] == T[i]) {
                if (!win[i - K]) {
                    if (T[i] == 'r') {
                    ans += P;
                    }
                    else if (T[i] == 's') {
                        ans += R;
                    }
                    else {
                        ans += S;
                    }
                    win[i] = true;
                }
            }
            else {
                if (T[i] == 'r') {
                    ans += P;
                }
                else if (T[i] == 's') {
                    ans += R;
                }
                else {
                    ans += S;
                }
                win[i] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int a[5];
    for (Int i = 0; i < (Int)5; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            print(i + 1);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3544
/*
author : seryu
title : ABC171C_"One Quadrillion and One Dalmetians"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	ll n;
	cin >> n;
	ll sum = 0;
	ll num = 1;
	while (true)
	{
		if(sum < n && n <= sum + powl(26, num))break;
		sum += pow(26, num);
		num++;
	}

	n -= sum;
	n -= 1;
	string ans(num, 'a');
	rep(i, num)
	{
		int a = n % 26;
		ans[i] += a;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans << endl;
	return;	
}

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


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define er(n) cout << "error " << n << endl;
#define pbds tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007

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

int32_t main() {
	//Abhay();
	int n, w; cin >> n >> w;
	pi a[n];
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i].F >> a[i].S;
	}
	int dp[2][w + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0 ; i < n ; i++) {
		for (int j = 0 ; j <= w ; j++) {
			dp[i & 1][j] = dp[1 - (i & 1)][j];
			if (j - a[i].F >= 0)
				dp[i & 1][j] = max(dp[i & 1][j], dp[1 - (i & 1)][j - a[i].F] + a[i].S);
		}
	}
	cout << dp[(n - 1) & 1][w];
	return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll p[n],q[n];
    
    rep(i,0,n-1)cin>>p[i];
    rep(i,0,n-1)cin>>q[i];
    ll a[n];rep(i,0,n-1)a[i]=i+1;
    ll c=0,a1,a2;
    do{
        c++;
        bool f=true;
        rep(i,0,n-1){
            if(p[i]!=a[i])f=false;
        }
        if(f)a1=c;
        f=true;
        rep(i,0,n-1){
            if(q[i]!=a[i])f=false;
        }
        if(f)a2=c;
    }while(next_permutation(a,a+n));
    
    cout<<abs(a2-a1)<<endl;
    
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    int sum = 0;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        if(i%2==0) sum+=a[i];
        else sum -=a[i];
    }
    vector<int> b(n);
    b[0] = sum;
    for(int i=1;i<n;i++){
        b[i] = 2 * a[i-1] - b[i-1];
    }
    rep(i,n){
        cout << b[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2048
from numpy import array as n
N, C = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(N)]
r1, r2, l1, l2 = [0],[0],[0],[0]
sum = 0
for x, cal in xy:
    sum += cal
    r1.append(max(r1[-1], sum-x))
    r2.append(max(r2[-1], sum-2*x))
sum = 0
for x, cal in xy[::-1]:
    sum += cal
    l1.append(max(l1[-1], sum-C+x))
    l2.append(max(l2[-1], sum-2*(C-x)))
out = max(n(r1+r2)+n(l2[::-1]+l1[::-1]))
print(out)

Measured memory_bytes: 54000
# frozen_string_literal: true

def chmin(a, b)
  a > b ? b : a
end

n = gets.to_i
h = gets.split.map(&:to_i)
dp = Array.new(100_010, 10_000_00007)
dp[0] = 0
(1..n - 1).each do |i|
  dp[i] = chmin(dp[i - 2] + (h[i] - h[i - 2]).abs, dp[i]) if i != 1
  dp[i] = chmin(dp[i - 1] + (h[i - 1] - h[i]).abs, dp[i])
end
puts dp[n - 1]


Measured memory_bytes: 8836
from collections import deque
import pprint
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]

#まずは#を0、.をinfにして初期化
for i in range(H):
    for j in range(W):
        if A[i][j]==".":
            A[i][j]=float("inf")
        else:
            A[i][j]=0
#上下左右に値を流し、最小を格納することで、暗黒からの最短距離を出せるはず
for i in range(H):
    for j in range(0,W-1):
        A[i][j+1]=min(A[i][j+1],A[i][j]+1)
#print(A)
for i in range(H):
    for j in range(W-1,0,-1):
        A[i][j-1]=min(A[i][j-1],A[i][j]+1)
#print(A)
for j in range(W):
    for i in range(0,H-1):
        A[i+1][j] = min(A[i+1][j], A[i][j] + 1)
#print(A)
for j in range(W):
    for i in range(H-1,0,-1):
        A[i-1][j] = min(A[i-1][j], A[i][j] + 1)
#pprint.pprint(A)
ma=0
for i in range(H):
    for j in range(W):
        ma=max(ma,A[i][j])
print(ma)



Measured memory_bytes: 139100
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50
bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

/*****************************************************************************/
LL ans = 0;
LL n;
void dfs(LL a) {
	if (a <= n) {
		st s = to_string(a);
		if (s.find('3') != -1 && s.find('5') != -1 && s.find('7') != -1) {
			ans++;
		}
	}
	else {
		return;
	}
	
	dfs(a * 10 + 3);
	dfs(a * 10 + 5);
	dfs(a * 10 + 7);
}

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

	cin >> n;
	dfs(0);
	cout << ans;
	return 0;
}

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

int main(){
    ll N;  cin >> N;
    vector<pair<ll, ll>> pos;
    for(ll i=1; i*i<=N; i++){
        if(N%i == 0){
            pos.push_back({i, N/i});
        }
    }

    ll ans = 1e18;
    for(auto p : pos){
        ans = min(ans, p.first-1 + p.second-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll sumv=0,sumc=0;
    int v[n+10],c[n+10];
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int j=0;j<n;j++)
        cin>>c[j];
    for(int i=0;i<n;i++)
    {
       if(v[i]>c[i])
       {sumv+=v[i];
       sumc+=c[i];}
    }
    cout<<sumv-sumc<<endl;
    return 0;
}


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

int main() {
	std::ios::sync_with_stdio(false);
	string str;
	cin>>str;
	int i=0;
	int t=-1;
	int len=str.length();
	int countt=0;
	while(i<len){
		if(str[i]=='S'){
			++t;
		}
		if(str[i]=='T'){
			if(t==-1){
				++countt;
			}
			if(t>=0){
				--t;
			}
		}
		++i;
	}
	printf("%i\n",t+1+countt);
	return 0;
}


Measured memory_bytes: 720
import string
pp = list(input())
pp=list(set(pp))
pp.sort()
pp.append("1")
s = ""
x = list(string.ascii_lowercase)
x.append("None")
for j in range(len(pp)):
    if pp[j] != x[j]: 
        s = x[j]
        break
    elif pp[j] =="1":
        s = "None"
print(s)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<ll> g[ohara];
bool vi[ohara];
ll ans_cou;
deque<ll> ans;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    ans.push_front(0LL);
    vi[0]=true;
    rep(i,Size(g[0])){
        if(!vi[g[0][i]]){
            if(cnt==0){
                ans.push_front(g[0][i]);
                vi[g[0][i]]=true;
            }
            else{
                ans.push_back(g[0][i]);
                vi[g[0][i]]=true;
            }
            cnt++;
            if(cnt>=2)break;
        }
    }
    ll now;
    while(1){
        //左端
        int ok=0;
        now=ans[0];
        rep(i,Size(g[now])){
            if(!vi[g[now][i]])ok=1;
        }
        if(ok){
            rep(i,Size(g[now])){
                if(!vi[g[now][i]]){
                    vi[g[now][i]]=true;
                    ans.push_front(g[now][i]);
                    break;
                }
            }
        }

        //
        int okk=0;
        now=ans[Size(ans)-1];
        rep(i,Size(g[now])){
            if(!vi[g[now][i]])okk=1;
        }
        if(!ok&&!okk)break;
        if(okk){
            rep(i,Size(g[now])){
                if(!vi[g[now][i]]){
                    vi[g[now][i]]=true;
                    ans.push_back(g[now][i]);
                    break;
                }
            }
        }
    }

    Cout(Size(ans));
    rep(i,Size(ans)){
        if(i==Size(ans)-1)Cout(ans[i]+1);
        else cout<<ans[i]+1<<" ";
    }
    return 0;
}


Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7
#define INF (int) 2e9

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 3e5 + 10;
int N, K, S, T, A[55];
int M, L, B[55];
LL Comb[55][55];
void preprocess()
{
    for(int i = 0; i <= N; i++)
		Comb[i][0] = 1;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= i; j++)
			Comb[i][j] = Comb[i-1][j] + Comb[i-1][j-1];
    for(int i = 1; i <= N; i++)
    {
        bool ok = true;
        int X = 0;
        for(int j = 17; j >= 0; j--)
        {
            int s = (S >> j) & 1, t = (T >> j) & 1, a = (A[i] >> j) & 1;
            if((!s && !t && a) || (s && t && !a) || (s && !t))
            {
                ok = false;
                break;
            }
            if(!s && t)
                X = (X << 1) ^ a;
        }
        if(ok)
            B[++M] = X;
    }
    for(int i = 17; i >= 0; i--)
    {
        int s = (S >> i) & 1, t = (T >> i) & 1;
        if(!s && t)
            L++;
    }
    K = min(K, M);
}
set<int> st;
int cnt[maxn];
LL calc(int X)
{
    st.clear();
    for(int i = 1; i <= M; i++)
    {
        st.insert(B[i] & X);
        cnt[B[i] & X]++;
    }
    LL res = 0;
    for(auto Y : st)
    {
        for(int i = 1; i <= min(K, cnt[Y]); i++)
            res += Comb[cnt[Y]][i];
        cnt[Y] = 0;
    }
    return res;
}
int bit_count(int X)
{
    int C = 0;
    while(X)
    {
        C += X & 1;
        X >>= 1;
    }
    return C;
}
int main()
{
    scanf("%d %d %d %d", &N, &K, &S, &T);
    for(int i = 1; i <= N; i++)
        scanf("%d", &A[i]);
    preprocess();
    LL ans = 0;
    for(int X = 0; X < (1 << L); X++)
    {
        if(bit_count(X) & 1)
            ans -= calc(X);
        else
            ans += calc(X);
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

struct DSU {
    vector<int> sz;
    vector<int> parent;

    int total;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            total--;
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        total = n;
        for (int i = 0; i < n; i++) make_set(i);
    };
};

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

const int N = 100000;

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

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

    vector<bitset<N>> kill_first(n), kill_second(n);

    vector<bool> bad(n);

    for (int i = 0; i<n; i++)
    {
        vector<bool> alive(n);
        alive[i] = true;

        for (int j = m-1; j>=0; j--)
        {
            if (alive[x[j]] && alive[y[j]])
            {
                bad[i] = true; break;
            }
            if (alive[x[j]])
            {
                kill_second[i][j] = 1; alive[y[j]] = true;
            }
            if (alive[y[j]])
            {
                kill_first[i][j] = 1; alive[x[j]] = true;
            }
        }
    }

    int cnt = 0;
    for (int i = 0; i<n; i++)
        for (int j = i+1; j<n; j++) if (!bad[i] && !bad[j])
        {
            if ((kill_first[i]&kill_second[j]).count()==0 && (kill_first[j]&kill_second[i]).count()==0)
            {
                //cout<<i<<' '<<j<<endl;
                cnt++;
            }
        }
    cout<<cnt;

}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  double r;
  cin>>r;
  cout<<PI*2*r<<endl;
}

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

using namespace std;

const int MAXN=1e5+10;
int N;
bool visited[MAXN];
int heights[MAXN];
int indices[MAXN];

int dx[]={1,-1};

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        scanf("%d",heights+i);
        indices[i]=i;
    }

    sort(
        indices+1,
        indices+N+1,
        [](auto fst,auto snd){return heights[fst]<heights[snd];}
    );

    int top=N;
    int ans=0;
    int islandcount=0;

    while(top>=1&&heights[indices[top]]!=0){
        int oldtop=top;
        while(top>=1&&heights[indices[top]]==heights[indices[oldtop]]) top--;

        for(int i=top+1;i<=oldtop;i++){
            int cur=indices[i];

            int neighborcount=0;
            visited[cur]=true;
            for(int j=0;j<2;j++){
                int next=cur+dx[j];
                if (next<1||next>N||!visited[next]) continue;
                neighborcount++;
            }

            if (neighborcount==0) islandcount++;
            else if (neighborcount==2) islandcount--; 

        }

        ans=max(ans,islandcount);

    }

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

    return 0;
}




Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> ans;
int id;

void dfs(int v, int p, vector<vector<int>> &G, vector<int> &c){
	ans[v] = c[id--];
	for(auto nv : G[v]){
		if(nv == p) continue;
		dfs(nv, v, G, c);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	id = n-1;
	vector<vector<int>> G(n);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll sum = 0;
	vector<int> c(n);
	rep(i,n){
		cin >> c[i];
		sum += c[i];
	}
	sort(c.begin(), c.end());
	sum -= c[n-1];
	cout << sum << endl;
	ans.resize(n);
	dfs(0, -1, G, c);
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
n = gets.chomp.to_i
hash = Hash.new(0)
n.times do 
    s = gets.chomp
    hash[s] += 1
end
m = gets.chomp.to_i
m.times do |i|
    t = gets.chomp
    hash[t] -= 1
end
ans = 0
hash.each do |item, i|
    ans = [ans,i].max
end
puts ans

Measured memory_bytes: 14116
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,P;
    cin>>N>>M>>P;
    const int NMAX=2525;
    const int MMAX=5050;
    vector<int> a(MMAX),b(MMAX);
    vector<ll> c(MMAX);
 
    REP(i,M){
        cin>>a[i]>>b[i]>>c[i];
        c[i] = -c[i];
    }
 
    vector<ll> dist(NMAX);
 
    REP(i,N) dist[i]=INF;
 
    dist[0]=0;
 
    for(int loop=0;loop<N;++loop){
        for(int i=0;i<M;++i){
            if(dist[a[i]-1]==INF) continue;
 
            if(dist[b[i]-1] > dist[a[i]-1]+c[i]+P) dist[b[i]-1] = dist[a[i]-1] + c[i] +P;
        }
    }
 
    ll ans = dist[N-1];
 
    vector<bool> negative(NMAX,0);
 
    for(int loop=0;loop<N;++loop){
        for(int i=0;i<M;++i){
            if(dist[a[i]-1]==INF) continue;
 
            if(dist[b[i]-1] > dist[a[i]-1]+c[i] + P){
                dist[b[i]-1] = dist[a[i]-1] + c[i] + P;
                negative[b[i]-1] = true;
            }
 
            if(negative[a[i]-1]==true) negative[b[i]-1]=true;
        }
    }
    //cout<<ans<<endl;
    if(negative[N-1]) cout<<-1<<endl;
    else if(ans>0) cout<<0<<endl;
    else cout<<-ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
bool used[201];
int main()
{
	char c[1002];
	scanf("%s",c);
	for(int i=0;i<strlen(c);i++)
	{
		if(used[c[i]])
		{
			printf("no\n");
			return 0;
		}
		else used[c[i]]=1;
	}
	printf("yes\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = 0;
		if (a == b) {
			x = c;
		} else if (b == c) {
			x = a;
		} else {
			x = b;
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int a,n;
    cin>>n>>a;
    n*=n;
    cout<<n-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int H;
    int A;
    
    cin >> H >> A;
    
    if ( H%A == 0) {
        cout << H/A << endl;
    } else {
        cout << H/A + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	n--;
	
	vector<int> b(n);
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	
	int ans = b[0] + b[n - 1];
	for(int i = 0; i < n - 1; ++i) {
		ans += min(b[i], b[i + 1]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
 
int main(){
    ll M;
    cin >> M;
    vector<ll> c(M), d(M);
    rep(i,M){
        cin >> d[i] >> c[i];
    }
    ll ans = 0;
    ll sum = 0;
    ll sum_b = 0;
    rep(i,M){
        ll tmp = d[i]*c[i];// + r;
        sum += c[i];
        sum_b += tmp;
        //r = tmp % 10;
    }
    while(sum_b >= 10){
        ll r = sum_b % 10;
        sum_b /= 10;
        ans += sum_b;
        sum_b += r;
    }
    cout << ans+sum-1 << endl;
}

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n;
    cin >> n;
    int dp[n + 5][3] = {};
    f1(n) {
    	fr(j,0,3) {
    		int x;
    		cin >> x;
    		fr(k,0,3) {
    			if (k ^ j) {
    				dp[i][j] = max(dp[i][j], dp[i - 1][k] + x);
    			}
    		}
    	}
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

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

int N,MOD=1000000007;
vector<pair<int,pair<string,int>>> memo;
//int count(string s,int count);


bool agc(string s){
  if((s[0]=='A'&&s[1]=='G'&&s[2]=='C')||
    (s[1]=='A'&&s[2]=='G'&&s[3]=='C')){
    return true;
  }
  return false;
}

bool ok(string s){
  string s4;
  if(s.size()<3){
    return true;
  }else if(s.size()==3){
    if(s=="AGC"||s=="GAC"||s=="ACG"){
    return false;
  }
  }else{
    s4 = s.substr(s.size()-4,4);
  }
  if(agc(s4)){
        return false;
  }
  for(int i=0;i<3;i++){
    string str = s4;
    str[i]=s4[i+1];
    str[i+1]=s4[i];
    if(agc(str)){
        return false;
    }
  }
  return true;
}

int f_count(string s,int count){
  int ans=count;
  string s3;
  if(s.size() >=3)s3 = s.substr(s.size()-3,3);
  if(s.size()<N){
    
    for(int i=0;i<memo.size();i++){
      if(memo[i].first==s.size() && s3==memo[i].second.first &&s.size()>=3){
        return memo[i].second.second;
      }
    }
    
    if(ok(s)){
      ans = (ans + f_count(s+"A",count)) % MOD;
      ans = (ans + f_count(s+"C",count)) % MOD;
      ans = (ans + f_count(s+"G",count)) % MOD;
      ans = (ans + f_count(s+"T",count)) % MOD;
      if(s.size() >=3)memo.push_back(make_pair(s.size(),make_pair(s3,ans)));
      //cout << s3 <<" " << s.size() << endl;
      return ans;
    }else {
      return 0;
    }
  }else{//s.size()==N
    if(ok(s)){
      return 1;
    }else{
      //cout << s << endl;
      return 0;
    }
    
  }
}

int main() {
  cin >> N;
  
  cout << f_count("",0) << endl;
}

Measured memory_bytes: 768
import math
N = int(input())
X = list(map(int,input().split()))

s = 0
for i in X:
    s += i
s = s/N

muf = math.floor(s)
muc = math.ceil(s)
ansf = 0
ansc = 0
for i in X:
    ansf += (muf-i)**2
    ansc += (muc-i)**2

print(min(int(ansf),int(ansc)))

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;
int N;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
        cout << "hon";
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
        cout << "pon";
    else
        cout << "bon";
    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

struct Sieve {
	int n;
	vector<int> f, primes;
	Sieve(int n=1):n(n), f(n+1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i*i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x) { return f[x] == x;}
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			} else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	SORT(a);
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	if(a[0] == 1){
		// 1の数が答え
		if(a[1] == 1){
			cout << 0 << endl; 
			return 0;
		}
		cout << 1 << endl;
		return 0;
	}

	vector<int> f(1e6+10,0);
	rep(i,n){
		int num = a[i];
		// ダブってたらそいつ自身もダメになる。
		if(f[num] == -1) f[num] = 1;
		else {
			if(f[num] == 1) {
			}else {
				f[num] = -1; //元の数としてあるということ。
			}
		}
		// numの倍数を1にしていく。
		for (ll j = 2; j * num < 1e6+10; j++){
			f[num*j] = 1;
		}
	}
	int ans = 0;
	rep(i,n){
		if(f[a[i]] == -1){
			ans ++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 7920
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 	int N = 0;
  	int R = 0;
  	cin >> N >> R;
  
	int rating = 0;
  	if (N < 10) {
      rating = R + 100 * (10 - N);
    } else {
      rating = R;
    }
  
  	cout << rating << endl;
  
  	return 0;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N];

pii TT, w[N];

string s;
vector<pii> line;
int dp[N];
int solve(int i){
    if(i >= n) return 0;
    if(dp[i] != -1) return dp[i];
    int ini = i, fim = n - 1, mid, best=n;
    while(fim >= ini){
        mid = (ini + fim)/2;
        if(line[mid].f >= line[i].s)
            best = mid, fim = mid - 1;
        else ini = mid + 1;
    }
    return dp[i] =max(solve(i + 1), solve(best) + 1);
}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0);
    memset(dp, -1,sizeof dp);
    cin>>n;
    for(int i = 1; i <= n; i++){
        int x, l;
        cin>>x>>l;
        line.pb({x - l, x + l});
    }
    sort(all(line));

    cout<<solve(0)<<"\n";
}

Measured memory_bytes: 5492
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];

    ll ans = INF9;

    for(int p = 1; p <= 1000; p++){
        ll sum = 0;
        rep(i, n){
            sum += (x[i] - p) * (x[i] - p);
        }
        chmin(ans, sum);
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define MAX_i 88888

typedef struct process{
    char name[11];
    int time;
}pr;
void enqueue(pr x);
pr dequeue();
pr p[MAX_i];
int head,tail;

int main(void){
    int n,q,i,sum=0;
    pr x;
    
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",p[i].name,&p[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
        x=dequeue();
        if(x.time<=q){
            sum+=x.time;
            printf("%s %d\n",x.name,sum);
        }else{
            sum+=q;
            x.time-=q;
            enqueue(x);
        }
    }
    return 0;
}

void enqueue(pr x){
    p[tail]=x;
    if(tail+1==MAX_i){
        tail=0;
    }else{
        tail++;
    }
}

pr dequeue(){
    if(head+1==MAX_i){
        head=0;
        return p[MAX_i-1];
    }else{
        head++;
        return p[head-1];
    }
}



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

using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef complex<ld> point;
typedef vector<int> vi;

inline void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

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

constexpr int MOD = 1e6 + 7;
constexpr int N = 2e5 + 10;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}

int n, m, arr[N], a[N], h[N], cur;

inline void add(int v, int u) {
  if (u == 1) {
    if (v - h[v] >= 0) {
      arr[v - h[v]]++;
      if (arr[v - h[v]] == 1) cur--;
    }
  } else {
    if (v - h[v] + 1 >= 0) {
      arr[v - h[v] + 1]--;
      if (arr[v - h[v] + 1] == 0) cur++;
    }
  }
  h[v] += u;
}

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

#ifndef LOCAL
  // fileIO("superposition");
#endif

  cin >> n >> m;
  cur = n;
  rep(i, 0, n) {
    cin >> a[i];
    a[i]--;
    add(a[i], 1);
  }
  rep(i, 0, m) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    add(a[u], -1);
    a[u] = v;
    add(a[u], 1);
    cout << cur << '\n';
  }

  return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*b) - (a + b - 1);
    
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	float x[4], y[4], ab[2], cd[2];
	int i;
	
	while (scanf("%f %f %f %f %f %f %f %f", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &x[3], &y[3]) != EOF){
	
		ab[0] = y[1] - y[0];
		ab[1] = x[1] - x[0];
		cd[0] = y[3] - y[2];
		cd[1] = x[3] - x[2];
	
		if (ab[0] * cd[0] + ab[1] * cd[1] == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return 0;	
}

/*
#include <stdio.h>

int main(void)
{
	char str[81];
	int i = 0;
	scanf("%s", str);
	
	while (str[i] != '\0'){
		if (0x30 <= str[i] && str[i] <= 0x39){
			
		}
		i++;
	}
	
	return 0;
}*/

Measured memory_bytes: 608
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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



int main(){
    string S;
    cin >> S;
    vector<int> Lindex, Rindex;
    char formalC = 'R';
    S.push_back('R');
    rep(i, S.length()){
        if(formalC == 'L' && S[i] == 'R'){
            Lindex.push_back(i - 1);
        }
        if(S[i] == 'R' && S[i + 1] == 'L'){
            Rindex.push_back(i);
        }
        formalC = S[i];
    }
    vector<int> ans(S.length(), 0);
    rep(i, Rindex.size()){
        int num = 0;
        int index = Rindex[i];
        while(index <= Lindex[i]){
            num++;
            index += 2;
        }
        index = Rindex[i] -2;
        if(i != 0){
            while(index > Lindex[i - 1]){
                num++;
                index -= 2;
            }
        }else{
            while(index >= 0){
                num++;
                index -= 2;
            }
        }
        ans[Rindex[i]] =num;
        int lnum = 0;
        if(i != 0){
            lnum = Lindex[i] - Lindex[i - 1] - num;
        }else{
            lnum = Lindex[i] - num + 1;
        }
        ans[Rindex[i] + 1] = lnum;
        //cout << "num: " << num << " lnum: " << lnum << endl;
    }

    rep(i, S.length() - 1)cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;
vector<int> S(MAX);

void solve(int A,int B,int left,int right,vector<int> used){
    
    if(left+2==right){
        S[left]=A;
        S[left+1]=B;
        return;
    }
    
    for(int i=0;i<18;i++){
        if((A&(1<<i))!=(B&(1<<i))){
            bool ok=true;
            for(int k=0;k<used.size();k++){
                if(i==used[k]) ok=false;
            }
            if(!ok) continue;
            
            int T=A-(A&(1<<i));
            int j;
            for(j=0;j<18;j++){
                if(i!=j){
                    bool ok=true;
                    for(int k=0;k<used.size();k++){
                        if(j==used[k]) ok=false;
                    }
                    if(ok) break;
                }
            }
            
            used.push_back(i);
            
            solve(A,(T^(1<<j))+(A&(1<<i)),left,(left+right)/2,used);
            solve((T^(1<<j))+(B&(1<<i)),B,(left+right)/2,right,used);
            return;
        }
    }
}

int main(){
    
    int N;cin>>N;
    int A,B;cin>>A>>B;
    
    int cnt=0;
    for(int i=0;i<20;i++){
        if(A&(1<<i)) cnt++;
        if(B&(1<<i)) cnt--;
    }
    if(abs(cnt)%2==0){
        cout<<"NO"<<endl;
        return 0;
    }
    
    cout<<"YES"<<endl;
    
    vector<int> c;
    
    solve(A,B,0,(1<<N),c);
    
    for(int i=0;i<(1<<N);i++){
        cout<<S[i]<<" ";
    }
    cout<<endl;
}





Measured memory_bytes: 1536
def triangle(N, Ls):
  result = 0
  res = []
  numbers = {}
  edgeLength = list(set(Ls))
  for i in edgeLength:
    numbers[i] = Ls.count(i)
  for i in range(len(edgeLength)):
    a = edgeLength[i]   
    copy1 = edgeLength[i+1:]
    for j in range(len(copy1)):
      b = copy1[j]
      copy2 = copy1[j+1:]
      for k in range(len(copy2)):
        c = copy2[k]
        if a + b > c and b + c > a and c + a > b:
          res.append([a, b, c])
  for val in res:
    result += numbers[val[0]] * numbers[val[1]] * numbers[val[2]]
  return result




if __name__ == "__main__":
  N = list(map(int, input().split()))
  Ls = list(map(int, input().split()))
  print(triangle(N, Ls))


Measured memory_bytes: 25588
i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
j = 0
 
for j in range(n):
  x = l + j
  alist.append(x)
  
   
k = 0
m = 0
for k in range(n-1):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
print(sum(alist) - alist[m])
 

Measured memory_bytes: 3060