akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : AOJ1154_nono.cpp
// Author      : mizo0203
// Version     :
// Copyright   : Your copyright free
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <stdio.h>
#include <algorithm>

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, false);
  array[1] = false;

  for (int i = 2; i < num; i++) {
    if (i % 7 == 1 || i % 7 == 6) {
      array[i] = true;
    }
  }

  for (int i = 2; i < num; i++) {
    if (!array[i])
      continue; //月曜土曜数以外を省く

    //月曜土曜数の倍数を削除していく
    for (int j = i * 2; j < num; j = j + i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[300000];
  int num;

  set_prime_number(prime_number, 300000);
  scanf("%d", &num);
  while (num != 1) {
    printf("%d:", num);
    for (int i = 0; i <= num; i++) {
      if (prime_number[i]) {
        if (num % i == 0) {
          printf(" %d", i);
        }
      }
    }
    printf("\n");
    scanf("%d", &num);
  }

  return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i = 0 ; i < n ;i++){
 cin>>arr[i];
}
sort(arr , arr+n);
for(int i = 0 ; i  < n-1 ; i++){
  if(arr[i] == arr[i+1]){
   cout<<"NO"<<endl;
   return 0;
  }
}
cout<<"YES"<<endl;
return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int max = 0;
		int mai = 0;
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			if (max < a[i]) {
				max = a[i];
				mai = i;
			}
		}
		int k = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < k; i++) {
			max = max * 2;
		}
		sum = max;
		for (int i = 0; i < 3; i++) {
			if (i != mai) {
				sum += a[i];
			}
		}
		System.out.println(sum);
		sc.close();
	}

}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

ll n,a,b,c;

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b >> c;
    ll cnt[3] = {a,b,c};
    vector<string> q(n);
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }
    //last one check
    vector<char> ans(n);
    for (int i = 0; i < n-1; ++i) {
        string& cur = q[i], nxt = q[i+1];
        if (cnt[cur[0] - 'A'] == 0 && cnt[cur[1] - 'A'] == 0) {
            cout << "No\n";
            return 0;
        }
        if (cur == nxt) {
            // no care
            if (cnt[cur[0] - 'A'] > 0) {
                ans[i] = cur[1];
                cnt[cur[0] - 'A'] -= 1, cnt[cur[1] - 'A'] += 1;
            }
            else {
                ans[i] = cur[0];
                cnt[cur[1] - 'A'] -= 1, cnt[cur[0] - 'A'] += 1;
            }
            continue;
        }
        char common,weak;
        if (cur[0] == nxt[0] || cur[0] == nxt[1]) weak = cur[1], common = cur[0];
        else common = cur[1], weak = cur[0];
        if (cnt[weak-'A'] > 0) {
            cnt[weak-'A'] -= 1, cnt[common-'A'] += 1;
            ans[i] = common;
        }
        else {
            cnt[weak-'A'] += 1, cnt[common-'A'] -= 1;
            ans[i] = weak;
        }
    }

    string& lst = q[n-1];
    if (cnt[lst[0]-'A'] == 0 && cnt[lst[1] - 'A'] == 0) {
        cout << "No\n";
        return 0;
    }
    else {
        if (cnt[lst[0]-'A'] > cnt[lst[1]-'A']) ans[n-1] = lst[1];
        else ans[n-1] = lst[0];
    }


    cout << "Yes\n";
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << '\n';
    }
    cout << endl;
    return 0;
}



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int dp[1001][1001];

int main() {
    string t, b;
    cin >> t >> b;
    int n = t.size(), m = b.size();
    dp[0][0] = 1;
    rep(i, n + 1) rep(j, m + 1) {
        if(i < n) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        if(i < n && j < m && t[i] == b[j]) {
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}  

Measured memory_bytes: 7172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    if((a[0]==a[1])&&(a[2]==a[3])&&(a[2]==a[0]))
    {
        cout<<"Yes";
    }
   else if((a[0]==a[1])&&(a[0]==a[2])&&(a[2]!=a[3]))
   {
       cout<<"Yes";
   }
    else if((a[1]==a[2])&&(a[1]==a[3])&&(a[2]!=a[0]))
   {
       cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }



    return 0;

}


Measured memory_bytes: 256
def resolve():
    K = int(input())
    if K%2==0:
        return print(-1)
    
    seven = 7
    for i in range(1, K+10):
        if seven%K==0:
            return print(i)
        seven = (seven*10+7)%K

    print(-1)


if __name__ == "__main__":
    resolve()

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  ll x;
  cin >> x;
  ll ans = x/11*2;
  if(x % 11 != 0) {
    if(x % 11 <= 6) ans++;
    else ans += 2; 
  }
  cout << ans << endl;
}

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

