akhauriyash/Code-Regression huggingface dataset:
unittest
{
	assert( [ "2 11 4" ].parse.expand.solve == 4 );
	assert( [ "3 9 5" ].parse.expand.solve == 3 );
	assert( [ "100 1 10" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc[ 0 ], abc[ 1 ], abc[ 2 ] );
}

auto solve( long a, long b, long c )
{
	return min( b / a, c );
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = 100;
		long b = sc.nextLong();
        int ans = 0;
        while(a<b){ans++;a+=a/100;
                            }
        
		System.out.println(ans);
	}
}


Measured memory_bytes: 35720
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int K;
    cin >> K;
    vector<ll> a;
    rep(i, 9) a.push_back(i + 1);
    vector<ll> old;
    old = a;
    while(1){
        if(a.size() >= K){
            cout << a[K - 1] << endl;
            break;
        }
        vector<ll> array;
        for(ll x : old){
            for(int i = -1; i <= 1; i++){
                int d = x % 10 + i;
                if(d == -1 || d == 10)continue;
                ll num = x * 10 + d;
                a.push_back(num);
                array.push_back(num);
            }
        }
        old = array;
    }
}

Measured memory_bytes: 5232
Imports System

Module Test2
Sub Main()
Dim input As String, S_line(999) As Integer, Output As String
Dim  A_int As Integer, B_int As Integer
Dim PP As Integer, S_test() As String
Input ="" : Output ="" 
Input=Console.ReadLine()
Dim a As Integer, b As Integer
S_test = Split(Input, " ")
a = S_test(0)
b = S_test(1)
For A_int = 1 To 999 Step 1
PP = 0
For B_int = 1 To A_int Step 1
PP = PP + B_int
Next
S_line(A_int) = PP
Next
Dim Ck_a As Integer, Ck_b As Integer
For A_int = 1 To 998 Step 1
Ck_a = S_line(A_int) - a
Ck_b = S_line(A_int + 1) - b
If Ck_a = Ck_b Then Exit For
Next
Output = Ck_a.ToString
Console.WriteLine(Output)
End sub
End Module

Measured memory_bytes: 13532
n,k = map(int,input().split())
l = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l[j-1] = 1
c = 0

for L in l:
    if(L == 0):c += 1
