akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define mod 2019
using namespace std;
ll l,r;
ll ans1,ans2;
ll ans3,ans4;
int main(){
    cin>>l>>r;
    ans1=l%mod;
    ans2=r%mod;
    if(r-l>=mod-ans1)
        return cout<<0<<endl,0;
    if(ans1>ans2)
        ans2+=mod;
    ll ans=(ll)1e9+7;
    for(int i=ans1;i<=ans2;i++)
        for(int j=i+1;j<=ans2;j++)
            ans=min(ans,(ll)i*j%mod);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
if x==1 or x==2*N-1:
    print('No')
elif N==2:
    print('Yes')
    for i in range(-1,2):
        print(x-i)
        
elif N>=3 and x==2:
    print('Yes')    
    a=[i for i in range(1,N*2)]
    del a[x-2:x+2]

    for i in range(N-2):
        print(a[i])

    print(x+1)
    print(x)
    print(x-1)
    print(x+2)
    
    for i in range(N+3,2*N):
        print(a[i-5])
else:
    print('Yes')    
    a=[i for i in range(1,N*2)]
    del a[x-3:x+1]

    for i in range(N-2):
        print(a[i])

    print(x-1)
    print(x)
    print(x+1)
    print(x-2)
    
    for i in range(N+3,2*N):
        print(a[i-5])

Measured memory_bytes: 12564
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[10000];
	int len,i;
	fgets(s,10000,stdin);
	len=strlen(s);
	for(i=0;i<len;i++){
		if(s[i] >= 'a' && s[i] <='z'){
			s[i] -= 'a' - 'A';
		}
		printf("%c",s[i]);
	}
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li cnt = 0;
li k;

inline bool dfs(li keta, string s) {
    if (sz(s) == keta) {
        cnt++;
        if (cnt == k) {
            cout << s << endl;
            return true;
        }
        return false;
    }
    for (char c = max((char)(s.back() - 1), '0'); c <= min((char)(s.back() + 1), '9'); ++c) {
        if (dfs(keta, s + c)) {
            return true;
        }
    }
    return false;
}

int main() {
    cin >> k;
    repp(keta, 1, 100) {
        repp(i, 1, 10) {
            string s = "";
            s += '0' + i;
            if (dfs(keta, s)) {
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

const int MOD = 1000000007;

const int N = 222;
const int W = 11111;

int n,w;
vector<int> p;

bool input(){
	cin>>n>>w;
	p.resize(n);
	rep(i,n)cin>>p[i];
	return true;
}

int dp[2][W];

int solve(){
	
	sort(p.rbegin(), p.rend());
	
	vector<int> sum(n+1);
	for(int i=n-1;i>=0;i--)sum[i] = sum[i+1] + p[i];
	
	rep(i,2)rep(j,W)dp[i][j] = 0;
	
	int dp1 = 0;
	int dp2 = 1;
	
	int ans = 0;
	rep(i,n){
		rep(j,W)dp[dp2][j] = 0;
		
		if(i==0){
			dp[dp2][0] = 1;
		}else{
			rep(j,w+1){
				dp[dp2][j] = dp[dp1][j];
				if(j-p[i-1]>=0){
					dp[dp2][j] += dp[dp1][j-p[i-1]];
					dp[dp2][j] %= MOD;
				}
			}
		}
		
		rep(j,w+1){
			int hev = sum[i+1] + j;
			if(w>=hev && w-hev < p[i]){
				ans += dp[dp2][j];
				ans %= MOD;
			}
		}
		swap(dp1,dp2);
	}
	if(sum[0]<=w){
		ans += 1;
		ans %= MOD;
	}
	
	return ans;
}

void call(){
	cout<<solve()<<endl;
}

int main(){
	input();
	call();
}

Measured memory_bytes: 1288
n = int(input())

ok = False
x = 0

for i in range(1000):
    if n == i * (i + 1) // 2:
        ok = True
        x = i
        break

if ok:
    print('Yes')
    d = n * 2 // x
    print(d)

    a = [[] for _ in range(d)]
    a[0].append(1)
    a[1].append(1)

    now = 1
    for i in range(2, d):
        for j in range(i):
            a[j].append(now + j + 1)
        for j in range(i):
            a[i].append(now + j + 1)
        now += i

    for i in range(d):
        print(x, *a[i])
else:
    print('No')


Measured memory_bytes: 76804
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
constexpr int P = 998'244'353, N = 400;
int n;
int a[N], b[N], factorial[N], invFactorial[N], pw[N];
int dp[2][N][N + 1];
int power(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = 1LL * res * a % P;
        a = 1LL * a * a % P;
        b >>= 1;
    }
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n;
    for (int i = 0; i < n; ++i)
        std::cin >> a[i] >> b[i];
    int s = std::accumulate(a, a + n, 0);
    int invS = power(s, P - 2);
    int r = std::accumulate(b, b + n, 0) - n;
    factorial[0] = 1;
    for (int i = 1; i <= r; ++i)
        factorial[i] = 1LL * factorial[i - 1] * i % P;
    invFactorial[r] = power(factorial[r], P - 2);
    for (int i = r; i >= 1; --i)
        invFactorial[i - 1] = 1LL * invFactorial[i] * i % P;
    int cur = 0;
    dp[0][0][0] = P - 1;
    for (int i = 0; i < n; ++i) {
        cur ^= 1;
        std::memset(dp[cur], 0, sizeof(dp[cur]));
        pw[0] = 1;
        int p = 1LL * a[i] * invS % P;
        for (int j = 1; j < b[i]; ++j)
            pw[j] = 1LL * pw[j - 1] * p % P;
        for (int j = 0; j <= r; ++j) {
            for (int k = 0; k <= s; ++k) {
                if (dp[cur ^ 1][j][k] == 0)
                    continue;
                dp[cur][j][k] = (dp[cur][j][k] + dp[cur ^ 1][j][k]) % P;
                for (int l = 0; l < b[i]; ++l)
                    dp[cur][j + l][k + a[i]] = (dp[cur][j + l][k + a[i]] + 1LL * (P - dp[cur ^ 1][j][k]) * invFactorial[l] % P * pw[l]) % P;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= r; ++i) {
        for (int j = 1; j <= s; ++j) {
            int inv = power(1LL * j * invS % P, P - 2 - i);
            ans = (ans + 1LL * factorial[i] * dp[cur][i][j] % P * inv) % P;
        }
    }
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1536
N=int(input())
a=list(map(int,input().strip().split()))
d={}

for n in range(N):
    if d.get(a[n])==None:
        d[a[n]]=1
    else:
        d[a[n]]+=1

cnt=0
for key in d.keys():
    if key>d[key]:
        cnt+=d[key]
    else:
        cnt+=d[key]-key

print(cnt)
    

Measured memory_bytes: 21636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s; cin >> s;
    set<int> v;
    while(v.count(s) == 0) {
        v.insert(s);
        s%2 ? s=3*s+1 : s/=2;
    } cout << v.size() + 1;
}





Measured memory_bytes: 256
N = int(input())
R = [0]*N
C = [0]*N
for i in range(N):
    R[i],C[i] = map(int, input().split())


def solve(N,R,C):
    dp = [[float('inf')]*N for _ in range(N)]

    for i in range(N):
        dp[i][i]=0
    for i in range(N-1,-1,-1):
        for j in range(i+1,N):
            for k in range(i,j):
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+R[i]*C[k]*C[j])
    ans = dp[0][N-1]
    return ans
print(solve(N,R,C))


Measured memory_bytes: 5668
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

typedef complex<double> P;
P pIN() { double x,y; cin >> x >> y; return P(x,y); }
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() { resize(2); }
};
ostream &operator<<(ostream &os, const L &a) {
  os << a[0] << " -> " << a[1];
  return os;
}
typedef vector<P> G;

bool isTriangle(const G &t) {
  if (t.size() != 3) return 0;
  if (abs(cross(t[1]-t[0], t[2]-t[0])) < EPS) return 0; // line or dot
  return 1;
}
int typeByLength(const G &t) {
  double a = norm(t[0]-t[1]);
  double b = norm(t[1]-t[2]);
  double c = norm(t[2]-t[0]);
  if (abs(a-b) < EPS && abs(b-c) < EPS) return 0; // Equilateral
  if (abs(a-b) < EPS || abs(b-c) < EPS || abs(c-a) < EPS) return 1; // Isosceles
  return 2;                     // Scalene
}
int typeByAngle(const G &t) {
  REP(i,3) {
    double tmp = dot(t[(i+1)%3]-t[i], t[(i+2)%3]-t[i]);
    if (abs(tmp) < EPS) return i+1; // Right
    if (tmp < 0) return -i-1;        // Oblique
  }
  return 0;                     // Acute
}
bool isTriangle(double a, double b, double c) {
  return abs(a-b)+EPS < c && c < a+b-EPS;
}
G triangleFromLength(double a, double b, double c) {
  G t(3);
  t[0] = P(0,0);
  t[1] = P(a,0);
  double x = (a*a+b*b-c*c)/(2*a);
  t[2] = P(x,sqrt(b*b-x*x));
  return t;
}
int main() {
  int a,b,c;
  int A=0,B=0,C=0,D=0;
  while(cin >> a >> b >> c) {
    if (!isTriangle(a,b,c)) break;
    G t = triangleFromLength(a,b,c);
    A++;
    int type = typeByAngle(t);
    if (type == 0) C++;
    else if (type > 0) B++;
    else D++;
  }
  printf("%d %d %d %d\n",A,B,C,D);
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main(void){
    string S;
    string T;
    int N;

    cin >> S >> T;
    
    cin >> N;

    int s_s, s_e, t_s, t_e;

    int S_asum[100005];
    S_asum[0] = 0;
    for(int j=1;j<=S.length();j++){
        S_asum[j] = (S_asum[j-1] + S[j -1] - 'A' + 1) % 3;
    }
    int T_asum[100005];
    T_asum[0] = 0;
    for(int j=1;j<=T.length();j++){
        T_asum[j] = (T_asum[j-1] + T[j -1] - 'A' + 1) % 3;
    }

    for(int i=0;i<N;i++){

        /*cin >> s_s >> s_e >> t_s >> t_e;*/
        scanf("%d%d%d%d", &s_s, &s_e, &t_s, &t_e);

        int s_tmp = 0;
        int t_tmp = 0;

        s_tmp = S_asum[s_e] - S_asum[s_s-1] + 3;
        t_tmp = T_asum[t_e] - T_asum[t_s-1] + 3;

        string ans = "NO";
        if((s_tmp - t_tmp) % 3 == 0){
            ans = "YES";
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool flag=true;
    int count=0;
    rep(i,s.size()){
        if(s.at(i)=='-') count++;
    }
    if(count!=1) flag=false;
    if(s.at(a)!='-')flag=false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;


const int MAXN = (int)2e5+1;
int N, BIT[MAXN];

void update(int x, int val)
{
      for(; x <= N; x += x&-x)
        BIT[x] += val;
}

int query(int x)
{
     int sum = 0;
     for(; x > 0; x -= x&-x)
        sum += BIT[x];
     return sum;
}


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    ll ans = 0;
    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        update(x, 1);
        ans += (query(x-1) == 0);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;


public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int mul = a * b;
	
	if ( mul % 2 == 0 ) {
	    System.out.println("Even");
	} else {
	    System.out.println("Odd");
	}
    }
    
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A;

ll i, j, k;

int main(){
    scanf("%lld", &A);
    j = 1;
    rep(i,0,3){
        j *= A;
        k += j;
    }
    printf("%lld\n", k);
    return 0;
}

Measured memory_bytes: 3812
from collections import deque

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
ans = 0
Q = deque()
Q.append(A[0])
for a in A[1:]:
    b = Q[0]
    if a == b:
        Q.append(a)
        ans += b
    else:
        b = Q.popleft()
        ans += b
        Q.append(a)
        Q.append(a)
print(ans)


Measured memory_bytes: 94888
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 k = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        long ans = 0;
        for (int i = 0; i < n - k; i++) {
            ans += h[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 93944
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a;
    string b;
    string c;
    getline(cin,a);
    getline(cin,b);
    getline(cin,c);
    cout<<a.at(0)<<b.at(1)<<c.at(2)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll sum = 0;
    ll n; cin >> n;
    ll tmp = n;
    while(tmp > 0){
        sum += tmp % 10;
        tmp /= 10;
    }
    if(n % sum == 0) puts("Yes");
    else puts("No");
}

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

int cost[100][100];
int mincost[100];
bool used[100];
const int INF = 1000000;

void init()
{
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(i==j)
				cost[i][j] = 0;
			else
				cost[i][j] = INF;
		}
	}
}

int main()
{
	int n,m;
	while(cin >> n >> m){
		if(n==0 && m==0)
			break;
		init();
		for(int i=0;i<m;i++){
			int a,b,c;
			cin >> a >> b >> c;
			cost[a][b] = c;
			cost[b][a] = c;
		}
		
		for(int i=0;i<n;++i){
			mincost[i] = INF;
			used[i] = false;
		}
		mincost[0] = 0;
		int res = 0;
		while(true){
			int v=-1;
			for(int u=0;u<n;u++){
				if(!used[u]&&(v==-1 || mincost[u] < mincost[v]))
					v = u;
			}
			if(v==-1)break;
			used[v] = true;
			res += mincost[v];
			for(int u=0;u<n;u++){
				mincost[u] = min(mincost[u], cost[v][u]);
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vi ans(n);
    rep(sv, n) {
        vi dist(n, INF);
        queue<int> q;
        auto ps = [&](int v, int d) {
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        ps(sv, 0);
        while (!q.empty()) {
            int pv = q.front(); q.pop();
            int pd = dist[pv];
            if (pv-1>=0) ps(pv-1, pd+1);
            if (pv+1<=n-1) ps(pv+1, pd+1);
            if (pv==x) ps(y, pd+1);
            if (pv==y) ps(x, pd+1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    rep1(i, n-1) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 256
n, l = map(int, input().split())

sum_n = []
for i in range(1,n+1):
    sum_n.append(l + i - 1)
num = 1000000000
for i in range(len(sum_n)):
    t = abs(sum_n[i])
    if num > t:
        num = t
        ans = i
print(sum(sum_n) - sum_n[ans])

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

int gcd(int a,int b) {
	if (b==0)
		return a;
	return gcd(b,a%b);
}
int main() {
	int n,k;
	cin>>n>>k;
	int t1,t2,mmax;
	cin>>t1; mmax=t1;
	if (n == 1)
		cout<<( (t1==k)?"POSSIBLE":"IMPOSSIBLE" )<<endl;
	else {
		while (--n>0) {
			cin>>t2; mmax=mmax>t2?mmax:t2;
			t1 = gcd(t1,t2);
		}
		cout<<( (k%t1==0&&k<=mmax)?"POSSIBLE":"IMPOSSIBLE" )<<endl;
	}
	return 0;
}


Measured memory_bytes: 888
N = int(input())
PU = []
PR = []
PD = []
PL = []
P = {'U':PU, 'R':PR, 'D':PD, 'L':PL}
for _ in range(N):
    X, Y, U = input().split()
    P[U].append((int(X), int(Y)))

ans = 100000000
    
# ===== 1 =====
DU = {}
for x, y in PU:
    if x not in DU: DU[x] = []
    DU[x].append(y)

DD = {}
for x, y in PD:
    if x not in DD: DD[x] = []
    DD[x].append(y)

for x, p1 in DU.items():
    if x not in DD: continue
    p2 = DD[x]
    
    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*5)

# ===== 2 =====
DR = {}
for x, y in PR:
    if y not in DR: DR[y] = []
    DR[y].append(x)

DL = {}
for x, y in PL:
    if y not in DL: DL[y] = []
    DL[y].append(x)

for y, p1 in DR.items():
    if y not in DL: continue
    p2 = DL[y]

    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*5)

# ===== 3-1 =====
DR = {}
for x, y in PR:
    if x+y not in DR: DR[x+y] = []
    DR[x+y].append(x)

DU = {}
for x, y in PU:
    if x+y not in DU: DU[x+y] = []
    DU[x+y].append(x)

for key, p1 in DR.items():
    if key not in DU: continue
    p2 = DU[key]

    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*10)

# ===== 3-2 =====
DD = {}
for x, y in PD:
    if x+y not in DD: DD[x+y] = []
    DD[x+y].append(x)

DL = {}
for x, y in PL:
    if x+y not in DL: DL[x+y] = []
    DL[x+y].append(x)

for key, p1 in DD.items():
    if key not in DL: continue
    p2 = DL[key]

    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*10)

# ===== 4-1 =====
DR = {}
for x, y in PR:
    if x-y not in DR: DR[x-y] = []
    DR[x-y].append(x)

DD = {}
for x, y in PD:
    if x-y not in DD: DD[x-y] = []
    DD[x-y].append(x)

for key, p1 in DR.items():
    if key not in DD: continue
    p2 = DD[key]

    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*10)

# ===== 4-2 =====
DU = {}
for x, y in PU:
    if x-y not in DU: DU[x-y] = []
    DU[x-y].append(x)

DL = {}
for x, y in PL:
    if x-y not in DL: DL[x-y] = []
    DL[x-y].append(x)

for key, p1 in DU.items():
    if key not in DL: continue
    p2 = DL[key]

    p1.sort()
    p2.sort()
    n = len(p2)
    i = 0
    for z in p1:
        while i<n and p2[i]<=z: i+=1
        if i==n: break
        ans = min(ans, (p2[i]-z)*10)
        
# ===== ans =====
print(ans if ans<100000000 else 'SAFE')


Measured memory_bytes: 80936
#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;
int dp[500000];

int main() {
	int n, m;
	int c[21];

	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> c[i];

	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i <= n; i++) {
		//if (dp[i] == 0 && i!=0) continue;
		for (int j = 0; j < m; j++) {
			dp[i + c[j]] = min(dp[i] + 1, dp[i + c[j]]);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int N;

ll bit[2][1000000];

void init(){
  rep(i, 2) rep(j, 1000000) bit[i][j] = 0;
}

void add(int l, int r, int val){
  for(int i = l; i <= N; i+= (i & -i)) bit[0][i] += -val * (l-1);
  for(int i = l; i <= N; i+= (i & -i)) bit[1][i] += val;
  for(int i = r+1; i <= N; i += (i & -i)) bit[0][i] += val*r;
  for(int i = r+1; i <= N; i += (i & -i)) bit[1][i] += -val;
}

ll sum(int i){
  vector<ll> ret(2);
  for(int idx = i; idx > 0; idx -= (idx & -idx)) ret[0] += bit[0][idx];
  for(int idx = i; idx > 0; idx -= (idx & -idx)) ret[1] += bit[1][idx];
  ret[1] *= i;
  return ret[0] + ret[1];
}

int mod = 1000000007;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int Q; cin >> N >> Q;
  vector<int> A(N+1); rep(i, N) cin >> A[i+1];
  vector<int> prev(N+1, 0);
  vector<pair<pair<int, int>, int>> query(Q);
  vector<ll> ans(Q);
  
  rep(i, Q){
    int l, r; cin >> l >> r;
    query[i] = make_pair(pair<int, int>(r, l), i);
  }
  sort(query.begin(), query.end());

  int idx = 1;
  rep(q, Q){
    int right = query[q].first.first, left = query[q].first.second;
    while(idx <= right){
      add(prev[A[idx]]+1, idx, 1);
      prev[A[idx]] = idx;
      idx++;
    }
    ans[query[q].second] = sum(left) - sum(left-1);
  }
  rep(i, Q) cout << ans[i] << endl;
  
  /*
  add(1, 3, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  add(1, 1, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  add(3, 5, 1);
  rep(i, N) cout << sum(i+1) << " "; cout << endl;
  */
  return 0;
}

Measured memory_bytes: 33108
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define int long long
vector<pair<int, int>> edges;
vector<long long> ans;
int p[(int)1e5+5];
long long size[(int)1e5+5];

int find_set(int u) {
	if(u==p[u]) return u;
	return p[u] = find_set(p[u]);
}

void union_set(int u, int v) {
	int x = find_set(u);
	int y = find_set(v);
	size[y] += size[x];
	p[x] = y;
}

signed main() {
	IOS
	long long n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++) p[i] = i;
	for(int i=0; i<n; i++) size[i] = 1;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edges.push_back(make_pair(a, b));
	}
	reverse(edges.begin(), edges.end());
	long long cnt = 0;
	long long a = n*(n-1)/2;
	for(int i=0; i<m; i++) {
		int u = edges[i].first, v = edges[i].second;
		if(find_set(u) != find_set(v)) {
			ans.push_back(a-cnt);
			cnt += size[find_set(v)] * size[find_set(u)];
			union_set(u, v);
		}
		else {
			ans.push_back(a - cnt);
		}
	}
	reverse(ans.begin(), ans.end());
	for(auto a : ans) cout << a << "\n";
	return 0;
}


Measured memory_bytes: 6256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int H,W; cin >> H >> W;
    vector<vector<int>> A(H,vector<int>(W));
    vector<vector<int>> B(H,vector<int>(W));

    for(auto& vec:A) for(auto& in:vec) cin >> in;
    for(auto& vec:B) for(auto& in:vec) cin >> in;

    int base = 13000;
    auto dp = make_v<int>(H+1,W+1,base*2);

    dp[0][0][base] = true;

    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            int v1 = A[i][j], v2 = B[i][j];
            for(int k = 0; k < 2*base;k++){
                if(dp[i][j][k]){
                    dp[i+1][j][k+v1-v2] = true;
                    dp[i+1][j][k+v2-v1] = true;
                    dp[i][j+1][k+v1-v2] = true;
                    dp[i][j+1][k+v2-v1] = true;
                }
            }
        }
    }

    res = INF;

    for(int k = 0; k < 2*base;k++){
        if(dp[H][W-1][k]){
            res = min(res,abs((ll)k-base));
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 678240
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,m,k; scanf("%d%d%d",&n,&m,&k);
    int tot=0;
    while(n--){
        if(tot==m)
            if(k<1000000000) {printf("%d ",k+1); continue;}
            else {printf("%d ",k-1); continue;}
        printf("%d ",k);
        tot++;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i=0,j=0;
		Scanner sc = new Scanner(in);
		int q = parseInt(sc.next());
		int[] l = new int[q];
		int[] r = new int[q];
		int mx = 0;
		for (i = 0; i < q; i++) {
			l[i] = parseInt(sc.next());
			r[i] = parseInt(sc.next());
			if(mx<r[i])mx=r[i];
		}
		sc.close();
		ArrayList<Integer> plist = new ArrayList<>(); 
		plist.add(2);
		boolean[] pflag = new boolean[mx+1];
		pflag[2] = true;
		for (i = 3; i <= mx; i+=2) {
			boolean f=true;
			for (j = 0; j < plist.size() && plist.get(j) * plist.get(j) <= i; j++) {
				if(i%plist.get(j)==0) {
					f=false;
					break;
				}
			}
			if(f) {
				plist.add(i);
			}
			pflag[i]=f;
		}
		int[] acc = new int[mx+2];
		int tmp=0;
		for (i = 3; i <= mx; i+=2) {
			if(pflag[i]&&pflag[(i+1)/2]) {
				tmp++;
			}
			acc[i]=tmp;
			acc[i+1]=tmp;
		}
		int[] cnt = new int[q];
		for (i = 0; i < q; i++) {
			cnt[i] = acc[r[i]] - acc[l[i] -1];
		}
		PrintWriter pw = new PrintWriter(out);
		for (i = 0; i < q; i++) {
			pw.println(cnt[i]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 59624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s, t;
    cin >> s >> t;
    bool ok = true;
    rep(i, s.size())
    {
        if (s[i] != t[i])
        {
            ok = false;
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3584
from math import cos
from math import radians
from math import sqrt

def hour2deg(hour, min):
  return hour*30 + min/2

def min2deg(min):
  return min*6

def resolve():
  A, B, H, M = map(int, input().split(" "))
  degree = abs(hour2deg(H, M) - min2deg(M))
  if degree > 180:
    degree = 360.0 - degree
  length = sqrt(A**2 + B**2 - 2*A*B*cos(radians(degree)))
  print(length)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// ACL template
int main() {
    ll T;
    cin >> T;
    rep(_, T){
        ll N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << '\n';
    }
}

Measured memory_bytes: 3704
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int fbc[200000];

int fb(int a)
{
	if(fbc[a]>0)
	return fbc[a];
	
	
	if(a<2)
	return 1;
	
	fbc[a]=fb(a-1)+fb(a-2);
	return fbc[a];
	
}

int main()
{
	iniarr(fbc,200000);
	int a;
	scd(a);
	a=fb(a);
	printf("%d\n",a);	
	return 0;
}

Measured memory_bytes: 3976
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int N = 4;

int main(void){
    for(int n; cin >> n, n;){
        vvi dp(n + 1, vi(N, inf));
        dp[0][0] = 0;

        int prep = 0, pret = 0;
        int stop = inf;

        vector<pii> in(n);
        rep(i, n){
            cin >> in[i].first >> in[i].second;
        }

        bool ok;
        range(i, 1, n + 1){
            int p = in[i - 1].first, t = in[i - 1].second;

            rep(j, N){
                int dist = max(p, prep) - min(p, prep);
                if(j + 1 < N && dist * (j + 1) <= (t - pret)){
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + dist);
                }
                if((double)prep * (j + 1) + p <= (t - pret)){
                    dp[i][1] = min(dp[i][1], dp[i - 1][j] + prep + p);
                }
            }

            ok = false;
            rep(j, N){
                if(dp[i][j] < inf) ok = true;
            }
            if(!ok){
                cout << "NG " << i << endl;
                break;
            }
            prep = p; pret = t;
        }
        int res = *min_element(all(dp[n])) + prep;
        if(ok) cout << "OK " << res << endl;
    }

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vary(ll,w,10,0);
  vary(ll,k,10,0);
  rep(i,10){
    cin >> w[i];
  }
  sort(all(w));
  reverse(all(w));
  rep(i,10){
    cin >> k[i];
  }
  sort(all(k));
  reverse(all(k));
  ll a = 0, b = 0;
  rep(i,3){
    a += w[i];
  }
  rep(i,3){
    b += k[i];
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3116
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, d: i64);
    let mut ret = 0usize;
    let d2 = d * d;
    for _ in 0..n {
        parse!(it, x: i64, y: i64);
        if x * x + y * y <= d2 {
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4800
N = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

a_b = 0
b_c = 0
count = 0
for b_item in b:
    while a_b < N and a[a_b] < b_item:
        a_b += 1
    while b_c < N and c[b_c] <= b_item:
        b_c += 1
    count += (a_b * (N - b_c))

print(count)


Measured memory_bytes: 22720
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 K = sc.nextInt();
		int a[] = new int[N];
		for(int i=0;i<N;i++) {
			int temp = sc.nextInt();
			a[temp-1]++;
		}
		int count=0;
		for (int i=0;i<N;i++) {
			if (a[i]>0) {
				count++;
			}
		}
		if (count<=K) {
			System.out.println(0);
			return ;
		}
		Arrays.sort(a);
		int i=0;
		for (;i<N;i++) {
			if (a[i]!=0) {
				break;
			}
		}
		int result=0;
		for (int j=0;j<count-K;j++) {
			result+=a[j+i];
		}
		System.out.println(result);
	}
}


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

int main()
{
    //データ定義
    int num_a;
    int num_b;

    //データ入力
    cin >> num_a >> num_b;

    //結果出力
    cout << num_a / num_b << " ";
    cout << num_a % num_b << " ";
    cout << fixed << setprecision(5) << (double) num_a / (double)num_b << endl;

    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
struct edge {int to; ll w; };
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N = in();
  vector<vector<edge>> G(N);
  vector<char> ret(N,'.');
  vi u(N+1), v(N+1); vector<ll> w(N+1);
  rep(i,N-1){
    cin >> u[i] >> v[i] >> w[i];
    G[u[i]-1].push_back({v[i]-1,w[i]});
    G[v[i]-1].push_back({u[i]-1,w[i]});
  }
  stack<int> s;
  s.push(0);
  ret[0] = '0';
  while(!s.empty()){
    int n = s.top(); s.pop();
    for(edge &e : G[n]){
      if(ret[e.to]!='.') continue;
      s.push(e.to);
      if(e.w%2) {
        if(ret[n]=='0') ret[e.to] = '1';
        else ret[e.to] = '0';
      } else {
        if(ret[n]=='0') ret[e.to] = '0';
        else ret[e.to] = '1';
      }
    }
  }
  rep(i,N) cout << ret[i] << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;
using ll = long long;

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

int main() {
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if (x > y) {
        swap(a, b);
        swap(x, y);
    }
    // cout << a << b << c << x << y;
    ll cost = 0;
    if (a + b > 2 * c) {
        if (b > 2 * c) {
            cost += 2 * y * c;
        } else {
            cost += 2 * x * c + (y - x) * b;
        }
    } else {
        cost += x * a + y * b;
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int H,W,N;
  cin>>H>>W>>N;
  int a[10001];
  for(int i=1;i<=N;i++) cin>>a[i];
  int answer[100][100];
  int w=0;
  int h=0;
  int ud=0;
  int num=1;
  int judge=0;
  while(w<W){
    answer[h][w]=num;
    if(ud==0){
      judge++;
      if(judge==a[num]){
        judge=0; num++;
      }
      h++;
      if(h==H){
        h=H-1; w++; ud=1;
      }
    }
    else{
      judge++;
      if(judge==a[num]){
        judge=0; num++;
      }
      h--;
      if(h==-1){
        h=0; w++; ud=0;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j<W-1) cout<<answer[i][j]<<' ';
      else cout<<answer[i][j]<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3208