akhauriyash/Code-Regression huggingface dataset:
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 31-May-2020 18:10:23
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    long long n; cin >> n;
    long long res = 0;
    long long m = n;
    for (long long i = 2; n > 1 && i * i <= m; ++i) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                ++cnt;
                n /= i;
            }
            for (int j = 1; j * (j + 1) / 2 <= cnt; ++j) {
                ++res;
            }
        }
    }
    if (n > 1) {
        ++res;
    }
    cout << res << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long LL;

int n, m;
vector<int> ch[100010];
int pa[100010];
vector<int> pre[100010], suf[100010];
int pos[100010];
int down[100010], up[100010];

void dfs(int u) {
    for (int i=0;i<ch[u].size();i++) {
        int v=ch[u][i];
        if (pa[u]==v) continue;
        pa[v]=u;
        pos[v]=i;
        dfs(v);
    }
}

int go_down(int u) {
    if (down[u]>=0) return down[u];
    for (int i=0;i<ch[u].size();i++) {
        int v=ch[u][i];
        if (pa[u]==v) {
            if (pre[u].size()==0) pre[u].push_back(1);
            else pre[u].push_back(pre[u][pre[u].size()-1]);
            continue;
        }
        int t=1;
        if (pre[u].size()>0) t=pre[u][pre[u].size()-1];
        pre[u].push_back((1LL*t*(go_down(v)+1))%m);
    }
    for (int i=(int)ch[u].size()-1;i>=0;i--) {
        int v=ch[u][i];
        if (pa[u]==v) {
            if (suf[u].size()==0) suf[u].push_back(1);
            else suf[u].push_back(suf[u][suf[u].size()-1]);
            continue;
        }
        int t=1;
        if (suf[u].size()>0) t=suf[u][suf[u].size()-1];
        suf[u].push_back((1LL*t*(go_down(v)+1))%m);
    }
    return down[u]=pre[u][pre[u].size()-1];
}

int go_up(int u) {
    if (up[u]>=0) return up[u];
    if (u==0) return 0;
    int f=pa[u];
    int ret=1;
    if (pos[u]-1>=0) ret=(1LL*ret*pre[f][pos[u]-1])%m;
    if ((int)suf[f].size()-pos[u]-2>=0) ret=(1LL*ret*suf[f][(int)suf[f].size()-pos[u]-2])%m;
    ret=(1LL*ret*(go_up(f)+1))%m;
    return up[u]=ret;
}

int main() {
    cin>>n>>m;
    for (int i=0;i<n-1;i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        ch[x-1].push_back(y-1);
        ch[y-1].push_back(x-1);
    }
    if (n==1) {
        cout<<1<<endl;
        return 0;
    }
    memset(pa,-1,sizeof(pa));
    dfs(0);
    memset(down,-1,sizeof(down));
    memset(up,-1,sizeof(up));
    for (int i=0;i<n;i++) go_down(i);
    cout<<go_down(0)<<endl;
    for (int i=1;i<n;i++) cout<<(1LL*go_down(i)*(1+go_up(i)))%m<<endl;
}

Measured memory_bytes: 25856
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

typedef long long ll;

#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