int  main()
{
	int a,b;
	cin >> a >> b;
	int i = max(a,b);
	i *= 10;
	while (i <= 1000)
	{
		if ((int)(i * 8 / 100 == a) && (int)(i * 10 / 100 == b))
		{
			cout << i; return 0;
		}
		i++;
	}
	cout << -1;
	return (0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        System.out.println(solve(s.nextLine()));

    }

    public static int solve(String s) {

        int n = s.length();

        int a = 0;
        int b = 0;
        for (int i = 0; i < n; i += 2) {

            if (s.charAt(i) == '0') {
                a++;
            } else {
                b++;
            }
        }

        for (int i = 1; i < n; i += 2) {

            if (s.charAt(i) == '1') {
                a++;
            } else {
                b++;
            }
        }

        return Math.min(a, b);

    }
}

Measured memory_bytes: 29644
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=105;
int n,m,k,mod;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int Fac[N],Inv[N];
int pw[N][N*N];
void prework(){
	int n=N-1;
	Fac[0]=1;
	For(i,1,n)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	For(i,0,n){
		pw[i][0]=1;
		For(j,1,n*n)
			pw[i][j]=(LL)pw[i][j-1]*i%mod;
	}
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int dp[4][N][N][N];
int f[4][N][N];
int main(){
	n=read(),m=read(),k=read(),mod=read();
	prework();
	if (n<m)
		swap(n,m);
	clr(dp);
	dp[0][1][0][0]=1;
	For(i,1,k){
		For(b,0,m)
			For(j,0,n){
				f[0][b][j]=(LL)Inv[j]*pw[k-i+1][b*j]%mod*pw[i][(m-b)*j]%mod;
				f[2][b][j]=(LL)Inv[j]*pw[k-i][b*j]%mod*pw[i][(m-b)*j]%mod;
			}
		For(a,0,n)
			For(j,0,m){
				f[1][a][j]=(LL)Inv[j]*pw[k-i+1][a*j]%mod*pw[i][(n-a)*j]%mod;
				f[3][a][j]=(LL)Inv[j]*pw[k-i][a*j]%mod*pw[i][(n-a)*j]%mod;
			}
		For(a,0,n)
			For(b,0,m)
				For(t,0,3){
					int v=dp[t][i][a][b];
					if (!v)
						continue;
					int T=(t+1)%4;
					if (t==0){
						For(j,0,n-a)
							Add(dp[T][i][a+j][b],(LL)v*f[0][b][j]%mod);
					}
					else if (t==1){
						For(j,0,m-b)
							Add(dp[T][i][a][b+j],(LL)v*f[1][a][j]%mod);
					}
					else if (t==2){
						For(j,0,n-a){
							int tmp=(LL)v*f[2][b][j]%mod;
							if (j&1)
								Del(dp[T][i][a+j][b],tmp);
							else
								Add(dp[T][i][a+j][b],tmp);
						}
					}
					else if (t==3){
						For(j,0,m-b){
							int tmp=(LL)v*f[3][a][j]%mod;
							if (j&1)
								Del(dp[T][i+1][a][b+j],tmp);
							else
								Add(dp[T][i+1][a][b+j],tmp);
						}
					}
				}
	}
	int ans=(LL)dp[0][k+1][n][m]*Fac[n]%mod*Fac[m]%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23168
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a >= k)cout << k << endl;
  else if(a+b >= k)cout << a << endl;
  else cout << 2 * a - k + b;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
long f(long n){
      return (1 + n) * n / 2;
}
int main()
{
    long n;
    cin >> n;
    
    long ans = 0;
    for(int i = 1;i <= n;i++)
    {
          ans +=  i * f(n / i);
    }
    cout <<  ans << endl;
}

Measured memory_bytes: 3636
N,X=map(int,input().split())
L=list(map(int,input().split()))
count=0
for i in range(N-1):
	if i==0:
		if L[i]>X:
			count+=L[i]-X
			L[i]=X
	if L[i+1]+L[i]>X:
		count+=(L[i+1]-(X-L[i]))
		L[i+1]=X-L[i]
print(count)

Measured memory_bytes: 14060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static int gcd(int x, int y){
		if(y == 0){
			return x;
		}else{
			return gcd(y, x % y);
		}
	}


	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {
			final int p = sc.nextInt();
			final int n = sc.nextInt();
			
			if(p == 0 && n == 0){
				break;
			}
			
			final double ans = Math.sqrt(p);
			double less = Double.MIN_VALUE;
			double more = Double.MAX_VALUE;
			int less_u = 1, less_v = 1, more_x = 1, more_y = 1;
			
			//bottom
			for(int b = 1; b <= n; b++){
				//calc
				final double b_ = b;
				
				double top = ans * b;
				
				int high_a = (int)(Math.ceil(top));
				int low_a  = (int)(top);
				
				//System.out.println(b + " " + high_a + " " + low_a);
				
				if(low_a >= 1 && low_a <= n && less < low_a / b_){
					final int gcd = gcd(low_a, b);
					
					less = low_a / b_;
					less_u = low_a / gcd;
					less_v = b / gcd;
				}
				
				if(high_a >= 1 && high_a <= n && more > high_a / b_){
					final int gcd = gcd(high_a, b);
					
					more = high_a / b_;
					more_x = high_a / gcd;
					more_y = b / gcd;
				}
			}
			
			System.out.println(more_x + "/" + more_y + " " + less_u + "/" + less_v);
			
		}
	}

}

