akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n;

	cin >> n;

	vector<ll> a(n + 1, 0);
	vector<ll> b(n + 1, 0);
	vector<ll> c(n + 1, 0);
	vector<vector<ll>> dp(n + 1, vector<ll>(3, -INF));

	REP(i, n) {
		cin >> a[i + 1] >> b[i + 1] >> c[i + 1];
	}

	REP(i, 3) {
		dp[0][i] = 0;
	}

	FOR(i, 1, n + 1) {
		REP(j, 3) {
			REP(k, 3) {
				if (i != 1 && k == j) {
					continue;
				}
				if (j == 0) {
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i]);
				}
				else if (j == 1) {
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + b[i]);
				}
				else {
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + c[i]);
				}
			}
		}
	}

	ll ans = 0;

	REP(i, 3) {
		ans = max(ans, dp[n][i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<int> >;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];


string N[100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

void dfs(int v, vector<bool> &seen, int &res) {
    bool end = true;
    for (int i = 0; i < seen.size(); ++i) if (!seen[i] && i != v) end = false;
    if (end) {
        ++res;
        return;
    }

    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv, seen, res);
    }
    seen[v] = false;
}
bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

int dp[100000];

int main() {
    int n; cin >> n;
    //int n=3;
    string s[n];
    for(int i=0; i<n; i++) cin >> s[i];
    int res = 1;
    sort(s, s+n);
    for(int i=1; i<n; i++){
        if(s[i]!= s[i-1]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 7924
Q = int(raw_input())
for i in range(Q):
    c, a, n = map(int, raw_input().split())
    team = 0
    while c>0 and a>0 and n>0:
        c -= 1
        a -= 1
        n -= 1
        team += 1
    while c>=2 and a>0:
        c -= 2
        a -= 1
        team += 1
    while c>=3:
        c -= 3
        team += 1
    print team

Measured memory_bytes: 4216
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for i in range(n + 1)]

for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]

print(sum(s))
for i in range(1, n + 1):
    if s[i]:
        print(i,end=' ')

Measured memory_bytes: 8636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,s1,s2,s3[55],s4="~";
  int ba=0;
  cin>>s>>s1;
  s2=s;
  if(s.size()<s1.size())
   {
    cout<<"UNRESTORABLE";
    return 0; 
   }
  for(int t=0;t<=s.size()-s1.size();t++)
    {
      string s0;
      s0=s.substr(t,s1.size());
      if(s0==s1)
        {
           for(int i=0;i<s.size();i++)
            {
              if(s[i]=='?')
             {
              s[i]='a';
             }
            }
            cout<<s;
            return 0;
        } 
	}
        
   for(int t=s.size()-s1.size();t>=0;t--)
      { 
        bool ok=1;
        for(int i=t;i<t+s1.size();i++)
           {
            if(s[i]==s1[i-t]||s[i]=='?')
              {
               s[i]=s1[i-t];
              }   
            else
              {
               ok=0;
               s=s2;
               break;
              } 
            }
            if(ok)
              { 
                for(int i=0;i<s.size();i++)
                   {
                     if(s[i]=='?')
                       { 
                        s[i]='a';
                       } 
                    } 
                s3[ba]=s;
                s4=min(s4,s);
                ba++;
              } 
           } 
        if(s4=="~")
          {
            cout<<"UNRESTORABLE";
          } 
        else
          {
            cout<<s4;
          } 
        return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    string s;
    ll n;
    cin >> n;
    vector<ll> a(4, 0);
    rep1(i, n){
        cin >> s;
        if (s == "AC") a[0]++;
        if (s == "WA") a[1]++;
        if (s == "TLE") a[2]++;
        if (s == "RE") a[3]++;
    }
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3596
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())


S = input()
cnt = [0]*3
for s in S:
    if s == 'a':
        cnt[0] += 1
    elif s == 'b':
        cnt[1] += 1
    elif s == 'c':
        cnt[2] += 1

if max(cnt)-min(cnt) <= 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 4460
#include <iostream>
using namespace std;
int main()
{
	int d;
	cin>>d;
	if(d==25) cout<<"Christmas"<<endl;
	if(d==24) cout<<"Christmas Eve"<<endl;
	if(d==23) cout<<"Christmas Eve Eve"<<endl;
	if(d==22) cout<<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}

int main()
{
    int n;
    cin >> n;
    int spin=0;
    int nebor=0;
    bool last=false;
    int ans=0;
    vector<int>p(n+1,0);
    for(int i=0;i<n;i++){
        cin >>p[i];
        if(p[i]==i+1){
           // cout<<"   "<<i<<endl;
            if(last ==false){
                last=true;
            }else{
                nebor++;
                last=false;
            }
        }else{
            if(last==true){
                spin++;
            }
            last=false;
        }
    }
    if(last==true){
        spin++; 
    }
  //  cout<<spin<<" "<<nebor<<endl;
    cout << spin + nebor << endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scanner.nextInt();
        long counter = 0;
        long[] dams = new long[N];
        for(int i = 0; i < N; i++){
            long temp = scanner.nextInt();
            if(i % 2 == 0){
                counter = counter + 2*temp;
            }
            else {
                counter = counter - 2*temp;
            }
            dams[i] = 2*temp;
        }
        long x = counter/2;
        for(int j = 0; j < N; j++){
            long temp = x;
            x = dams[j] - x;
            dams[j] = temp;
        }

        for(int k = 0; k < N; k++){
            System.out.print(dams[k] + " ");
        }


    }
}


