akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	string s;
	int n,t;
	cin >> n >> t;
	int cmin = 10000;
	while(n--){
		int c, t_;
		cin >> c >> t_;
		if(t_ <= t){
			cmin = min(cmin, c);
		}
	}
	if(cmin <= 1000){
		cout << cmin << endl;
	}else{
		cout << "TLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
int gcd(int x, int y) {
	/*最大公約数 O(log MAX_X)*/
	if (y == 0) return x;
	return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {

	string a;
	cin >> a;

	if (a == "A" || a == "B" | a == "C" || a == "D" | a == "E" || a == "F" | a == "G" || a == "H" |
		a == "I" || a == "J" | a == "K" || a == "L" | a == "M" || a == "N" | a == "O" || a == "P" |
		a == "Q" || a == "R" | a == "S" || a == "T" | a == "U" || a == "V" | a == "W" || a == "X" |
		a == "Y" || a == "Z")cout << "A" << endl;
	else cout << "a" << endl;

}

Measured memory_bytes: 3628
/**
 *   author: Shubham Srivastava
 *   created: 26 January 2020  12:21:41
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll k,n;cin>>k>>n;
    ll sum = 0;
    for(int i=0;i<n;i++){
    	ll a;cin>>a;
    	sum += a;
    }
    if(sum >= k)
    	cout<<"Yes";
    else
    	cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair 
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll sum = 0;
int md(int n){
	if(n>0)return n;
	else return -n;
}
string str1,str2;
void solve(){
	ll n;cin>>n;
	Yn(n>=30);
}


int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
     cin.tie(0);
    ios::sync_with_stdio(false);
   
	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3484
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)  # リストの要素をカウント
cnt = [k for k, v in c.items() if v >= 2]

if len(cnt) < 2:
    print(0)
else:
    cnt = sorted(cnt, reverse=True)
    if c[cnt[0]] >= 4:
        print(cnt[0] * cnt[0])
    else:
        print(cnt[0] * cnt[1])

Measured memory_bytes: 18600
#include<iostream>
#include<algorithm>
#include<vector>
#define INF 1e9
using namespace std;

struct item {
    int wt;
    int val;
};

// Bottom Up Approach
long long int knapsackBottomUp(vector<item> arr, int n, int W) {
    long long int dp[n + 1][W + 1]; // Memory
    // Base Case
    for(int w = 0; w <= W; w++) dp[1][w] = 0;
    dp[1][arr[1].wt] = arr[1].val;
    // Iteratively Calculating Other Cases In Bottom Up Fashion
    for(int i = 2; i <= n; i++) {
        for(int w = 0; w <= W; w++) {
            dp[i][w] = dp[i - 1][w];
            if(arr[i].wt > w) continue;
            dp[i][w] = max(dp[i][w], (arr[i].val + dp[i - 1][w - arr[i].wt]));
        }
    }  
    return *max_element(dp[n], (dp[n] + W + 1));
}

int main() {
    int n, w;
    cin >> n >> w;
    vector<item> arr(n + 1);
    for(int i = 1; i <= n; i++) cin >> arr[i].wt >> arr[i].val;
    cout << knapsackBottomUp(arr, n, w) << endl;
    return 0;
}

Measured memory_bytes: 81664
#include <stdio.h>

int main(void){
    int x;
    int y;
    while(1){
    scanf("%d %d",&x,&y);
    if(x == 0 && y == 0){
    break;
    }
    if(x < y){
    printf("%d %d\n",x,y);
    }
    else{
    printf("%d %d\n",y,x);
    }
    }
    return 0;
}     

Measured memory_bytes: 596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func min64(nums ...int64) int64 {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	N, K := nextInt(), nextInt()
	x, y := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		x[i], y[i] = nextInt(), nextInt()
	}

	ans := int64(9223372036854775807)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				for l := 0; l < N; l++ {
					if i == j && j == k && k == l {
						continue
					}
					x1 := min(x[i], x[j], x[k], x[l])
					y1 := min(y[i], y[j], y[k], y[l])
					x2 := max(x[i], x[j], x[k], x[l])
					y2 := max(y[i], y[j], y[k], y[l])
					cnt := 0
					for p := 0; p < N; p++ {
						if x1 <= x[p] && x[p] <= x2 && y1 <= y[p] && y[p] <= y2 {
							cnt++
						}
					}
					if cnt >= K {
						s := int64(x2-x1) * int64(y2-y1)
						ans = min64(ans, s)
					}
				}
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;

}


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

using namespace std;

typedef long long ll;

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

    ll K;
    cin >> K;

    char c;
    ll now = 0;
    for(ll i = 0; i < S.size(); i++) {
        c = S[i];
        if(S[i] != '1') break;
        now += 1;
        if(now >= K) break;
    }

    cout << c << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
    double r;
    cin>>r;
    const double pi=acos(-1.0);
    printf("%.7lf\n", 2*pi*r);
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int vs[1001];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}
	std::sort(vs, vs + n);
	//for (int i = 0; i < n; i++) {
	//	cout << vs[i] << " ";
	//}

	double sum = vs[0];
	for (int i = 1; i < n; i++) {
		sum = (vs[i] + sum)/2.0;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
s = list(str(input()))

ans = 0
for bits in range(1 << len(s) - 1):
    check = ''
    for i in range(len(s)):
        if (bits >> i & 1) == 1:
            check += s[i] + '+'
        else:
            check += s[i]
    ans += eval(check)
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1ll << 60);
const auto MOD = static_cast<ll>(1e9 + 7);

/************* Utils *************/

/*********** Variables ***********/
ll N, K, W_MAX, ANS;
vector<ll> W;

/*********** Functions ***********/
bool init() {
    cin >> N >> K;
    W.resize(N);
    W_MAX = 0;
    for (auto& w : W) {
        cin >> w;
        W_MAX = max(W_MAX, w);
    }
    ANS = INF;
    return true;
}

void solve() {
    ll left = W_MAX, right = INF;
    while (left < right) {
        ll mid = left + (right - left) / 2;
        ll m = 1, w = 0;
        for (ll i = 0; i < N; i++) {
            if (w + W[i] <= mid) {
                w += W[i];
            }
            else {
                w = W[i];
                m++;
            }
        }
        if (m > K) {
            left = mid + 1;
        }
        else {
            right = mid;
            ANS = min(mid, ANS);
        }
    }
}

void output() {
    cout << ANS << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}


Measured memory_bytes: 3628
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k;

int modpow(int x, int n, int m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

const int MAXN = 101000;
int dp[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> k;
  int ans = 0;
  for(int i=k;i>=1;i--){
    int coef = k/i;
    dp[i] = modpow(coef,n,mod);
    for(int j=i+i;j<=k;j+=i){
      dp[i] = (dp[i] - dp[j] + mod )%mod;
    }
    ans = (ans + i*dp[i])%mod;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,a,n,max=0,min=0x7fffffff;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a>max)
		{
			max=a;
		}
		if(a<min)
		{
			min=a;
		}
	}
	printf("%d",max-min);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

sc = sorted(sc)

for i in range(1000):
    a = list(str(i))
    if len(a) == N:
        check = True
        for s, c in sc:
            if int(a[s - 1]) != c:
                check = False
                break
        if check:
            print(''.join(a))
            exit()

print(-1)



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;
    rep(x,1000) {
        int keta = 1;
        int nx = x/10;
        vector<int> d(1,x%10);
        while(nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if (keta != n) continue;
        bool ok = true;
        reverse(d.begin(),d.end());
        rep(i,m) {
            if (d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

int n, w;

void solve() {
  vector<int> v(n);
  for (auto &e: v) cin >> e;

  int vmax = *max_element(v.begin(), v.end());
  int m = (vmax / w);

  vector<int> h(m+1, 0);
  for (auto e: v) {
    h[e/w]++;
  }

  double mv = *max_element(h.begin(), h.end());
  double ans = 0.01;

  for (int i = 0; i < m; ++i) {
    ans += (double)(m-i)/m * h[i]/mv;
  }

  cout << ans << endl;
}

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while (cin >> n >> w, n) solve();

  return 0;
}



Measured memory_bytes: 3232
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 100002
int N,M;
int X[MAX]={0};

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
   scanf("%d %d",&N,&M);
    for(int i=0;i<M;i++)
        scanf("%d",X+i);
    qsort(X,M,sizeof(int),compare_int);
    int diff[MAX];
    for(int i=0;i<M-1;i++)
        diff[i] = X[i+1]-X[i];  //差を持っとく
    qsort(diff,M-1,sizeof(int),compare_int);
    int hole = 0;
    for(int i=0;i<N-1 && i<M-1;i++)
        hole += diff[M-2-i];
    printf("%d",X[M-1]-X[0]-hole);
}


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

int main(){
  int N;double x;string u;
  double money =0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x >> u;
    if(u=="JPY")
      money += x;
    if(u=="BTC")
      money += x*380000.0;
  }
  cout << money;
}

Measured memory_bytes: 256
#074_C
from bisect import bisect_left, bisect_right
a, b, c, d, e, f = map(int, input().split())
water = set()
sugar = set()
for i in range(30):
    for j in range(30):
        if 0 < (a * i + b * j) * 100 <= f:
            water.add((a * i + b * j) * 100)
for i in range(f//c + 1):
    for j in range(f//d + 1):
        if 0 < (c * i + d * j) <= f:
            sugar.add(c * i + d * j)
water = sorted(list(water))
sugar = sorted(list(sugar))
ans = [100 * a, 0]
for w in water:
    x = min(w * e // 100, f - w)
    if bisect_right(sugar, x) == 0:
        continue
    s = sugar[bisect_right(sugar, x) - 1]
    if ans[1] * (s + w) < s * ans[0]:
        ans = [s+w, s]
print(*ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int s=0;
    s=n%10;
    if (s==3) cout<<"bon"<<endl;
    if (s==0||s==1||s==6||s==8) cout<<"pon"<<endl;
    if (s==2||s==4||s==5||s==7||s==9) cout<<"hon"<<endl;
	return 0;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int a, b;
    while (cin >> a >> b)
        if (a >= 13)
            cout << b << '\n';
        else if (a >= 6)
        {
            b /= 2;
            cout << b << '\n';
        }
        else cout << 0 << '\n';
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str,ans;
    cin>>str;
    int s=str.size();
    for(int i=0;i<s;i++)
    {
        if(str[i]=='B')
        {
            if(ans.size()>0)
            {
                ans.pop_back();
            }
        }
        else
            ans.push_back(str[i]);
    }
   cout<<ans;
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string s, t;
  cin >> N >> s >> t;

  int ans = N;
  REP(i, N) {
    if (s.substr(i, N - i) == t.substr(0, N - i)) {
      break;
    } else {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  double n, k, res, ans = 0;
  cin >> n >> k;

  for (int i = 1; i <= n; i++) {
    res = 1;
    int now = i;
    while (now < k) {
      res /= 2.0;
      now *= 2;
    }
    ans += res;
  }
  ans /= n;
  printf("%.15lf\n", ans);
}


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

int H,W;
char s[27][27];
int d[27][27];

int move(int i,int j,int n){

    if((i<=0)||(i>H)||(j<=0)||(j>W)){
        return 0;
    }
    
    if(s[i][j]=='.' && (d[i][j]>n || d[i][j]==-1)){
         d[i][j] = n;
         move(i,j+1,n+1);
         move(i+1,j,n+1);
         move(i,j-1,n+1);
         move(i-1,j,n+1);
    }
}

int main() {
  cin >> H >> W;
  for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
          cin >> s[i][j];
      }
  }
 int ans=0;
  for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
          
            for(int k=1;k<=H;k++){
               for(int l=1;l<=W;l++){
                     d[k][l]=-1;
                }
             }
       
       move(i,j,0);

       for(int x=1;x<=H;x++){
               for(int y=1;y<=W;y++){
                     ans = max(ans,d[x][y]);
                }
             }





      }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] arrA = new long[n + 1];
		long[] arrB = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    int x = sc.nextInt();
		    arrA[i] = x + arrA[i - 1];
		    if (x < 0) {
		        x = 0;
		    }
		    arrB[i] = x + arrB[i - 1];
		}
		long max = Long.MIN_VALUE;
		for (int i = 1; i + k - 1 <= n; i++) {
		    max = Math.max(max, arrB[n] - (arrB[i + k - 1] - arrB[i - 1]));
		    max = Math.max(max, arrB[n] - (arrB[i + k - 1] - arrB[i - 1]) + arrA[i + k - 1] - arrA[i - 1]);
		}
		System.out.println(max);
   }
}




Measured memory_bytes: 59344
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	map<int, ll> m;
	rep(i, n) m[a[i]]++;
	repn(i, 1, n + 1){
		ans += (m[i] * (m[i] - 1)) / 2;
	}
	rep(i, n){
		cout << ans - (m[a[i]] - 1) << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 17024
n,k = map(int,input().split())
a = list(map(int,input().split()))
x = 0
y = 0
mod = 10**9 + 7
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                x += 1
            if i < j:
                x += 1
                y += 1
ans = x*k*(k-1)//2 % mod
ans += y*k % mod
ans %= mod
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MAGIC_PRIME{ 1000000000 + 7 };
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> a[i];
    }
    int l = 0, r = w, b = 0, t = h;
    for (int i = 0; i < n; i++)
    {
        switch (a[i])
        {
        case 1:
            l = max(x[i], l);
            break;
        case 2:
            r = min(x[i], r);
            break;
        case 3:
            b = max(y[i], b);
            break;
        case 4:
            t = min(y[i], t);
            break;
        default:
            break;
        }
    }

    cout << max(r - l, 0) * max(t - b, 0) << endl;

    return 0;
}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int ispalindarome(string a,int size){
    int flag;
    //cout<<"str="<<a<<endl;
    for(int i=0;i<=size/2;i++)
        if(a[i]==a[size-1-i])
            flag=1;
        else{
            flag=0;
            break;
        }
        return flag;
}
int main(){
  string s,s1="",s2="";
  int y,y1,y2,n;
  cin>>s;
  n=s.length();
  y=ispalindarome(s,s.length());
  for(int i=0 ;i<(n-1)/2;i++)
        s1=s1+s[i];
    y1=ispalindarome(s1,s1.length());
  for(int i=((n+3)/2)-1 ;i<n;i++)
        s2=s2+s[i];
    y2=ispalindarome(s2,s2.length());
    //cout<<y<<y1<<y2<<endl;
    if(y==1 and y1==1 and y2==1)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
  
  
}
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  int t = 0;
  int r = 0;
  vector<int> time(K, -1);
  bool ok = false;
  while (1){
    t++;
    r = (r * 10 + 7) % K;
    if (r == 0){
      cout << t << endl;
      ok = true;
      break;
    }
    if (time[r] != -1){
      break;
    }
    time[r] = t;
  }
  if (!ok){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 7208
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn f(p: i64, i: i64) -> i64 {
    if p % i == 0 {
      1 + f(p / i, i)
    } else {
      0
    }
}

fn main() {
    // 入力
    let (N, P) = get!(i64, i64);

    // 素因数分解した結果を用いて解を求める
    let (ans, _) = if N == 1 {
        (P, 1)
    } else {
        let Q = ((P as f64).sqrt().ceil() as i64) + 1;
        (2..Q).fold(
            (1, P),
            |(acc, p), i| {
                let k = f(p, i);
                (
                    acc * i.pow((k / N) as u32),
                    p / i.pow((k as u32))
                )
            }
        )
    };

    // 出力
    println!("{}", ans);
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, k;
    cin >> n >> k;
    if (n % k == 0)
        OP(0);
    else
        OP(1);
        
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 3000003
#define MOD 1000003
using namespace std;
using LL = long long;
LL pw(LL x,LL y) {
    LL res=1, tmp=x;
    while (y) {
        if (y&1) res = res*tmp%MOD;
        tmp = tmp*tmp%MOD;
        y /= 2;
    }
    return res;
}
LL fact[M];
LL comb(LL x,LL y) {
    return fact[x] * pw(fact[y], MOD-2) % MOD * pw(fact[x-y], MOD-2) % MOD;
}
LL fct(LL x,LL y) {
    LL res = fact[x];
    if (x-y>=0) res *= pw(fact[x-y], MOD-2);
    return res % MOD;
}
int q;
int main()
{
    fact[0] = 1;
    REP(i,1,M-1) fact[i] = fact[i-1] * i % MOD;
    
    int x,d,n;
    while (~scanf("%d", &q)) {
        while (q--) {
            scanf("%d %d %d",&x,&d,&n);
            x %= MOD;
            d %= MOD;

            if (d==0) {
                printf("%lld\n", pw(x,n));
                continue;
            }

            LL st = x * pw(d, MOD-2) % MOD;
            LL tmp = (MOD-x) * pw(d, MOD-2) % MOD;
            if (n-1>=tmp) {
                puts("0");
                continue;
            }            

            LL ans = pw(d, n) * fct(st+n-1, n) % MOD;
            printf("%lld\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 24320
loop do
    m, f, r = gets.split.map(&:to_i)
    break if m == -1 and f == -1 and r == -1

    if [m, f].include?(-1)
        puts "F"
    elsif m + f >= 80
        puts "A"
    elsif m + f >= 65
        puts "B"
    elsif m + f >= 50
        puts "C"
    elsif m + f >= 30
        puts r >= 50 ? "C" : "D"
    else
        puts "F"
    end
end


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

int n, c, d1, d2;
bool ans;

int main() {
  cin >> n;
  c = 0;
  ans = false;
  rep (i, n) {
    cin >> d1 >> d2;
    if (d1 == d2) c++;
    else c = 0;
    if (c == 3) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << (long double)(w * h) / 2 << " ";
	if ((x == 0 || x == w) && (y == 0 || y == h)) {
		cout << 0 << endl;
	}
	else if (x * h == y * w || (w - x) * h == y * w) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int N, A;
vector<int> x;
LL dp[50+2][50+2][2500+2] = {0};
int done[50+2][50+2][2500+2] = {0};


LL calcDP(int i, int j, long long k){
	if(k <= 0) return 0;
	if(j > i || j<= 0) return 0;
	if(done[i][j][k]) return dp[i][j][k];

	LL ret = 0;
	if(i == 1 || j == 1){
		for(int s=0; s<=i-1; s++){
			if(x[s] == k){
				ret++;
			}
		}
		dp[i][j][k] = ret;
		done[i][j][k] = 1;
		return ret;
	}

	LL u = calcDP(i - 1, j, k);
	LL v = calcDP(i - 1, j - 1, k - x[i-1]);
	dp[i][j][k] = u + v;
	done[i][j][k] = 1;
	return (u + v);
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> A;
	for(int i=1; i<=N; i++){
		int u;
		cin >> u;
		x.push_back(u);
	}
	sort(x.begin(), x.end());
	int S=0;
	for(int i=0; i<x.size(); i++){ S += x[i]; }

	for(int i=1; i<=N; i++){
		for(int j=1; j<=i; j++){
			for(int k=1; k<=S; k++){
				long long w = calcDP(i, j, k);
			}
		}
	}
	long long ans = 0;
	for(int j=1; j<=N; j++){
		ans += calcDP(N, j, j*A);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 76544
#define REP(i, n) for (int (i) = 0;(i)<(int)(n);(i)++)
#define rep(i, n) REP(i, n)
#define REPI(i, a, n) for(int i=int(a);i<int(b);i++)
#define repi(i, a, n) REPI(i, a, n)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define putn(x, n) cout<<fixed<<setprecision(n)<<x<<endl
#define PB push_back

typedef long long ll;

#include <bits/stdc++.h>

using namespace std;


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

    double n,k,a;
    cin>>n>>k;
    while(cin>>a){}
    n--;
    k--;
    cout << ceil(n/k)<<endl;
}

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

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

void dfs(vector<vector<int>> &ab,vector<int> &p,vector<int> &ans,int now,int nextp){
	ans.at(now)=p.at(now)+nextp;
	for(int i=0;i<ab.at(now).size();i++){
		dfs(ab,p,ans,ab.at(now).at(i),ans.at(now));
	}
}

int main(){
	int N,Q;
	cin >> N >> Q;
	vector<vector<int>> ab(N);
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		ab.at(a).push_back(b);
	}
	vector<int> p(N,0);
	for(int i=0;i<Q;i++){
		int pi,x;
		cin >> pi >> x;
		pi--;
		p.at(pi)+=x;
	}
	/*
	for(int i=0;i<N;i++){
		cout << i << ": ";
		for(int j=0;j<ab.at(i).size();j++){
			cout << ab.at(i).at(j) << ",";
		}
		cout << endl;
	}
	cout << "************" << endl;
	for(int i=0;i<Q;i++)	cout << i << ":" << p.at(i) << endl;
	*/

	vector<int> ans(N,0);
	dfs(ab,p,ans,0,0);
	for(int i=0;i<N-1;i++){
		cout << ans.at(i) << " ";
	}
	cout << ans.at(N-1) << endl;

	return 0;
}


Measured memory_bytes: 30464
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	int minv=min(min(q*4,h*2),s);
	if(minv*2<=d){
		cout<<minv*n;
	}
	else{
		cout<<(n%2)*minv+n/2*d;
	}
	return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef pair<pair<int, int>, pair<int, int>> Pr;
signed main() {
	int n;
	while (cin >> n, n) {
		Pr p; vector<Pr>v;
		for (int i = 0; i < n; i++) {
			cin >> p.second.first >> p.second.second >> p.first.first >> p.first.second;
			p.first.first = 11 - p.first.first;
			v.push_back(p);
		}
		sort(v.begin(), v.end());
		int f[1200]; for (int i = 1; i <= 1000; i++)f[i] = 0;
		vector<int>ans;
		for (Pr i : v) {
			if (ans.size() < 10) {
				if (f[i.second.second] < 3) {
					ans.push_back(i.second.first);
					f[i.second.second]++;
				}
			}
			else if (ans.size() < 20) {
				if (f[i.second.second] < 2) {
					ans.push_back(i.second.first);
					f[i.second.second]++;
				}
			}
			else if (ans.size() < 26) {
				if (f[i.second.second] < 1) {
					ans.push_back(i.second.first);
					f[i.second.second]++;
				}
			}
		}
		for (int i : ans)cout << i << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    
    //if (N == 1) {
    //    cout << "No" << endl;
    //    return 0;
    //}
    
    int sqr = sqrt(N * 2);
    if (sqr * (sqr + 1) != 2 * N) {
        cout << "No" << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
    }
    
    int V = sqr + 1;
    cout << V << endl;
    vector<vector<int>> ans(V);
    int cnt = 1;
    for (int i = 0; i < V; ++i) for (int j = i + 1; j < V; ++j) {
        ans[i].push_back(cnt);
        ans[j].push_back(cnt);
        ++cnt;
    }
    rep(i, V) {
        cout << ans[i].size() << " ";
        rep(j, ans[i].size()) {
            cout << ans[i][j];
            if (j != ans[i].size() - 1) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2, mod);
	x = x * x % mod;
	if(e&1) x = x * a % mod;
	return x;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	cat tot = 1, dif = 0, fac_inv = 1, mod = 998244353;
	for(int i = 1; i < N; i++) {
		tot = tot * (3*M+i) % mod;
		fac_inv = fac_inv * i % mod;
	}
	vector<cat> prod_m1(N+3*M+1, 0), prod_m2(N+3*M+1, 0);
	prod_m1[0] = fac_inv;
	prod_m2[0] = fac_inv * pw(N-1, mod-2, mod) % mod;
	for(int i = 0; i < M; i++) {
		prod_m1[i+1] = prod_m1[i] * (i+N) % mod * pw(i+1, mod-2, mod) % mod;
		prod_m2[i+1] = prod_m2[i] * (i+N-1) % mod * pw(i+1, mod-2, mod) % mod;
	}
	for(int i = 0; i < M; i++) dif = (dif + prod_m2[i]) % mod;
	dif = dif * N % mod * (N-1) % mod;
	vector<cat> C(N+1, 0); // C(N, i)
	C[0] = 1;
	for(int i = 1; i <= N; i++) C[i] = C[i-1] * pw(i, mod-2, mod) % mod * (N-i+1) % mod;
	for(int i = M+1; i <= min(3*M, N); i++) if((M-i)%2 == 0)
		dif = (dif + prod_m1[(3*M-i)/2] * C[i]) % mod;
	cat ans = (tot - dif) * pw(fac_inv, mod-2, mod) % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  vint S(n+1);
  S[0] = 0;
  rep1(i,n+1){
    S[i] = S[i-1] + A[i-1];
  }
  //rep(i,n+1) cout << S[i] << " ";
  sort(S.begin(),S.end());
  int ans = 0;
  int count = 1;
  rep(i,n){
    if(S[i] == S[i+1]){
      count++;
      if(i == n-1){
        ans += count*(count-1)/2;
      }
    }
    else{
      ans += count*(count-1)/2;
      count = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll x; cin >> x; ll countg = 0; ll countf = 0;
  countg = x/500;
  countf = (x-(x/500)*500)/5;
  cout << 1000*countg+5*countf << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    int w,a,b,l1,l2,r1,r2;
    cin>>w>>a>>b;
    l1=a;
    r1=a+w;
    l2=b;
    r2=b+w;
    cout<<max(0,max(l2-r1,l1-r2));
	return 0;
}


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


int main() 
{
    long long N,A,B;

    cin >>N>>A>>B;

  	long long rem;
  
    rem=N%(A+B);

  	if(rem<=A)
      cout<<N/(A+B)*A+rem;
    else
      cout<<(N/(A+B)+1)*A;
  
    return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

s=int(input())
n=s//3

Mod=10**9+7
M=10**4 #書き換え
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
ans=0
for i in range(1,n+1):
    m=s-i*3
    ans+=COM(m+i-1,i-1)
    ans%=Mod
print(ans)

Measured memory_bytes: 77632
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String name[] = {"A","B","C","D","E"};
		
		while(true){
			int max_team = 0;
			int max_buy = Integer.MIN_VALUE;
			
			for(int i = 0; i < 5; i++){
				int one = sc.nextInt();
				int two = sc.nextInt();
				
				if(one == 0 && two == 0){
					System.exit(0);
				}
				
				if(max_buy < (one + two)){
					max_buy = one + two;
					max_team = i;
				}
			}
			
			System.out.println(name[max_team] + " " + max_buy);
		}
		
		
	}
	
}

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

int main(){
  ll n,num[3];
  cin>>n;
  for(int i=0;i<n;i++) cin>>num[i];
  if(n==2) num[2]=num[1];
  ll d=__gcd(num[0],num[1]);
  d=__gcd(d,num[2]);

  for(int i=1;i<=d;i++)if(d%i==0) cout <<i<<endl;  

  return 0;
}

Measured memory_bytes: 1160
while True:
    T, D, L = map(int, input().split())
    if T == 0 and D == 0 and L == 0: break

    wet=[0]*(T+D)
    for i in range(T):
        if int(input())>=L : 
            wet[i] += 1
            wet[i+D] -= 1
    for i in range(1,T):
        wet[i] += wet[i-1]
    print(sum(x>0 for x in wet[:T-1]))


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    int R = 1;
    while((R+1)*(R+1) <= N) R++;
    vector<int> upper(R+2);
    upper[R+1] = R;
    for(int i=R; i>=1; i--){
        int ok = R, ng = N+1;
        while(ng-ok>1){
            int64_t mid = (ok+ng)/2;
            (i*mid <= N ? ok : ng) = mid;
        }
        upper[i] = ok;
    }

    static int64_t dp[101][40001], dpu[101][40001];
    dp[0][1] = 1;
    for(int i=0; i<K; i++){
        int64_t sum = 0;
        for(int j=1; j<=R; j++){
            add(sum, dp[i][j]);
            add(dpu[i+1][j], sum * (upper[j] - upper[j+1]));
        }
        for(int j=R; j>=1; j--){
            add(sum, dpu[i][j]);
            add(dp[i+1][j], sum);
        }
    }
    int64_t ans = 0;
    for(int j=1; j<=R; j++) add(ans, dp[K][j] + dpu[K][j]);
    cout << ans << endl;
}


Measured memory_bytes: 62464
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  ll now_T = 0,now_A = 0;

  for(int i = 0;i < n;i++){
    ll t,a;
    cin >> t >> a;
    if(now_T < t && now_A < a){
      now_T = t;
      now_A = a;
    }
    else{
      ll next = max((now_T + t-1) / t,(now_A + a - 1) / a);
      now_T = t * next;
      now_A = a * next;
    }
  }
  
  cout << now_A + now_T << endl;

}


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

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

        int N = sc.nextInt();
        int[] d = new int[N];
        for (int i = 0; i < d.length; ++i) {
            d[i] = sc.nextInt();
        }

        System.out.println(solve(d));

        sc.close();
    }

    static int solve(int[] d) {
        return (int) Arrays.stream(d).distinct().count();
    }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;
  vector<pll> a(n);
  REP(i,n){
    ll ai,bi;
    cin >> ai >> bi;
    a[i] = make_pair(ai,bi);
  }
  sort(a.begin(),a.end(),[](pll ai,pll bi){return ai.first < bi.first;});
  queue<pll> q;
  REP(i,n) q.push(a[i]);

  //REP(i,n) cout<< a[i].first << "," << a[i].second << endl;

  auto c = [](pll ai,pll bi){return ai.second < bi.second;};
  priority_queue<ll, vector<pll>, decltype(c)> gain(c);

  ll ans = 0;
  REP(i,m+1){
    while(q.size()>0 && (q.front()).first<=i){
      gain.push(q.front());
      q.pop();
    }
    if(gain.size()>0){
      pll job = gain.top();
      ans += job.second;
      //cout << "Day " << i+1 << ", a=" << job.first << ",b=" << job.second << endl;
      gain.pop();
    }
  }

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


Measured memory_bytes: 5640
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 3) {
		    System.out.println(61);
		    return;
		}
		int[][][][] dp = new int[n + 1][4][4][4];
		for (int i = 0; i < 4; i++) {
		    for (int j = 0; j < 4; j++) {
		        for (int k = 0; k < 4; k++) {
		            dp[3][i][j][k] = 1;
		        }
		    }
		}
		for (int a = 4; a <= n; a++) {
    		for (int i = 0; i < 4; i++) {
    		    for (int j = 0; j < 4; j++) {
    		        for (int k = 0; k < 4; k++) {
    		            for (int l = 0; l < 4; l++) {
    		                if (checkNum(i, j, k, l)) {
    		                    continue;
    		                }
    		                dp[a][j][k][l] += dp[a - 1][i][j][k];
    		                dp[a][j][k][l] %= MOD;
    		            }
    		        }
    		    }
    		}
		}
		int ans = 0;
		for (int i = 0; i < 4; i++) {
		    for (int j = 0; j < 4; j++) {
		        for (int k = 0; k < 4; k++) {
		            ans += dp[n][i][j][k];
		            ans %= MOD;
		        }
		    }
		}
		System.out.println(ans);
    }
    
    static boolean checkNum(int a, int b, int c, int d) {
        return ((a == 0 && b == 1 && c == 2) ||
            (b == 0 && c == 1 && d == 2) ||
            (b == 0 && a == 1 && c == 2) ||
            (a == 0 && c == 1 && d == 2) ||
            (a == 0 && c == 1 && b == 2) ||
            (c == 0 && b == 1 && d == 2) ||
            (a == 0 && b == 1 && d == 2) ||
            (b == 0 && d == 1 && c == 2));
    }
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> a(n + 1, true);
    int x;
    REP(i, m) {
        cin >> x;
        a[x] = false;
    }

    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    FOR(i, 1, n + 1) {
        if (i == 1) {
            if (a[1]) {
                dp[i] = 1;
            }
        } else if (a[i]) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int N,M;
long long int a[100001];
long long int sum;
long long int ans,ans2;
int main(){
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> a[i];
  }
  
  for(int i=0;i<N;i++){
    sum+=a[i];
    if(i%2==0){
      if(sum<=0){ans+=abs(sum)+1;sum=1;}
    }
    else{
      if(sum>=0){ans+=abs(sum)+1;sum=-1;}
    }
  }
  sum=0;
  for(int i=0;i<N;i++){
    sum+=a[i];
    if(i%2==1){
      if(sum<=0){ans2+=abs(sum)+1;sum=1;}
    }
    else{
      if(sum>=0){ans2+=abs(sum)+1;sum=-1;}
    }
  }
  
  
  cout << min(ans,ans2) << endl;
  return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    long int h[100000];
    int c[100000]={};
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(h[a-1]>h[b-1]){
            c[b-1]=1;
        }
        else if(h[b-1]>h[a-1]){
            c[a-1]=1;
        }
        else{
            c[a-1]=1,c[b-1]=1;
        }
    }
    int num=0;
    for(int i=0;i<n;i++){
        if(c[i]==0){
            num++;
        }
    }
    cout<<num<<endl;
}

Measured memory_bytes: 4808