Measured memory_bytes: 21372
if __name__ == '__main__':
    n = int(input())
    a = [int(s) - 1 for s in input().split()]
    b = [int(s) for s in input().split()]
    c = [int(s) for s in input().split()]
    ans = b[a[0]]
    for i, v in enumerate(a[1:]):
        ans += b[v]
        if v - a[i] == 1:
            ans += c[v - 1]
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = int(s.size());
  rep(i, n){
    if(s[i] == 'a') continue;
    int t = s[i] - 'a';
    t = 26 - t;
    if(k >= t){
      s[i] = 'a';
      k -= t;
    }
  }
  k %= 26;

  s[n-1] += k;
  if(s[n-1] > 'z') s[n-1] -= 26;

  cout << s << endl;
}


Measured memory_bytes: 592
N=int(input())

A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]

ans=sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        ans+=C[A[i]-1]
print(ans)




Measured memory_bytes: 38384
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])

const ans = () => {
  const sum = String(n)
    .split('')
    .map(Number)
    .reduce((p, c) => p + c)

  console.log(n % sum === 0 ? 'Yes' : 'No')
}

ans()


Measured memory_bytes: 7500
s = input()
t = input()
ls = len(s)
lt = len(t)

a = []
for i in range(ls-lt+1):

    f=True
    sa = list(s.replace('?', 'a'))
    for j in range(lt):
        sa[i+j] = t[j]
        if s[i+j]!='?' and s[i+j]!=t[j]:
            f=False
            break
    if f:
        a.append(''.join(sa))

if a==[]:
    print('UNRESTORABLE')
else:
    a.sort()
    print(a[0])


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

bool compareFunction (pair<int,int> a, pair<int,int> b) { 
	return (a.first<b.first); 
}

int main(){
	vector< pair<int,int> > data;
	int N, num1, num2;
	long long K;
	cin >> N >> K;
	for (int i =0;i<N;i++){
		cin >> num1 >> num2;
		data.push_back( {num1, num2} );
	}
	sort(data.begin(),data.end(),compareFunction);
	for (int i=0;i<data.size();i++){
		if (K > data[i].second){
			K -= data[i].second;
		}else{
			cout << data[i].first << endl;
			break;
		}
	}
	

}