Measured memory_bytes: 67012
using System;
class Program
{
	static void Main(string[] args)
	{
      	string[] input = Console.ReadLine().Split(' ');
		int k = int.Parse(input[0]);
		int n = int.Parse(input[1]);
        int[] a = new int[n];
        input = Console.ReadLine().Split(' ');
        for(int i = 0; i<n; i++)
        {
          a[i] = int.Parse(input[i]);
        }
        int max = k - a[n-1] + a[0];
        for(int i = 1; i < n; i++)
        {
          int diff = a[i] - a[i-1];
          if(max < diff) max = diff;
        }
        Console.WriteLine(k - max);

	}
}

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define NL cout<<"\n";
#define test cerr<<"abcd\n";

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////

	int n;
	cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin>>a[i];

	unordered_map<int,long long> m;
	
	for(auto x: a) m[x]++;

	long long tr = 0;

	for(auto x: m){
		tr += (x.second >= 2)?((x.second)*(x.second-1))/2 : 0;
	}

	long long temp;
	for(auto x: a){
		if(m[x] >= 2){
			temp = tr - (m[x]*(m[x]-1))/2;
			temp += (m[x]-1 >= 2)?((m[x]-1)*(m[x]-2))/2 : 0;
			cout<<temp<<"\n";
		}
		else{
			cout<<tr<<"\n";
		}
	}

  return 0;
}

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

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

int N;

int main() {
	while (scanf("%d", &N), N) {		
		int ans = 0, f = 0;
		
		for_(i,0,N) {
			int k; scanf("%d", &k);
			if (k >= 1) ++ans;
			if (k > 1) f = 1;
		}
		
		if (f) printf("%d\n", ans + 1);
		else printf("NA\n");
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    set<int> a;
    for(int i = 0; i < 3; i++){
        int x;
        cin >> x;
        a.insert(x);
    }
    Yes(a.size() == 2);
}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

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

	string s;
	cin >> s;
	
	int min1 = 9999;
	FOR(i,0,s.size()-3+1){
	    int tmp = stoi(s.substr(i,3));
	    //cout << tmp << endl;
	    
	    min1 = min(min1, abs(tmp-753));
	}
	cout << min1 << endl;
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

void solve(int n)
{
	if(n==1){
		cout<<"#"<<endl;
		return;
	}
	vs a(n,string(n,'#'));
	int di[]={-1,0,1,0};
	int dj[]={0,1,0,-1};
	int ci=n-1,cj=1,k=0;
	rep(i,10000){
		a[ci][cj]=' ';
		int ti=ci+di[k]*2,tj=cj+dj[k]*2;
		if(ti<0 || n<=ti || tj<0 || n<=tj || a[ti][tj]==' ')
			k=(k+1)%4;
		else{
			ci+=di[k];
			cj+=dj[k];
		}
	}
	rep(i,n)
		cout<<a[i]<<endl;
}

int main()
{
	int d; cin>>d;
	rep(i,d){
		if(i) cout<<endl;
		int n; cin>>n;
		solve(n);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;

    bool is_ok = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == (i * j)) is_ok = true;
        }
    }
    if (is_ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	cout << min((N + A - 1) / A * B, (N + C - 1) / C * D) << endl;
	return 0;
}