ll AB[2], K;
int main() {
   cin >> AB[0] >> AB[1] >> K;
   rep(i, 0, K) {
      ll t = i % 2;
      if (AB[t] % 2 > 0) {
         AB[t]--;
      }
      AB[(t+1)%2] += AB[t]/2;
      AB[t] = AB[t]/2;
   }
   cout << AB[0] << " " << AB[1] << endl;
   return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<cmath>
#include<functional>
#include<algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=1;i<=n;i++)
int main()
{
	char S[10];
	scanf("%s", &S);
	if (S[0] == 'S') 
	{
		printf("Cloudy");
	}
	if(S[0] == 'C')
	{
		
			printf("Rainy");

	}
	else if(S[0]=='R')
	{
		printf("Sunny");
	}

	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
   int n,i;
   long a[200000],t,t2,s,r,c;
 
   scanf("%d",&n);
   t=0;
   for (i=0;i<n;i++) {
      scanf("%ld",&a[i]);
      t+=a[i];
   }
   s=0;
   t2=(t+1)/2;
   for (i=0;s<t2 && i<n;i++) s+=a[i];
   r=t-s;
   if (s==r) c=0;
   else      c=s-r;
   s-=a[i-1];
   r=t-s;
   if (r-s<c) c=r-s;
   printf("%ld\n",c);
   return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
static const int INF = (1<<30)-1;
int n,f[101][10],p[101][11];
int main(){
  cin >> n;
  for(int i=0;i<n;i++) for(int j=0;j<10;j++) cin >> f[i][j];
  for(int i=0;i<n;i++) for(int j=0;j<11;j++) cin >> p[i][j];

  int benefit_max = -INF;
  for(int bit=1;bit<(1<<10);bit++){
    int benefit = 0;
    for(int i=0;i<n;i++){
      int cnt = 0;
      for(int j=0;j<10;j++){
        if(bit & (f[i][j] << j)) cnt++;
      }
      benefit += p[i][cnt];
    }
    if(benefit_max < benefit) benefit_max = benefit;
  }
  cout << benefit_max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

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

  for(int i=0;i<S.length();i++){
  cout << 'x';
  }
}


Measured memory_bytes: 256
N = int(input())
S = []
for n in range(N):
    S.append(input())
    
C = [0, 0, 0, 0]
for s in S:
    if s == "AC":
        C[0] += 1
    elif s == "WA":
        C[1] += 1
    elif s == "TLE":
        C[2] += 1
    else:
        C[3] += 1
        
print("AC", "x", str(C[0]))
print("WA", "x", str(C[1]))
print("TLE", "x", str(C[2]))
print("RE", "x", str(C[3]))

Measured memory_bytes: 79340
// D - Derangement
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &P){
	int ans = 0;
	rp(i, 1, N+1){//1 origin
		if(P[i] == i){//X
			ans++;
			i++;
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi P(N+1); rp(i, 1, N+1) cin>>P[i];//1 origin
	cout<< solve(N, P) <<endl;
}

Measured memory_bytes: 640
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()

b=[]
i=0
j=len(a)-1
test=10**9
while j-i>=1:
    b.append(a[i])
    b.append(a[j])
    i+=1
    j-=1
if i==j:
    for k in b:
        test=min(test,abs(k-a[i]))
    b.append(a[i])


ans=[abs(b[-1]-b[0])]
for i in range(len(b)-1):
    ans.append(abs(b[i+1]-b[i]))




print(sum(ans)-min(ans+[test]))


Measured memory_bytes: 12884
#include <stdio.h>
int main()
{
  int m, f, r ;

  while(1){
    scanf("%d %d %d",&m,&f,&r) ;
    if( m == -1 && f == -1 && r == -1 ){
      break ;
    }
    else{
      if( m == -1 || f == -1 ){
        printf("F\n") ;
      }else if( m + f < 30){
        printf("F\n") ;
      }else if( 80 <=  m + f ){
        printf("A\n") ;
      }else if( m + f < 80 && 65 <=  m + f ){
        printf("B\n") ;
      }else if( m + f < 65 && 50 <=  m + f ){
        printf("C\n") ;
      }else if( m + f < 50 && 30 <=  m + f ){
        if( 50 <= r ){
          printf("C\n") ;
        }else if( m + f < 50 && 0 <=  m + f ){
          printf("D\n") ;
        }
      }
    }
  }

  return 0 ;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
  
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

    int a,b,c,d,h1,h2,flag=0;
    cin>>a>>b>>c>>d;
    while(a!=0 && c!=0)
    {
        c=c-b;
        if(c<=0)
        {
        flag=1;
        break;
        }
        a=a-d;
        if(a<=0)
        {
        flag=2;
        break;
        }
    }
    if(flag==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;



    return 0 ;

}

Measured memory_bytes: 3532
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main(){



               long long int n;

               string s;
               cin>>s;


               if(s[5]=='1'){

                cout<<"TBD";
               }
               else if(s[6]=='4'||s[6]=='3'||s[6]=='2'||s[6]=='1'){

                cout<<"Heisei";
               }
               else{

                cout<<"TBD";
               }



}


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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> s(n+1,vector<ll>(k+1));
  s[0][0] = 1;
  for(ll i = 1; i <= n; i++) {
    for(ll j = 1; j <= k; j++) {
      s[i][j] = (s[i-1][j-1] + j*s[i-1][j]) % mod;
    }
  }
  ll ans = 0;
  rep(i,k+1) ans = (ans + s[n][i]) % mod;
  cout << ans << endl; 
  return 0;
}



Measured memory_bytes: 10808
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  map<int,int> ans;
  for(int i=1; i<n; i++){
    long long int a;
    cin>>a;
    ans[a]++;
  }
  for(int i=1; i<=n; i++){
    cout<<ans[i]<<endl;
  }
}

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

int main()
{
    string S;
    int check;

    do{
        check = 0;
        cin >> S;
        for(int i=0;i<3;i++){
            if(S[i]!='A' && S[i]!='B')check = 1;
        }
    }while(S.length() > 3 || check == 1);

    if(S[0] == S[1] && S[1] == S[2])
    {
        cout << "No";
    }else{
        cout << "Yes";
    }



    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int N, K, R, S, P;

int score(char t){
	if(t == 'p')return S;
	if(t == 's')return R;
	if(t == 'r')return P;
	return 0;
}

int main(){
	string input;
	cin >> N >> K >> R >> S >> P >> input;
	vector<bool> used(N, false);
	ll ans = 0;
	rep(i,N){
		if(i >= K){
			if(input[i] == input[i-K]){
				if(!used[i-K]){
					ans += score(input[i]);
					used[i] = true;
				}
			}else{
				ans += score(input[i]);
				used[i] = true;
			}
		}else{
			ans += score(input[i]);
			used[i] = true;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
/*input
7
1 1 1 1 1 1 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=8e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
ll mult(ll a,ll b){
    a%=MOD;
    b%=MOD;
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    REP(i,n) cin>>arr[i];
    sort(arr,arr+n);
    reverse(arr,arr+n);
    ll ans=0;
    REP(i,n){
        ans+=arr[i/2];
    }
    ans-=arr[0];
    cout<<ans;
}

Measured memory_bytes: 4420
K = int(input())
A,B = (int(x) for x in input().split())
c = A // K
while True:
    if K == 1:
        print('OK')
        break
    b = K * (c)
    if b >= A and b <= B:
        print('OK')
        break
    elif b > B:
        print('NG')
        break
    c += 1

Measured memory_bytes: 9184
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, X, mod = mapint()
first = set()
second = set()
in_loop = []
ans = 0
for i in range(min(10**5*2, N)):
    if X in first:
        if X in second:
            break
        in_loop.append(X)
        second.add(X)
    first.add(X)
    ans += X
    X = pow(X, 2, mod)
else:
    print(ans)
    exit()

loop_len = len(in_loop)
rest = N-len(first)-len(in_loop)
ans += (rest//loop_len)*sum(in_loop)
amari = rest%loop_len
for i in range(amari):
    ans += in_loop[i]
print(ans)

Measured memory_bytes: 86492
import sys
from collections import deque
def main():
    movey = (0, -1, 0, 1)
    movex = (1, 0, -1, 0)
    warpy = (-2, -2, -2, -2, -2, -1, -1, -1, -1,  0, 0,  1,  1, 1, 1, 2, 2, 2, 2, 2)
    warpx = (-2, -1,  0,  1,  2, -2, -1,  1,  2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2)

    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    dummy = tuple(['#'] * (w + 4))
    maze = {e: [] for e in range(h + 4)}
    maze[0] = dummy
    maze[1] = dummy
    for i in range(h):
        row = ['#'] + ['#'] + list(input()) + ['#'] + ['#']
        maze[i+2] = row
    maze[h+2] = dummy
    maze[h+3] = dummy
    maze[ch][cw] = 0
    maze[dh][dw] = 'g'

    nodes = deque()
    nodes.append((ch, cw))
    res = []
    while nodes:
        (n_y, n_x) = nodes.popleft()
        cur_masu = maze[n_y][n_x]
        flag = False
        for j1 in range(4):
            ny = n_y + movey[j1]
            nx = n_x + movex[j1]
            next_masu = maze[ny][nx]
            if next_masu == 'g':
                res.append(cur_masu)
            elif next_masu == '.':
                maze[ny][nx] = cur_masu
                nodes.appendleft((ny, nx))
            elif next_masu == '#':
                flag = True
            elif next_masu > cur_masu:
                maze[ny][nx] = cur_masu
                nodes.appendleft((ny, nx))
        if flag:
            for j1 in range(20):
                ny = n_y + warpy[j1]
                nx = n_x + warpx[j1]
                next_masu = maze[ny][nx]
                if next_masu == 'g':
                    res.append(cur_masu+1)
                elif next_masu == '.':
                    maze[ny][nx] = cur_masu + 1
                    nodes.append((ny, nx))
                elif next_masu == '#':
                    pass
                elif next_masu > cur_masu + 1:
                    maze[ny][nx] = cur_masu + 1
                    nodes.append((ny, nx))

    if res:
        print(min(res))
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 164020
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = nextInt()
	}
	return result
}

func main() {
	N := nextInt()
	S := readInts(N)
	var ANS int
	for i := 1; i < N; i++ {
		if S[i-1] > S[i] {
			n := S[i-1] - S[i]
			ANS += n
			S[i] += n
		}
	}
	fmt.Println(ANS)
}


Measured memory_bytes: 6428
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define endl "\n"
#define int long long int
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef pair<int, int> pii;
typedef vector<int> vi;

string to_string(string s)      {    return '"' + s + '"';   }
string to_string(const char* s) {   return to_string((string) s);   }
string to_string(bool b)        {   return (b ? "true" : "false");  }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int n,m,k,i,j,mod;
vector<int> a;
map<int,int> mm;
map<int,int> mini;

void remove(int L,int R)
{
  auto it=mm.lower_bound(L);
  auto jt=mm.upper_bound(R+1);
  --jt;
  if(jt->X!=R+1)
  {
    mm[R+1]=jt->Y;
    mini[R+1+jt->Y]++;
  }
  while(it->X<=R)
  {
    mini[it->X+it->Y]--;
    mm.erase(it++);
  }
  // mm[L]=1e12;
  it=mini.begin();
  while(it->Y==0)
    mini.erase(it++);
}

int32_t main(void) {
  FASTIO;
  cin>>n>>m;
  for(int i=1;i<=m;++i)
    mm[i]=-i;
  mm[0]=1e12;
  mm[m+1]=1e12;
  mini[0]=m;
  mini[1e12]++;
  mini[1e12+m+1]++;

  // debug(mm);
  for(int i=1;i<=n;++i)
  {
    int l,r;
    cin>>l>>r;
    remove(l,r);
    debug(mm);
    debug(mini,i);
    int ans=i+mini.begin()->X;
    debug(ans);
    cout<<(ans>=1e10?-1:ans)<<endl;
  }
  return 0;
}


Measured memory_bytes: 16152
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<ll, int> amap;
  for(ll x=1;x<=100;++x) {
    for(ll y=1;y<=100;++y) {
      for(ll z=1;z<=100;++z) {
        amap[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(int i=1;i<=N;++i) cout<<amap[i]<<endl;
}



Measured memory_bytes: 5976
#include <stdio.h>

int main()
{
  int a,b,c, ans;
  scanf("%d %d %d", &a, &b, &c);
  
  if(a == b && b == c)
    ans = 1;
  else if(a == b || a == c || b == c)
    ans = 2;
  else
    ans = 3;
  printf("%d", ans);
  
  return 0;
}

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

int n, x[100100], y[100100], ds[100100];
vector <int> ver[100100], hor[100100];

int get(int u)
{
  return ds[u] == u ? u : ds[u] = get(ds[u]);
}

void unite(int u, int v)
{
  int du = get(u), dv = get(v);
  if (du != dv)
    ds[dv] = du;
}

int main()
{
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    ds[i] = i;
    cin >> x[i] >> y[i];
    ver[x[i]].push_back(i);
    hor[y[i]].push_back(i);
  }

  for (int i = 1; i <= 100000; i++)
  {
    for (int j = 1; j < ver[i].size(); j++)
      unite(ver[i][j], ver[i][j - 1]);
    for (int j = 1; j < hor[i].size(); j++)
      unite(hor[i][j], hor[i][j - 1]);
  }

  long long ans = 0;
  for (int i = 0; i < n; i++)
    if (get(i) == i)
    {
      set <int> allX, allY;
      for (int j = 0; j < n; j++)
        if (get(j) == i)
        {
          allX.insert(x[j]);
          allY.insert(y[j]);
        }
      ans += 1LL * allX.size() * allY.size();
    }

  cout << ans - n << endl;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
ll mod                = 1e9 + 7;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
long long modpow(long long a, long long n, long long mod=(1LL<<62)){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
void COMinit() {// テーブルを作る前処理
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k){ // 二項係数:nCk計算
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	string l;
	COMinit();
	ll ans = 0LL;
	cin >> l;
	int one = 0;
	reverse(all(l));
	for (int i = l.size() - 1; i >= 0;i--){
		if(l[i]=='1'){
			ans += modpow(3,i , mod)*modpow(2,one,mod)%mod;
			one++;

		}
		ans %= mod;
	//	clog << ans << endl;
		
	}
	ans += modpow(2, one, mod);
	cout << ans%mod << endl;
}
/*
0:0 0
1:0 1
  1 0
10:00 10
   10 00
11:11 00
   00 11
   10 01
   01 10
100:000 100
    100 000
101 (2^2)
110 (2^2)
111 (2^3)
1 :0   ==1
1 1 : 1== 1+2=3
1 2 1 : 11 == 1+2*2+4=9
1 3 3 1:111 =1+3*2+3*4+8=27
1 4 6 4 1: 1111 = 1+4*2+6*4+4*8+16=81
nCk : 1..xn.1 で1がkこ立っている == 3^n
1がnこ立っているかいくつかが分かれば一発
*/

Measured memory_bytes: 15680
#include <iostream>
#include <cmath>

using namespace std;

bool isPower(int n) {
    int x = (int)sqrt(n);
    if(x*x == n) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int n;
	cin >> n;
    for (int i = n;i > 0;i--){
        if(isPower(i)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int limit=scn.nextInt();
        int minCost=1001;
        for(int i=0;i<n;i++){
            int cost=scn.nextInt();
            int time=scn.nextInt();
            if(limit>=time){
                if(minCost>cost) minCost=cost;
            }
        }
        if(minCost==1001){
            System.out.println("TLE");
        }else{
            System.out.println(minCost);
        }
    }
}

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

typedef long long ll;

int main()	
{
	int n,k;
	cin>>n>>k;
	int mx = -1;
	int a[n];

	for(int i=0;i<n;i++){ 
		cin>>a[i];
		mx = max(mx,a[i]);
	}

	int gcd = a[0];
	
	for(int i=1;i<n;i++)
		gcd = __gcd(a[i],gcd);


	if(mx<k||(k%gcd!=0)){
		puts("IMPOSSIBLE");
	}

	else{
		puts("POSSIBLE");
	}
}

Measured memory_bytes: 3892
p = str(input())

q =list(str(p))
r = []

for i in range(len(q)):
    r.append(int(q[i]))

a = r[0]
b = [-r[1],r[1]]
c = [-r[2],r[2]]
d = [-r[3],r[3]]

e = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a + b[i] + c[j] + d[k] == 7:
                e.append(a)
                e.append(b[i])
                e.append(c[j])
                e.append(d[k])

for i in range(len(e)):
    if e[i] < 0 or i == 0:
        e[i] = str(e[i])
    else:
        e[i] = '+' + str(e[i])
        
print(e[0] + e[1] + e[2] + e[3] + '=7') 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template<class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;




void Main() {
    int K;
    cin >> K;
    priority_queue<pi, vector<pi>, greater<pi>> pq;
    int dist[100005];
    fill(dist, dist+K+1, 1e9);
    dist[1] = 0;
    pq.emplace(0, 1);
    while (!pq.empty()) {
        pi top = pq.top();
        pq.pop();
        int d = top.first, u = top.second;
        if (d > dist[u]) continue;
        for (pi edg : {pi((10*u) % K, 0), pi((u+1) % K, 1)}) {
            int v = edg.first, w = edg.second;
            if (d + w < dist[v]) {
                dist[v] = d + w;
                pq.emplace(dist[v], v);
            }
        }
    }
    cout << 1 + dist[0] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef _DEBUG
//        freopen("in.txt", "r", stdin);
//        freopen("out.txt", "w", stdout);
    #endif
    Main();
    return 0;
}


Measured memory_bytes: 1276
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
c_list = []
c_sum = 0
total = 0
for i in range(1, len(a)):
    if a[i] - 1 == a[i - 1]:
        c_list.append(a[i-1]-1)
    else:
        continue

for num in c_list:
    c_sum += c[num]

total = c_sum + sum(b)
print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")

// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define MAX_V 10

int d[MAX_V][MAX_V];    //d[u][v] is cost of e(u, v)
const int V = 10;      //num of v

void warshall_floyd(){
    for(int k = 0; k < V; k++)
        for(int i = 0; i < V; i++)
            for(int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
    int H,W;
    cin >>H>>W;
    REP(i,10)
        REP(k,10)
            cin >> d[i][k];


    warshall_floyd();
    //queue<int> q;
    //q.push(1);
    //while(!q.empty()){
    //    int p = q.front();
    //    q.pop();
    //    for(int v = 0; v < )
    //}

    //REP(i,10){
    //    REP(k,10) cout << d[i][k] << " ";
    //    cout << endl;
    //}

    int inp;
    int num = 0;
    REP(i,H){
        REP(k,W){
            cin >> inp;
            if(inp == -1) continue;
            num += d[inp][1];
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 764
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int N;
        N = int.Parse(arr[0]);
        if (new int[] { 2, 4, 5, 7, 9 }.Contains(N % 10))
            Console.WriteLine("hon");
        else if (new int[] { 0, 1, 4, 6, 8 }.Contains(N % 10))
            Console.WriteLine("pon");
        else
            Console.WriteLine("bon");
        return;
    }
}


Measured memory_bytes: 27660
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;

const int N = 200005;
LL val[N * 4], sum[N * 4], base[N];

void push_down(int rt, int sl, int m, int sr) {
    val[rt * 2] += val[rt];
    sum[rt * 2] += val[rt] * (m - sl + 1);
    val[rt * 2 + 1] += val[rt]; 
    sum[rt * 2 + 1] += val[rt] * (sr - m);
    val[rt] = 0;
}
void push_up(int rt) {
    sum[rt] = sum[rt * 2] + sum[rt * 2 + 1];
    sum[rt] = sum[rt * 2] + sum[rt * 2 + 1];
}
void build(int sl, int sr, int rt) {
  if(sl == sr) {
    val[rt] = 0;
    sum[rt] = base[sl];
    return ;
  }
  int m = (sl + sr) / 2;
  build(sl, m, rt * 2);
  build(m + 1, sr, rt * 2 + 1);
  push_up(rt);
}
void update(int l, int r, LL w, int sl, int sr, int rt) {
    //printf("%d %d %d %d\n", l, r, sl, sr);
    if(l == sl && r == sr) {
        val[rt] += w;
        sum[rt] += (r - l + 1) * w;
        return ;
    }
    int m = (sl + sr) / 2;
    push_down(rt, sl, m, sr);
    if(r <= m) update(l, r, w, sl, m, rt * 2);
    else if(l > m) update(l, r, w, m + 1, sr, rt * 2 + 1);
    else {
        update(l, m, w, sl, m, rt * 2);
        update(m + 1, r, w, m + 1, sr, rt * 2 + 1);
    }
    push_up(rt);
}

LL query(int l, int r, int sl, int sr, int rt) {
    if(l == sl && r == sr) {
        return sum[rt];
    }

    int m = (sl + sr) / 2;
    push_down(rt, sl, m, sr);
    LL ans;
    if(r <= m) ans = query(l, r, sl, m, rt * 2);
    else if(l > m) ans = query(l, r, m + 1, sr, rt * 2 + 1);
    else {
        ans = query(l, m, sl, m, rt * 2) + query(m + 1, r, m + 1, sr, rt * 2 + 1);
    }
    push_up(rt);
    return ans;
}

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);

  vector<vector<int>> e(n + 1);

  build(1, n, 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    e[u].push_back(v);
    update(v, n, 1, 1, n, 1);
  }
  LL ans = 0;
  for (int i = 1; i <= n; i++) {
    LL x = n + 1 - i;
    LL cur = x * (x + 1) / 2;
    LL all = query(i, n, 1, n, 1);
    ans += cur - all; 
    for (auto v : e[i]) {
      update(v, n, -1, 1, n, 1);
    }
  }
  cout << ans << endl;

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 22584
#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>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n;
 	scanf("%d",&n);
 	
 	std::vector<vector<int>> occ(10,vector<int>(10));
 	ll ans = 0;
 	for(int i=1;i<=n;i++){
 		occ[to_string(i)[0]-'0'][to_string(i).back()-'0']++;
 	}
 	for(int i=1;i<=n;i++){
 		ans+=occ[to_string(i).back()-'0'][to_string(i)[0]-'0'];
 	}
 	printf("%lld\n",ans );
}		


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))
using ll = long long;
using namespace std;

ll f(ll b, ll n) {
    if (b < 2) return -1;
    ll acc = 0;
    for (; n; n /= b) acc += n % b;
    return acc;
}

ll solve(ll n, ll s) {
    // search lower half
    int sqrt_n = min<ll>(n, sqrt(n) + 3);
    REP3 (b, 2, sqrt_n) if (f(b, n) == s) return b;
    // search upper half
    if (s == n) return n + 1;
    REP3R (a, 1, sqrt_n) {
        ll b = (n - s) / a + 1;
        if (f(b, n) == s) return b;
    }
    return -1;
}

int main() {
    ll n, s; scanf("%lld%lld", &n, &s);
    ll result = solve(n, s);
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 256
import math
def combi(a, b):
    mod = 10**9+7
    if (a+b)%2 == 0:
        return (math.factorial(a)%mod * math.factorial(b)%mod * 2) % mod
    else:
        return (math.factorial(a)%mod * math.factorial(b)%mod) % mod
def main():

    N, M = map(int, input().split())
    if abs(N-M) > 1:
        print(0)
    else:
        print(combi(N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4100
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    VVI r(n);
    BIT bit(n);
    REP(i,m){
        int x = in() - 1, y = in() - 1;
        r[x].push_back(y);
        bit.add(y, 1);
    }
    VI ans(q);
    VVI que(n), ind(n);
    REP(i,q){
        int x = in() - 1, y = in() - 1;
        que[x].push_back(y);
        ind[x].push_back(i);
    }
    REP(i,n){
        REP(j,que[i].size()){
            ans[ind[i][j]] = bit.sum(que[i][j]);
        }
        for (int x : r[i]){
            bit.add(x, -1);
        }
    }
    REP(i,q) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>


using namespace std;

int main(){
    int N, count = 0, k;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    for(int i = 0; i < N-2; i++){
        for (int j = i+1; j < N-1; j++){
            k = j+1;
            while(L[k] < L[i]+L[j] && k < N){
                count += 1;
               // cout << L[i] << L[j] << L[k] << k << endl;
                ++k;           
            }
        }
    }
    cout << count << endl;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<int64_t> a(x), b(y), c(z);
    for (auto&& aa : a) {
        cin >> aa;
    }
    for (auto&& bb : b) {
        cin >> bb;
    }
    for (auto&& cc : c) {
        cin >> cc;
    }

    vector<int64_t> d;
    for (auto bb : b) {
        for (auto cc : c) {
            d.push_back(bb + cc);
        }
    }

    sort(d.rbegin(), d.rend());

    d.resize(k);

    vector<int64_t> e;
    for (auto aa : a) {
        for (auto dd : d) {
            e.push_back(aa + dd);
        }
    }

    sort(e.rbegin(), e.rend());

    e.resize(k);

    for (auto ee : e) {
        cout << ee << "\n";
    }
}

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

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<vector<int> > lis(h, vector<int>(w, 0));
    vector<vector<int> > ans(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        string s; cin >> s;
        for(int l = 0; l < w; l++){
            if(s[l] == '#'){
                lis[i][l] = 1;
            }else{
                lis[i][l] = 0;
            }
        }
    }
    int m = 1;
    int first = 0;
    vector<int> flag(h, 0);
    for(int i = 0; i < h; i++){
        for(int l = 0; l < w; l++){
            ans[i][l] = m;
            if(lis[i][l] == 1){
                if(first != 0){
                    m++;
                }
                first = 1;
                ans[i][l] = m;
                flag[i] = 1;
            }
        }
        first = 0;
        m++;
        if(flag[i] == 0){
            for(int l = 0; l < w; l++){
                ans[i][l]--;
            }
            m--;
        }
    }
    for(int i = 0; i < h; i++){
        if(flag[i] == 0){
            int l = i + 1;
            while(1){
                if(l >= h){
                    break;
                }
                if(flag[l] == 1){
                    break;
                }
                l++;
            }
            if(l >= h){break;}
            for(int k = i; k < l; k++){
                for(int o = 0; o < w; o++){
                    ans[k][o] = ans[l][o];
                }
            }
        }
    }
    if(flag[h-1] == 0){
            int l = h-2;
            while(1){
                if(l < 0){
                    break;
                }
                if(flag[l] == 1){
                    break;
                }
                l--;
            }
            for(int k = h-1; k >l; k--){
                for(int o = 0; o < w; o++){
                    ans[k][o] = ans[l][o];
                }
            }
    }

    for(int i = 0; i < h; i++){
        for(int l = 0; l < w; l++){
            cout << ans[i][l] << " "; 
        }
        cout << endl;
    }
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    string s;
    cin >> s;
    int size = s.size();
    vector<int> ans(size);
    int j=(-1), k=(-1);
    bool l=true;
    rep(i,size) {
        if (s.at(i) == 'R') {
            if (i+1>j) j=i; while (s.at(j) == 'R') j++;
            if ((j-i)%2 == 0) ans.at(j)++;
            else ans.at(j-1)++;
            l = true;
        }
        else {
            if (l) k=i; while (s.at(k) == 'L') k--;
            if ((i-k)%2 == 0) ans.at(k)++;
            else ans.at(k+1)++;
            l = false;
        }
    }
    rep(i,size-1) cout << ans.at(i) << " ";
    ct(ans.at(size-1));
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int cnt=0;
  for (int i=min(a,b); i>0; i--) {
    if (a%i==0 and b%i==0) {
      cnt++;
    }
    if (cnt == k){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  int k = in(), t = in();
  priority_queue<pii> pq;
  REP(i, t) {
    pq.push(mp(in(), i));
  }
  int id = pq.top().Se;
  pii b = pq.top();
  pq.pop();
  pq.push(mp(b.Fi - 1, b.Se));
  int ans = 0;
  while (true) {
    pii a = pq.top(); pq.pop();
    if (a.Se == id) {
      if (pq.empty()) {
        id = a.Se;
        ++ans;
        if (a.Fi - 1 != 0){
          pq.push(mp(a.Fi - 1, a.Se));
        }
        //cerr << a.Fi << " " << a.Se << __LINE__ << '\n';
      } else {
        pii c = pq.top(); pq.pop();
        pq.push(a);
        id = c.Se;
        if (c.Fi - 1 != 0) {
          pq.push(mp(c.Fi - 1, c.Se));
        }
        //cerr << c.Fi << " " << c.Se <<  " " << __LINE__ << id<< '\n';
      }
    } else {
      id = a.Se;
      if (a.Fi - 1 != 0) {
        pq.push(mp(a.Fi - 1, a.Se));
      }
      //cerr << a.Fi << " " << a.Se <<__LINE__<< '\n';
    }
    
    if (pq.empty()) break;
  }
  print(ans);

  return 0;
}


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

using namespace std;

int A[3], res = 0;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	int x = A[2] - A[1];
	res += x;
	A[0] += x, A[1] += x;
	int y = (A[2] - A[0] + 1) / 2;
	res += y;
	A[0] += 2 * y;
	if (A[0] > A[2])
		++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
M, K = map(int,input().split())
if M == 1 and K == 1:
    print(-1)
elif K == 0:
    for i in range(2**M):
        print(i,end=" ")
        print(i,end=" ")
elif 2**M <= K:
    print(-1)
else:
    for i in range(2**M):
        if i != K:
            print(i,end=" ")
    print(K, end=" ")
    for i in reversed(range(2**M)):
        if i != K:
            print(i,end=" ")
    print(K, end=" ")

Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    ll i = 0;
    A = 100;
    while (A < N)
    {
        A = (ll)(A * 1.01);
        i++;
    }
    
    cout << i;
    return 0;
}

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

const int MX = 246913;
bool isPrime[MX];
int cum[MX];

int main() {
    for (int i=0; i<MX; ++i) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for (int i=2; i*i<MX; ++i) {
        if ( ! isPrime[i]) continue;
        for (int j=2*i; j<MX; j+=i) {
            isPrime[j] = false;
        }
    }
    cum[0] = 0;
    for (int i=1; i<MX; ++i) {
        cum[i] = cum[i-1] + (int)isPrime[i];
    }
    int n;
    while (cin >> n, n) {
        cout << cum[2*n] - cum[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 2364