Measured memory_bytes: 1400
def selectionSort(A):
    counter = 0
    for i, _ in enumerate(A):
        min_j = i
        for j in range(i, len(A)):
            if A[j] < A[min_j]:
                min_j = j
        A[i], A[min_j] = A[min_j], A[i]
        if i != min_j:
            counter += 1
    return A, counter
    
N = int(input())
A = list(map(int, input().split()))

ans = selectionSort(A)
print(' '.join(str(a) for a in ans[0]))
print(ans[1])



Measured memory_bytes: 5604
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b;
string s;
int main()
{
	cin>>a>>b;
	cin>>s;
	if(s[a]=='-')
	{
		s.erase(a,1);
		int k=s.find("-");
		if(k==-1) cout<<"Yes";
		else cout<<"No"; 
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

using std::sort;

static long long
solve(int N, vector<long> &a)
{
  sort(a.begin(), a.end());
  long long ret = 0;
  for (int n = 0; n < N; n++)
  {
    ret += a[N * 3 - n * 2 - 2];
  }
  return ret;
}

int
main()
{
  int N;
  cin >> N;
  vector<long> a(N * 3);
  for (int n = 0; n < N; n++)
  {
    cin >> a[n * 3 + 0] >> a[n * 3 + 1] >> a[n * 3 + 2];
  }
  cout << solve(N, a) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

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

    map<Int, Int> mp;
    Int a;
    for (Int i = 0; i < n; ++i) {
        cin >> a;
        a--;
        mp[a] = i + 1;
    }
    for (Int i = 0; i < n; ++i) {
        cout << mp[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9884
h, w = gets.chomp.split(" ").map(&:to_i)
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
result = []

for i in 0..n-1
	for j in 0..a[i]-1
		result.push(i+1)
	end
end

for i in 0..h-1
	if i % 2 == 0
		print result[i*w..i*w+w-1].join(" ")
	else
		print result[i*w..i*w+w-1].reverse.join(" ")
	end
	puts ""	
end


Measured memory_bytes: 2940
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    x=[]
    y=[]
    x=list(map(int,input().split()))
    y=list(map(int,input().split()))
    ans=0
    ans_list=[]
    for i in range(1,4):
        for x_value,y_value in zip(x,y):
            ans+=abs(x_value-y_value)**i
            ans_list.append(abs(x_value-y_value))
        print("{:.6f}".format(ans**(1/i)))
        ans=0
    print("{:.6f}".format(max(ans_list)))
    
if __name__=="__main__":
    main()


Measured memory_bytes: 5660
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
const lli nax = 1e18;
void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
void solve() {
	lli a;
	long double  b;
	cin >> a >> b;
	cout << (lli) (a * b) << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3756
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



int poi[100005];
int tot;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>poi[i];
	}
	tot+=abs(poi[0]);
	for(int i=1;i<n;i++)
	{
		tot+=abs(poi[i]-poi[i-1]);
	}
	tot+=abs(poi[n-1]);
	for(int i=0;i<n;i++)
	{
		int tmp=tot;
		if(i==0)
		{
			tot-=abs(poi[i]);
			tot-=abs(poi[i+1]-poi[i]);
			tot+=abs(poi[i+1]);
		}
		else if(i==n-1)
		{
			tot-=abs(poi[i-1]-poi[i]);
			tot-=abs(poi[i]);
			tot+=abs(poi[i-1]);
		}
		else
		{
			tot-=abs(poi[i-1]-poi[i]);
			tot-=abs(poi[i+1]-poi[i]);
			tot+=abs(poi[i+1]-poi[i-1]);
		}
		cout<<tot<<endl;
		tot=tmp;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,A,B;
  cin>>N>>A>>B;

  cout<< min(B,A*N)<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#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)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    bool flag = true;
    rep1(i, n) {
        int a; cin >> a;
        if (a%2==0) {
            if (a%3==0 || a%5==0) continue;
            else flag = false;
        }
    }
    (flag) ? puts("APPROVED") : puts("DENIED");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		long a[];
		a = new long[100001];

		int result = 0;
		for (int i = 0; i < n; i++) {
			long x = Long.parseLong(sc.next());

			if (x >= 100001) {
				result++;
			} else {
				if (a[(int) x] == x) {
					result++;
				} else {
					a[(int) x]++;
				}
			}
		}

		for (int i = 1; i <= 100000; i++) {
			if (a[i] != 0 && a[i] != i) {
				result += a[i];
			}
		}

		System.out.println(result);

	}
}


Measured memory_bytes: 59632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll n;
	cin >> n;
	string res = "";
	while(n > 0) {
		n--;
		res += 'a' + n%26;
		n /= 26;
	}
	reverse(all(res));
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, x[N], a[N];
ii b[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",&b[i].st);
		b[i].nd = i;
	}

	sort(b + 1, b + n + 1);

	for(int i = 1; i <= n; i++){
		int yaz = b[i].nd - 1, son = 1;
		while(son <= n*n and yaz){
			if(!a[son]){
				a[son++] = b[i].nd;
				yaz--;
			}
			else
				son++;
		}son--;
		if(son >= b[i].st){
			puts("No");
			return 0;
		}
		a[b[i].st] = b[i].nd;
	}
	for(int i = n; i >= 1; i--){
		int yaz = n - b[i].nd, son = n*n;
		while(son >= 1 and yaz){
			if(!a[son]){
				a[son--] = b[i].nd;
				yaz--;
			}
			else
				son--;
		}son++;
		if(son <= b[i].st){
			puts("No");
			return 0;
		}
		a[b[i].st] = b[i].nd;
	}
	puts("Yes");
	for(int i = 1; i <= n*n; i++)
		printf("%d ", a[i]);
	return 0;
}

Measured memory_bytes: 5248
n = int(input())
data = list(map(int, input().split()))

d = {}

for i in data:
    if d.get(i) is None:
        d[i] = 1
    else:
        d[i] += 1
    if d.get(i+1) is None:
        d[i+1] = 1
    else:
        d[i+1] += 1
    if d.get(i-1) is None:
        d[i-1] = 1
    else:
        d[i-1] += 1

print(max(d.values()))

Measured memory_bytes: 19748
"use strict"

let arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
arg_str = arg_str.split('\n')
const arg_str_0 = arg_str[0].split(' ')
const N = arg_str_0[0]
const K = arg_str_0[1]
const Q = arg_str[1].split(' ')

const a = Q.filter(x=>+x>=+K)

console.log(a.length)

Measured memory_bytes: 27724
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000000; // いくつまで調べるか
bool prime[MAX_N + 1]; // 添字が素数ならtrue、それ以外はfalse
void sieve()
{
  prime[0] = prime[1] = false; // 例外処理
  // 配列prime の初期化
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  // 素数でないものを調べる
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}
int is_prime(int n)
{
  return prime[n];
  }//*/

/*bool is_prime(int n)
{
  if(n == 1)return false;
  for(int i = 2; i < n; ++i)
    if(n % i == 0)return false;
  return true;
  }*/

int main()
{
  sieve();
  int a,d,n;
  for(;;){
    cin >> a >> d >> n;
    if(d==0)return 0;
    int now,count=0;
    int tmp;
    for(int i=a;;i+=d){
      if(is_prime(i))count++;
      if(count==n){printf("%d\n",i);break;}
    }
  }
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
#define MAX 10000000
bool prime[MAX+1]; 
int base[MAX+1];
lli nd[MAX+1];
int findndiv(int n){
    if(n==1) return 1;
    if(prime[n]) return 2;
    int l=base[n],c=0;
    while(!(n%l)) c++,n=n/l;
    return (c+1)*nd[n];
}
int main()
{
  memset(prime, true, sizeof(prime)); 
  rep(i,MAX) base[i]=i;
    for (int p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=MAX; i += p) {
                if(prime[i])
                base[i]=p,prime[i] = false; 
            }
                
        } 
    } 
    //rep(i,20) cout<<
    rep(i,MAX+1) nd[i]=findndiv(i);
    reps(i,2,MAX+1) nd[i]=nd[i-1]+i*1ll*nd[i];
    int n;
    cin>>n;

    cout<<nd[n]<<endl;
}


Measured memory_bytes: 130576
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    multiset<int> used,rem;
    rep(_,1<<n) {
        int s;
        cin >> s;
        rem.insert(s);
    }
    used.insert(*rem.rbegin());
    rem.erase(rem.find(*rem.rbegin()));
    while(rem.size()) {
        vi add;
        for(int i : used) {
            auto it = rem.lower_bound(i);
            if(it == rem.begin()) {
                Yes(0);
                return 0;
            }
            it--;
            add.pb(*it);
            rem.erase(it);
        }
        for(int i : add) used.insert(i);
    }
    Yes(1);
}


Measured memory_bytes: 16240
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
typedef long long ll;

ll countChar(ll lo, ll hi, ll d) {
  auto c = [hi, lo](ll n){return hi / n - lo / n;};
  ll c15 = c(15);
  ll c5 = c(5) - c15;
  ll c3 = c(3) - c15;
  ll cc = (hi - lo) - (c15 + c5 + c3);
  return c15 * 8 + c5 * 4 + c3 * 4 + cc * d;
}

ll f(ll n) {
  ll base = 1;
  ll ret = 0;
  int d = 1;
  for(; base * 10 < n; base *= 10) {
    ret += countChar(base - 1, base * 10 - 1, d);
    d++;
  }
  ret += countChar(base - 1, n, d);
  return ret;
}

string fizzbuzz(ll n) {
  if (n % 15 == 0) return "FizzBuzz";
  if (n % 5 == 0) return "Buzz";
  if (n % 3 == 0) return "Fizz";
  return to_string(n);
}
 
int main() {
  ll N;
  cin >> N;
  ll n = N;
  for(; n < N + 20; n++) {
    ll ok = 0, ng = 1e18;
    while(abs(ok - ng) > 1) {
      ll c = (ok + ng) / 2;
      if (f(c) < n) {
        ok = c;
      } else {
        ng = c;
      }
    }
    string last = fizzbuzz(ok + 1);
    cout << last[n - f(ok) - 1];
  }
  cout << endl;
  return 0;
}


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

public class Main {

	private void compute(){

		Scanner scanner = new Scanner (System.in);
		int n = scanner.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for (int i=0;i<n;i++) {
			list.add(scanner.nextInt());
		}
		Collections.sort(list);
		
		long max = 0;
		for (int r=0;r<2;r++) {
			long buf = 0;
			int bef = -1;
			for (int i=0;i<n;i++) {
				int b;
				if (i == 0) {
					b = list.get(n/2);
				} else if (i % 2 == 0) {
					b = list.get(n-i/2);
				} else {
					b = list.get(i/2);
				}
				if (bef != -1)
					buf += abs(bef - b);
						
				bef = b;
			}
			Collections.reverse(list);
			if (buf > max)
				max = buf;
		}
		System.out.println(max);
	}
	
	int abs(int a) {
		return a > 0 ? a : -a;
	}

	public static void main(String[] args) {
		new Main().compute();
	}

}

Measured memory_bytes: 61524
#include <bits/stdc++.h>
using namespace std;
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int n, K, MOD, f[305][305], C[305][305];
int main()
{
	n = read()+1, K = read(), MOD = read(); for(rint k = 1; k <= K; f[0][k] = 1, k++);
	for(rint i = 0, j; i <= n; i++) for(j = C[i][0] = 1; j <= i; C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD, j++);
	for(rint i = 1, k, j; i <= n; i++) for(f[i][1] = 1, k = 2; k <= K; k++) for(j = 0; j <= i; j++)
		f[i][k] = (f[i][k]+1ll*C[i-1][j-1]*f[j][k-1]%MOD*f[i-j][k])%MOD; printf("%d\n",f[n][K]); return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n, a[101], b, c, d, fix[105], m, i;
int main() {
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        fix[a[i]]++;
    }
    sort(a,a+n);
    d=a[n-1];b=(d+1)/2;
    for(i=b;i<=d;i++)fix[i]-=2;
    for(i=1;i<b;i++)if(fix[i]){cout<<"Impossible\n";return 0;}
    for(i=b+1;i<=d;i++)if(fix[i]<0){cout<<"Impossible\n";return 0;}
    if(d%2==0&&fix[b]!=-1){cout<<"Impossible"<<endl;return 0;}
    if(d%2==1&&fix[b]!=0){cout<<"Impossible"<<endl;return 0;}
    cout<<"Possible\n";
    return 0;
}

Measured memory_bytes: 256
import numpy as np

a,b,c = input()
#print(a)
#print(b)
#print(c)
s = np.zeros(3)
num = 0
if a == '1':
    num = num + 1
if b == '1':
    num = num + 1
if c == '1':
    num = num + 1
print(num)

Measured memory_bytes: 12396
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B;
    char op;
    cin >> A >> op >> B;
    if (op == '-') {
        cout << A - B << endl;
    } else if (op == '+') {
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
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>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  while(1){
   ll m,f,r;
   cin >> m >> f >> r;
   if(m == -1 && f == -1 && r == -1)break;
   if(m == -1 || f == -1) cout << "F";
   else if(m+f >= 80)cout << "A";
   else if(m+f >= 65)cout << "B";
   else if(m+f >= 50 || (m+f >= 30 && r >= 50))cout << "C";
   else if(m+f >= 30)cout << "D";
   else cout << "F";
   cout << endl;
  }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);
typedef pair<ll, ll> P;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  A = A - B;
  vector<ll> v(N);
  for(int i=0;i<N;i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  ll l = 0;
  ll r = INF;
  while(r-l>1){
    ll m = (l+r)/2;
    ll now = 0;
    for(auto &&x : v){
      now += max((ll)0, ((x - B*m)+A-1) / A);
    }
    if(now <= m)
      r=m;
    else
      l=m;
  }
  cout << r << endl;
  return 0;
}


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

struct prob
{
    int prob_no;
    int ac_count=0;
    int wa_count=0;
};
int main()
{
    int no;
    string verdict;
    int correct_ans=0;
    int penalties=0;
    int M,N;
    cin>>N>>M;
    prob arr[N];
    for(int i=0; i<M; i++)
    {
        cin>>no;
        cin>>verdict;
        arr[no-1].prob_no=no;
        if(verdict=="AC")
        {
            if(arr[no-1].ac_count==0)
            {
                penalties+=arr[no-1].wa_count;
                arr[no-1].ac_count++;
                correct_ans++;
            }
        }
        else
        {
            if(arr[no-1].ac_count==0)
            {
                arr[no-1].wa_count++;
            }
        }
    }
    cout<<correct_ans<<" "<<penalties<<endl;
    return 0;
}


Measured memory_bytes: 1408
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,M = map(int,readline().split())
if M == 0:
    print(-1)
    exit()
m = map(int,read().split())
P,Q,C = zip(*zip(m,m,m))

V = []
V += [p<<32 for p in range(1,N+1)]
V += [(p<<32)+c for p,c in zip(P,C)]
V += [(q<<32)+c for q,c in zip(Q,C)]
V = set(V)
label = {x:i for i,x in enumerate(V)}
start = label[1<<32]
goal = label[N<<32]

N = len(V)
graph = [[] for _ in range(N)]
for p,q,c in zip(P,Q,C):
    v0 = label[p<<32]; v1 = label[(p<<32)+c]
    w0 = label[q<<32]; w1 = label[(q<<32)+c]
    graph[v0].append((v1,1))
    graph[w0].append((w1,1))
    graph[v1].append((v0,0))
    graph[w1].append((w0,0))
    graph[v1].append((w1,0))
    graph[w1].append((v1,0))

INF = 10 ** 10
dist = [INF] * N
dist[start] = 0
q = deque([(0,start)])
while q:
    dv,v = q.popleft()
    for w,cost in graph[v]:
        dw = dv + cost
        if dw >= dist[w]:
            continue
        dist[w] = dw
        if not cost:
            q.appendleft((dw,w))
        else:
            q.append((dw,w))

answer = dist[goal]
if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 187292
n,y = map(int,input().split())
flag = 0
y_10 = 0
y_5 = 0

for i in range(n+1):
    y_10 = i * 10000
    if y_10 > y:
        break
    for j in range(0,n-i+1):
        y_5 = j*5000
        if y_10+y_5 > y:
            break
        k = n-i-j
        if y_10 + y_5 + 1000*k == y:
            print(i,j,k)
            flag = 1
            break
    if flag == 1:
        break

if flag == 0:
    print('-1 -1 -1')


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

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

  int R; cin >> R;

  printf("%lf\n", 2 * M_PI * R);

  return 0;
}


