akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8
N, K = map(int,input().split())
nums = list(input().split())

for i in range(N):
    if nums[i] == "1":
        index = i

if N == K:
    print("1")
else:
    if index % (K-1) == 0:
        total = index // (K-1)
    else:
        total = index // (K-1) + 1

    after = N - (total * (K-1) + 1)

    if after % (K-1) == 0:
        total += after // (K-1)
    else:
        total += after // (K-1) + 1

    print(total)


Measured memory_bytes: 10612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double N, ans = 1;
    cin >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
        ans *= A[i];
    }
    double tmp = ans, sum = 0.0;
    rep(i, N)
    {
        sum += tmp / A[i];
    }
    printf("%.13lf\n", ans / sum);
    return 0;
}

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

int main() {
  string line;
  cin >> line;
  int count = 1;
  for (int i = 0; i < 4; i++) {                                                            
    if (count >= 3) {
      cout << "Yes" << endl;
      return (0);
    } else if (line[i] == line[i + 1])
      count++;
    else
      count = 1;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  trump := getAllTrump()
  n := nextInt()
  for i := 0; i < n; i++{
      mark := getStdin()
      num := getStdin()
      num_int,_ := strconv.Atoi(num)
      trump[mark][num_int] = num 
  }

  printNonSelectedNumber("S", trump["S"])
  printNonSelectedNumber("H", trump["H"])
  printNonSelectedNumber("C", trump["C"])
  printNonSelectedNumber("D", trump["D"])
}

func printNonSelectedNumber(mark string, trump map[int]string) {
    for j := 1; j < 14; j++ {
        if trump[j] == "" {
          fmt.Println(mark + " " + strconv.Itoa(j))
        }   
    }   
}

func getAllTrump() (map[string]map[int]string) {
    trump := map[string]map[int]string{
        "S":{1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",10:"",11:"",12:"",13:""},
        "H":{1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",10:"",11:"",12:"",13:""},
        "C":{1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",10:"",11:"",12:"",13:""},
        "D":{1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",10:"",11:"",12:"",13:""},
        }
    return trump
}

func getStdin() (string) {
    sc.Scan()
    v := sc.Text()
    return v
}

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

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



Measured memory_bytes: 1120
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n); cin >> as;
    ll sum = 0;
    for(auto& a : as){
        sum ^= a;
    }
    ll ans = 0;
    vector<int> is;
    for(int i = 62; i >= 0; i--){
        if(sum >> i & 1){
            ans |= 1ll << i;
            is.push_back(i);
        }
    }
    for(auto& a : as){
        a &= ~sum;
    }
    priority_queue<ll> pq;
    for(auto& a : as){
        pq.push(a);
    }
    printde(as);
    printde(sum, ans);
    // auto calc = [&](ll num){ 
    //     for(int j = 62; j >= 0; j--){
    //         if(num >> j & 1){
    //             return 1ll << j;
    //         }
    //     }
    //     return 0ll;
    // };
    vector<ll> used;
    for(int i = 62; i >= 0; i--){
        priority_queue<ll> nexts;
        ll maxi = pq.top();
        if((maxi >> i & 1) == 0){ continue; }
        pq.pop();
        while(pq.size()){
            ll num = pq.top(); pq.pop();
            if(num >> i & 1){
                num ^= maxi;
            }
            nexts.push(num);
        }
        for(auto& u : used){
            if(u >> i & 1){
                u ^= maxi;
            }
        }
        used.push_back(maxi);
        nexts.swap(pq);
    }
    printde(used);
    ll partial = 0;
    for(auto& u : used){
        partial ^= u;
    }
    while(pq.size()){
        ll num = pq.top(); pq.pop();
        partial ^= num;
    }
    // for(int i = 62; i >= 0; i--){
    //     priority_queue<ll> nexts;
    //     ll maxi = pq.top(); pq.pop();
    //     used.push_back(maxi);
    //     ll msb = calc(maxi);
    //     partial |= msb;
    //     while(pq.size()){
    //         ll num = pq.top(); pq.pop();
    //         // printde(num);
    //         if(msb == calc(num)){
    //             num ^= maxi;
    //         }
    //         // num &= msb - 1;
    //         nexts.push(num);
    //     }
    //     for(auto& u : used){
    //         if(msb == calc){
    //         }
    //     }
    //     nexts.swap(pq);
    //     printde(i);
    //     printdbe(partial);
    // }
    cout << ans + 2 * partial << '\n';
}


Measured memory_bytes: 4628
n = int(input())
verdict = [input() for i in range(n)]

opt_dict = {"AC" : 0, "WA" : 0, "TLE" : 0, "RE" : 0}

for j in verdict:
    opt_dict[j] = opt_dict[j] + 1

for k, v in opt_dict.items():
    print(f"{k} x {v}")

Measured memory_bytes: 79216
N,M = (int(x) for x in input().split())
abc = [[None] * 3 for _ in range(M)]
check = set()
for x in abc:
    x[0],x[1] = (int(x) for x in input().split())
    x[2] = list(map(int, input().split()))
    check = check | set(x[2])
if len(check) < N:
    print('-1')
else:
    a = [x[0] for x in abc]
    c = [0] * (M+1)
    dp = [[float('inf')] * pow(2,N) for _ in range(M+1)]
    for i in range(1,M+1):
        c[i] = sum(pow(2,y-1) for y in abc[i-1][2])
    for i in range(M+1):
        dp[i][0] = 0
    for i in range(1,M+1):
        for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
    print(dp[M][pow(2,N)-1])

Measured memory_bytes: 187284
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
  auto abc = readln.chomp.split.map!(to!int);
  if (count(abc, 5) == 2 && count(abc, 7) == 1) {
    "YES".writeln;
  } else {
    "NO".writeln;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    if (3200 <= a) {
      System.out.println(s);
    } else {
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21076
import java.text.DecimalFormat;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double output = 0;
		double addition = 0;
		for(int i = 0;i<N;i++) {
			double under = 1/sc.nextDouble();
			addition += under;
		}
		output = 1/addition;
		System.out.println(output);
		
	}

}


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

int main()
{
	int T, D, L;
	while (cin >> T >> D >> L, T | D | L) {
		int last = -D, res = 0;
		for (int i = 0; i < T; i++) {
			int w;
			cin >> w;
			if (w >= L) last = i;
			if (i + 1 < T) res += i < last + D;
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K <= A) cout << K << endl;
    else if(K > A && K <= A+B) cout << A << endl;
    else cout << A - (K - (A + B)) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int m = n % 10;
    if(m==2||m==4||m==5||m==7||m==9){
        cout << "hon" << endl;
    }
    else if(m==3){
        cout << "bon" << endl;
    }
    else cout << "pon" << endl;
}

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

const int32_t MAX_N = 2000;

struct Vertex {
    bool vis;
    std::vector< int32_t > v;
};

int32_t k, cnt;
Vertex g[MAX_N + 5];

void dfs(int32_t v, int32_t dep) {
    if(dep > k / 2) {
        cnt++;
    }
    g[v].vis = true;
    
    for(auto &u : g[v].v) {
        if(!g[u].vis) {
            dfs(u, dep + 1);
        }
    }
}

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

    int32_t n;
    std::cin >> n >> k;

    std::vector< std::pair< int32_t, int32_t > > edges(n - 1);
    for(int32_t i = 0; i < n - 1; i++) {
        int32_t u, v;
        std::cin >> u >> v;

        edges[i] = { u, v };
        g[u].v.push_back(v);
        g[v].v.push_back(u);
    }

    int32_t ans = n;
    if(k % 2 == 0) {
        for(int32_t i = 1; i <= n; i++) {
            for(int32_t j = 1; j <= n; j++) {
                g[j].vis = false;    
            }

            cnt = 0;
            dfs(i, 0);

            ans = std::min(ans, cnt);
        }
    }
    else {
        for(int32_t i = 0; i < n - 1; i++) {
            for(int32_t j = 1; j <= n; j++) {
                g[j].vis = false;    
            }
            cnt = 0;

            g[edges[i].second].vis = true;
            dfs(edges[i].first, 0);

            for(int32_t j = 1; j <= n; j++) {
                g[j].vis = false;    
            }

            g[edges[i].first].vis = true;
            dfs(edges[i].second, 0);

            ans = std::min(ans, cnt);
        }
    }

    std::cout << ans << '\n';
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>

using namespace std;
int main(){
    char hina;
    int i,n;
    int check = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%c",&hina);
      if(hina == 'Y'){
            check = 1;
        }
    }
    if(check == 0){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  for (int i = 0; i < D; i++) cin >> p.at(i) >> c.at(i);
  
  int ans = 1000000;
  for (int tmp = 0; tmp < (1 << D); tmp++){
    bitset<10> bits(tmp);
    int score = 0;
    int count = 0;
    for (int i = 0; i < D; i++){
      if (bits.test(i)) {
        score += (100 * (i + 1) * p.at(i) + c.at(i));
        count += p.at(i);
      }
    }
    int max_not_choiced = 0;
    for (int i = D - 1; i >= 0; i--){
      if (!bits.test(i)){
        max_not_choiced = i;
        break;
      }
    }
    
    if (score >= G){
      ans = min(ans, count);
    }
    else if (G - score < 100 * (max_not_choiced + 1) * p.at(max_not_choiced)){
      int z = 0;
      if ((G - score) % (100 * (max_not_choiced + 1)) != 0) z = 1;
      ans = min(ans, count + (G - score) / (100 * (max_not_choiced + 1)) + z);
    }
    //cout << "bits " << bits << endl;
    //cout << "ans " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

const long long MOD = 1000000007;

void solve(long long N){
    ll power = 1;
    for (ll i = 1; i <= N; i++) {
        power *= i;
        power %= MOD;
    }
    cout << power << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int N;
int a[200000];

int main(){
    cin>>N;

    int k=1;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>a[i];

        if(a[i]==k){
            k++;
        }else{
            ans++;
        }
    }

    if(ans==N){
        cout<<-1<<endl;
        return 0;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
   queue<pair<string,int>> Q;
   int N,q;
   cin >>N >>q;
   for(int i=0;i<N;i++) {
       pair<string,int> a;
        cin >> a.first >> a.second;
        Q.push(a);
   }
   int n=0;
   string name;
   while(! Q.empty()) {
       pair<string,int> b= Q.front();
       Q.pop();
       if (b.second >q){
           b.second -=q;
           pair<string,int> c=make_pair(b.first,b.second);
           Q.push(c);
           n +=q;
       }
       else{
           n +=b.second;
           name =b.first;
           cout << name+" " << n << endl; 
       }
      
   }
  
}


Measured memory_bytes: 6236
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
ans = -2 * sum(a[:n // 2])
if n % 2 == 0:
    ans += 2 * sum(a[n // 2:]) + a[n // 2 - 1] - a[n // 2]
else:
    ans += 2 * sum(a[n // 2 + 1:]) + max(a[n // 2 - 1] - a[n // 2], a[n // 2] - a[n // 2 + 1])
print(ans)

Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    long long n,x;
    cin>>n>>x;
    cout<<(n-gcd(n,x))*3<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

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

Vl ans;

int main() {
    ll n; cin >> n;
    Vl a(n);
    ans.resize(n);
    rep(i, 0, n) cin >> a[i];

    rep(i, 0, n){
        if(i%2 == 0) ans[0] += a[i];
        else ans[0] -= a[i];
    }
    rep(i, 1, n){
        ans[i] = 2*a[i-1] - ans[i-1];
    }
    rep(i, 0, n){
        if(i) cout << " ";
        cout << ans[i];
    }
    coel;

    return 0;
}


Measured memory_bytes: 2944
#include <string>
#include <algorithm>

#include <iostream>
using namespace std;

int main(){
    string s;
    string t;
    cin>>s;
    cin>>t;
    
    for (int i=0; i<s.length(); i++) {
        long int num=s.length()-i-1;
        for (int k=0; k<num; k++) {
            if (s[k]>s[k+1]) {
                char mae=s[k+1];
                char ato=s[k];
                s[k]=mae;
                s[k+1]=ato;
            }
        }
    }
    
    for (int i=0; i<t.length(); i++) {
        long int num=t.length()-i-1;
        for (int k=0; k<num; k++) {
            if (t[k]>t[k+1]) {
                char mae=t[k+1];
                char ato=t[k];
                t[k]=mae;
                t[k+1]=ato;
            }
        }
    }
    
    string t2;
    t2=t;
    
    for (int i=0; i<t.length(); i++) {
        t[i]=t2[t.length()-1-i];
    }
    
    if (s<t) {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int H,W;
vector<vector<int>> A(200, vector<int>(200,INF));
vector<vector<int>> c(10, vector<int>(10,INF));

int main() {
    cin >> H >> W;
    REP(i,10){
        REP(j,10){
            cin >> c[i][j];
        }
    }

    REP(i,H){
        REP(j,W){
            cin >> A[i][j];
        }
    }

    REP(i,10){
        REP(j,10){
            REP(k,10){
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    int ans = 0;

    REP(i,H){
        REP(j,W){
            if (A[i][j] == -1) continue;
            ans += c[A[i][j]][1];
        }
    }

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

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

int main() {
  int N,cnt=1;
  cin >> N;
  vector<int>v(N);
  for (int i=0; i<N; i++) cin >> v.at(i);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int x = v.at(0);
  for (int i=1; i<N; i++){
    if (x > v.at(i)){
      cnt++;
      x = v.at(i);
    }
  }
  cout << cnt << endl;
}


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

L={(i,q):0 for i in range(1,10) for q in range(1,10)}

for i in range(1,n+1):
    if i%10!=0:
        s=str(i)
        a=int(s[0])
        b=int(s[-1])
        L[(a,b)]+=1

ans=0
for i in range(1,9):
    for q in range(i+1,10):
        ans+=2*L[(i,q)]*L[(q,i)]

for i in range(1,10):
    ans+=L[(i,i)]**2

print(ans)

Measured memory_bytes: 3064
def perm(n, k, p):
  ret = 1
  for i in range(n, n-k, -1):
    ret = (ret * i)%p
  return ret

def comb(n, k, p):
  a = perm(n, k, p)
  b = perm(k, k, p)
  return (a*pow(b, p-2, p))%p

S = int(input())

ans = 0
S -= 3
t = 0
while S >= 0:
    ans += comb(S+t,t, 10**9+7)
    S -= 3
    t += 1

print(ans%(10**9+7))

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

int N, Q, K;
int AC[100010];


int main(){

	cin >> N >> K >> Q;

	for(int i = 0; i < Q; i++){
		int person;
		cin >> person;
		AC[person] += 1;
	}

	for(int i = 1; i <= N; i++){
		if(K-Q+AC[i] > 0){
			cout << "Yes" << endl;
		}else
		{
			cout << "No" << endl;
		}	
	}

	return 0;
}

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

typedef long long ll;
const int inf = 1e9;

int n, k, sum;

int main(){
	sum = 0;
	cin>>n>>k;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	sort(vec.begin(), vec.end());
	sum = 0;
	for(int i = 0; i < k; ++i)sum += vec[i];
	cout<<sum<<endl;	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
       cout << "a > b" << endl;
    else if (a == b)
       cout << "a == b" <<endl;
    else
       cout << "a < b" << endl;
     
    return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, int> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL A[100000], B[100000], C[100000];
LL maxL[100000], maxR[100000]; //maxL[i]=[0,i]の最大 maxR[i]=[i,X+Y+Z-1]
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	vector<PLL> v;
	rep(i, X + Y + Z) {
		cin >> A[i] >> B[i] >> C[i];
		v.push_back(MP(A[i] - B[i], i));
	}
	sort(v.begin(), v.end());
	priority_queue<LL, vector<LL>, greater<LL> > Q1;
	LL sumL = 0, addL = 0;
	rep(i, Y) {
		sumL += C[v[i].second];
		addL += B[v[i].second] - C[v[i].second];
		Q1.push(B[v[i].second] - C[v[i].second]);
	}
	maxL[Y - 1] = sumL + addL;
	REP(i, Y, Y + Z) {
		sumL += C[v[i].second];
		addL += B[v[i].second] - C[v[i].second];
		Q1.push(B[v[i].second] - C[v[i].second]);
		addL -= Q1.top();
		Q1.pop();
		maxL[i] = sumL + addL;
	}
	priority_queue<LL, vector<LL>, greater<LL> > Q2;
	LL sumR = 0, addR = 0;
	for (int i = X + Y + Z - 1; i >= Y + Z; i--) {
		sumR += C[v[i].second];
		addR += A[v[i].second] - C[v[i].second];
		Q2.push(A[v[i].second] - C[v[i].second]);
	}
	maxR[Y + Z] = sumR + addR;
	for (int i = Y + Z - 1; i >= Y; i--) {
		sumR += C[v[i].second];
		addR += A[v[i].second] - C[v[i].second];
		Q2.push(A[v[i].second] - C[v[i].second]);
		addR -= Q2.top();
		Q2.pop();
		maxR[i] = sumR + addR;
	}
	LL ans = 0;
	REP(i, Y - 1, Y + Z) {
		ans = max(ans, maxL[i] + maxR[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6128
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll I,O,T,J,L,S,Z;
  cin>>I>>O>>T>>J>>L>>S>>Z;
  ll re=O;
  ll a=0,b=J/2*2+L/2*2+I/2*2;
  if(I&&J&&L){
    a=3+(I-1)/2*2+(J-1)/2*2+(L-1)/2*2;
  }
  cout<<re+max(a,b)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 0x3f3f3f3f
int n;
int a[150];
int sum;
int main()
{
    scanf("%d",&n);
    sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    double average=sum*1.0/n;
    double minn=10000;
    int minx;
    for(int i=0;i<n;i++)
    {
        if(average-a[i]<minn&&a[i]-average<minn)
        {
            minx=i;
            minn=max(average-a[i],a[i]-average);
        }
    }
    cout<<minx<<endl;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
ll h[100000];

void solve()
{
    bool ok = true;
    REPR(i, N-1){
        if(i < N-1){
            if(h[i] > h[i+1]){
                ok = false;
#if 0
                cout << "i=" << i
                     << ", h[i]=" << h[i]
                     << ", h[i+1]=" << h[i+1] <<endl;
#endif
                break;
            }
        }
        if(i > 0){
            if(h[i-1] > h[i]){
                h[i-1]--;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> h[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    
    int a = 0;
    int b = 0;
    int c = 0;
    
    int value = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(b < c){
        if( a < b){
            value = 1;
        }
    }
    
    if(value){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
int main()
{
    int s,m,h,a;
    scanf("%d" ,&a);
    s=a%60;
    a=a/60;
    m=a%60;
    h=a/60;
    printf("%d:%d:%d\n",h,m,s );
    return 0;
}

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

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

    double r;
    cin >> r;
    // printf("%.19f\n", 2*r*M_PI);
    cout << setprecision(12) << 2*r*M_PI << endl;
    return 0;
}

Measured memory_bytes: 3800
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
 
int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > p[5];
int memo[5][5][1111];
 
int solve(int k, int t, int q){
 
  if(k == 4) return abs(p[t][q].F-gx) + abs(p[t][q].S-gy);
  if(memo[k][t][q]) return memo[k][t][q];
 
  int ans = INF, d = (t+1)%5, c;
  for(int i=0;i<p[d].size();i++){
    if(!k) c = abs(sx-p[d][i].F) + abs(sy-p[d][i].S);
    else c = abs(p[t][q].F-p[d][i].F) + abs(p[t][q].S-p[d][i].S);
    ans = min(ans, solve(k+1, d, i) + c);
  }
 
  return memo[k][t][q] = ans;
}
 
int main(){
 
  int w,h;
  char c;
 
  while(scanf("%d %d", &w, &h), w){
 
    for(int i=0;i<5;i++) p[i].clear();
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	scanf(" %c", &c);
	if(c == '.') continue;
	else if(c == 'S') sx = j, sy = i;
	else if(c == 'G') gx = j, gy = i;
	else p[c-'1'].push_back(P(j,i));
      }
    }
     
    P q = P(0,INF);
    for(int i=0;i<5;i++){
      memset(memo, 0, sizeof(memo));
      if(q.S > solve(0,i,0)) q.F = i+1, q.S = solve(0,i,0);
    }
 
    if(q.S == INF) puts("NA");
    else printf("%d %d\n", q.F, q.S);
 
  }
}

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


int main(){
	int k, s, ans = 0;
	cin >> k >> s;
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			if(i+j <= s){
				if(s-(i+j) <= k){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int a,b;

int main()
{
  scanf("%d %d",&a,&b);
  printf("%d\n",(a+b)%24);
  return 0;
}










Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {1, 0, -1,    1, -1, 1, 0, -1};
int main(){
	int M;
	int N;
	int data[102][102];
	char tmp[1000];

	scanf("%d %d", &M, &N);
	for(int i = 1; i <= M; i++){
		data[i][0] = 0;
		data[i][N] = 0;
		scanf("%s", tmp);
		for(int j = 1; j <= N; j++){
			if(tmp[j - 1] == 'o'){
				data[i][j] = 1;
			}else if(tmp[j - 1] == 'x'){
				data[i][j] = 2;
			}else{
				data[i][j] = 0;
			}
		}
	}
	for(int i = 0; i <= N + 1; i++){
		data[0][i] = 0;
		data[M + 1][i] = 0;
	}
	int ans = 0;
	for(int i = 2; i <= M; i++){
		for(int j = 1; j <= N; j++){
			if(data[i][j] != 0) continue;
			int flg = 0;
			for(int k = 0; k < 8; k++){
				if(data[i + dy[k]][j + dx[k]] == 2){
					flg = 1;
					break;
				}
			}
			if(flg) continue;
			if(data[i][j - 1] == 1 || data[i][j + 1] == 1) continue;
			ans++;
		}
	}
	printf("%d\n", ans);
}
	

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

ll n, x, a[105];
int main()
{
   ios_base::sync_with_stdio(false);
   cin >> n >> x;
   for (int i = 1; i <= n; i++)
      cin >> a[i];
   sort(a + 1, a + n + 1);

   ll sum = 0, total = 0;
   for (int i = 1; i <= n; i++)
      if (sum + a[i] <= x)
         sum += a[i], total++;
      else
         break;

   if (sum < x && total == n) // ne-au ramas si am dat la toti; la un copil ii stricam
      total--;
   cout << total;

   return 0;
}


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b)
	{
		cout<<"a < b"<<endl;
	}
    else if (a>b)
    {
		cout<<"a > b"<<endl;
	}
	else {
		cout<<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
long long int A;
long long int B;
long long int K;

int main(void){
  scanf("%lld",&A);
  scanf("%lld",&B);
  scanf("%lld",&K);
  
  if(K<=A){
    printf("%lld",A-K);printf(" ");printf("%lld",B);
  }
  else if(K>A && K<=(A+B)){
    printf("0");printf(" ");printf("%lld",B-K+A);
    }
  else{
     printf("0");printf(" ");printf("0");
    }
}



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

int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    if(a>b) {
        printf ("a > b");
   }
   else if(a<b){
      printf ("a < b");
   }
   else{
       printf("a == b");
   }
    cout << endl;
}



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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)cout<<c<<endl;
  if(b==c)cout<<a<<endl;
  if(c==a)cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    long a[n];
    long min,max,sum;
    for(int i = 0;i < n;i++){
        scanf("%ld",&a[i]);
    }
    sum = a[0];
    max = a[0];
    min = a[0];
    for(int i = 1;i < n;i++){
        sum += a[i];
        if(a[i] > max){
            max = a[i];
            continue;
        }
        if(a[i] < min){
            min = a[i];
        }
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
    }


Measured memory_bytes: 2780
N, K = map(int, input().split())
S = input()
K-= 1
if S[K]=="A":
	print(S[:K] + "a" + S[K+1:])
if S[K]=="B":
	print(S[:K] + "b" + S[K+1:])
if S[K]=="C":
	print(S[:K] + "c" + S[K+1:])

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
  int a,b,c;
  int rect = 0, diam = 0;
  while(scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if (c * c == a * a + b * b)
      rect++;
    else if (a == b)
      diam++;
  }

  cout << rect << endl;
  cout << diam << endl;
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



ll N;

int dfs(string s) {
  if (stoll(s) > N) {
    return 0;
  }

  int ret = 1;
  if (s.find('7') == string::npos) {
    ret = 0;
  }
  if (s.find('5') == string::npos) {
    ret = 0;
  } 
  if (s.find('3') == string::npos) {
    ret = 0;
  }

  ret += dfs(s + '7');
  ret += dfs(s + '5');
  ret += dfs(s + '3');

  return ret;
}

int main () {
  cin >> N;

  cout << dfs("0") << "\n";
}

Measured memory_bytes: 256
program palace
	implicit none
    integer :: N,T,A,i,pt
    integer,allocatable :: H(:)
	real :: temp,dt
    dt=10000.0
	read(*,*) N
    read(*,*) T,A
    allocate(H(N))
    read(*,*) H
    do i=1,N
    	temp=ABS(T-0.006*H(i)-A)
        !write(*,*) temp
        if(temp.lt.dt) then
        	dt=temp
            pt=i
        endif
    end do
    write(*,'(i0)') pt
    deallocate(H)


end program palace

Measured memory_bytes: 768
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, d, a = ns()
    x = []
    for _ in range(n):
        xi, hi = ns()
        x.append([xi, hi])

    x.sort()
    x.append([INF, INF])

    perm = [0 for _ in range(n + 1)]
    idx = [xi for xi, hi in x]

    ans = 0
    cnt = 0
    for i in range(n):
        cnt -= perm[i]

        if x[i][1] - cnt * a > 0:
            tmp = ((x[i][1] - cnt * a) + a - 1) // a
        else:
            continue
        ans += tmp
        cnt += tmp

        if cnt > 0:
            tmp_idx = bisect.bisect_right(idx, x[i][0] + 2 * d)
            perm[tmp_idx] += tmp

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50940
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int, D: "List[int]"):

    D = set([str(c) for c in D])
    for ans in range(N, 10*N):
        if set(str(ans)).isdisjoint(D):
            print(ans)
            return

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    speed;
    int a, b;
    cin >> a >> b;
    int ans = max(max(a + b, a - b), a * b);
    cout << ans;
    ed;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
li=[]
for i in range(n):
    li.append(int(input()))
    
a=[max(li),li.index(max(li))]
li2=li[:]
v=sorted(li2)[-2]
b=[v,li.index(v)]

for i in li:
    if i==a[0]:
        print(b[0])
    else:
        print(a[0])

Measured memory_bytes: 14940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		//int n=scn.nextInt();
	    double d=scn.nextDouble();
	     double  t=scn.nextDouble();
	     double s =scn.nextDouble();
	     if(d/s<=t){
	    	 System.out.println("Yes");
	     }else{
	    	 System.out.println("No");
	     }

	}

}

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

int main()
{
    int N, D;
    cin >> N >> D;

    int x = 2 * D + 1;

    int ans;
    for(int i = 1; i <= 20; i++)
    {
        if(i * x >= N)
        {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int i,j,k,l;

	while(scanf("%d", &n) != EOF){
		int lim = 10;
		int sum = 0;

		if(n<9) lim = n+1;
		for(i=0;i<lim;i++){
			for(j=0;j<lim;j++){
				for(k=0;k<lim;k++){
					for(l=0;l<lim;l++){
						if(i+j+k+l==n){
							sum++;
						}
					}
				}
			}
		}

		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 596
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
using mat = vector<vector<ll>>;
using vec = vector<ll>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

int N;
cin>>N;
int M;
cin>>M;
Graph G(N+1);
rep(i,M){
    int A,B;
    cin>>A>>B;
    G[A].push_back(B);
    G[B].push_back(A);

}
int sign[N+1];
memset(sign,-1,sizeof(sign));


queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    sign[1]=0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (sign[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            sign[nv] = v;
            que.push(nv);
        }
    }
bool judge=true;
rep4(i,2,N)if(sign[i]==-1)judge=false;
if(judge){
    cout<<"Yes"<<endl;
    rep4(i,2,N)cout<<sign[i]<<endl;
}
else cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 10208
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

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

    ll last = s[s.length() - 1] - '0';
    if (last == 3)
        printf("bon");
    else if (last == 2 || last == 4 || last == 5 || last == 7 || last == 9)
        printf("hon");
    else
    {
        printf("pon");
    }
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int n;
  int c=0;
  cin >> n;
  vector <string> s(n);
  for(int i=0;i<n;i++)cin >> s[i];
  sort(ALL(s));
  for(int i=0;i<n-1;i++){
    if(s[i] == s[i+1])c++;
  }
  cout << n-c;
  return 0;
}


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

int main() {
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '+') {
      ans++;
    }
    else ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

fn main() {
    input!{
        N: usize,
        W: usize,
        wv: [(usize, usize); N],
    }
    let mut dp = vec![vec![0; W + 10]; N + 10];
    dp[0][0] = 0;
    for i in 1..(N+1) {
        let (wi, vi) = wv[i - 1];
        for w in 0..(W+1) {
            if w >= wi {
                chmax!(dp[i][w], dp[i-1][w-wi] + vi);
            }
            chmax!(dp[i][w], dp[i-1][w]);
        }
    }
    let mut ans = 0;
    for w in 0..(W+1) {
        chmax!(ans, dp[N][w]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 116988
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
n = [K - Q] * N
for i in range(Q):
    n[A[i]-1] += 1
for i in range(N):
    if n[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 10472
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
using namespace std;

vector<ll> dp(1e5, 1e9L);

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

    int n, W;
    cin >> n >> W;
    vector<ll> weight(n, 0), value(n, 0);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
        sum += value[i];
    }
    ll ans = 0;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(ll j = sum; j >= value[i]; j--){
            dp[j] = min(dp[j], dp[j - value[i]] + weight[i]);
        }
    }
    for(ll i = sum; i >= 0; i--){
        if(dp[i] <= W){
                ans = max(ans, i);
         }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024