print(c)

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    while(true){
		String[] st = sc.readLine().split(" ");
		int H = Integer.valueOf(st[0]), W = Integer.valueOf(st[1]);
		if(H==0 && W==0)
		    break;
		int[][] map = new int[H][W];
		for(int i=0; i<H; i++){
		    String sp = sc.readLine();
		    for(int j=0; j<W; j++){
			if(sp.charAt(j)=='>')
			    map[i][j] = 1;
			else if(sp.charAt(j)=='v')
			    map[i][j] = 2;
			else if(sp.charAt(j)=='<')
			    map[i][j] = 3;
			else if(sp.charAt(j)=='^')
			    map[i][j] = 4;
		    }
		}
		int x=0, y=0; boolean flag = false;
		while(true){
		    int a = x, b = y;
		    if(map[x][y]==1)
			y++;
		    else if(map[x][y]==2)
			x++;
		    else if(map[x][y]==3)
			y--;
		    else if(map[x][y]==4)
			x--;
		    else if(map[x][y]==0)
			break;
		    else if(map[x][y]==-1){
			flag = true;
			break;
		    }
		    map[a][b] = -1;
		}
		if(flag)
		    System.out.println("LOOP");
		else
		    System.out.println(y+" "+x);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 11000
#include <stdio.h>
#include <string.h>
 
int main(){
    int m, h;
    char cards[256], temp[256], result[256];
    int i, j=0, len;
 
    while(1){
        scanf("%s", cards);
        len=strlen(cards);
        if(strcmp(cards, "-")==0&&len==1)break;
        scanf("%d", &m);
        for(;m>0;m--){
            scanf("%d", &h);
            strcpy(temp, cards);
            for(i=0;i<h;i++){
                cards[len-h+i]=temp[i];
            }
            for(i=0;i<len-h;i++){
                cards[i]=temp[i+h];
            }
        }
        for(i=0;i<len;i++){
            result[j++]=cards[i];
        }
        result[j++]='\n';
    }
    result[j]='\0';
    printf("%s", result);
 
    return 0;
}\

Measured memory_bytes: 608
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,a[110];

int main(){
    cin >> N;

    int i,sum=0;
    for (i=1; i<=N; i++){
        cin >> a[i];
        sum+=a[i];
    }

    if (sum%10!=0){
        cout << sum << "\n";
        return 0;
    }

    int res=0;
    for (i=1; i<=N; i++)
        if (a[i]%10!=0)
            res=max(res,sum-a[i]);

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}

int main(void)
{
    int na, nb, nc;
   scanf("%d", &na);
   scanf("%d", &nb);
   scanf("%d", &nc);
    
    sort3(&na, &nb, &nc);
    printf("%d %d %d\n", na,nb,nc);
    
    return (0);
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 33;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int c;
int a[N][N];
int d[3][N];
vector < int > v[3];

void solve()
{
        cin >> n >> c;
        for(int i = 1; i <= c; i++){
                for(int j = 1; j <= c; j++){
                        cin >> a[i][j];
                }
        }
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                        int x;
                        cin >> x;
                        v[(i + j) % 3].push_back(x);
                }
        }
        for(int i = 0; i < 3; i++){
                for(int j = 1; j <= c; j++){
                        for(int x: v[i]){
                                d[i][j] += a[x][j];
                        }
                }
        }
        int ans = 1e9;
        for(int i = 1; i <= c; i++){
                for(int j = 1; j <= c; j++){
                        for(int h = 1; h <= c; h++){
                                if(i == j || i == h || j == h){
                                        continue;
                                }
                                ans = min(ans, d[0][i] + d[1][j] + d[2][h]);
                        }
                }
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1520
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n = 3 , i , x , j , temp , q;
    long long int arr[n][n] , hash[n][n];
    for(i = 0 ; i < 3 ; i++){
        for(j = 0 ; j < 3 ; j++){
            cin >> arr[i][j];
            hash[i][j] = 0;
        }
    }
    cin >> q;
    while(q--){
        cin >> x;
        for(i = 0 ; i < 3 ; i++){
            for(j = 0 ; j < 3 ; j++){
                if(arr[i][j] == x){
                    hash[i][j] = 1;
                }
            }
        }
    }
    bool flag = false;
    for(i = 0 ; i < 3 ; i++){
        temp = 0;
        for(j = 0 ; j < 3 ; j++){
            temp += hash[i][j];
        }
        if(temp == 3){
            flag = true;
        }
    }
    for(i = 0 ; i < 3 ; i++){
        temp = 0;
        for(j = 0 ; j < 3 ; j++){
            temp += hash[j][i];
        }
        if(temp == 3){
            flag = true;
        }
    }
    temp = 0;
    for(i = 0 ; i < 3 ; i++){
        for(j = 0 ; j < 3 ; j++){
            if(i == j)
            temp += hash[j][i];
        }
    }
    if(temp == 3){
        flag = true;
    }
    temp = 0;
    for(i = 0 ; i < 3 ; i++){
        for(j = 0 ; j < 3 ; j++){
            if((i + j) == n - 1){
                temp += hash[j][i];
            }
        }
    }
    if(temp == 3){
        flag = true;
    }
    if(flag){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for i in range(1,n+1):
    s = str(i)
    k = (s[0],s[-1])
    d[k] += 1

ans = 0
for i in range(1,n+1):
    s = str(i)
    k = (s[-1],s[0])
    ans += d[k]
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){

    int n;
    cin>>n;

    if (n>=30){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

    


}








            






Measured memory_bytes: 3620
package main

import(
	"fmt"
)

func gcd(a,b int)int{
	for a>0{
		a,b=b%a,a
	}
	return b
}

func lcd(a,b int)int{
	return a*b/gcd(a,b)
}

func divNum(a,b,c int)int{
	return b/c-(a-1)/c
}

func main(){
	var a,b,c,d int
	fmt.Scanln(&a,&b,&c,&d)
	cd:=lcd(c,d)
	divisable_num:=divNum(a,b,c)+divNum(a,b,d)-divNum(a,b,cd)
	ans:=b-a+1-divisable_num
	fmt.Println(ans)
}

Measured memory_bytes: 512
# Drawing Lots

import sys


w = 0
n = 0
lots = None

for (i, line) in enumerate(sys.stdin):
	if i == 0:
		w = int(line)
		lots = [lot for lot in xrange(1, w+1)]
	elif i == 1:
		n = int(line)
	else:
		a, b = map(int, line.split(","))
		lots[b-1], lots[a-1] = lots[a-1], lots[b-1]

for i in xrange(w):
	print lots[i]

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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 200005;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int n;
pair<int, int> x[MAXN];
int b[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i].first;
        x[i].second = i;
    }
    sort(x, x + n);

    for (int i = 0; i < n; i++) {
        int j = n / 2 - (i >= n / 2);
        b[x[i].second] = x[j].first;
    }
    for (int i = 0; i < n; i++)
        cout << b[i] << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    string s; cin >> s;
    int mx = 0,tmp = 0;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == 'A'|| s[i] == 'T'|| s[i] == 'G'|| s[i] == 'C'){
            tmp++;
            if(i == n-1){
                mx = max(mx,tmp);
            }
        } else {
            mx = max(mx,tmp);
            tmp = 0;
        }
    }
    cout << mx << endl;
    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[][] A = new int[3][3];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                A[i][j] = sc.nextInt();
            }
        }

        int N = sc.nextInt();

        int[] b = new int[N];
        for(int i=0; i<N; i++){
            b[i] = sc.nextInt();
        }

        int[][] x = new int[3][3];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                x[i][j] = 0;
                for(int k=0; k<N; k++){
                    if(A[i][j]==b[k]){
                        x[i][j] = 1;
                        break;
                    }
                }
            }
        }

        for(int i=0; i<3; i++){
            if(x[i][0]==1 && x[i][1]==1 && x[i][2]==1){
                System.out.println("Yes");
                return;
            }
        }
        for(int i=0; i<3; i++){
            if(x[0][i]==1 && x[1][i]==1 && x[2][i]==1){
                System.out.println("Yes");
                return;
            }
        }
        if(x[0][0]==1 && x[1][1]==1 && x[2][2]==1){
            System.out.println("Yes");
            return;
        }
        if(x[2][0]==1 && x[1][1]==1 && x[0][2]==1){
            System.out.println("Yes");
            return;
        }

        System.out.println("No");
    }
}

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