Measured memory_bytes: 3820
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int b[2];
int main()
{
	int m,p;
	scanf("%d %d",&m,&p);
	int tem;
	int i;
	for(i=0;i<m;i++)
		scanf("%d",&tem),b[tem%2]++;
	long long int ans=0;
	if(p%2&&b[1]>=1)
		ans=(1LL<<b[0])*(1LL<<b[1]-1);
	else if(!(p%2))
		ans=(1LL<<b[0])*(1LL<<max(b[1]-1,0));
	printf("%lld\n",ans);
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int sod(int a){
    int ans=0;
    while(a>0){
        ans+=(a%10);
        a/=10;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x,y;
    cin>>x>>y;
    int ans=0;
    while(x<=y){
        x<<=1;
        ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

int N;
map<string, int> M;

void input_init(void) {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		++(M[str]);
	}
}

ll solve(void) {
	ll cnt = (ll)0;
	map<string, int>::iterator itr;
	for (itr = M.begin(); itr != M.end(); ++itr) {
		int c = itr->second;
		cnt += (ll)c * (c - 1) / 2;
	}
	return cnt;
}

int main(void) {
	input_init();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<int> bit;

void init_bit(int n){
    bit.assign(n+1,0);
}

void add(int n,int a,int w){
    for(int i=a;i<=n;i+=i&-i) bit[i]+=w;
}

int sum(int n,int a){
    int res=0;
    for(int i=a;i>0;i-=i&-i) res+=bit[i];
    return res;
}

int main(){
    int n,q; cin>>n>>q;
    vector<int> c(n,0),last(n,-1),ans(q,0);
    vector<vector<int>> cc(n+1);
    vector<vector<pp>> qs(n+1);
    init_bit(n);
    rep(i,n){
        cin>>c[i]; c[i]--;
    }
    rep(i,q){
        int l,r; cin>>l>>r;
        qs[r].push_back(mk(i,l));
    }
    for(int i=1;i<=n;i++){
        add(n,i,1);
        if(last[c[i-1]]!=-1){
            add(n,last[c[i-1]],-1);
        }
        last[c[i-1]]=i;
        for(auto p:qs[i]){
            if(p.second==1) ans[p.first]=sum(n,i);
            else ans[p.first]=sum(n,i)-sum(n,p.second-1);
        }
    }
    rep(i,q) printf("%d\n",ans[i]);
}


Measured memory_bytes: 76292
# 最小かつ最長はzzzzzなので各文字+4まで調べてみるか（27^5-1で全探索もできると思うがやり方がわからん
s = input()
k = int(input())
d = set()
for i in range(len(s)):
    for j in range(1, 6):
        if i + j <= len(s):
            d.add(s[i : i + j])
print(sorted(list(d))[k-1])


Measured memory_bytes: 4592
#include<iostream>
using namespace std;
int main(){
	bool flag = 0;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		}
		
	for(int i = 0; i < n; i++){
		if(flag == 1){
			break;
			}
		if(a[i]%2 == 0){
			if(a[i] > 5 && (a[i]%3 == 0 || a[i]%5 == 0)){
					flag = 0;
				}
			else{
				flag = 1;
				}
			}
		}
			
		if(flag == 0){
			cout << "APPROVED";
			}
		else if(flag == 1){
			cout << "DENIED";
			}
			
		}			


Measured memory_bytes: 256