akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
X = LIST()
Y = []

for i, x in enumerate(X):
	Y.append([i, x])
Y.sort(key = lambda x: x[1])
#print(Y)
M1 = Y[N//2][1]
M2 = Y[N//2-1][1]
#print(M1, M2)
for i in range(N):
	if i >= N//2:
		Y[i][1] = M2
	else:
		Y[i][1] = M1
#print(Y)
Y.sort(key = lambda x: x[0])
#print(Y)
print(*[x[1] for x in Y], sep="\n")




Measured memory_bytes: 45192
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	char ti[10000];
	int ho[10000];
	while(1){
		int n,win[10000]={},lose[100000]={},blow[100000]={};
	
		cin >> n;
		if(n == 0) break;
		for(int i=0;i < n;i++){
			cin >> ti[i];
			for(int j=0;j<n-1;j++){
				cin >> ho[j];
				if(ho[j] == 0) win[i]+=1;
				if(ho[j] == 1) lose[i]+=1;
			}
		}for(int i=0;i<n;i++){
			for(int j=0;j+1<n;j++){
				if(win[j] < win[j+1] || (win[j]==win[j+1] && lose[j] > lose[j+1]) ){
					swap(lose[j],lose[j+1]);	
					swap(win[j],win[j+1]);	
					swap(ti[j],ti[j+1]);
				}
			}
		}for(int i=0;i<n;i++){
		 cout << ti[i] << endl;	
		}
	}
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll ans = 1;
  ll check = 1;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  if(A.at(0) == 0){
    cout << 0 << endl;
    return 0;
  }
  bool tf = true;
  rep(i,N){
    check = ans;
    if(1000000000000000000 / A.at(i) >= ans && tf){
      ans *= A.at(i); 
    }
    else{
      tf = false;
    }
  }
  if(tf){
    cout << ans << endl;
    return 0;
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 4056
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001



int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> rc(n), gc(n), bc(n), red(n), green(n), blue(n);
  int r = 0, g = 0, b = 0;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == 'R') { r++; rc[i]++;}
    else if (s[i] == 'G') { g++; gc[i]++;}
    else { b++; bc[i]++;}
    red[i] = r; green[i] = g; blue[i] = b;
  }
  //cout << "set" << endl;
  ll ret = 0;

  for (int a = 0; a < n-2; a++) { //red
    if (!rc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //green
      if (!gc[b]) continue;
      int adds = blue[b+1];
      if((b+b-a < n) && (bc[b+b-a])) adds--;
      ret += adds;
    }
  }

  for (int a = 0; a < n-2; a++) { //red
    if (!rc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //blue
      if (!bc[b]) continue;
      int adds = green[b+1];
      if((b+b-a < n) && (gc[b+b-a])) adds--;
      ret += adds;
    }
  }

  for (int a = 0; a < n-2; a++) { //blue
    if (!bc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //red
      if (!rc[b]) continue;
      int adds = green[b+1];
      if((b+b-a < n) && (gc[b+b-a])) adds--;
      ret += adds;
    }
  }

  for (int a = 0; a < n-2; a++) { //blue
    if (!bc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //green
      if (!gc[b]) continue;
      int adds = red[b+1];
      if((b+b-a < n) && (rc[b+b-a])) adds--;
      ret += adds;
    }
  }

  for (int a = 0; a < n-2; a++) { //green
    if (!gc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //red
      if (!rc[b]) continue;
      int adds = blue[b+1];
      if((b+b-a < n) && (bc[b+b-a])) adds--;
      ret += adds;
    }
  }

  for (int a = 0; a < n-2; a++) { //green
    if (!gc[a]) continue;
    for (int b = a+1; b < n-1; b++) { //blue
      if (!bc[b]) continue;
      int adds = red[b+1];
      if((b+b-a < n) && (rc[b+b-a])) adds--;
      ret += adds;
    }
  }

  cout << ret << endl;
  
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

LL dp[4096][4096];
string s;
vector<int> sum;
LL mod = 998244353ll;

LL solve(int turn, int b) {
  if (turn == (int)s.size() * 2) {
    if(b == sum[(int)s.size() - 1]) return 1;
    else return 0;
  }
  int index = min(turn, (int)s.size() - 1);
  if(b > sum[index]) return 0;
  if(b < sum[index] - ((int)s.size() * 2 - turn)) return 0;
  if(dp[turn][b] != -1) return dp[turn][b];
  LL answer = 0ll;
  if((index + 1) * 2 - sum[index] > turn - b) answer += solve(turn + 1, b);
  if(sum[index] > b) answer += solve(turn + 1, b + 1);
  answer %= mod;
  dp[turn][b] = answer;
  return dp[turn][b];
}

int main(void)
{
  cin >> s;
  sum.resize(s.size());
  REP(i,s.size()) sum[i] = s[i] - '0';
  REP(i,s.size() - 1) sum[i+1] += sum[i];
  REP(i, 4096) REP(j, 4096) dp[i][j] = -1;
  cout << solve(0,0) << endl;

  return 0;
}


Measured memory_bytes: 131584
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int k,x;
  cin >> k >> x;
  if(k*500>=x)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll n;
  	ci(n);
  ll ans=0;
  FOR(i,0,n){
    ll b;
		ci(b)
  ans+=(b-1);
  }
  co(ans)
}