int main() {
	int n; cin >> n;
	int arr[n];
	int maxi = 0;
	for (int i = 0; i < n; i++) {
	    cin >> arr[i];
	    maxi = max(maxi, arr[i]);
	}
	int many = 0;
	for (int i = 0; i < n; i++) {
	    if (arr[i] == maxi) many++;
	}
	if (many > 1) {
	    for (int i = 0; i < n; i++) {
	        cout << maxi;
	        if (i != n - 1) cout << endl;
	    }
	}
	else {
	    int nextmax = -1;
	    for (int i = 0; i < n; i++) {
	        if (arr[i] != maxi) nextmax = max(nextmax, arr[i]);
	    }
	    for (int i = 0; i < n; i++) {
	        if (arr[i] == maxi) cout << nextmax;
	        else cout << maxi;
	        if (i != n - 1) cout << endl;
	    }
	}
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
/*
bool prime(ll n){if(n==1)return false;for(ll i=2;i*i<=n;i++)if(n%i==0){return false;}return true;}
void prime_fact(int n){for(int i=2;i*i<=n;i++){int count=0;if(n%i==0){while(n%i==0)n/=i,count++;cout<<i<<"^"<<count<<" ";}}if(n>1)cout<<n<<"^1";}
ll power(ll base ,ll pow){ll res=1;while(pow>0){if(pow&1)res*=base,pow-=1;else base*=base,pow/=2;}return res;}
void prime_fact_seieve(int n){for(int i=2;i<=size;i++){if(A[i]==0)for(ll j=i;j<=size;j+=i)if(A[i]==0)A[j]=i;}while(n>2){cout<<A[n]<<"*";n/=A[n];}}
template <class X> X gcd(X a , X b) { return b==0?a: gcd( b, a%b); }
template <class X> X lcm(X a , X b) { return a/gcd(a,b) * b ; }
ll Ab[N][N],I[N][N];  // identity matrix and a matrix to store result
void multiply(ll I[][N],ll A[][N],int dim)
{   int res[dim+1][dim+1];
    for(int i=0;i<dim;i++)
    {  for(int j=0;j<dim;j++)
        {
           res[i][j]=0;
           for(int k=0;k<dim;k++)
           {  res[i][j]+=((I[i][k]%mod)*(A[k][j])%mod)%mod;}}}

        for(int i=0;i<dim;i++)
            for(int j=0;j<dim;j++)
                I[i][j]=res[i][j];}
void powerMat(ll A[][N],int dim,int n)
{   for(int i=0;i<dim;i++)
    for(int j=0;j<dim;j++)
    {if(i==j) I[i][j]=1;
     else     I[i][j]=0;}
     while(n>0)
     {
         if(n%2)
         multiply(I,A,dim),n--;
         else
         multiply(A,A,dim),n/=2;
     }
     for(int i=0;i<dim;i++)
         for(int j=0;j<dim;j++)
             A[i][j]=I[i][j];
}
void printMat(ll A[][N],int dim)
{
    for(int i=0;i<dim;i++)
    {for(int j=0;j<dim;j++)
        {
            cout<<A[i][j]<<" ";
        }cout<<"\n";}
}
// REMEMBER PREFIX SUM SUFFIX SUM OR GCD VERY INTERESTING QUESTIONS
ll power(ll base ,ll pow,ll mo){ll res=1;while(pow>0){if(pow&1)res=(res%mo*base%mo)%mo,pow-=1;else base=(base%mo*base%mo)%mo,pow/=2;}return res;}*/
bool Binary(vector<int> arr,int n,int ele,int b)
{  int l=0,r=n-1,m;
   while(l<=r)
   {
       m=l+(r-l)/2;
       if(arr[m]==ele)
       {arr[m]=b;return true;}
       else if(arr[m]>ele)
           r=m-1;
       else
           l=r+1;
   }
    return false;

}
int t[101][1001];
int Knap(int wt[],int val[],int W,int n)
{
    if(n==0||W==0)
        return 0;
    if(t[n][W]!=-1)
        return t[n][W];
    if(wt[n-1]>W)
        return t[n][W]=Knap(wt,val,W,n-1);
    else if(wt[n-1]<=W)
        return t[n][W]=max((val[n-1]+Knap(wt,val,W-wt[n-1],n-1)),Knap(wt,val,W,n-1));

}
ll power(ll base,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1)
            res*=base,p--;
        else
            base*=base,p/=2;

    }
    return res;
}

