akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
    ll n;cin>>n;
    ll ans=0;
    /*
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
        if(i%j==0)ans+=i;
    }
    */
    for(ll i=1;i<=n;i++){
        ll t=n/i;
        ans+=i*(t+1)*t/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 45


int N,K;
ll MIN,MAX;
ll POW[SIZE];
ll coin[SIZE];
vector<ll> A[SIZE],B[SIZE];


int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %lld %lld",&N,&K,&MIN,&MAX);

	for(int i = 0; i < N; i++){

		scanf("%lld",&coin[i]);
	}

	if(N == 1){

		ll ans = 0;
		for(int i = 0; i < N; i++){

			if(coin[i] >= MIN && coin[i] <= MAX){

				ans++;
			}
		}

		printf("%lld\n",ans);
		return 0;
	}

	vector<ll> LEFT,RIGHT;
	for(int i = 0; i < N/2; i++){

		LEFT.push_back(coin[i]);
	}
	for(int i = N/2; i < N; i++){

		RIGHT.push_back(coin[i]);
	}

	for(int state = 0; state < POW[LEFT.size()]; state++){

		int num = 0;
		ll sum = 0;

		for(int loop = 0; loop < LEFT.size(); loop++){
			if(state & POW[loop]){

				num++;
				sum += LEFT[loop];
			}
		}
		A[num].push_back(sum);
	}

	for(int i = 0; i < LEFT.size(); i++){

		sort(A[i].begin(),A[i].end());
	}

	for(int state = 0; state < POW[RIGHT.size()]; state++){

		int num = 0;
		ll sum = 0;

		for(int loop = 0; loop < RIGHT.size(); loop++){
			if(state & POW[loop]){

				num++;
				sum += RIGHT[loop];
			}
		}
		B[num].push_back(sum);
	}

	for(int i = 0; i < RIGHT.size(); i++){

		sort(B[i].begin(),B[i].end());
	}

	int limit = min(K,(int)LEFT.size());

	ll ans = 0;
	int L,R,left,right,mid;

	for(int a = 0; a <= limit; a++){

		int b = K-a;
		if(B[b].size() == 0)continue;

		for(int i = 0; i < A[a].size(); i++){

			L = B[b].size();
			left = 0,right = B[b].size()-1,mid = (left+right)/2;
			while(left <= right){

				if(A[a][i]+B[b][mid] >= MIN){

					L = mid;
					right = mid-1;
				}else{

					left = mid+1;
				}
				mid = (left+right)/2;
			}

			if(L == B[b].size())continue;

			R = -1;
			left = 0,right = B[b].size()-1,mid = (left+right)/2;
			while(left <= right){

				if(A[a][i]+B[b][mid] <= MAX){

					R = mid;
					left = mid+1;
				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}
			ans += max(0,R-L+1);
		}
	}

	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 23352
#include<cstdio>
#include<algorithm>
using namespace std;
int N,Ans,Max,A[200005],F[200005];
int main()
{
	scanf("%d",&N);
	for (int i=1;i<=N;i++) scanf("%d",&A[i]);
	for (int i=1;i<=N;i++) F[A[i]]=F[A[i]-1]+1,Max=max(Max,F[A[i]]);
	printf("%d\n",N-Max);
	return 0;
}

Measured memory_bytes: 1664
while(True):
    n = int(input())
    if n == 0:
         break
    arr = []
    for i in range(n):
        arr.append(list(map(int, input().split())))
    arr = [ l+[sum(l)] for l in arr]
    brr = [0]*(n+1)
    for i in range(n):
        for j in range(n+1):
            brr[j] += arr[i][j]
    crr = arr+[brr]
    for c in crr:
        for d in c:
            print("%5d"%d,end="")
        print()


Measured memory_bytes: 5624
#include <iostream>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define vvl vector<vector<ll>>
#define in(a) insert(a)
#define M 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279


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

 	int t{},T{};
 	//cin>>t;T=t;
    t=1;
 	while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        int n{},m{},ans{},x,tt,k{},a{},b{},c{},f{1};
        cin>>n>>x>>tt;
        
        if(n<=x){
            cout<<tt<<endl;
        }else{
            if(n%x==0){
            cout<<(n/x)*tt<<endl;;
            
            }else{
                cout<<(n/x)*tt+tt<<endl;
            }
        }
    }
    
    
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int r[N],c[N];
int DP[2*N-1],DN[2*N-1];
bool x[N][N];

void in(){
  int i;
  for(i=0;i<N;i++){
    r[i]=FREE;
    c[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    DP[i]=FREE;
    DN[i]=FREE;
  }
}

void PB(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(x[i][j]){
        if(r[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(r[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void rec(int i){
  if(i==N){
    PB();
    return;
  }
  int j;
  for(j=0;j<N;j++){
    if(NOT_FREE==c[j]||NOT_FREE==DP[i+j]||NOT_FREE==DN[i-j+N-1])continue;
    r[i]=j;
    c[j]=DP[i+j]=DN[i-j+N-1]=NOT_FREE;
    rec(i+1);
    r[i]=c[j]=DP[i+j]=DN[i-j+N-1]=FREE;
  }
}

int main(){
  in();
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++)x[i][j]=false;
  }
  int k;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    int r,c;
    scanf("%d%d",&r,&c);
    x[r][c]=true;
  }
  rec(0);
  return 0;
}



Measured memory_bytes: 2112
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a = -111, b = -111;
	//int m;
	int h, w;
	int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	int x, y;

	//string s[111111];
	//string s[100000];
	string c[7];
	//int a[200000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	//int box[1000000000000000000];
	//int box = 0;
	int box[7][7] = { 0 };
	//int box2;
	//int p[1111];

	//long double aaa;

	int count = 0;
	//int k, d;
	int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//bool flag = true;
	bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b;
	//cin >> h >> w >> k;
	cin >> x;
	/*for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> c[i][j];
		}
	}*/

	if (x <= 599)
	{
		all = 8;
	}
	else if (x >= 600 && x <= 799)
	{
		all = 7;
	}
	else if (x >= 800 && x <= 999)
	{
		all = 6;
	}
	else if (x >= 1000 && x <= 1199)
	{
		all = 5;
	}
	else if (x >= 1200 && x <= 1399)
	{
		all = 4;
	}
	else if (x >= 1400 && x <= 1599)
	{
		all = 3;
	}
	else if (x >= 1600 && x <= 1799)
	{
		all = 2;
	}
	else if (x >= 1800 && x <= 1999)
	{
		all = 1;
	}

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//for (int i = 0; i < 1000; i++)
	//{
	//	if (n < 1000)
	//	{
	//		all = 1000 - n;
	//		break;
	//	}
	//	n -= 1000;
	//	if (n == 0)
	//	{
	//		all = 0;
	//		break;
	//	}
	//}

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	cout << all << "\n";
	//cout << box << "\n";
	//cout << a << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    n -= k;
    cout << (k == 1 ? 0 : n) << endl;    
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    int cnt=0;
    
    for(int i=0;i<n;i++){
        int minj=i;
        
        for(int j=i;j<n;j++){
            if(hoge.at(minj)>hoge.at(j)){
                minj=j;
            }
        }
        
        if(minj!=i){
            int pre=hoge.at(i);
            hoge.at(i)=hoge.at(minj);
            hoge.at(minj)=pre;
            
            cnt++;
        }
    }
    
    for(int i=0;i<n;i++){
        cout<<hoge.at(i);
        if(i<n-1) cout<<" ";
    }
    
    cout<<endl<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int g=0,p=0,score=0;
  string s;
  cin >> s;
  FOR(i,0,s.size()){
    if(s[i] == 'g'){
      if(p+1 <= g){
        score++;
        p++;
        cerr << 'p';
      }
      else{
        g++;
        cerr << 'g';
      }
    }
    else{
      if(p+1 <= g){
        p++;
        cerr << 'p';
      }
      else{
        score--;
        g++;
        cerr << 'g';
      }
    }
  }
  cout << score << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int[] costs = new int[n];
        int[][] values = new int[n][m];

        for (int i = 0; i < n; i++) {
            costs[i] = scanner.nextInt();
            for (int j = 0; j < m; j++) {
                values[i][j] = scanner.nextInt();
            }
        }

        int result = select(costs, values, x, new int[m], 0, 0);
        System.out.println(result == Integer.MAX_VALUE ? -1 : result);
    }

    private static int select(int[] costs, int[][] values, int x,
                       int[] learned, int current, int prevCost) {
        boolean successful = true;
        for (int value : learned) {
            if (value < x) {
                successful = false;
                break;
            }
        }
        if (successful) return prevCost;
        if (current >= costs.length) return Integer.MAX_VALUE;

        int notSelectCost = select(costs, values, x, learned, current + 1, prevCost);

        int[] newLearned = new int[learned.length];
        for (int i = 0; i < learned.length; i++) {
            newLearned[i] = learned[i] + values[current][i];
        }
        int selectCost = select(costs, values, x, newLearned, current + 1, prevCost + costs[current]);

        return Math.min(notSelectCost, selectCost);
    }
}

Measured memory_bytes: 37820
import Control.Applicative
import Control.Monad (forM_)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU

type Distance  = Int
type Adjacency = [Int]
type Queue     = [Int]

main :: IO ()
main = do
    n <- readLn :: IO Int
    adjs <- V.replicateM n $ map ((subtract 1) . fst . fromJust . B.readInt) . drop 2 . B.words <$> B.getLine :: IO (V.Vector Adjacency)
    let distance0 = VU.replicate n (-1) VU.// [(0,0)] :: VU.Vector Distance
        distanceN = bfs [0] adjs distance0
    forM_ [0..n-1] $ \i ->
        putStrLn $ show (i + 1) ++ " " ++ show (distanceN VU.! i)

bfs :: Queue -> V.Vector Adjacency -> VU.Vector Distance -> VU.Vector Distance
bfs [] _ dists = dists
bfs queue adjs dists =
    let
        q   = last queue
        adj = adjs V.! q
    in
    case next adj dists of
        Nothing ->
            bfs (init queue) adjs dists
        Just n ->
            let
                newDists = update q n dists
            in
            bfs (n:queue) adjs (update q n dists)

next :: Adjacency -> VU.Vector Distance -> Maybe Int
next [] _ = Nothing
next (n:ns) dists =
    if dists VU.! n == -1 then
        Just n
    else
        next ns dists

update :: Int -> Int -> VU.Vector Distance -> VU.Vector Distance
update q n dists =
    let
        v = dists VU.! q + 1
    in
    dists VU.// [(n, v)]


Measured memory_bytes: 4892
n = int(input())
l = [input() for i in range(n)]
n_l = [l[0]]
ans = "Yes"
for i in range(1,n):
    if l[i] not in n_l:
        n_l.append(l[i])
    else:
        ans = "No"
        break

    if l[i-1][-1] == l[i][0]:
        continue
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 38384
inp = input().split(" ")
N, A, B = (int(inp[0]), int(inp[1]), int(inp[2]))
if int(N % (A + B)) <= A:
    print(int(N / (A + B)) * A + int(N % (A + B)))
else:
    print(int(N / (A + B)) * A + A)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
A=sorted(map(int,input().split()))
B=[0]+A[:]
for i in range(n):
    B[i+1]+=B[i]

def solve_binary(mid):
    tmp=0
    for i,ai in enumerate(A):
        tmp+=n-bisect.bisect_left(A,mid-ai)
    return tmp>=m

def binary_search(n):
    ok=0
    ng=n
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve_binary(mid):
            ok=mid
        else:
            ng=mid
    return ok

binresult=binary_search(2*10**5+1)
for i ,ai in enumerate(A):
    ans+=ai*(n-bisect.bisect_left(A,binresult-ai))+B[n]-B[bisect.bisect_left(A,binresult-ai)]
    count+=n-bisect.bisect_left(A,binresult-ai)
    # print(ans,count)
ans-=binresult*(count-m)
print(ans)
# print(binresult)

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

int main()
{
    int w, a, b;

    scanf("%d%d%d", &w, &a, &b);
    if (a + w < b) {
        printf("%d\n", b - a - w);
    } else if (a > b + w) {
        printf("%d\n", a - b - w);
    } else {
        puts("0");
    }
}


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


int main(){

    string S;
    string yyyymmdd;
    int yyyymmdd_int;

    cin >> S;
    yyyymmdd = S.substr(0,4);
    yyyymmdd = yyyymmdd + S.substr(5,2);
    yyyymmdd = yyyymmdd + S.substr(8,2);

    yyyymmdd_int = atoi(yyyymmdd.c_str());
    
    if(yyyymmdd_int<=20190430){
        cout << "Heisei";
    }else{
        cout << "TBD";
    }

}

Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
D=[]
for i in range(N):
  for j in range(i,N):
    D.append(sum(A[i:j+1]))
ans=0
k=42
for i in range(1,k+1):
  cnt=0
  DD=[]
  for j in D:
    if (j>>(k-i))&1==1:
      cnt+=1
      DD.append(j)
  if cnt>=K:
    ans+=2**(k-i)
    D=DD
  elif cnt>=K:
    ans+=2**(k-i)
print(ans)


Measured memory_bytes: 86364
#include <iostream>

using namespace std;

bool InRange(const int &v, const int &minV, const int &maxV)
{
    return (maxV - v) * (v - minV) >= 0;
}

int SumKeta(int num)
{
    int sum = 0;

    while (num > 0)
    {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int sum = 0;
    for (int i = 1; i <= N; ++i)
    {
        if (InRange(SumKeta(i), A, B))
        {
            sum += i;
        }
    }
    cout << sum;
    return 0;
}

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

using namespace std;

int main(){
	long long w,h,i,j;
	
	while(1){
		cin>>w>>h;
		if(w==0 && h==0) break;
		for(i=1;i<=h;i++){
			cout<<"#";
		}
		cout<<"\n";
		for(i=2;i<w;i++){
			cout<<"#";
			for(j=2;j<h;j++){
				cout<<".";
			}
			cout<<"#\n";
		}
		for(i=1;i<=h;i++){
			cout<<"#";
		}
		cout<<"\n"<<"\n";
	}
}


Measured memory_bytes: 3056
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,c,x,y = i2()

ans = float("inf")
note = 0
for i in range(0,2*max(x,y)+1,2):
	note = a*max(0,x-i//2)+b*max(0,y-i//2)+c*i
	ans = min(ans,note)
print(ans)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int n;
    cin>>n;
    vint a(n);
    int ans=0;
    for (size_t i = 0; i < n; i++)
    {
        cin>>a[i];
        if((i+1)%2 == 1 and a[i] %2 == 1)
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
// i hate myself
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        long[] a = new long[n];
        long[] b = new long[n];
        long max_a = -1L;
        for( int i = 0; i < n; i++ ) {
            a[i] = in.nextLong();
            b[i] = in.nextLong();
            max_a = Math.max(max_a, a[i]);
        }
        long ct = 0L;
        Arrays.sort(b);
        for( int i = n-1; i >= 0; i-- ) {
            if(b[i] > max_a && k > 0) {k -= b[i]; ct += 1L;}
            else break;
        }
        if(k>0) ct += Math.ceil(k/(double)max_a);
        System.out.println(ct);
    }
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	string s[]={"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
	int c=25-n;
	cout << s[3-c]<<"\n";
	return 0;
}


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

int main(){
  long i,j,sum=0;
  string S;
  cin >> S;

  for(i=0;i<pow(2,S.size()-1);++i){
    long x = S.at(0)-'0',result=0;

    for(j=0;j<S.size()-1;++j){
      int digit;
      digit = (i >> j) & 1;

      if(digit == 0)
        x = x * 10 + (S.at(j+1)-'0');
      else{
        result += x;
        x = S.at(j+1)-'0';
      }
    }
    sum += result + x;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    bool x; cin >> x;
    cout << (!x ? 1 : 0) << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(10000) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<ll> pos[26];

int main() {
    ll n, m;
    string s, t;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    REP(i,n){
        int id = s[i] - 'a';
        pos[id].push_back(i);
    }
    bool ok = true;
    REP(i,m){
        int id = t[i] - 'a';
        ok &= pos[id].size() > 0;
    }
    if(!ok){
        cout << -1 << endl;
    }
    else{
        REP(i,26){
            pos[i].push_back(IINF);
        }
        ll ans = 0, p = -1;
        REP(i,m){
            int id = t[i]-'a';
            ll x = *upper_bound(ALL(pos[id]), p);
            if(x == IINF){
                x = pos[id].front();
                ans += n-p-1;
                p = -1;
            }
            ans += x-p;
            p = x;
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    if (a < b) {
        for (int k = 0; abs(a-k) <= abs(b-k); k++) {
            if (abs(a-k) == abs(b-k)) {
                cout << k << endl;
                exit(0);
            }
        }
    } else {
        for (int k = 0; abs(b-k) <= abs(a-k); k++) {
        if (abs(b-k) == abs(a-k)) {
            cout << k << endl;
            exit(0);
        }
    }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final int A[] = new int[N];
        for (int i=0; i<N; i++) {
            A[i] =  Integer.parseInt(sc.next());
        }
        sc.close();

        int cnt = 1;
        int ans = 0;
        for (int i=0; i<N; i++) {
            if (cnt==A[i]) {
                cnt++;
            } else {
                ans++;
            }
        }

        if (ans==N)
            ans = -1;

        System.out.println(ans);
    }
}

Measured memory_bytes: 51588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n; cin >> n;
  cout << 24+(24-n) << endl;
  system("pause");
}

Measured memory_bytes: 504
a, b, c, x = [int(input()) for i in range(4)]
ans = 0
# a:500, b:100, c:50

for i_a in range(a+1):
    for i_b in range(b+1):
        for i_c in range(c+1):
            money = i_a*500 + i_b*100 + i_c*50
            if x == money:
                ans += 1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int x, y;
int main(){
	cin>> x>> y;
	if((y-2*x)%2 == 0 && (y-2*x)/2 >= 0 && (y-2*x)/2 <= x){
		cout<< "Yes";
	}else{
		cout<< "No";
	}
	return 0;
} 

Measured memory_bytes: 3580
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    a=parseMap(split(readline()))
    INF=2<<32
    visited=[INF for i in 1:n]
    visited[1]=0
    now=1
    loop=(1,n)
    for i in 1:1000000
        if visited[a[now]]<INF
            loop=(a[now],now)
            break
        end
        visited[a[now]]=visited[now]+1
        now=a[now]
    end
    res=k-visited[loop[1]]
    if res<0
        res=k
    elseif loop[2]==loop[1]
        res=visited[loop[1]]
    else
        res=res%(visited[loop[2]]-visited[loop[1]]+1)+visited[loop[1]]
    end
    println(findfirst(x->x==res,visited))
end
main()

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

int a[10];

bool dfs(int id, int l_last, int r_last){
	if (id == 10)
		return true;
	if (a[id] > l_last && dfs(id + 1, a[id], r_last))
		return true;
	if (a[id] > r_last && dfs(id + 1, l_last, a[id]))
		return true;
	return false;
}

void solve(){
	if (dfs(0, -1, -1))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < 10; ++j)
			cin >> a[j];
		solve();
	}
	return 0;
}

Measured memory_bytes: 3000
#include <stdio.h>

int main()
{
    int n,a[200000],i,j = 1,ans = 0;
    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    
    for (i = 0; i < n; i++)
    {
        if(a[i] == j)j++;
        else ans++;
    }
    if(ans == n)printf("-1");
    else
    {
        printf("%d",ans);
    }
    
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector <int> h(n);
  REP(i, n) {
	cin >> h[i];
  }
  sort(all(h));
  ll ans = 0;
  REP(i, n - k) {
	ans += h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int work = 0;
  vector<int> v(n);
  
  for(int i=0; i<n-1; i++){
    int temp;
    cin >> temp;
    v[temp-1] += 1;
  }
  
  for(int i=0; i<n; i++){
    cout << v[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
#define fir first
#define sec second

const int maxn = 4006; 
const int oo = maxn * 5; 

char a[maxn], b[maxn];  
int n; 
int L[maxn], R[maxn]; 
int cc[maxn]; 

int main() {
	scanf( "%s", a+1 ); 
	scanf( "%s", b+1 ); 
	n = strlen(a+1); 
	for (int i = 1; i <= n; ++i) b[i+n] = b[i]; 
	for (int i = 1; i <= n; ++i) {
		L[i] = oo; 
		for (int j = 0; j <= n; ++j) 
			if (b[i+n-j] == '1') {
				L[i] = j; 
				break; 
			}
		R[i] = oo; 
		for (int j = 0; j <= n; ++j) 
			if (b[i+j] == '1') {
				R[i] = j; 
				break; 
			}
	}
	int ans = oo; 
	for (int i = 0; i <= n; ++i) {
		int k = 0, t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[j+n-i]) {
				if (L[j] > i) k = max(k, R[j]); 
				t++; 
			}
		ans = min(ans, i+k*2+t); 
	}
	for (int i = 0; i <= n; ++i) {
		int k = 0, t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[j+i]) {
				if (R[j] > i) k = max(k, L[j]); 
				t++; 
			}
		ans = min(ans, i+k*2+t); 
	}
	//--------------------------------------------
	for (int i = 0; i <= n; ++i) {
		int k = i, t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[j+n-i]) {
				k = max(k, L[j]); 
				t++; 
			}
		ans = min(ans, k*2-i+t); 
	}
	for (int i = 0; i <= n; ++i) {
		int k = i, t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[j+i]) {
				k = max(k, R[j]); 
				t++; 
			}
		ans = min(ans, k*2-i+t); 
	}
	//--------------------------------------------
	for (int i = -n; i <= n; ++i) {
		bool flag = false; 
		for (int j = 1; j <= n; ++j) 
			if (L[j] > n) {
				flag = true; 
				break; 
			}
		if (flag) continue; 
		for (int j = 0; j <= n; ++j) cc[j] = 0; 
		int t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[(j+i+n)%n+n]) {
				cc[L[j]] = max(cc[L[j]], R[j]); 
				++t; 
			}
		int rb = 0; 
		for (int j = n; j >= 0; --j) {
			ans = min(ans, (max(rb,i)+max(j,-i))*2-max(i,-i)+t); 
			rb = max(rb, cc[j]); 
		}
	}
	//--------------------------------------------
	for (int i = 0; i <= n; ++i) {
		int t = 0; 
		for (int j = 1; j <= n; ++j) 
			if (a[j] != b[j+i]) {
				t++; 
				if (L[j] > n) t = oo; 
			}
		ans = min(ans, n+t+min(i,n-i)); 
	}
	if (ans >= n*5) puts( "-1" ); 
	else cout<<ans<<endl; 
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnline_DataStructure
{
    public class Node
    {
        public int id;
        public bool isPassed = false;
        public int groupId;
        public int cost = int.MaxValue;
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            var nodes = new List<Node>();
            var n = Convert.ToInt32(Console.ReadLine());
            var p = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; i++)
            {
                var node = new Node()
                {
                    id = i,
                    cost = Convert.ToInt32(p[i])
                };
                nodes.Add(node);
            }

            foreach (var node in nodes)
            {
                Console.Write("node " + (node.id + 1) + ": key = " + node.cost + ", ");
                var maxIndex = nodes.Count();

                if (node.id != 0)
                {
                    Console.Write("parent key = " + p[(node.id - 1) / 2] + ", ");
                }

                if (node.id * 2 + 1 < maxIndex)
                {
                    Console.Write("left key = " + p[node.id * 2 + 1] + ", ");
                }

                if (node.id * 2 + 2 < maxIndex)
                {
                    Console.Write("right key = " + p[node.id * 2 + 2] + ", ");
                }

                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    switch (n % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl; break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl; break;
        case 3:
            cout << "bon" << endl; break;
    } 
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int n, m, k, x;
double ans;

void dfs(int node, int sum) {
    if (node == n) {
        if (sum-k < 1) sum = 1;
        else sum -= k;
        ans += (double)sum / x;
        return;
    }
    for (int i = 1; i < m+1; i++) {
        dfs(node+1, sum+i);
    }
    return;
}

int main(void){
    while (cin>>n>>m>>k && n) {
        ans = 0;
        x = pow(m,n);
        dfs(0, 0);
        printf("%.12lf\n",ans);
    }
}

Measured memory_bytes: 3224
from collections import deque

n,m=map(int,input().split())
L=[[] for i in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	L[a-1].append(b-1)
	L[b-1].append(a-1)
D=[float('inf') for i in range(n)]

def bfs():
	que=deque([])
	que.append(0)
	D[0]=0
	while que:
		p=que.popleft()
		for np in L[p]:
			if D[np]==float('inf'):
				que.append(np)
				D[np]=p+1

bfs()

if sum(D)==float('inf'):
	print('No')
else:
	print('Yes')
	for i in range(1,n):
		print(D[i])

Measured memory_bytes: 37264
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};


int a,b;
int ans=0;
vector<vector<bool>> v;
void dfs(int y,int x){
    //cout<<x<<" "<<y<<endl;
    if(y==b-1&&x==a-1){
        ans++;
    }
    if(y+1<b&&v[y+1][x])dfs(y+1,x);
    if(x+1<a&&v[y][x+1])dfs(y,x+1);
    return;
}

int main (){ 
    while(cin>>a>>b&&a&&b){
        ans=0;
        v.clear();
        v.resize(b,vector<bool>(a,true));
        int n;
        cin>>n;
        rep(i,0,n){
            int x,y;
            cin>>x>>y;
            x--; y--;
            v[y][x]=false;
        }
        dfs(0,0);
        cout<<ans<<endl;
    }
    return 0;
}


/*
3 3 3 4 4
3 3 4 4 4
3 3 3 3 3

*/



Measured memory_bytes: 3088
using System;
using System.Linq;
using System.Collections.Generic;
 

class Program
 {
        static void Main(string[] args)
        {
    　　int a = 0;
            //a = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の
    List<string> lt = new List<string>(str);
List<int> lis = new List<int>();
for(int i=0;i<str.Length;i++){
lis.Add(int.Parse(str[i]));
        }
lis.Sort();
int dis0 = lis[1] - lis[0];
int dis1 = lis[2]-lis[1];
if(dis0 % 2 == 1){
dis1++;
dis0++;
}
else{

}
a=dis0/2+dis1;
Console.Write(a);
 }}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    ll curr = 0;
    ll n = 0;
    for (ll i=0; i<100000000; i++){
        if (Z*(i+1) + i*Y <= X)n++;
        else break;
    }
    cout << n - 1<< endl;
}

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

int main() {
    int m, f, r;
    cin >> m >> f >> r;
    //m:中間　f:期末　r:再試験
    while ( 1 ) {
        if ( m == -1 || f == -1) {
            cout << 'F' << endl;
        } else if ( m + f < 30 ) {
            cout << 'F' << endl;
        } else if ( m + f >= 80 ) {
            cout << 'A' << endl;
        } else if ( m + f >= 65 && m + f < 80 ) {
            cout << 'B' << endl;
        } else if ( m + f >= 50 && m + f < 65 ) {
            cout << 'C' << endl;
        } else if ( m + f >= 30 && m + f < 50 ) {
            if ( r < 50 ) {
                cout << 'D' << endl;
            } else {
                cout << 'C' << endl;
            } 
        }
        cin >> m >> f >> r;
        if ( m == -1 && f == -1 && r == -1 ) {
          break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll flag = 0;
    ll m = a[0];
    ll x = 1;
    ll check = 1;
    for(ll i=1;i<n;++i){
        if(m == a[i]){
            check++;
            if(check == 3){
                continue;
            }
            if(flag == 0){
                x *= a[i];
                flag++;
            }else{
                x *= a[i];
                cout<<x<<endl;
                return 0;
            }
        }else{
            m = a[i];
            check = 1;
        }
    }
    cout<<0<<endl;

    return 0;
}

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

typedef pair<int,int> pii;

vector<pii> testi[20];

int n;

int hitung(int x){
	int ret = 0;
	while(x>0){
		ret += (x&1);
		x /= 2;
	}
	return ret;
}

bool cek(int x){
	for(int j=0;j<n;j++){
		if((1<<j) & x){
			for(int k=0;k<testi[j].size();k++){
				int stat = (1<<testi[j][k].first) & x;
				if(stat > 0) stat = 1;
				if(stat != testi[j][k].second) return 0;
			}
		} 
	}
	return 1;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		for(int j=1;j<=x;j++){
			int u,v;
			scanf("%d%d",&u,&v);
			testi[i].push_back(make_pair(u-1,v));
		}
	}
	int ans = 0;
	for(int i=0;i<(1<<n);i++){
		if(cek(i)){
			ans = max(ans,hitung(i));
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 0

minXY = min(X,Y)
ans += minXY * min((A+B), 2*C)
X -= minXY
Y -= minXY

if X != 0:
	ans += X * min(A, 2*C)
else:
	ans += Y * min(B, 2*C)

print(ans)

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

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

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

    vector<lint> c(n);
    for(auto& elem : c)  cin >> elem;

    sort(begin(c), end(c));

    mint ans = 0;
    for(lint i=0; i<n; i++) {
        lint lc = i;
        lint rc = n-i-1;
        
        mint tmp = c[i];
        tmp *= mint::pow(2, lc);
        tmp *= mint(rc) * mint::pow(2, rc-1) + mint::pow(2, rc);
        ans += tmp;
    }

    cout << ans*mint::pow(2, n) << endl;
}

Measured memory_bytes: 1792
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    a.sort!"a > b";
    long amax = a[0];
    a.popFront;
    long ahalf = long.max / 2;
    foreach (x; a)
    {
        if (abs(x-amax/2) < abs(ahalf-amax/2)) ahalf = x;
    }

    writeln(amax, " ", ahalf);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    int n,r;
    char m;
    cin >> n;
    int T[4][13]={};
    for (int i=0; i<n; i+=1){
        cin >> m >> r;
            if (m=='S') m=0;
            else if (m=='H') m=1;
            else if (m=='C') m=2;
            else if (m=='D') m=3;

        T[m][r-1] = 1;
    }
    
    for (int j=0; j<4; j+=1){
        for (int k=0; k<13; k+=1){
            int p=T[j][k];
            if (p==0){
                r = k+1;
                if (j==0) m='S';
                else if (j==1) m='H';
                else if (j==2) m='C';
                else if (j==3) m='D';
                cout << m << " " << r << "\n";  
            }
        }
    }
    
    return 0;
}


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

string lcs(string& a,string& b){
	int al=a.length(),bl=b.length();
	int dp[al+1][bl+1];
	for(int i=0;i<=al;i++){
		for(int j=0;j<=bl;j++){
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(a[i-1]==b[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	string ans="";
	int i=al,j=bl;
	while(i>0 && j>0){
		if(a[i-1]==b[j-1]){
			ans=a[i-1]+ans;
			i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;		
	}
	return ans;
}

int main(){
	string s,t; cin>>s>>t;
	
	cout<<lcs(s,t);
}

Measured memory_bytes: 35456
#include <stdio.h>
#include <stdlib.h>

int main() {
    long long n, k;
    scanf("%lld%lld", &n, &k);
    long long x = n%k;
    if(x > abs(x-k))
        x = llabs(x-k);
    printf("%lld\n", x);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int n;
	cin >> n;
	int ans = sqrt(n);
	ans = ans*ans;
	cout << ans << endl;

	return 0;
}


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

 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  
  int mx = 0;
  rep(i,n) mx = max(mx,a.at(i));
  
  int d = INF;
  int ans ;
  rep(i,n){
    if(abs(mx/2 - a.at(i)) < d && a.at(i) != mx){
      ans = a.at(i);
      d = abs(mx/2 - a.at(i));
    }
  }
  cout << mx <<" " << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
 int main()
{
  long long int n,a,b;
  cin>>n>>a>>b;

  long long int x=a+b;
  long long int q=n/x;
  long long int ans=0;
  ans+=a*q;
  long long int r=n%x;
  if(r<=a)
  ans+=r;
  else
  ans+=a;
  cout<<ans;


}

Measured memory_bytes: 256