Measured memory_bytes: 256
# 各桁の総和を求める関数
def calcDigitSum(n):
    digitSum = 0
    digitSum += n % 10
    wari = n // 10

    while wari > 0:
        digitSum += wari % 10
        wari = wari // 10
    
    return digitSum

n = int(input())

a = 1
b = 0
ad = 0
bd = 0

if n % 10 != 0:

    while ad <= 0 or bd <= 0:
        ad = calcDigitSum(a)

        bd = calcDigitSum(n - a)

        a += 1
        b = n - a

    print(ad + bd)

else:
    print(10)

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

using namespace std;

int main() {
    
    //forItachi
	vector<int> vect{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int i;
	cin>>i;
	cout<<vect[i-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,x,y,r;
cin>>a>>b>>x>>y>>r;
if(x-r<0||x+r>a){
cout<<"No"<<endl;
}
else if(y-r<0||y+r>b){
cout<<"No"<<endl;
}
else if(x-r>=0&&x+r<=a){
cout<<"Yes"<<endl;
}
     return 0;
}

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

#define INF 1000000000000000000

int R, C;
int N;

typedef pair<int, int> P;
vector<P> edges[200010];
bool vis[200010];
long long A[200010];

long long m1, m2;
void dfs(int x, long long v) {
  if (vis[x]) return;
  vis[x] = true;

  A[x] = v;
  if (x < R) m1 = min(m1, A[x]);
  else       m2 = min(m2, A[x]);

  for (P p : edges[x]) {
    dfs(p.first, (long long)p.second - A[x]);
  }
}

int main() {
  cin >> R >> C;
  cin >> N;

  for (int i=0; i<N; i++) {
    int r, c, a;
    cin >> r >> c >> a;
    edges[r-1  ].push_back(P(c-1+R, a));
    edges[c-1+R].push_back(P(r-1,   a));
  }

  for (int i=0; i<R+C; i++) {
    m1 = INF, m2 = INF;
    dfs(i, 0);
    if (m1 + m2 < 0) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i=0; i<R; i++) {
    for (auto p : edges[i]) {
      int j = p.first;
      if (A[i] + A[j] != p.second) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}



Measured memory_bytes: 12928
from sys import stdin
import math
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
if a*a*b/2 > x:
    theta = (2*x)/(a*b*b)
    ans =  90 - math.degrees(math.atan(theta))
    print(ans)
else:
    theta = (2*b-2*x/(a*a))/a
    ans = math.degrees(math.atan(theta))
    print(ans)

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	int n;
	cin >> n;
	int g[n];
	for(int i = 0; i < n; i++){
		cin >> g[i];
	}
	int ans = 99999;
	for(int i = 0; i < n; i++){
		int left = 0;
		int right = 0;
		for(int j = 0; j < n; j++){
			if(j >= i)left += g[j];
			else right += g[j];
		}
		ans = min(ans,abs(right-left));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
    int n = 0;

    // input
    std::cin >> n;

    if (n < 0 || n > 52)
    {
        std::cout << "Error : out of range!" << std::endl;
        return -1;
    }

    bool cards[4][13];

    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 13; ++j)
        {
            cards[i][j] = false;
        }
    }

    std::string key_1;
    int key_2 = 0;

    for (int i = 0; i < n; ++i)
    {
        // input
        std::cin >> key_1;
        std::cin >> key_2;

        if ("S" == key_1)
        {
            cards[0][key_2 - 1] = true;
        }
        else if ("H" == key_1)
        {
            cards[1][key_2 - 1] = true;

        }
        else if ("C" == key_1)
        {
            cards[2][key_2 - 1] = true;

        }
        else if ("D" == key_1)
        {
            cards[3][key_2 - 1] = true;
        }
        else
        {
            std::cout << "Error : invalid key!" << std::endl;
            return -2;
        }
    }

    // output
    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 13; ++j)
        {
            if ((true != cards[i][j]) && 0 == i)
            {
                std::cout << "S" << " " << j + 1 << std::endl;
            }
            else if ((true != cards[i][j]) && 1 == i)
            {
                std::cout << "H" << " " << j + 1 << std::endl;
            }
            else if ((true != cards[i][j]) && 2 == i)
            {
                std::cout << "C" << " " << j + 1 << std::endl;
            }
            else if ((true != cards[i][j]) && 3 == i)
            {
                std::cout << "D" << " " << j + 1 << std::endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3148
n=int(input())
scr=[int(input()) for i in range(n)]
s=sum(scr)
if s%10!=0:
  print(s)
  exit()
scr.sort()
for i in range(n):
  if scr[i]%10!=0:
    print(s-scr[i])
    exit()
print(0)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-


def main():
    from itertools import accumulate

    n = int(input())
    a = list(accumulate([0] + list(map(int, input().split()))))
    ans = float('inf')

    for i in range(1, n + 1):
        ans = min(ans, abs((a[n] - a[i]) - a[i]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25772
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int s, w;
    
    cin >> s >> w;
    
    if(s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n, m;
int c[120000];
vector<int> c0[120000];
vector<int> c1[120000];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		int y = x % m;
		if (y > m - y)
			c1[m - y].push_back(x);
		else
			c0[y].push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		if ((i + i) % m == 0) {
			ans += (c0[i].size() + c1[i].size()) / 2;
			continue;
		}
		sort(c0[i].begin(), c0[i].end());
		sort(c1[i].begin(), c1[i].end());
		int cc = 0;
		if (c0[i].size() > c1[i].size()) {
			for (int j = 0; j < (int)c0[i].size(); ++j) {
				if (j != (int)c0[i].size() && c0[i][j] == c0[i][j + 1])
					++cc, ++j;
			}
		}
		else {
			for (int j = 0; j < (int)c1[i].size(); ++j) {
				if (j != (int)c1[i].size() && c1[i][j] == c1[i][j + 1])
					++cc, ++j;
			}
		}
		int mx = max(c0[i].size(), c1[i].size());
		int mn = min(c0[i].size(), c1[i].size());
		cc = min(cc, (mx - mn) / 2);
		ans += cc + mn;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll dp[n+100][n+100];
    srep(i,1,n+1){
        rep(j,n+1-i){
            if(n<=j+i-1){
                dp[i][j] = -10000000070000;
                continue;
            }
            if(i==1){
                dp[i][j] = a[j];
            }else{
                ll left = a[j] - dp[i-1][j+1];
                ll right = a[j+i-1] - dp[i-1][j];
                dp[i][j] = max(left,right);
            }
        }
    }
    
    cout << dp[n][0] << endl;

    return 0;
}
 
 


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

const int n = 1000 * 1000;
int spf[n]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<n; i++) 
        spf[i] = i; 
  
    for (int i=4; i<n; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<n; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<n; j+=i) 
  
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

long long count_divisors(int x){
    long long ret = 1l;
    map<int, long long> f;

    while (x != 1) { 
        f[spf[x]]++;
        x = x / spf[x]; 
    } 

    for(auto i : f)
        ret *= (i.second + 1l);

    return ret;
}
  

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    sieve();

    int N;
    cin >> N;
    long long res = 0l;

    for(int c = 1; c < N; c++){
        long long rhs = N - c;
        res += count_divisors(rhs);
    }         

    cout << res << '\n';

    cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
    return 0;
}

Measured memory_bytes: 7748
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;
vector<int> zAlgorithm(string t) {
  vector<int> A(t.size(), 0);
  A[0] = t.size();
  int i = 1, j = 0;
  while (i < t.size()) {
    while (i + j < t.size() && t[j] == t[i + j]) ++j;
    A[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i + k < t.size() && k + A[k] < j) A[i + k] = A[k], ++k;
    i += k;
    j -= k;
  }

  return A;
}

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

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    string t = s.substr(i, s.size() - i);

    vector<int> z = zAlgorithm(t);
    for (int j = 0; j < t.size(); j++) {
      int tmp = min(j, z[j]);
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define PI 3.14159265358979323846264338327950288
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //



int main(void) {

	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double C = abs((H * 30 + M / 2) - (6 * M));
	C = min(C, 360 - C);

	C = C / 180 * PI;
	double ans2 = (A * A) + (B * B) - (2 * A * B * cos(C));
	ans2 = (double)sqrt(ans2);

	cout << setprecision(20) << ans2 << endl;

	return 0;
}



Measured memory_bytes: 4240
N = int(input())
a_list = list(map(int, input().split()))

count = 0
c_list = []
increment = False
decrement = False

for i, a in enumerate(a_list):
    if i == 0:
        c_list.append(a)

    elif not increment and not decrement:
        if a > c_list[0]:
            c_list.append(a)
            increment = True
        elif a < c_list[0]:
            c_list.append(a)
            decrement = True
        else:
            continue
    else:
        if increment:
            if a >= c_list[-1]:
                c_list.append(a)
            else:
                c_list = [a]
                increment = False
                decrement = False
                count += 1
        else:
            if a <= c_list[-1]:
                c_list.append(a)
            else:
                c_list = [a]
                increment = False
                decrement = False
                count += 1

print(count+1)

Measured memory_bytes: 14436
N = int(input())
abc = [list(map(int,input().split())) for c in range(N)]
dp = [[0,0,0] for c in range(N)]
dp[0] = [abc[0][0],abc[0][1],abc[0][2]]
for i in range(1,N):
    for j in range(3):
        # print([dp[i-1][c] + abc[i][j] for c in range(3) if c != j])
        dp[i][j] = max([dp[i-1][c] + abc[i][j] for c in range(3) if c != j])
        # print(dp[i][j])

print(max([dp[N-1][i] for i in range(3)]))


Measured memory_bytes: 50076
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n,p;
	int check;

	int i1,i2;

	while(1){
		cin >> n >> p;
		if(n==-1 && p==-1) break;

		vector<int> sosu;

		i1=n+1;
		if(i1==1 || i1==2) {
			sosu.push_back(2);
			i1=3;
		}

		while(sosu.size()<=p){
			
			check=0;

			
			for(i2=2;i2*i2<=i1;i2++){
				if(i1%i2==0){
					check=1;
					break;
				}
			}

			if(check==0) sosu.push_back(i1);
			i1++;

		}

		vector<int> matsuzaki;

		for(i1=0;i1<sosu.size();i1++){
			for(i2=i1;i2<sosu.size();i2++){
				matsuzaki.push_back(sosu[i1]+sosu[i2]);
			}
		}

		sort(matsuzaki.begin(), matsuzaki.end());

		cout << matsuzaki[p-1] << endl;

	}
	return 0;


}

Measured memory_bytes: 1276
import heapq
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N-1)]
Q,K = map(int,input().split())
K -= 1
qs = [tuple(map(int,input().split())) for i in range(Q)]

es = [[] for i in range(N)]
for a,b,c in src:
    a,b = a-1,b-1
    es[a].append((c,b))
    es[b].append((c,a))

INF = float('inf')
dists = [INF] * N
dists[K] = 0
hq = [(0,K)]
heapq.heapify(hq)

while hq:
    dist,v = heapq.heappop(hq)
    dists[v] = dist
    for dd,to in es[v]:
        if dists[to] != INF: continue
        heapq.heappush(hq, (dist+dd, to))

for a,b in qs:
    a,b = a-1,b-1
    print(dists[a] + dists[b])

Measured memory_bytes: 71188
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  string s;
  cin >> s;
  deque<char> que;
  for (auto c : s)
    que.push_back(c);
  int q;
  cin >> q;
  bool rev = false;
  rep(qi, q)
  {
    int t;
    cin >> t;
    if (t == 1)
    {
      rev ^= 1;
    }
    else
    {
      int f;
      char c;
      cin >> f >> c;
      if (rev)
      {
        if (f == 2)
          que.push_front(c);
        else
          que.push_back(c);
      }
      else
      {
        if (f == 1)
          que.push_front(c);
        else
          que.push_back(c);
      }
    }
  }
  if (rev)
  {
    for (auto itr = que.rbegin(); itr != que.rend(); itr++)
      cout << *itr;
    cout << endl;
  }
  else
  {
    for (auto itr = que.begin(); itr != que.end(); itr++)
      cout << *itr;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

bool isPrime(int x) {
    bool ret = true;
    for(int i = 2; i * i <= x; ++i) {
        if(x % i == 0) {
            ret = false;
            break;
        }
    }
    return ret;
}

int main() {
    int N; cin >> N;
    vector<int> ans;
    int pos = 11;
    while(ans.size() < N) {
        for(int i = pos; i <= 55555; ++i) {
            if(i % 5 == 1){
                if(isPrime(i)){
                    ans.pb(i);
                    pos = i + 1;
                    break;
                }
            }
        }
    }
    for(int i : ans) {
        cout << i << ' ';
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
# 整数の入力
n = int(input())
numlist = np.array(input().split()).astype(int)
s1 = 0 
sums = numlist.sum()
s2 = sums
diffs = abs(sums-numlist[0])
for i in numlist:
    s1 += i
    s2 -= i
    newdiffs = abs(s2-s1)
    if newdiffs > diffs:
        pass
    else:
        diffs = newdiffs
print(diffs)

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

bool prime_or_not(int N)
{
    if (N == 1) return false;
    if (N == 2) return true;
    if (N % 2 == 0) return false;

    int cnt = 2;
    for (int n = 3; n <= pow(N, 0.5); n += 2)
    {
        if (N % n == 0) cnt++;
    }

    if (cnt == 2) return true;
    else return false;
}

int main()
{
    int cnt[100005] = {};
    // cnt[n] = (1からnまでの整数のうち、2017に似た奇数の個数)
    cnt[0] = 0;
    for (int i = 1; i < 100000; i += 2)
    {
        if (prime_or_not(i) && prime_or_not((i + 1) / 2))
        {
            cnt[i] = cnt[i - 1] + 1;
        }
        else cnt[i] = cnt[i - 1];

        cnt[i + 1] = cnt[i];
    }

    int Q; cin >> Q;
    for (int j = 1; j <= Q; j++)
    {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
<?php

while ($line = trim(fgets(STDIN))) {
    $num = explode(" ",$line);
    if ($num[0] == 0 && $num[1] == 0) {
        exit();
    }
    sort($num);
    $line = implode(" ",$num);
    echo $line . PHP_EOL;
}

?>


Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589
 
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max({a*c,a*d,b*c,b*d});
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int maximum(int a,int b,int c){
    if (a >= b && a >= c) return a;
    else if (b >= a && b >= c) return b;
    else return c;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int a,b,c = 0;
    cin  >> a >> b >> c;
    
    int max = maximum(a, b, c);
    
    int result = max * 3 - a - b - c;
    if(result % 2 == 1) result += 3;
    cout << result / 2 << endl;
    
//    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
from math import ceil

def solve():
    N, K = MI()

    NmodK = N % K if N % K != 0 else K
    times = ceil(N / K)
    ans = 0
    for a in range(1, K+1):
        b = K - a if K - a > 0 else K
        c = b
        # print(a, b, c)
        if (b + c) % K == 0:
            cnt_b = (N - b) // K + 1
            # print('bbb', cnt_b)
            if a <= NmodK:
                t = times
            else:
                t = times - 1
            # print(cnt_b ** 2, t)
            ans += cnt_b ** 2 * t
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x, ll mod) { return mod_pow(x, mod - 2, mod); }

ll mod_com(int n, int k, ll mod) {
    if (n < k) return 0;
    if (n - k < k) k = n - k;
    ll x = 1, y = 1;
    for (int i = 0; i < k; i++) x = x * (n - i) % mod;
    for (int i = k; i > 0; i--) y = y * i % mod;
    return x * mod_inv(y, mod) % mod;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = (mod_pow(2, n, MOD) - 1) - mod_com(n, a, MOD) - mod_com(n, b, MOD);
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_A
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


template<typename T>
// return true:素数
bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    return true;
}


int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; ++i)
    {
      cin >> a.at(i);
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i)
    {
      if(isPrime(a.at(i)))
      {
        ++cnt;
      }
    }

    cout << cnt << endl;


    return 0;    
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n, m;
  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i < n; ++i) {
    cin >> blue[i];
  }
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; ++i) {
    cin >> red[i];
  }

  int res = 0;
  auto calc = [&](string s) {
    int buf = 0;
    for (string t: blue) {
      if (t == s) ++buf;
    }
    for (string t: red) {
      if (t == s) --buf;
    }
    return buf;
  };

  for (string t: blue) {
    res = max(res, calc(t));
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    int n, c;
    string s;
    cin >> n >> s;
    int count[n + 1] = {};
    rep(i, n)
    {
        if (s[i] == '.')
            count[0]++;
    }
    rep(i, n)
    {
        if (s[i] == '#')
            count[i + 1] = count[i] + 1;
        else
            count[i + 1] = count[i] - 1;
    }
    int min = INT_MAX;
    rep(i, n + 1)
    {
        if (min > count[i])
            min = count[i];
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll N;
    cin >> N;

    map<ll, ll> mp;
    for (ll i = 0; i < N; i++)
    {
        ll ai;
        cin >> ai;
        mp[ai] += 1;
    }
    
    ll extra = 0;
    for (auto &&e : mp)
    {
        extra += e.second - 1;
    }

    if (extra % 2 == 0) {
        cout << N - extra << endl;
    } else {
        cout << N - extra - 1 << endl;
    }
}

Measured memory_bytes: 6528
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val n = readInt() 
    val a = readListOfInt().sorted()

    var numShouldDelete = 0
    var targetNum = 0
    var numIdx = 0
    for(i in 0 until n) {
        val ca = a[i]
        if(targetNum != ca) {
            numShouldDelete += if(numIdx < targetNum) numIdx else numIdx - targetNum
            targetNum = ca
            numIdx = 0
        }
        numIdx++
    }
    numShouldDelete += if(numIdx < targetNum) numIdx else numIdx - targetNum
    println(numShouldDelete)
     
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


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

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string U;
  rep(i, N){
    U += S[i];
    U += T[i];
  }
  cout << U << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
string a;
int last;
int first;
int main(){
    cin>>a;
    for(last=a.size()-1;a[last]!='F'&&last>=0;last--);
    for(first=0;a[first]!='C'&&first<a.size();first++);
    if(first<last){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007;
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

#define int long long

int f(int a, int b) {
  //D("(a, b) = (" << a << ", " << b << ")");
  if (a == 0 || b == 0) return 0;
  if (a > b) return 2 * (a / b) * b + f(a % b, b);
  else return 2 * a * (b / a) + f(a, b % a);
}

signed main() { 
  int n, x;
  cin >> n >> x;
  int ans = n + f(n - x, x) - __gcd(n, x);
  D(ans);
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        int ans = 1000;
        for (int i = 0; i <= S.length() - 3; i++) {
            int s = Integer.parseInt("" + S.charAt(i) + S.charAt(i+1) + S.charAt(i+2));
            ans = Math.min(ans, Math.abs(753 - s));
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 1000000000
using namespace std;
 
 
int main() {
	int n, m;
	cin >> n >> m;
	string s;
	char map[100][100], serch[100][100];
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			map[i][j] = serch[i][j] = 'w';
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < n; j++) {
			map[i][j] = s[j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> s;
		for (int j = 0; j < m; j++) {
			serch[i][j] = s[j];
		}
	}
	bool ans = false;
	for (int i = 0; i <= n-m; i++) {
		for (int j = 0; j <= n-m; j++) {
			int c = 0;
			for (int h = 0; h < m; h++) {
				for (int w = 0; w < m; w++) {
					if (map[i + h][j + w] == serch[h][w]) {
						c++;
					}
				}
			}
			if (c == m*m) {
				ans = true;
			}
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	int ans = 1e9;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(i == j || j == k || k == i) continue;
				ans = min(ans, abs(a[i] - a[j]) + abs(a[j] - a[k]));
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {
    static long mod = 1000000000+7;
    static int n,a,b,k;
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        int r = sc.nextInt(), g = sc.nextInt(), b = sc.nextInt(), n = sc.nextInt();
        long ans = 0;
        for(int i=0;i<=n/r;i++){
            for(int j=0;j<=n/g;j++){
                if(i*r+j*g>n) break;
                if((n-i*r-j*g)%b==0) ans++;
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 22228
import numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

search = 1

if a.min()>1:
    print(-1)
else:
    for i in range(N):
        if a[i]==search:
            search += 1
        else:
            continue
    else:
        print(N-search+1)

Measured memory_bytes: 34172
main(a,b,c,X,Y,A,f,i,j){for(;scanf("%d%d%d",&a,&b,&c),a;printf("%d %d\n",X,Y))
for(A=99999999,f=i=0;!f;i++)
	for(j=0;j<=i;j++)
		if(a*j+b*(i-j)==c||a*j==b*(i-j)+c||a*j+c==b*(i-j))
			if(f=1,A>a*j+b*(i-j))A=a*j+b*(i-j),X=j,Y=i-j;
exit(0);}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void get_all_primes(int upto_primes, vector<int> &primes) {
    primes.clear();
    vector<bool> mark(upto_primes + 2, true);

    for (int i = 3; i * i <= upto_primes; i += 2) {
        if (mark[i]) {
            for (int j = i * i; j <= upto_primes; j += 2 * i) {
                mark[j] = false;
            }
        }
    }
    primes.push_back(2);
    for (int i = 3; i <= upto_primes; i += 2) {
        if (mark[i]) {
            primes.push_back(i);
        }
    };
}

void solve() {

    vi primes;
    get_all_primes(101 , primes);
    map<int,int> data;
    int n ;
    cin>>n;
    for(int i = 1 ; i<= n ; i++){
        int term = i;
        for(int p = 0 ; primes[p] * primes[p] <= term ; p++){
            int c = 0;
            if(term % primes[p] == 0){
                while(term % primes[p] == 0){
                    c++;
                    term /= primes[p];
                }
                data[primes[p]] += c;
            }
        }
        if(term != 1){
            data[term]++;
        }
    }
    vi a;
    for(auto i : data){
        a.push_back(i.second);
    }
    int s = a.size();
    int c = 0;
    for(auto i : a){
        if(i >= 74)
            c++;
    }
    for(int i = 0 ; i < s - 1 ; i++){
        for(int j = i + 1 ; j < s ; j++){
            if(a[i] >= 2 && a[j] >= 24)
                c++;
            if(a[i] >= 4 && a[j] >= 14)
                c++;
            if(a[i] >= 14 && a[j] >= 4)
                c++;
            if(a[i] >= 24 && a[j] >= 2)
                c++;
        }
    }
    for(int i = 0 ; i < s - 2 ; i++){
        for(int j = i + 1 ; j < s -1 ; j++){
            for(int k = j + 1 ; k < s ; k++){
                if(a[i] >= 2 && a[j] >= 4 && a[k] >= 4)
                    c++;
                if(a[i] >= 4 && a[j] >= 2 && a[k] >= 4)
                    c++;
                if(a[i] >= 4 && a[j] >= 4 && a[k] >= 2)
                    c++;
            }
        }
    }
    cout<<c<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) o++;
	}
      }
    }

    cout << o << endl;

    cin >> n >> x;
  }


  return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	typedef tuple<string,int,int>ti;
	int N;cin>>N;
	vector<ti>vec;
	FOR(i,1,N){
		string s;cin>>s;
		int a;cin>>a;
		vec.pb(ti(s,-a,i));
	}
	sort(all(vec));
	for(auto i:vec)cout<<get<2>(i)<<"\n";
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;

int df(int a, int b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

int dc(int a, int b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}


int p[10], c[10];

int main()
{
    int n, g;
    cin >> n >> g;
    g /= 100;
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    int sol = 1e9;
    for (int i = 0; i < (1 << n); ++i)
    {
        int sum = 0, num = 0;
        vector<pair<int, int>> v;
        for (int j = 0; j < n; ++j)
        {
            if (i & (1 << j))
            {
                sum += (j + 1) * p[j] + c[j];
                num += p[j];
            }
            else
                v.emplace_back(j + 1, p[j]);
        }
        sort(all(v));
        reverse(all(v));
        sum = min(sum, g);
        for (int i = 0; i < v.size(); ++i)
        {
            int val, cnt;
            tie(val, cnt) = v[i];
            int take = dc(g - sum, val);
            take = min(take, cnt);
            sum += take * val;
            sum = min(sum, g);
            num += take;
        }
        if (sum >= g)
            sol = min(sol, num);
    }
    cout << sol;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{string S;
	int K;
	cin >> S >> K;
	fx(S.size()) {
		if (K<=0) {
			break;
		}
		if (x == S.size() - 1) {
			if (S[x] + K > 'z' && K - (26 - (S[x] - 'a')) >= 0) {
				K = K - (26 - (S[x] - 'a'));
				S[x] = 'a';
			}
			K -= K / 26 * 26;
			S[x] += K;
		}
		else {
			if (S[x]=='a') {
				continue;
			}
			if (S[x]+K>'z'&& K - (26 - (S[x] - 'a'))>=0) {
				K = K - (26 - (S[x] - 'a'));
				S[x] = 'a';
			}
		}

		if (S[x]>'z') {
			S[x] = S[x]- 'z' + 'a' - 1;
		}

	}

	ce(S)
    return 0;
}



Measured memory_bytes: 512
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int a[4];
int b[4];

int main(void) {
    while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
        for (int i = 0; i < 4; i++) {
            cin >> b[i];
        }
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) hit++;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (a[i] == b[j]) {
                    blow++;
                }
            }
        }
        blow -= hit;
        cout << hit << " " << blow << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import std.stdio,std.string,std.conv,std.algorithm;
void main(){
	int inte;
	int[] ins;
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	ins ~= to!int(chomp(readln()));
	
	sort!("a > b")(ins);
	writeln( ins[0] );
	writeln( ins[1] );
	writeln( ins[2] );
}

Measured memory_bytes: 1056