int count(int x,int y,int n,int m)
{
    int ans=4;
    if(x==0||x==n-1)
        ans--;
    if(y==0||y==m-1)
        ans--;
    return ans;
}

int main()
{   fast;
    int n;
    cin>>n;
    if(n%1000==0)
        cout<<0;
    else
        cout<<1000-n%1000;





}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int solve(int n, int x, int y){
	int ans;
	if(y <= x)ans = y%3;
	else ans = x%3;
	if(!ans)return 3;
	else return ans;
}

int main(){
	int n, k, x, y;
	scanf("%d%d", &n, &k);
	int m = (n+1)/2;
	for(int i = 0;i < k;i++){
		scanf("%d%d", &x, &y);
		if(m < x)x = n-x+1;
		if(m < y)y = n-y+1;
		printf("%d\n", solve(n, x, y));
	}
	return 0;
}

Measured memory_bytes: 3224
def solve(N, A):
    a = [(i, ai) for i, ai in enumerate(A)]
    a.sort(key=lambda x: x[1], reverse=True)

    # import numpy as np
    # dp = np.zeros((N+1, N+1), np.int8)

    dp = [[0] * (N + 1) for _ in range(N + 1)]

    dp[0][0] = 0
    for i, ai in enumerate(a):
        for l in range(i+1):
            r = i - l
            dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ai[1] * ((N-1-r) - ai[0]))
            dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + ai[1] * (ai[0] - l))

    print(max(dp[N]))

N = int(input())
A = list(map(int, input().split()))
solve(N,A)