Measured memory_bytes: 3100
const fs = require('fs')
const inputs = fs.readFileSync('/dev/stdin', 'utf8').trim().split(/\s+/).map(s => parseInt(s))

const n = inputs.shift()
const arr = inputs.slice()
const allXor = arr.reduce((a, b) => a ^ b, 0)
const results = arr.map(a => allXor ^ a)

console.log(results.join(' '))


Measured memory_bytes: 71324
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;

  int max = 0;
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int L; std::cin >> L;
    sum += L;
    max = std::max(max, L);
  }

  sum -= max;

  if (max < sum) std::cout << "Yes" << std::endl;
  else           std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
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 (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    vector<int> sum1(n+1),sum2(n+1);
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,n) {
        cin >> b[i];
    }
    rep(i,n) {
        if (i==0) {
            sum1[i+1] = a[i];
            sum2[i+1] = b[i];
        }
        else {
            sum1[i+1] = sum1[i]+a[i];
            sum2[i+1] = sum2[i]+b[i];
        }
    }
    int ans = 0;
    int tmp;
    REP(i,1,n+1) {
        tmp = sum1[i]+sum2[n]-sum2[i-1];
        chmax(ans,tmp);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3632
import sys
import numpy as np
# for AtCoder
import fractions
from collections import deque 
from functools import reduce

n, m = map(int, input().split())

s = list(map(int, input().split()))

s.sort(reverse=True)

if (sum(s) / (4 * m)) > s[m-1]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 22284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll dp[100][2][5];
int main() {
	string s;
	cin>>s;
	ll k;
	cin>>k;
	dp[0][0][0]=1;
	for(ll i=0;i<s.size();i++){
		for(ll j=0;j<=9;j++){
			if(s[i]-'0'==j){
				if(j==0){
					//cout << i<< " "<<j;
					for(ll l=0;l<4;l++){
						dp[i+1][0][l]+=dp[i][0][l];
						dp[i+1][1][l]+=dp[i][1][l];
					}
				//	cout << " "<<dp[1][0][1]<< " "<<dp[1][1][1]<<endl;
				}
				else{
					for(ll l=0;l<4;l++){
						dp[i+1][0][l+1]+=dp[i][0][l];
						dp[i+1][1][l+1]+=dp[i][1][l];
					}
				}
			}
			else{
				if(j==0){
					for(ll l=0;l<4;l++){
						dp[i+1][1][l]+=dp[i][0][l];
						dp[i+1][1][l]+=dp[i][1][l];
					}
				}
				else{
					for(ll l=0;l<4;l++){
						if(s[i]-'0'>j){
							dp[i+1][1][l+1]+=dp[i][0][l];
						}
						dp[i+1][1][l+1]+=dp[i][1][l];
					}
				}
			}
		}
	}
	cout << dp[s.size()][0][k]+ dp[s.size()][1][k];
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
while true
    a, b = gets.chomp.split.map(&:to_i)
    break if [a, b] == [0, 0]
    arr = []
    amount = b - a
    arr[2], amount = amount.divmod(1000)
    arr[1], amount = amount.divmod(500)
    arr[0] = amount / 100
    puts arr.join(" ")
end


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int X,Y,Z,K;
vi A,B,C;

signed main() {
    cin>>X>>Y>>Z>>K;
    rep(i,0,X) {
        int x; cin>>x; A.pb(x);
    }
    rep(i,0,Y) {
        int y; cin>> y; B.pb(y);
    }
    rep(i,0,Z) {
        int z; cin>>z; C.pb(z);
    }

    SORTG(A); SORTG(B); SORTG(C);

    vi D;
    rep(i,0,X) {
        rep(j,0,Y) {
            D.pb(A[i]+B[j]);
        }
    }

    
    SORTG(D);
    vi E;
    int ret;
    if(X*Y>=K) ret=K;
    else ret=X*Y;
    rep(i,0,ret) {
        rep(j,0,Z) {
            E.pb(D[i]+C[j]);
        }
    }
    SORTG(E);
    rep(i,0,K) cout<<E[i]<<endl;
    return 0;
}
            






Measured memory_bytes: 43384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int countbits(long long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

bool dfs(VVI &es, LL &bs, map<PII,int> &ma, int pos, int t, int par = -1) {
    if (pos == t) {
        return true;
    }
    for (int dst: es[pos]) {
        if (dst == par) continue;
        if (dfs(es,bs,ma,dst,t,pos)) {
            bs |= (1LL<<(ma[MP(pos,dst)]));
            return true;
        }
    }
    return false;
}

void solve() {
    int n,m,a,b;
    cin >> n;
    VVI es(n);
    map<PII,int> ma;
    REP(i,0,n-1) {
        cin >> a >> b;
        --a; --b;
        es[a].push_back(b);
        es[b].push_back(a);
        ma[MP(a,b)] = i;
        ma[MP(b,a)] = i;
    }

    cin >> m;
    VLL bs(m);
    REP(i,0,m) {
        cin >> a >> b;
        --a; --b;
        dfs(es,bs[i],ma,a,b);
    }

    LL ans = 0;
    REP(p,0,1<<m) {
        int b = __builtin_popcountl(p);
        // int pm = (b % 2 == 0) ? 1 : -1;
        LL bp = 0;
        REP(i,0,m) {
            if (!(p & (1<<i))) continue;
            bp = bp | bs[i];
        }
        LL cnt = (1LL << (n-1-__builtin_popcountl(bp)));
        // ans += cnt * pm;
        if (b % 2 == 0) ans += cnt;
        else ans -= cnt;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main() 
{
	int num[10000],n;
	n = 0;
	while (1) 
	{
		scanf("%d", &num[n]);
		if (num[n] == 0) break;
			n = n + 1;
	}
	n = 0;
	while (num[n] != 0)
	{
		printf("Case %d: %d\n", n+1, num[n]);
		n = n + 1;
	}
	return 0;
}

Measured memory_bytes: 1068
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 1001001001;
    for (int i = 0; i < 200005; i += 2) {
        ll sum = 0;
        sum += i * c;
        sum += max(0LL, (x - (i / 2))) * a + max(0LL, (y - (i / 2))) * b;
        chmin(ans, sum);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, dead_code)]
use proconio::fastout;
use proconio::input;
use rand::Rng;

#[fastout]
fn main() {
    input! {
        D:usize,
        C:[i32;26],
        S:[[i32;26];D]
    }
    let start = std::time::Instant::now();
    let mut rng = rand::thread_rng();
    let mut T = vec![0; D];
    let mut Tmax = vec![0; D];
    //let mut cnt = 0;
    for i in 0..D {
        let mut saidai = 0;
        for j in 1..26 {
            if S[i][saidai] < S[i][j] {
                saidai = j;
            }
        }
        T[i] = saidai;
        Tmax[i] = saidai;
    }
    let mut ans = score(D, &C, &S, &T);
    loop {
        let r_day = rng.gen::<usize>() % D;
        let r_con = rng.gen::<usize>() % 26;
        T[r_day] = r_con;
        //cnt += 1;
        let x = score(D, &C, &S, &T);

        // 最大値を更新できたら値を更新するが、そうでなければ元に戻す。
        if ans < x {
            ans = x;
            Tmax[r_day] = T[r_day];
        } else {
            T[r_day] = Tmax[r_day];
        }
        let duration = start.elapsed();
        if duration > std::time::Duration::from_millis(1900) {
            break;
        }
    }
    for i in 0..D {
        println!("{}", Tmax[i] + 1);
    }
    //println!("cnt:{}, point:{}", cnt, ans);
}
fn score(D: usize, C: &Vec<i32>, S: &Vec<Vec<i32>>, T: &Vec<usize>) -> i32 {
    let mut last = vec![vec![0i32; 26]; D];
    for d in 0..D {
        let i = T[d];
        last[d][i] = d as i32 + 1;
        for e in d + 1..D {
            if T[e] != i {
                last[e][i] = d as i32 + 1;
            } else {
                break;
            }
        }
    }
    let mut x = 0;
    for d in 0..D {
        let i = T[d];
        x += S[d][i];
        //println!("ss{}", x);
        for j in 0..26 {
            x -= C[j] * (d as i32 + 1 - last[d][j]);
            //println!("C[{}]={} -> {}", j, C[j], x);
        }
    }
    x
}


Measured memory_bytes: 2740
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());

		int array[];
		array = new int[53];
		for(int i=1; i<=52; i++){
			array[i] = i;
		}

		for(int j=1; j<=n; j++){
			String suit = std.next();
			int rank = Integer.parseInt(std.next());
			if(suit.equals("S")) {rank+=0;}
			else if(suit.equals("H")) {rank+=13;}
			else if(suit.equals("C")) {rank+=26;}
			else if(suit.equals("D")) {rank+=39;}

			array[rank] = 0;
		}

		for(int i=1; i<=52; i++){
			if(array[i]!=0){
				String ret = "";
				if((i-1)/13==0){ret+="S ";}
				else if((i-1)/13==1){ret+="H ";}
				else if((i-1)/13==2){ret+="C ";}
				else if((i-1)/13==3){ret+="D ";}
				if(i%13!=0){ret += i%13;}else{ret+="13";}
				System.out.println(ret);
			}
		}
	}
}

Measured memory_bytes: 26060
using System;

namespace AizuOnLine
{
    class Program
    {
        private static int i = 1;
        private static int x = 0;

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            Program.CheckNum(n);
        }

        static void CheckNum(int n)
        {
            Program.x = Program.i;
            if (Program.x % 3 == 0)
            {
                Console.Write(" " + Program.i);
                Program.EndCheckNum(n);
            }
            else
            {
                Program.Include3(n);
            }
        }

        static void Include3(int n)
        {
            if(Program.x % 10 == 3)
            {
                Console.Write(" " + Program.i);
                Program.EndCheckNum(n);
            }

            if (Program.i <= n)
            {
                Program.x /= 10;

                if (Program.x != 0)
                {
                    Program.Include3(n);
                }
                else
                {
                    Program.EndCheckNum(n);
                }
            }
        }
        
        static void EndCheckNum(int n)
        {
            if (++Program.i <= n)
            {
                Program.CheckNum(n);
            }
            else
            {
                Console.WriteLine(string.Empty);
            }
        }
    }
}

