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

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t.at(i);
    }
    sort(t.begin(), t.end());

    int ans = 0;
    int nowTime = -1;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (cnt + 1 <= c && t.at(i) <= nowTime) cnt++;
        else {
            ans++;
            nowTime = t.at(i) + k;
            cnt = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P =pair<int,int>;

int main() {
    string s;
    int Q,F;
    char C;
    int r=0;
    cin>>s>>Q;
    rep(i,Q){
        int T; cin>>T;
        if(T==1){
            if(r==0){
                r=1;
            }
            else{
                r=0;
            }
        }
        else{
            cin>>F>>C;
            if(F==1){
                if(r==0){
                s.insert(s.begin(),C);
                }
                else{
                  s.push_back(C);
                }
            }
            else{
                if(r==0){
               s.push_back(C);
                }
                else{
                  s.insert(s.begin(),C);
                }
            }
        }
    }
    if(r==1){
     reverse(s.begin(),s.end());
    }
    cout<<s<<endl;
}
    
    
   
    
    
    
    
    
    
    
    

    




Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

string s;

int dp[512][512];

int solve(int l, int r){
    int & res = dp[l][r];
    if (res != -1) return res;
    
    if (l == r) res = true;
    else if (r - l < 3) res = false;
    else if (r - l == 3) res = s.substr(l, 3) == "mew";
    else if (s[l] != 'm' || s[r - 1] != 'w') res = false;
    else {
        res = false;
        for (int i = l + 1; i < r; i++){
            if (s[i] == 'e'){
                if (solve(l + 1, i) && solve(i + 1, r - 1)) {
                    res = true;
                    break;
                }
            }
        }
    }
    return res;
}

int main(){
    while (cin >> s){
        memset(dp, -1, sizeof(dp));
        cout << (solve(0, s.size()) ? "Cat" : "Rabbit") << endl;
    }
}

Measured memory_bytes: 2240
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s;
    cin >>n >>s;
    int mid = n / 2;
    string a = s.substr(0, mid);
    string b = s.substr(mid);
    if(a == b)
        cout <<"Yes";
    else 
        cout <<"No";
    return 0;
}


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


int main(){
    
    int n;
    cin >> n;
    
    vector<double> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    
    // a[i][j] : i枚目のコインまでで 表j枚のときの確率
    // 答えは a[n][n/2 + 1] + ... + a[n][n]
    
    vector<vector<double>> a(n+2, vector<double>(n+2, 0));
    
    a[0][0] = 1.0; // 0枚目で表0枚である確率は1
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= i; j++){
            a[i+1][j+1] += a[i][j] * p[i];
            a[i+1][j] += a[i][j] * (1-p[i]);
        }
    }
    
    double ans = 0.0;
    
    for (int i = n/2 + 1; i <= n; i++) ans += a[n][i];
    
    cout << fixed << setprecision(15);
    cout << ans << endl;
    
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<string.h>