Measured memory_bytes: 124600
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	while(cin >> str)
	{
		int cntJ=0; int cntI=0;
		for(int i=0;i<str.size()-2;i++)
		{
			string ptr;
			ptr=str.substr(i,3);
			if(ptr=="JOI") cntJ++;
			if(ptr=="IOI") cntI++;
		}
		cout << cntJ << '\n' << cntI << '\n' ;
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORI(i, y, x) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, a[200005], c[200005];
vector <int> v;
int main() {
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    int k = n/2 + 1;
    FOR(i, k, n) {
        c[i] = a[i];
        if (a[i] == 1) v.pb(i);
    }
    for (int i=k-1; i>=1; i--) {
        int cnt = 0;
        for (int j=i+i; j<=n; j+=i) cnt += c[j];
        //printf("%d %d\n", i, cnt);
        cnt %= 2;
        if (cnt != a[i]) {
            c[i]++;
            v.pb(i);
        }
    }
    int size = v.size();
    cout << size << endl;
    FOR(i, 0, size-1) printf("%d%c", v[i], i==size-1? '\n' : ' ');
    return 0;
}

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

int main() {
	ll q,h,s,d; cin >> q >> h >> s >> d;
	ll n; cin >> n;
	h=min(2*q,h);
	s=min(2*h,s);
	ll w=n/2;
	ll y=n%2;
	ll ans=min(2*s,d)*w+y*s;
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, arr[200], i, count = 0;
  bool isOdd;
  cin >> n;
  
  for(i = 0; i < n;i++){
    cin >> arr[i];
  }
  
  
  while(isOdd == false){
      for(i = 0; i < n;i++)
      {
        if(arr[i] % 2 == 1){
            //isOdd = true;
            
            goto conout;
        }
        
        arr[i] /= 2;
      }
      
      count++;
  }
    
      conout:
      cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import statistics

def get_data():
    data = int(input())
    return data

def get_data_list():
    data_list = input().split()
    for i, v in enumerate(data_list):
        data_list[i] = int(v)
    return data_list

def count_num_under_average(list_num, reverse_sorted_num_list, average_num):
    count = list_num
    for v in reverse_sorted_income_list:
        if v > average_num:
            count -= 1
        else:
            break
    return count


if __name__ == "__main__":
    while True:
        population = get_data()
        if population == 0:
            break
        income_list = get_data_list()
        reverse_sorted_income_list = sorted(income_list, reverse=True)
        average_income = statistics.mean(reverse_sorted_income_list)
        count = count_num_under_average(population, reverse_sorted_income_list, average_income)
        print(count)




Measured memory_bytes: 7804
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int N;
int diff[MaxN];
LL PowerMod(LL a, LL b, LL c) 
{
	LL ans = 1;
	a = a % c;
	while(b>0)
	{
		if(b % 2 == 1) ans = (ans * a) % c;
		b = b/2;
		a = (a * a) % c;
	}
	return ans;
}
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d", &N);
    for(int i=1;i<=N;i++) scanf("%d", &diff[i]);
    sort(diff+1, diff+1+N, [](int x,int y){return x>y;});
    bool flag = true;
    int cnt = N-1, num = 0;
    for(int i=1;i<=N&&flag;i++)
    {
        if(diff[i] == cnt)
        {
            num++;
            if(num==2)
            {
                cnt -=2;
                num = 0;
            }
        }
        else flag = false;
    } 
    if(flag) printf("%lld\n", PowerMod(2,N/2,mod));
    else puts("0");
    //system("pause");
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{


  int a,b,c;
  while(cin>>a>>b>>c)
  {
      if((a+b)>=c&&a<=c)
        cout<<"YES"<<endl;
      else
        cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    string s;
    cin >> s;
    repi(i,s.size(),0){
        if(s.at(i) == '7'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s;
  cin >> s;
  char bef = s[0];
  repz(i, 1, SIZE(s)) {
    if (bef == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
      bef = s[i];
  }
  cout << "Good" << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	double t,x;
	cin >> t >> x;
	cout << t / x << endl;
}

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

bool solve() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll x = C - A - B;
    ll y = 4 * A * B;
    if ( x < 0 ) return false;
    return x*x > y;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

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 n, x, t;
  cin >> n >> x >> t;

  if ((n / x) * x >= n)
  {
    cout << (n / x) * t << endl;
  }
  else
  {
    cout << (n / x + 1) * t << endl;
  }

  return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_7_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            HashSet<int> hs = new HashSet<int>();
            for (int i = 0 ; i < n ; i++)
            {
                int[] line = ReadIntAr();
                switch (line[0])
                {
                    case 0:
                        hs.Add(line[1]);
                        Console.WriteLine(hs.Count());
                        break;
                    case 1:
                        Console.WriteLine(hs.Contains(line[1]) ? 1 : 0);
                        break;
                    case 2:
                        hs.Remove(line[1]);
                        break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 28596
def c_unification(S):
    stack = []
    ans = 0
    for c in S:
        if len(stack) == 0:
            stack.append(c)
        elif (stack[-1] == '0' and c == '1') or (stack[-1] == '1' and c == '0'):
            stack.pop()
            ans += 2
        else:
            stack.append(c)
    return ans

S = input()
print(c_unification(S))

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

using namespace std;

char st[107010];
int l,r,ans;
int main() {
	scanf("%s",st);
	int l=0,r=strlen(st)-1;
	while(l<=r){
		if(st[l]==st[r]){
			l++;r--;
			continue;
		}
		if(st[l]=='x'){
			l++;
			ans++;
			continue;
		}
		if(st[r]=='x'){
			r--;
			ans++;
			continue;
		}
		printf("%d\n",-1);
		return 0;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import math
n = int(input())
ans=0
k = [[0]*10 for i in range(10)]

for i in range(1,n+1):
  j = str(i)
  l = int(j[0])
  r = int(j[-1])
  k[l][r]+=1
  
for i in range(10):
  for j in range(10):
    if i==0 or j==0:
      continue
    if i==j:
      ans += k[i][j]*k[i][j]
    else:
      ans += k[i][j]*k[j][i]
print(ans)

Measured memory_bytes: 73532
from collections import deque

n = int(input())
d = deque()
for i in range(n):
    tmp = input().split()
    ope = tmp[0]
    if ope == "insert":
        m = tmp[1]
        d.appendleft(m)
    elif ope == "delete":
        m = tmp[1]
        if m in d:
            d.remove(m)
    elif ope == "deleteFirst":
        d.popleft()
    elif ope == "deleteLast":
        d.pop()
print(*d)

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

int main() {
	int N;
	cin >> N;
	long A[N];
	for(int i=0; i<N; ++i){
		cin >> A[i];
	}
	
	long a=A[0];
	long ans=1;
	int d=0; //incr:1 decr:-1 other:0
	for(int i=1; i<N; ++i){
		if(a<A[i]){
			if(d==-1){ans++;d=0;}
			else if(d==0){d=1;}
		}
		if(a>A[i]){
			if(d==1){ans++;d=0;}
			else if(d==0){d=-1;}
		}
		a=A[i];
		
		//cout<< "i=" << i << ":" << "d=" << d << ":ans=" << ans << endl;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
long long dp[605][605], fact[605], ans;
int x[605], y[605], pre[605];
int main()
{
	// freopen("AGC028-D.in", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	n <<= 1;
	fact[0] = 1;
	for (int i = 2; i <= n; i++) {
		fact[i] = fact[i - 2] * (i - 1) % MOD;
	}
	for (int i = 0; i < k; i++) {
		scanf("%d%d", x + i, y + i);
		pre[--x[i]] = pre[--y[i]] = 1;
	}
	for (int i = 0; i < n; i++) {
		pre[i] = !pre[i] + (i ? pre[i - 1] : 0);
	}
	for (int l = 0; l < n; l++) {
		for (int r = l + 2; r <= n; r += 2) {
			int cnt = pre[r - 1] - (l ? pre[l - 1] : 0);
			if (cnt & 1) {
				continue;
			}
			bool flg = true;
			for (int i = 0; i < k; i++) {
				flg &= (l <= x[i] && x[i] < r) == (l <= y[i] && y[i] < r);
			}
			if (!flg) {
				continue;
			}
			dp[l][r] = fact[cnt];
			for (int i = l + 2; i < r; i += 2) {
				(dp[l][r] -= dp[l][i] * fact[pre[r - 1] - pre[i - 1]]) %= MOD;
			}
			(ans += dp[l][r] * fact[n - cnt - (k << 1)]) %= MOD;
		}
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int flag = 2;
		for (int i = 357; i <= n; i += 2) {
			if (is753(i)) {
				count++;
			}
			flag++;
			if (flag == 3) {
				flag = 0;
				i += 14;
			}
		}
		
		System.out.println(count);
		
	}

	
	public static boolean is753(int x) {
		int count7 = 0;
		int count5 = 0;
		int count3 = 0;
		while (x != 0) {
			switch (x % 10) {
				case 7 :
				count7++;
				break;
				case 5 :
				count5++;
				break;
				case 3:
				count3++;
				break;
				default :
				return false;
			}
			x /= 10;
		}
		return (count7 * count5 * count3 > 0);			
	}
	
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int a[20];
int b[200];
bool re[21][2001];
int n,q;
int in_or_not(int m){
    for(int i=0;i<n;i++)
        re[i][0]=true;
    for(int i=1;i<=m;i++)
    {
        if(a[0]==i)
            re[0][i]=true;
        else
            re[0][i]=false;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(re[i-1][j]==true)
                re[i][j]=true;
            else{
                if(j-a[i]>=0&&re[i-1][j-a[i]]==true)
                    re[i][j]=true;
                else
                    re[i][j]=false;
            }
        }
    }
    if(re[n-1][m]==true)
        cout<<"yes"<<endl;
    else
        cout<<"no"<<endl;
    return 0;
}
int main(){

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

    return 0;
}



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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long long> a(n+1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	long counter = 0;
	long numm = 1;
	for (long i = 1; i <= n; i++) {
		if (a[i] == numm) { 
			counter++;
			numm++;
		}
	}

	cout << (counter!=0? n-counter : -1) << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a[3];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    puts(a[0] * a[0] + a[1] * a[1] == a[2] * a[2] ? "YES" : "NO");
  }
  return 0;
}



Measured memory_bytes: 3132
# Longest non-increasing subsequenceの長さを求める
import sys
input = sys.stdin.readline

def bisect_right_reverse(L, target):
    ok = len(L)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if L[mid] < target:
            ok = mid
        else:
            ng = mid
    return ok

N = int(input())
A = [int(input()) for _ in range(N)]

dp = [-1]  # A[i] >= 0なので、A[0] > dp[0]となる。
for i in range(N):
    k = bisect_right_reverse(dp, A[i])
    if k == len(dp):
        dp.append(A[i])
    else:
        dp[k] = A[i]

print(len(dp))

Measured memory_bytes: 13636
/*
R         R R R R        R        R R R      R      R    R    R      R    R R R R                                                     
R         R             R R       R    RR    R R    R    R    R R    R    R              
R         R            R   R      R R R      R  R   R    R    R  R   R    R   R R                 
R         R R R       R R R R     R R        R   R  R    R    R   R  R    R     R                       
R         R          R       R    R   RR     R    R R    R    R    R R    R     R           
R R R R   R R R R   R         R   R     RR   R      R    R    R      R    R R R R               

*/


#include<bits/stdc++.h>
using namespace std;
#define  bf            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll            long long
#define  pb            push_back
#define  pr            10
#define  mx            100000 // 10^6
#define  md            1000000007
#define  result(a)     cout<<a<<endl;
#define  forr(a,x)     for(int i=a;i<=x;i++)
#define  input(n,a)    int a[n];for(int i=0;i<n;i++)cin>>a[i];
#define  print(a)      for(auto it:a)cout<<it<<' '; //0-based 
#define  printt(n,a)   for(i=0;i<n;i++)cout<<a[i]<<' '; //1-based 
#define  sz(a)         cout<<a.size()<<endl; 
#define  prefx(n,a)    for(i=1;i<n;i++)a[i]=a[i-1]+a[i]; //0-based
#define  sortt(v)      sort(v.begin(),v.end());
#define  srt(n,a)      sort(a,a+n);
#define  rev(n,a)      reverse(a,a+n);
#define  revr(a)       reverse(a.begin(),a.end());
#define  yes           cout<<"Yes\n";
#define  no            cout<<"No\n";

int main()
{
  int a,b;
  cin>>a>>b;
  if(a<=8&&b<=8)
  {
    cout<<"Yay!\n";
  }
  else
  {
    cout<<":(\n";
  }
}


Measured memory_bytes: 3620
k=input()
lis=list(k)


if lis[-1]=="2" or lis[-1]=="4" or lis[-1]=="5" or lis[-1]=="7" or lis[-1]=="9":
	print('hon')
elif lis[-1]=="0" or lis[-1]=="1" or lis[-1]=="6" or lis[-1]=="8":
	print('pon')
elif lis[-1]=="3":
	print('bon')





Measured memory_bytes: 61696
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std ;

#define int long long

const int N = 400010 ; 

int n, p ;
int g[N] ; 
int s[N] ; 
int buc[N] ;
int base[N] ; 
long long ans ;
map<int, int>res ;

int expow(int a, int b){
	int res = 1 ; a %= p ; 
	while (b){
		if (b & 1)
			(res *= a) %= p ;
		(a *= a) %= p ; b >>= 1 ;
	}
	return res ;
}
signed main(){
	cin >> n >> p ;	
	if (p == 5 || p == 2){
		for (int i = 1 ; i <= n ; ++ i){
			scanf("%1lld", &base[i]) ; base[i] %= p ;
			if (!base[i]) ans += (long long)(i - 1), ++ ans ;
		}
		cout << ans << endl ; 
		return 0 ; 
	}
	res[0] = 1 ; g[0] = expow(10, p - 2) ; 
	for (int i = 1 ; i <= n ; ++ i){
		scanf("%1lld", &base[i]) ;
		(g[i] = g[i - 1] * 10) %= p ;
		s[i] = (s[i - 1] * 10 % p + base[i]) % p ;
		res[(s[i] * expow(g[i], p - 2) % p + p) % p] ++ ;
	}
	for (int i = 0 ; i < n ; ++ i){
		res[s[i] * expow(g[i], p - 2) % p] -- ;
		ans += res[s[i] * expow(g[i], p - 2) % p] ;
		//cout << ans << " " ;
	}
	cout << ans << endl ;
	return 0 ; 
}


Measured memory_bytes: 8576
from collections import deque
import sys
H,W=map(int,input().split())
S =[]
kuro=0
for i in range(H):
    s = list(input())
    for j in s:
        if j=='#':
            kuro +=1
    S.append(s)

visit=[[False]*W for i in range(H)]
dist=[[]]
kei=deque()
kei.append((0,0,1))
visit[0][0]=True
X =[-1,0,1,0]
Y=[0,-1,0,1]
while kei:
    y,x,d=kei.popleft()
    if y==H-1 and x==W-1:
        print(H*W-d-kuro)
        sys.exit()
    for i in range(4):
        nx = x +X[i]
        ny = y +Y[i]
        if (0<=nx< W) and (0<=ny<H) and S[ny][nx]=='.':
            if not visit[ny][nx]:
                kei.append((ny,nx,d+1))
                visit[ny][nx]=True
print(-1)


Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
int len,p=0,g=0,score=0;
char s[100010];

int main()
{
	int i,j;
	
	scanf("%s",s);
	len = strlen(s);
	
	for(i=0;i<len;i++)
	{
		if(s[i]=='p')
		{
			if(p<g)
			{
				p++;
			}
			else
			{
				g++;
				score--;
			}
		}
		else if(s[i]=='g')
		{
			if(p<g)
			{
				p++;
				score++;
			}
			else
			{
				g++;
			}
		}
	}
	
	printf("%d\n",score);
}

Measured memory_bytes: 3920
x = gets.to_i

def is_not_prime?(n)
  for i in Math.sqrt(n).floor.downto(2)
    if n % i == 0
      return true
    end
  end
  false
end

loop do
  if is_not_prime?(x)
    x = x.next
  else
    break
  end
end
puts x


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << (n - 1) * n / 2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int N,i;
int A,B,C[100000];
long long int a,b;
int main()
{
	N=read();
	for(i=0;i<N;i++)
	{
		A=read();
		B=read();
		C[i]=A+B;
		b+=B;
	}
	sort(C,C+N,greater<int>());
	for(i=0;i<N;i+=2)
	{
		a+=C[i];
	}
	cout << a-b;
	return 0;
}




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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<pair<string, pair<int, int>>> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first >> p[i].second.first;
    p[i].second.first = -p[i].second.first;
    p[i].second.second = i+1;
  }
  sort(p.begin(), p.end());
  for(int i=0;i<n;++i) {
    cout << p[i].second.second << endl;
  }

}


Measured memory_bytes: 256
int main()
{
  char c;
  int change;
  int cnt;
  int end=0;
  int hand,nowhand;
  while(1)
    {
      cnt=0;
      change=0;
      while(1)
	{
	  scanf("%c",&c);
	  if(c=='#')
	    {
	      end=1;
	      break;
	    }
	  if(c=='\n') break;
	  switch(c)
	    {
	    case 'y':
	    case 'u':
	    case 'i':
	    case 'o':
	    case 'p':
	    case 'h':
	    case 'j':
	    case 'k':
	    case 'l':
	    case 'n':
	    case 'm':
	      hand=1;
	      break;
	    default:
	      hand=0;
	      break;
	    }
	  if(cnt==0) nowhand=hand;
	  else if(hand!=nowhand)
	    {
	      change++;
	      nowhand=hand;
	    }
	  cnt++;
	}
      if(end) break;
      printf("%d\n",change);
    }
  return 0;
}

Measured memory_bytes: 536
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


int main() { 
    string a, b;
    cin >> a >> b;
    int ab = atoi((a+b).c_str());
    int n = (int)sqrt(ab);
    cout << (n*n == ab ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,s,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	x=0; s=0;
	while(1){
		x+=a;
		s++;
		if(s%7==0){
			x+=b;
		}
		if(c<=x){
		break;
		}
	}
	printf("%d\n",s);
	return 0;
}
		


Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

int main(){
  string s;
  cin>>s;
  if(s[0]==s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
w= list(map(int,input().split()))
s=sum(w)
ans=s
key=0
for i in range(n-1):
    s-=2*w[i]
    if(s<0):
        s=-s
        key=1
    ans=min(ans,s)
    if(key==1):
        s=-s
        key=0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int n;
ll h;
ll w;
ll A;
ll B;

int main()
{
	FAST;

	cin >> n >> h >> w;
	ll ans=0;
	rep(i,n) {
		cin >> A >> B;
		if ((h<=A) && (w<=B)) 
		{
			ans++;
		}
	}
	cout << ans <<LF;

	return 0;
}

Measured memory_bytes: 256
n,a,b = list(map(int,input().split()))
s = input()
y = 0
z = 0
for x in s:
    if x == 'a' and y+z<(a+b):
        print('Yes')
        y+=1
    elif x == 'b' and y+z<(a+b) and z<b:
        print('Yes')
        z+=1
    else:
        print('No')


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

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

    sort(s.begin(),s.end());
    for(int i=1; i<s.length(); i++){
        if(s[i] == s[i-1]){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

n, m, k = map(int, input().split())
mod = 998244353

fact = [1] * (n + 1)
ifact = [0] * (n + 1)
for i in range(1, n + 1):
    fact[i] = fact[i-1] * i % mod
ifact[n] = pow(fact[n], mod - 2, mod)
for i in range(n, 0, -1):
    ifact[i-1] = ifact[i] * i % mod

def comb(n, k):
    if k < 0 or k > n:
        return 0
    return fact[n] * ifact[k] * ifact[n-k] % mod

ans = 0
for i in range(k + 1):
    ans = (ans + comb(n - 1, i) * m * pow(m - 1, n - 1 - i, mod)) % mod
print(ans)

Measured memory_bytes: 24708
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
int main(void){
    int n,tmp,keta = 0;
    cin >> n;
    tmp = n;
    while(tmp > 0){
        tmp /= 10;
        keta++;
    }
    if(keta == 1){
        cout << n << endl;
    }else if(keta == 2){
        cout << 9 << endl;
    }else if(keta == 3){
        cout << n-90 << endl;
    }else if(keta == 4){
        cout << 909 << endl;
    }else if(keta == 5){
        cout << n-9090 << endl;
    }else{
        cout << 90909 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define strVecSORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int R,G;
  cin>>R>>G;
  cout<<(2*G)-R<<endl;
}


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int x[33] = {}, r = 0;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			x[a] += 1;
		}
	}
	for (int i = 1; i <= m; i++)
		if (x[i] == n) r++;
	cout << r << endl;
	return 0;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

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

ll A[10];
ll i, j, k;

int main(){
    rep(i,0,4){
        scanf("%lld", &A[i]);
    }
    k = -1e18;
    rep(i,0,2){
        rep(j,0,2){
            k = max(k, A[i] * A[j + 2]);
        }
    }
    printf("%lld\n", k);

    return 0;
}

Measured memory_bytes: 3824