Measured memory_bytes: 10648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
 
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
 
using namespace std;
 
typedef long long int lli;
 
template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
 
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}
 
int main() {
    int N;
    cin >> N;
    vector<lli> x(N), y(N), h(N);
    auto mp = make_v(101, 101, -1);
    REP(i, 0, N) {
        cin >> x[i] >> y[i] >> h[i];
        mp[y[i]][x[i]] = h[i];
    }
    const int inf = 2000000000;
    REP(CX, 0, 101) {
        REP(CY, 0, 101) {
            if (mp[CY][CX] == 0) {
                continue;
            }
 
            lli candi = mp[CY][CX];
            lli uppr = inf;
            bool ok = true;
            REP(i, 0, N) {
                if (h[i] > 0) {
                    lli tmph = h[i] + abs(x[i] - CX) + abs(y[i] - CY);
                    if (candi != -1 && tmph != candi) {
                        ok = false;
                        break;
                    }
                    candi = tmph;
                } else {
                    uppr = min(uppr, h[i] + abs(x[i] - CX) + abs(y[i] - CY));
                }
            }
            if (candi == -1 && uppr == 1) {
                candi = 1;
            }
            if (ok && candi >= 0 && candi <= uppr) {
                cout << CX << ' ' << CY << ' ' << candi << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    if (i%2 == 0) {
      if (a%2 == 1) {
        a--;
      }
      b += a/2;
      a /= 2;
    }
    else {
      if (b%2 == 1) {
        b--;
      }
      a += b/2;
      b /= 2;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
    string napis;
    cin >> napis;
    if(napis[2] == napis[3] && napis[4] == napis[5]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>

#define MAXN 2005
#define INF 2000000090

using namespace std;

int n, k, q;
int m, a[MAXN], b[MAXN], c[MAXN], d[MAXN];
int nc, nd;

int cal(int lim)
{
    int pos = 0;
    nd = 0;
    while (pos < n) {
        if (a[pos] >= lim) {
            int rpos = pos;
            while (rpos < n && a[rpos] >= lim)
                rpos++;
            nc = 0;
            for (int i = pos; i < rpos; i++)
                c[nc++] = a[i];
            sort(c, c + nc);
            for (int i = 0; i + k <= nc; i++)
                d[nd++] = c[i];
            pos = rpos;
        } else {
            pos++;
        }
    }
    if (nd < q)
        return INF;
    sort(d, d + nd);
    return d[q - 1] - lim;
}

int main()
{
    while (scanf("%d%d%d", &n, &k, &q) == 3) {
        for (int i = 0; i < n; i++)
            scanf("%d", a + i);
        memcpy(b, a, n * sizeof(int));
        sort(b, b + n);
        m = unique(b, b + n) - b;
        int ans = INF;
        for (int i = 0; i < m; i++)
            ans = min(ans, cal(b[i]));
        if (ans == INF)
            ans = -1;
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
# N= int(input())
# N, K = [int(_) for _ in input().split()]
def gcd(a, b):
    if b > a:
        a, b = b, a
    c = a % b
    return b if c == 0 else gcd(b, c)


a, b = [int(_) for _ in input().split()]
d = gcd(a, b)
print(a // d * b // d * d)


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

int main(){
  int n; string s; cin >> n >> s;
  int max_reg=0;
  for(int i=0; i<n-1; i++) {
    vector<int> a0(26,0), a1(26,0);
    string s0 = s.substr(0, i);
    string s1 = s.substr(i, n-i);
    for(int j=0; j<i; j++){
	    a0[(int)(s0[j]-'a')] = 1;
    }
    for(int j=0; j<n-i; j++){
	    a1[(int)(s1[j]-'a')] = 1;
    }
    
    int reg=0;
    for(int k=0; k<26; k++){
	    if(a0[k]*a1[k]==1) reg++;
    }
    max_reg = max(max_reg, reg);
  }
  
  cout << max_reg << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;
 
#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
 
 
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  string str;cin >> str;
  str+='T';
  vector<ll>s;
  ll x,y ; cin >> x >> y;
 
  vector<ll> xx, yy;
 
  ll co=0;
  rep(i,str.size()){
    if(str[i]!='T')co++;
    else {s.pb(co); co=0;}
  }
  rep(i,s.size()){
    if(i%2==0) xx.pb(s[i]);
    else yy.pb(s[i]);
  }

  x -= xx[0];
  xx.erase(xx.begin()+0);
  xx.pb(abs(x)); yy.pb(abs(y));
  
  sort(rall(xx));
  sort(rall(yy));
 
  ll ans = 0;
  rep(i,xx.size()){
    if(ans >= 0) ans -= xx[i];
    else ans+=xx[i];
  }
  if(ans !=0) {cout << "No" << endl; return 0;}
  
  rep(i,yy.size()){
    if(ans >=0) ans -= yy[i];
    else ans +=yy[i];
  }
 
  if(ans!=0){cout << "No" << endl; return 0;}
  cout << "Yes" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint p(N);
    rep(i, N) cin >> p[i];
    ll ans = 0;
    int i = 0;
    while(1) {
        if (i >= N) break;
        if (i + 1 < N && p[i] == i + 1 && p[i + 1] == i + 1 + 1) {
            ans++;
            i += 2;
        }
        else if (p[i] == i + 1) {
            ans++;
            i += 1;
        }
        else {
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = sorted(list(map(int, input().split())))

def gcd(x, y):
    if x <= y:
        x, y = y, x
    if y == 1:
        return 1
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

l = []
r = []

for i in range(n):
    if i == 0:
        l.append(a[i])
        r.append(a[n-i-1])
    else:
        l.append(gcd(l[i-1], a[i]))
        r.append(gcd(r[i-1], a[n-i-1]))
r = sorted(r)

m = []
for i in range(n):
    if i == 0:
        m.append(r[1])
    elif i == n-1:
        m.append(l[-2])
    else:
        m.append(gcd(l[i-1], r[i+1]))

print(max(m))

Measured memory_bytes: 14488
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    if(op.contains("+")){
      System.out.println(a + b);
    }else{
      System.out.println(a - b);
    }
  }
}

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

struct Vertex{
	int key;
	int parent;
	int left;
	int right;
};

vector<Vertex> V;
int root=-1;

void Preorder(int r){
	cout <<" "<< V[r].key;
	if(V[r].left!=-1) Preorder(V[r].left);
	if(V[r].right!=-1) Preorder(V[r].right);
	return;
}

void Inorder(int r){
	if(V[r].left!=-1) Inorder(V[r].left);
	cout <<" "<< V[r].key;
	if(V[r].right!=-1) Inorder(V[r].right);
	return;
}

void Postorder(int r){
	if(V[r].left!=-1) Postorder(V[r].left);
	if(V[r].right!=-1) Postorder(V[r].right);
	cout <<" "<< V[r].key;
	return;
}

void insert(int k){
	Vertex z;
	z.key=k;
	z.left=-1;
	z.right=-1;
	
	int y=-1;
	int x=root;
	while(x!=-1){
		y=x;
		if (z.key<V[x].key){
			x=V[x].left;
		}else{
			x=V[x].right;
		}
	}
	z.parent=y;
	V.push_back(z);
	
	if(y==-1){
		root = 0;
	}else if(z.key < V[y].key){
		V[y].left=V.size()-1;
	}else{
		V[y].right=V.size()-1;
	}
}

void printVertex(int i){
	cout << V[i].key <<" " <<V[i].parent <<" " << V[i].left << " " << V[i].right <<endl;
}

void print(){
	Inorder(root);
	cout <<endl;
	Preorder(root);
	cout <<endl;
}

int main(){
	int n,k;
	string s;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> s;
		if(s=="insert"){
			cin >> k;
			insert(k);
		}else{
			print();
		}
	}
	/*
	for(int i=0;i<n;i++){
		printVertex(i);
		cout <<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 10236
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

const int N = 100010;
int bit[N];
void add(int k, int x){
  k++;
  while (k < N){
    bit[k] += x;
    k += k & -k;
  }
}
int sum(int k){
  int s = 0;
  while (k){
    s += bit[k];
    k -= k & -k;
  }
  return s;
}

int n, m;
vector<tuple<int, int, int>> v;

int main(){
  cin >> n >> m;
  rep(i, n){
    int l, r;
    cin >> l >> r, r++;
    v.emplace_back(r - l, l, r);
  }
  sort(all(v));
  int p = 0;
  rep(i, 1, m + 1){
    while (p < n){
      int w, l, r;
      tie(w, l, r) = v[p];
      if (i <= w) break;
      add(l, 1);
      add(r, -1);
      p++;
    }
    int s = n - p;
    rep(j, 0, m + 1, i) s += sum(j + 1);
    cout << s << endl;
  }
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
long long int n,m,i,j,k,l,arr[300009]={},brr[300009]={},t;
int main()
{
    scanf("%lld",&n);
    k=0;
    for(i=0;i<n;i++){
        scanf("%lld",&arr[i]);
     if(arr[i]%2==0 && (arr[i]%3!=0 && arr[i]%5!=0))
            k=1;
    }

    if(k==0)
        printf("APPROVED\n");
    else
        printf("DENIED\n");
    }


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


using namespace std;

using ll = long long;


int main(void) {
    ll N;
    cin >> N;
    vector<ll> players(N);
    for (ll i = 0; i < N; i++) {
        cin >> players[i];
    }
    sort(players.rbegin(), players.rend());

    priority_queue<ll> comfort;
    comfort.push(players[0]);

    ll ans = 0;
    for (auto it = players.begin() + 1; it != players.end(); ++it) {
        ll c = comfort.top();
        comfort.pop();

        ans += c;

        for (ll i = 0; i < 2; i++) {
            comfort.push(*it);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6908
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(i => Number(i))
    var B = lines[2].split(" ").map(i => Number(i))
    var C = lines[3].split(" ").map(i => Number(i))

    A.sort((a, b) => a - b); // console.log(A)
    B.sort((a, b) => a - b); // console.log(B)
    C.sort((a, b) => a - b); // console.log(C)


    var ans = 0;

    for (var b = 0; b < N; b++) {
        var x = binary_search_A(B[b], A, -1, N) + 1;
        var y = N - binary_search_C(B[b], C, -1, N);

        // console.log(x, y)
        ans += x * y;
    }
    console.log(ans)
});

function binary_search_A(target, array, l, r) {
    var center = Math.floor((l + r) / 2);
    while (l + 1 < r) {
        if (array[center] < target) { l = center; center = Math.floor((l + r) / 2); }
        else { r = center; center = Math.floor((l + r) / 2); }
    }
    return (center);
}

function binary_search_C(target, array, l, r) {
    var center = Math.ceil((l + r) / 2);
    while (l + 1 < r) {
        if (array[center] <= target) { l = center; center = Math.ceil((l + r) / 2); }
        else { r = center; center = Math.ceil((l + r) / 2); }
    }
    return (center);
}


Measured memory_bytes: 56040
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#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 INF 99999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

typedef pair<Weight, int> Result;
map<pair<int,int>,Result>M;
Result visit(int p, int v, const Graph &g) {
  auto it=M.find({p,v});
  if(it!=M.end())return it->second;
  Result r(0, v);
  FOR(e, g[v]) if (e->dst != p) {
    Result t = visit(v, e->dst, g);
    t.first += e->weight;
    if (r.first < t.first) r = t;
  }
  return M[{p,v}]=r;
}
Weight diameter(const Graph &g, int s) {
  //Result r = visit(-1, 0, g);
  Result t = visit(-1, s, g);
  return t.first; // (r.second, t.second) is farthest pair
}

int main(){
	int i,V,E,s,t,e,r=0;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		Graph g(V);
		Graph x(V);
		for(;E;E--)scanf("%d%d",&s,&t),g[s-1].push_back(Edge(s-1,t-1,1)),x[t-1].push_back(Edge(t-1,s-1,1));
		for(int i=0;i<V;i++)if(x[i].empty())r=max(r,diameter(g,i));
		printf("%d\n",r);
	//}
}


Measured memory_bytes: 26752
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    
    int res = 0 ;
    
    int lenge = min(k , a);
    a-=lenge;
    k-=lenge;
    
    res+=lenge;
    
    
    lenge = min(k , b);
    b-=lenge;
    k-=lenge;
    
    lenge = min(k , c);
    res-=lenge;
    cout<<res<<endl;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100000],y[100000],z[100000];
signed main() {
	int a;
	cin>>a;
	cout<<a*a*a<<endl;
}


Measured memory_bytes: 256
def main():
  from collections import deque
  s=deque(input())
  q=int(input())
  count=0
  for _ in [0]*q:
    a=list(input().split())
    if len(a)==1:
      count+=1
    else:
      if count%2==0:
        if a[1]=='1':
           s.appendleft(a[2])
        else:
          s.append(a[2])
      else:
        if a[1]=='1':
          s.append(a[2])
        else:
          l=(a[2],s)
          s.appendleft(a[2])
  if count%2==1:
    s=list(s)[::-1]
  print(''.join(s))
if __name__=='__main__':
  main()


Measured memory_bytes: 10072
#include <iostream>
using namespace std;
int main(){
    int a,b,c,mem;
    cin >> a >> b >> c;
    if(a>b){
        mem = a;
        a = b;
        b = mem;
    }
    if(b>c){
        mem = b;
        b = c;
        c = mem;
    }
    if(a>b){
        mem = a;
        a = b;
        b = mem;
    }
    cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3096
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
	
		int[] data =new int[10];
		
		BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
		
		for(int i =0;i<10;i++){
			String str= buf.readLine();
			data[i]=Integer.parseInt(str);
		}
		
		for(int i=0;i<data.length-1;i++){
			int min=i;
			for(int j=i+1;j<data.length;j++){
				if(data[min]>data[j]){
					min=j;
				}
			}
			if(min != i){
					int tmp=data[min];
					data[min]=data[i];
					data[i]=tmp;
			}
		}
		
		System.out.println(data[9]);
		System.out.println(data[8]);
		System.out.println(data[7]);
	}
}

Measured memory_bytes: 16864
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r = sc.nextInt();
    
    int ans;
    
    if(n>=10){
      ans = r;
    }else{
      ans = r + (100 * (10-n));
    }

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35700