int main(void){
    char v[100][100];
    int i, j;

    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%c", &v[i][j]);
        }
        getchar();
    }
    printf("%c%c%c", v[0][0],v[1][1],v[2][2]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int a, b, c, d, e, f;
	double by, ey, x, y, cc, ff;
	while (cin >> a >> b >> c >> d >> e >> f) {
		by = b*d;
		cc = c*d;
		ey = e*a;
		ff = f*a;
		y = (ff - cc) / (ey - by);
		x = (c - b*y) / a;
		int xx = x * 10000, yy = y * 10000;
		if (xx % 10 >= 5) {
			x += 0.001;
		}
		if (yy % 10 >= 5) {
			y += 0.001;
		}
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3228
n = int(input())
li = list(map(int,input().split()))
a = 1
count = 0
if li.count(0) >= 1:
    print(0)
    exit()
for i in range(n):
    a = a*li[i]
    if a > 10**18:
        print("-1")
        count += 1
        break
if count != 1:
    print(a)
else:
    exit()

Measured memory_bytes: 21644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N;
  cin >> N;
  vector<int> B(N);
  rep(i, 0, N) {
    cin >> B[i];
    B[i] -= i + 1;
  }

  sort(all(B));

  int b = B[N/2];
  ll ans = 0;
  rep(i, 0, N) {
    ans += abs(b - B[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
  double w,h,x,y,area;
  int way;
  cin >> w >> h >> x >> y;
  area = w*h/2;
  if(w/2 == x && h/2 == y){
    way = 1;
  }else{
    way = 0;
  }
  printf("%f %d\n",area,way);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
const int MAX_N=105;
int a[MAX_N],n;
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%d",&n);
	int sum=0;bool flag=false;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		sum+=a[i];
		if(a[i]%10)
		{
			flag=true;
		}
	}
	if(flag)
	{
		if(sum%10)
		{
			printf("%d\n",sum);
			return 0;
		}
		sort(a,a+n);
		for(int i=0;i<n;i++)
		{
			if(a[i]%10)
			{
				sum-=a[i];
				printf("%d\n",sum);
				return 0;
			}
		}
	}
	else
	{
		puts("0");
	}
	return 0;
}



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

using namespace std;

int N;
const int MAX_N = 100;
long long a[MAX_N];

long long gcd(long long x, long long y) {
	long long v0 = x, v1 = y, v2 = x % y;
	while (v2 != 0) {
		v0 = v1;
		v1 = v2;
		v2 = v0 % v1;
	};
	return v1;
}

long long lcm(long long x, long long y) {
	return x / gcd(x, y) * y;
}

void solve() {
	long long ans = a[N - 1];
	for (int i = N - 2; i >= 0; --i) {
		ans = lcm(ans, a[i]);
	}
	cout << ans << endl;
}

int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	solve();
	return 0;
}

Measured memory_bytes: 256
x = int(input())
if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600 <= x <= 1799:
  print(2)
elif 1800 <= x <= 1999:
  print(1)

Measured memory_bytes: 9192
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    vec<ll> o(a+1);
    for(ll x=1; x<100; x++){
        for(ll y=1; y<100; y++){
            for(ll z=1; z<100; z++){
                ll c = x*x+y*y+z*z+x*y+x*z+y*z;
                if(c<=a) o[c]++;
            }
        }
    }
    for(int q=1; q<=a; q++) cout<<o[q]<<"\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll C(N);
  vvll G(200010, vll(0));
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
    G.at(C.at(i)).push_back(i);
  }
  vll dp(N, 0LL);
  dp.at(0) = 1LL;
  for(int i = 1; i < N; i++){
    dp.at(i) = dp.at(i-1); //i番目を操作に使わない場合
    auto ite = lower_bound(ALL(G.at(C.at(i))), i);
    int dist = distance(G.at(C.at(i)).begin(), ite);
    if(dist > 0){
      int ii = G.at(C.at(i)).at(dist-1);
      if(i - ii != 1){
        dp.at(i) += dp.at(ii);
        dp.at(i) %= MOD;
      }
    }
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


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

		for (int i = 0; i < a; i++) {
			if (k == 0)break;
			ans++;
			k--;
		}

		for (int i = 0; i < b; i++) {
			if (k == 0)break;
			k--;
		}

		for (int i = 0; i < c; i++) {
			if (k == 0)break;
			ans--;
			k--;
		}
		cout << ans;
	
}

Measured memory_bytes: 3592
a, b = map(int, input().split())

c = 0

for i in range(a, b+1):
    s = i % 10
    t = int(i / 10000) % 10
    u = int(i / 10) % 10
    v = int(i / 1000) % 10
    if s == t and u == v:
        c += 1

print(c)

Measured memory_bytes: 39792
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(count(x->x=='1',readline()))
end
main()

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


int main()
{


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

  int t;
  cin>>t;
  map<long long int, int>nish;
  //vector<long long int >all;
  long long int ans=0;
  for(int i=1;i<=t;i++)
  {
   long long int first;
    cin>>first;
    //all.push_back(i-first);
   // cout<<i-first<<endl;
    nish[i+first]++;
    ans+=nish[i-first];
  }

 // long long int ans=0;
  

  cout<<ans<<endl;


  return 0;

}

Measured memory_bytes: 26348
# coding: utf-8
n = int(input())
dp1 = [0] * n
dp2 = [0] * n
dp3 = [0] * n
#print(dp1)
a, b, c = map(int,input().split())
dp1[0] = a
dp2[0] = b
dp3[0] = c
for i in range(1,n):
    a, b, c = map(int,input().split())
    dp1[i] = max(dp2[i-1]+a, dp3[i-1]+a)
    dp2[i] = max(dp1[i-1]+b, dp3[i-1]+b)
    dp3[i] = max(dp2[i-1]+c, dp1[i-1]+c)
print(max(dp1[n-1], dp2[n-1], dp3[n-1]))

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

int gcd(int x, int y){
    if(x%y==0) return y;
    else{
        return gcd(y, x%y);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0; i<n; i++){
        cin >> A.at(i);
    }
    vector<int> L(n);
    vector<int> R(n);
    L.at(0)=A.at(0);
    R.at(n-1)=A.at(n-1);
    for(int i=0; i<n-1;i++){
        L.at(i+1) = gcd(max(L.at(i),A.at(i+1)), min(L.at(i),A.at(i+1)));
    }
    
    for(int i=n-1; i>=1; i--){
        R.at(i-1) = gcd(max(R.at(i),A.at(i-1)), min(R.at(i),A.at(i-1)));
    }
    int ans=max(R.at(1), L.at(n-2));
    for(int i=1; i<n-1; i++){
        int calc;
        calc=gcd(L.at(i-1),R.at(i+1));
        ans = max(ans, calc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4516
#include<iostream>
using namespace std;
int main()
{
    int n;
    char c;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> c;
        if(c == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S, W;
    cin >> S >> W;
    bool ok = true;
    if (S <= W) {
        ok = false;
    }
    yesno(ok, "safe", "unsafe");
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
k=int(n**0.5)+1
a=[0 for i in range(n+1)]
for x in range(1,k):
    for y in range(1,k):
        for z in range(1,k):
            g=x*x+y*y+z*z+x*y+y*z+x*z
            if g<=n:
                a[g]+=1
print(*a[1:],sep='\n')

Measured memory_bytes: 9712
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b;
	scan(a>>b);
	if(a==b) prin(2*a);
	else prin(max(2*a-1,2*b-1));
	return 0;
}


Measured memory_bytes: 256
def solve():
    h, w = list(map(int, input().split()))
    field = [["."] * (w + 2)] + [["."] + list(input()) + ["."] for _ in range(h)] + [["."] * (w + 2)]
    # result = [[0] * (w + 2)] * (h + 2)

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if field[i][j] == ".":
                count = 0
                for dx in [-1, 0, 1]:
                    for dy in [-1, 0, 1]:
                        if field[i + dx][j + dy] == "#":
                            count += 1
                field[i][j] = str(count)

    for i in range(1, h + 1):
        print(''.join([str(e) for e in field[i][1:w + 1]]))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextLong()
    val A = scn.nextLong()
    val B = scn.nextLong()

    var p = N/(A+B)
    var d = N-p*(A+B)

    println(p*A + min(A,d))
}

Measured memory_bytes: 31392
import itertools
ABCD = input()
for op in itertools.product(['+','-'], repeat=3):
    s = ABCD[0]+op[0]+ABCD[1]+op[1]+ABCD[2]+op[2]+ABCD[3]
    if eval(s) == 7:
        print(s+'=7')
        exit()


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<ll,ll> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

string S;

int main(){
    cin>>S;

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

    string ans="YES";
    rep(i,S.size()){
        if(S.substr(i,5)=="maerd") i+=4;
        else if(S.substr(i,7)=="remaerd") i+=6;
        else if(S.substr(i,5)=="esare") i+=4;
        else if(S.substr(i,6)=="resare") i+=5;
        else ans="NO";
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min( int a, int b){
    return a < b ? a : b;
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for( i = 0; i < n; ++i){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 0; tail = n;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


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

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll a,b,k,memo = 0;
	cin >> a >> b >> k;
	
	memo = max((ll)0, k - a);
	a = max((ll)0,a - k);
	
	b = max((ll)0, b - memo);
	
	cout << a << " " << b << endl;
	
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] black=new int[N*2-1];
   for(int i=0; i<black.length;i++){
     	black[i]=(M-N)+(i+1);
        
   }
    for(int i=0; i<black.length;i++){
      System.out.println(black[i]);
    }
  }
}



Measured memory_bytes: 22608
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int w = stdIn.nextInt();
			int d = stdIn.nextInt();
			if(w == 0 && d == 0) break;
			int[] wh = new int[w];
			int[] dh = new int[d];
			for(int i = 0; i < w; i++) {
				wh[i] = stdIn.nextInt();
			}
			for(int i = 0; i < d; i++) {
				dh[i] = stdIn.nextInt();
			}
			int count = 0;
			if(w >= d) {
				for(int i = 0; i < w; i++) {
					for(int j = 0; j < d; j++) {
						if(wh[i] == dh[j]) {
							count += wh[i];
							wh[i] = 0;
							dh[j] = 0;
						}
					}
				}
			}
			else {
				for(int i = 0; i < d; i++) {
					for(int j = 0; j < w; j++) {
						if(dh[i] == wh[j]) {
							count += dh[i];
							wh[j] = 0;
							dh[i] = 0;
						}
					}
				}
			}
			for(int i = 0; i < w; i++) {
				count += wh[i];
			}
			for(int i = 0; i < d; i++) {
				count += dh[i];
			}
			System.out.println(count);
		}
	}
}
	

Measured memory_bytes: 23412
#include<iostream>
using namespace std;
int main(){
  int A, B, ans;
  cin >> A >> B;
  if (A <= 5)
    ans = 0;
  else if (6 <= A && A <= 12)
    ans = B/2;
  else
    ans = B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    string s; cin >> s;
    if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes";
    else cout << "No";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3640
def solve(n,s,l1,l2,l3):
  ans = len(l1)*len(l2)*len(l3)

  for a in l1:
    for b in l2:
      if a < b:
        if 2*b-a in l3:
          ans -= 1
        if 2*a-b in l3:
          ans -= 1
        if (b-a-1)%2==0:
          continue
        else:
          if (b-a)%2 == 0 and (b-a)/2 + a in l3:
            ans -= 1
      else:
        if 2*a-b in l3:
          ans -= 1
        if 2*b-a in l3:
          ans -= 1
        if (a-b-1)%2==0:
          continue
        else:
          if (a-b)%2 == 0 and (a-b)/2 + b in l3:
            ans -= 1
  return ans



if __name__ == "__main__":
  n= int(input())
  s = input()
  r_list = set()
  g_list = set()
  b_list = set()
  r_count = 0
  g_count = 0
  b_count = 0
  for i, str in enumerate(s):
    if str == "R":
      r_list.add(i+1)
      r_count += 1
    elif str == "G":
      g_list.add(i+1)
      g_count += 1
    else:
      b_list.add(i+1)
      b_count += 1

  if r_count <= g_count and r_count <= b_count:
    l1 = r_list
    if g_count <= b_count:
      l2 = g_list
      l3 = b_list
    else:
      l2 = b_list
      l3 = g_list
  elif g_count <= r_count and g_count <= b_count:
    l1 = g_list
    if r_count <= b_count:
      l2 = r_list
      l3 = b_list
    else:
      l2 = b_list
      l3 = r_list
  elif b_count <= g_count and b_count <= r_count:
    l1 = b_list
    if g_count <= r_count:
      l2 = g_list
      l3 = r_list
    else:
      l2 = r_list
      l3 = g_list

  print(solve(n, s, l1,l2,l3))

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

int main() {
  int n;
  cin >> n;
  int v[n], c[n];
  int s[n];
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> c[i];
    s[i] = v[i] - c[i];
    if(s[i] > 0) ans += s[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    vi bi(n);
    rep(i,0,n){
        cin >> bi[i];
    }
    rep(i,0,n){
        if(bi[i]>i+1){
            cout << -1 << endl;
            return 0;
        }
    }

    vi ans(n);
    rep(i,0,n){
        for(int j=n-1-i;j>=0;j--){
            if(bi[j]==j+1){
                ans[n-1-i] = j;
                rep(k,j,n-1-i){
                    bi[k] = bi[k+1];
                }
                break;
            }
        }
    }

    trav(a,ans){
        cout << a+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n), q(n), a(n);
    rp(i, 0, n) cin >> p[i];
    rp(i, 0, n) cin >> q[i];
    rp(i, 0, n) a[i] = i + 1;
    ll qq, pp;
    ll co = 0;
    do
    {
        co++;

        bool isp = true, isq = true;
        rp(i, 0, n)
        {
            if (a[i] != p[i])
                isp = false;
            if (a[i] != q[i])
                isq = false;
        }

        if (isp)
            pp = co;
        if (isq)
            qq = co;

    } while (next_permutation(a.begin(), a.end()));
    cout << llabs(pp - qq);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <regex>

using namespace std;

int main() {
    string s;
    cin >> s;

    cout << (std::regex_match(s, std::regex("^(dream|dreamer|erase|eraser)*$"))
                 ? "YES"
                 : "NO")
         << endl;
}

Measured memory_bytes: 39808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define M 1000000007
#define vll vector<ll>
#define pll pair<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
ll a[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll t, n, i, j, c, k, m, x, y, f, ans;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans = 0;
  for (i = 1; i < n; i++) {
    if (a[i - 1] > a[i]) {
      ans += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 5172
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, M = mi()
nos = set(input().split())
#昇順ソート
availables = sorted(list(set(map(str, (0,1,2,3,4,5,6,7,8,9))) - nos))

#方針
#桁数が変われば、(1)0が使える場合は、使える一番低い数字+あとは全部0
#              (2)0が使えない場合は、使える一番低い数字で埋めるだけ
#とはいえ、元々が3桁とかなら全探索で十分
#5桁になると怪しいので、(1)(2)を活かす

#まずは9999までの間に答えがあるかどうか
#N=9999でも、9が嫌いじゃない場合があるから探索する
ans = 0
for i in range(N, 10000):
  if not (set(str(i)) & nos): #使えない(nos)のに使ってる(set内)が無かったら
    ans = i
    break
if ans == 0:
  #もしここまでで答えが出ていなかったら
  if '0' in availables:
    print(str(list(availables)[1])+str(list(availables)[0])*4)
    exit()
  else:
    print(str(list(availables)[0])*5)
    exit()

print(ans)



Measured memory_bytes: 39280
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>

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

const int MAX = 100010;
std::vector<std::vector<int>> G;
int dp[MAX];

int rec(int v)
{
    if(dp[v]!=-1) return dp[v];

    int res = 0;
    for(auto nv : G[v])
        chmax(res, rec(nv) + 1);
    
    return dp[v] = res;
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    int N, M;
    std::cin >> N >> M;
    
    G.assign(N, std::vector<int>());
    
    for(int i=0; i<M; i++)
    {
        int x, y;
        std::cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }

    for(int i=0; i<N; i++)
    {
        dp[i] = -1;
    }
    
    int res = 0;
    for(int v = 0; v < N; ++v) chmax(res, rec(v));
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 8192
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const buttons = input.slice(1, -1).map((line) => Number(line[0]));

  let count = 0;
  let next = 1;

  while (true) {
    const button = buttons[next - 1];
    buttons[next - 1] = -1;

    count += 1;

    if (button === -1) {
      return -1;
    }

    if (button === 2) {
      break;
    }

    next = button;
  }

  return count;
};

console.log(main(read()));


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

int main(){
    int m;
    cin>>m;
    int a[44];
    a[0]=1;
    a[1]=1;
    for(int i=2;i<=m;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[m]<<endl;
    return 0;
}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int n, W;
vector<int> w, v;
vector<vector<int>> vv(4);

int solve(int k, int cap, int ans) {
    if(k == 4) return ans;
    int ret = solve(k+1, cap, ans);
    int sum = 0;
    for(int i=1;i<=min(cap/(w[0]+k), (int)vv[k].size());i++){
        sum += vv[k][i-1];
        ret = max(ret, solve(k+1, cap - i*(w[0]+k), ans+sum));
    }
    return ret;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin >> n >> W;
    w.resize(n);
    v.resize(n);
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
        vv[w[i]-w[0]].push_back(v[i]);
    }
    for(int i=0;i<4;i++){
        sort(vv[i].begin(), vv[i].end());
        reverse(vv[i].begin(), vv[i].end());
    }

    cout << solve(0, W, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll H, W;
  cin >> H >> W;
  vvc SS(H, vc(W));
  string S;
  rep(i, H){
    cin >> S;

    rep(j, W) SS[i][j] = S[j];
  }

  vvl cross(H, vl(W, 0));
  ll cnt, leng;

  rep(i, H){
    cnt = 0;

    rep(j, W){
      if(SS[i][j] == '#'){
		leng = cnt;

        while(cnt > 0){
          cross[i][j - cnt] += leng;
          cnt--;
        }
      } else cnt++;
    }

    if(cnt > 0){
      leng = cnt;

      while(cnt > 0){
        cross[i][W - cnt] += leng;
        cnt--;
      }
    }
  }

  rep(j, W){
    cnt = 0;

    rep(i, H){
      if(SS[i][j] == '#'){
        leng = cnt;

        while(cnt > 0){
          cross[i - cnt][j] += leng;
          cnt--;
        }
      } else cnt++;
    }

    if(cnt > 0){
      leng = cnt;

      while(cnt > 0){
        cross[H - cnt][j] += leng;
        cnt--;
      }
    }
  }

  ll ans = -1;

  rep(i, H){
    rep(j, W){
      ans = max(ans, cross[i][j]);
    }
  }

  cout << ans - 1 << endl;
  
  return 0;
}


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

int main() {
  int n;
  cin >>n;
  vector<ll> a(3*n);
  rep(i,3*n) cin >>a[i];
  ll ans = 0;
  sort(a.begin(), a.end());
  for(ll i = n; i<3*n; i+=2){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
    int x,y,sum = 0;
    scanf("%d%d", &x, &y);
    if( x == 1 ){
        sum+= 300000;
    }
    if( x == 2 ){
        sum+= 200000;
    }
    if( x == 3 ){
        sum+= 100000;
    }
    if( y == 1 ){
        sum+= 300000;
    }
    if( y == 2 ){
        sum+= 200000;
    }
    if( y == 3 ){
        sum+= 100000;
    }
    if (x == 1 && y == 1){
        sum += 400000;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

  ll a; cin >> a;

  if(a >= 30){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int res = 0;
  if(s == "SUN") res = 7;
  else if(s == "MON") res = 6;
  else if(s == "TUE") res = 5;
  else if(s == "WED") res = 4;
  else if(s == "THU") res = 3;
  else if(s == "FRI") res = 2;
  else if(s == "SAT") res = 1;
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    const int last_digi = N % 10;
    switch(last_digi) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }
    return 0;
}

/**
cheat sheet

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end());
=> 0 1 2 3 4 5 6 7 8 9

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end(), greater<int>());
=> 9 8 7 6 5 4 3 2 1 0

struct A { int x, y; };
bool comp(A i1, A i2) { return (i1.y < i2.y); }
vector<A> v { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
sort(v.begin(), v.end(), comp);
=> [1, 9] [2, 4] [4, 7] [6, 8]

*/


Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	ll n, t, a, x=1, y=1;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> t >> a;
		ll m=max((x+t-1)/t, (y+a-1)/a);
		x=m*t;
		y=m*a;
	}
	cout << x+y << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

bool isok(int a, int b, int c) {
  if ( std::abs(b-c) < a && a < b + c ) return true;
  return false;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> L(N); rep(i,N) std::cin >> L[i];
  std::sort( all(L) );

  int ans = 0;
  for(int i=N-1; i>=0; i--) for(int j=i-1; j>=0; j--) {
    int s = std::distance(std::lower_bound( all(L), L[i]+L[j]), L.end());
    ans += (N-1-i) - s;
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
def change(a):
    if a == 0:
        return 1
    if a == 1:
        return 0

s = list(map(int,input()))
ans = 0
if len(s) == 0:
    print(0)
else:
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] = change(s[i+1])
            ans += 1
print(ans)


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

// ????°??????¨???
struct EdgeC{
  int to, cap, cost, rev;
  EdgeC(int to_=0, int cap_ = 0, int cost_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};
using GraphC = vector<vector<EdgeC>>;
void add_edge(GraphC& G, int from, int to, int cap, int cost){
  G[from].emplace_back(to, cap, cost, G[to].size());
  G[to].emplace_back(from, 0, -cost, G[from].size()-1);
}

/**
 * prime-dual
 * ?????????????????¨???????????¨??????
 * O(FElogV) or O(FV^2)
 * ??????????????¨???-INF
 */
int min_cost_flow(GraphC& G, int s, int t, int f){
  int V = G.size();
  vector<int> dist(V);
  vector<int> h(V);
  vector<int> prevv(V), preve(V);
  int res = 0;
  while(f > 0){
    priority_queue<PII,vector<PII>,greater<PII>> pq;
    fill(begin(dist), end(dist), INF);
    pq.push(PII(0,s));
    dist[s] = 0;
    while(!pq.empty()){
      PII p = pq.top(); pq.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      for(unsigned int i=0;i<G[v].size();++i){
        auto& e = G[v][i];
        if(e.cap > 0 && dist[v] + e.cost + h[v] - h[e.to] < dist[e.to]){
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          pq.push(PII(dist[e.to], e.to));
        }
      }
    }
    if(dist[t] == INF) return -INF;
 
    for(int v=0;v<V;++v) h[v] += dist[v];
    int d = f;
    for(int v=t;v!=s;v=prevv[v])
      d = min(d, G[prevv[v]][preve[v]].cap);
 
    f -= d;
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]){
      auto& e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
   
  return res;
}

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

  int V, E, F;
  cin >> V >> E >> F;
  GraphC G(V);
  REP(i,E){
	int u, v, c, d;
	cin >> u >> v >> c >> d;
	add_edge(G, u, v, c, d);
  }
  int res = min_cost_flow(G, 0, V-1, F);
  cout << (res==-INF?-1:res) << endl;

  return 0;
}

Measured memory_bytes: 3216
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll sum=0;
	int N;
	cin >> N;

	map<string, int> mp;
	fi(N) {
		string s;
		cin >> s;
		sorts(s);
		mp[s]++;
	}

	for(auto p:mp) {
		int t = p.second;
		sum += (ll)t*(t - 1) / 2;

	}


	ce(sum);
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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

using namespace std;
//    cout << setprecision(20) << ans << "\n";

class DisjointSet {
 private:
  std::vector<int> r;

 public:
  DisjointSet(int n) : r(n, -1) {}

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x != y) {
      if (x > y) {
        std::swap(x, y);
      }
      r[x] += r[y];
      r[y] = x;
    }

    return x != y;
  }

  bool same(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -r[x]; }

 private:
  int root(int x) { return r[x] < 0 ? x : r[x] = root(r[x]); }
};

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

  int n, m;
  cin >> n >> m;
  DisjointSet uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }

  int ans = -1;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, uf.size(i));
  }
  
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3984
require "prime"
N = gets.to_i
ds = N.prime_division

def dig(ds, n = 1, depth = 0)
  if depth < ds.size
    q,d = ds[depth]
    s = 0
    (0..d).each{ |d|
      s += dig(ds, n, depth+1)
      n *= q
    }
    return s
  else
    m = n - 1
    r = N/n
    return r < m ? m : 0
  end
end

p dig(ds)


Measured memory_bytes: 3964
_N,A,B=map(int,input().split())
S=input()
a,b=0,0
for s in S:
  if a+b < A+B:
    if s=='a':
      a+=1
      print('Yes')
    elif s=='b' and b < B:
      b+=1
      print('Yes')
    else:
      print('No')
  else:
    print('No')


Measured memory_bytes: 4016
#include <iostream>
  #include <vector>
  #include <algorithm>
  #include <ctime>
  #include <cmath>
  #include <string>
  #include <stdlib.h>
  #include <fstream>
  #include <set>
  #include <map>
  #include <stack>
  #include <deque>
  #include <iterator>
  using namespace std;


  int main(){
      long long n, ans = 100000000;
      cin >> n;
      vector<long long> a(n);
      for(int i = 0; i < n; ++i) cin >> a[i];
      for(int i = 1; i <= 100; ++i){
        long long nans = 0;
        for(int j = 0; j < n; ++j) nans += (a[j] - i) * (a[j] - i);
        ans = min(ans, nans);
      }
      cout << ans;
  }

Measured memory_bytes: 256
s=list(input())
k=int(input())
z=[]
for i in range(1,k+1):
    for j in range(len(s)):
        if j+i<=len(s):
            z.append(s[j:j+i])
a=[]
for i in z:
    a.append(''.join(i))
a=list(set(a))
a.sort()
print(a[k-1])

Measured memory_bytes: 7796
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int min = b;
		int max = b;
		long  sum = b;
		for(int i = 0 ;i<a-1 ;i++){
			int c = in.nextInt();
			if(min>c){
				min = c;
			}
			if(max<c){
				max = c;
			}
			sum += c;
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 42288