akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int a, b, c; cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust";
	else cout << "win";
	return 0;
}

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

int n;

int main() {
    cin >> n;
    vector<int> a(3);
    a.at(0) = n % 10;
    n -= a.at(0);
    a.at(1) = (n / 10) % 10;
    n -= a.at(1) * 10;
    a.at(2) = n / 100;
    n = 0;
    if (a.at(2) < a.at(1)) { //450
        int b = a.at(2) + 1;
        n = b + b * 10 + b * 100;
    }
    else if (a.at(2) > a.at(1)) { //540
        n = a.at(2) + a.at(2) * 10 + a.at(2) * 100;
    }
    else { // 55?4
        if (a.at(1) < a.at(0)) { //556
            int b = a.at(2) + 1;
            n = b + b * 10 + b * 100;
        }
        else { //555
            n = a.at(2) + a.at(2) * 10 + a.at(2) * 100;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
a=[]
b=[]
for _ in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
a=sorted(a)
b=sorted(b)
if N%2==1:
    print(b[N//2]-a[N//2]+1)
else:
    print(int(((b[N//2-1]+b[N//2])/2-(a[N//2-1]+a[N//2])/2)*2+1))

Measured memory_bytes: 27020
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll l,r;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>l>>r;
    if(l+2019<=r){
        cout <<0<<"\n";
        return 0;
    }
    ll ans=100000;
    rep(i,l,r+1){
        rep(j,i+1,r+1){
            ans=min(ans, i*j%2019);
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
import math
def com(a):
    if a == 0 or a == 1:
        return 0
    elif a == 2:
        return 1
    else:
        return math.factorial(a)/2/math.factorial(a-2)
A = list(map(int, input().split()))
result  = int(com(A[0])+com(A[1]))
print (result)

Measured memory_bytes: 3060
import sys
import numpy as np

def main():
    N = int(sys.stdin.readline().rstrip())
    L = [int(x) for x in sys.stdin.readline().rstrip().split()]
    L = np.array(L)
    # L.sort()
    # print(L)
    cnt = 0

    if N < 3:
        print(0)
        return

    for i in range(N - 2):
        for j in range(i+1, N - 1):
            for k in range(j+1, N):
                # print((i+1, j+1, k+1), L[i], L[j], L[k])
                if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                    continue
                cnt += 1 if L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i]else 0

    print(cnt)


main()

Measured memory_bytes: 27124
#include <stdio.h>
#include <math.h>

int sosuufi(int n){
  int i;
  int flag=1;
  for(i=2;i<=(int)sqrt(n);i++){
    if(n%i==0){
      flag=0;
    }
  }
  return flag;
}

void sosuu(int*A){
  int i;
  int k=0;
  for(i=1;i<139;i++){
    if(sosuufi(10*i+1)==1){
      A[k]=10*i+1;
      k++;
    }
  }
}

int main(){
  int n;
  scanf("%d",&n);
  int A[55];
  sosuu(A);
  int i;
  for(i=0;i<n;i++){
    printf("%d ",A[i]);
  }
  return 0;
}


Measured memory_bytes: 128
//ABC089C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	long long int m = 0, a = 0, r = 0, c = 0, h = 0;
	long long int ans;
	for(int i=0;i<n;i++){
		cin >> s;
		if(s.at(0) == 'M'){
			a++;
		}else if(s.at(0) == 'A'){
			m++;
		}else if(s.at(0) == 'R'){
			r++;
		}else if(s.at(0) == 'C'){
			c++;
		}else if(s.at(0) == 'H'){
			h++;
		}
	}
	ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
	cout << ans << endl;
	return 0;
}

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

int main(){
	long double a,b,h,m;
	cin >> a >> b >> h >> m;
	double angle = M_PI*abs(6*m - (30*h + m/2))/180;
	double ans = sqrt(a*a+b*b-2*a*b*cos(angle));
	printf("%.14lf", ans);
    return 0;
}



Measured memory_bytes: 4232
l = raw_input().split()

N = int(l[0])
X = int(l[1])

acc = []

for i in range(N):
    acc.append(int(raw_input()))

acc.sort()
first, rest = acc[0], acc[1:]

priceAmt = reduce(lambda x,y: x+y ,rest)
rem = X - priceAmt

size = rem / first

print size + len(rest)


Measured memory_bytes: 2820
def solve():
    R, G, B, N = [int(_) for _ in raw_input().split()]
    X = min(R, G, B)
    if X == R:
        Y = min(G,B)
        Z = max(G,B)
    elif X == G:
        Y = min(R,B)
        Z = max(R,B)
    else:
        Y = min(R,G)
        Z = max(R,G)
    ret = 0
    for i in range(N/Z, -1, -1):
        for j in range((N - i * Z)/Y, -1, -1):
            sum2 = N - i * Z - j * Y
            if sum2 % X == 0:
                ret += 1
    print str(ret)

if __name__ == '__main__':
    solve()


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

ab_list = []
for i in range(N):
    a, b = map(int, input().split())
    ab_list.append((a,b))

ab_list = sorted(ab_list, key=lambda x: x[1])

#print()                                                                                 
t = 0
f = 0
for a,b in ab_list:
    #print(a,b,t)                                                                        
    t += a
    if t > b:
        f = 1
        break

if f == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 33396
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
#include<numeric>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/



int main() {
	long long N, K, cnt = 0, tmp, ans = 0;
	long long M;
	cin >> N >> M;
	vector<long long> k(M) , p(M);
	vector<vector<long long>> s;
	s = vector<vector<long long>>(M);
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		s[i] = vector<long long>(k[i]);
		for (int j = 0; j < k[i]; j++) {
			cin >> tmp;
			s[i][j] = tmp - 1;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < (int)pow(2, N); i++) {
		bool flag = true;
		for (int j = 0; j < M; j++) {
			cnt = 0;
			for (int l = 0; l < k[j]; l++) {
				cnt += (i >> s[j][l]) % 2;
			}
			if (cnt%2 != p[j]) {
				flag = false;
				break;
			}
		}
		if(flag) ans++;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
const int MAXN = 1e6+20;
const long long INF = 1e16;
using namespace std;
 
long long n,ans;
int main()
{
 
	ios_base::sync_with_stdio(0);
 
//	freopen("longpath.in", "r", stdin);
//	freopen("longpath.out", "w", stdout);
	cin>>n;
	ans = (n*(n+1))/2 - n;
	cout<<ans<<endl; 
 
 
}


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

int main()
{
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    for (int i = 0; i < X; i++) cin >> A[i];
    vector<ll> B(Y);
    for (int i = 0; i < Y; i++) cin >> B[i];
    vector<ll> C(Z);
    for (int i = 0; i < Z; i++) cin >> C[i];
    
    priority_queue<ll> q1, q2;
    for (int x = 0; x < X; x++) {
        for (int y = 0; y < Y; y++) {
            q1.push(A[x]+B[y]);
        }
    }
    for (int k = 0; k < min(K, X*Y); k++) {
        ll ab = q1.top(); q1.pop(); 
        for (int z = 0; z < Z; z++) {
            q2.push(ab+C[z]);
        }
    }

    for (int k = 0; k < K; k++) {
        ll ans = q2.top(); q2.pop();
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 43368
from sys import stdin
from itertools import combinations_with_replacement

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

ave = sum(li)/n
mi = 10**9
now = 0
for i,j in enumerate(li):
    if abs(j-ave) < mi:
        mi = abs(j-ave)
        now = i
print(now)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		long[] a = new long[N];
		for (int i = 0; i < N; ++i) {
			a[i] = Long.parseLong(sc.next());
		}
		Arrays.sort(a);
		long ans = 0;
		for (int t = N - 1; t > 5; --t) {
			for (int i = 0; i < (1 << 6); ++i) {
				if (Integer.bitCount(i) != 3) continue;
				ArrayList<Long> t1 = new ArrayList<Long>();
				ArrayList<Long> t2 = new ArrayList<Long>();
				for (int j = 0; j < 6; ++j) {
					if ((i & (1 << j)) == 0) {
						t1.add(a[t - j]);
					} else {
						t2.add(a[t - j]);
					}
				}
				if (tri(t1) && tri(t2)) {
					ans = Math.max(ans, a[t] + a[t - 1] + a[t - 2] + a[t - 3] + a[t - 4] + a[t - 5]);
				}
			}
		}
		boolean[] tri = new boolean[N];
		for (int i = 2; i < N; ++i) {
			ArrayList<Long> len = new ArrayList<Long>();
			for (int j = 0; j < 3; ++j) {
				len.add(a[i - j]);
			}
			tri[i] = tri(len);
		}
		long first = 0;
		int i = N - 1;
		while (i > 0) {
			if (tri[i]) {
				if (first > 0) {
					ans = Math.max(ans, first + a[i] + a[i - 1] + a[i - 2]);
					break;
				}
				first = a[i] + a[i - 1] + a[i - 2];
				i -= 2;
			}
			--i;
		}
		System.out.println(ans);
	}

	static boolean tri(ArrayList<Long> len) {
		return len.get(0) < len.get(1) + len.get(2);
	}

}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    int64_t
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,ans=0,w[101],v[101],m;
int dp[1001][1001];
string s[1001], t;
void solve(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#');
			else{
				if(i-1>=0)
					dp[i][j]+=dp[i-1][j];
				if(j-1>=0)
					dp[i][j]+=dp[i][j-1];
			}	
			dp[i][j]%=hell;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    
     string S[100];
    
    for(int i=0; i<H; i++){
            cin >> S[i];
        }
    //上
    for(int i=0; i< W+2; i++){
             cout<<"#";
        }
        cout<<endl;
        
    //左右
    for(int i=0; i< H; i++){
        cout<<"#"<<S[i]<<"#"<<endl;
    }
    
    //下
    for(int i=0; i< W+2; i++){
        cout<<"#";
    }cout << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int flag = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == S.at(i + 1))flag = 1;
  }
  if(flag == 0)cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}

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

int main(){
    char b;
    cin >> b;

    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}

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

ll maxDistance(ll n) {
    ll largestFactor = -1;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n%i == 0) {
            largestFactor = i;
        }
    }
    
    ll otherFactor = n/largestFactor;
    return largestFactor + otherFactor -2;
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    cout << maxDistance(n);
    return 0;
}

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

vector<ll> G[MAX_V]; // グラフ
ll color[MAX_V]; // 頂点iの色(1 or -1)
ll b = 0, w = 0;
// 頂点を1と-1で塗っていく
bool dfs(ll v, ll c) {
	color[v] = c; // 頂点vをcで塗る
	if (c == 1) b++;
	if (c == -1) w++;
	for (int i = 0; i < G[v].size(); i++) {
		// 隣接している頂点が同じ色ならfalse
		if (color[G[v][i]] == c) return false;
		// 隣接している頂点がまだ塗られていないなら-cで塗る
		if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
	}
	// すべての頂点を塗れたらtrue
	return true;
}

void solve(long long N, long long M, vector<long long> A, vector<long long> B){
	if (!dfs(0, 1)) printf("%lld\n", max(N*(N-1)/2-M,0LL)); else printf("%lld\n", max(b*w-M,0LL));
}

int main(){
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> B(M-1+1);
	vector<long long> A(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		G[A[i]-1].push_back(B[i]-1);
		G[B[i]-1].push_back(A[i]-1);
	}
	solve(N, M, A, B);
	return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  int n;
  cin >> n;
  
  //int a[n];
  int Amin = n+1, c=0;
  rep(i,n){
    int a;
    cin >> a;
    if(Amin>a){
      c++;
      Amin = a;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

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

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int k,x;cin >> k >> x;
    for(int i=x-(k-1);i<=x+(k-1);i++){
        cout << i << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
d = {}
while 1:
    try:
        se = input().lower()
    except:
        break
    for i in se:
        if i.isalpha():
            d[i] = d.get(i, 0) + 1
for i in 'abcdefghijklmnopqrstuvwxyz':
    d[i] = d.get(i, 0)
    print("{} : {}".format(i, d[i]))


Measured memory_bytes: 5560
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

INF = 10 ** 9

def dfs (cur, a, b, c):
   if (cur == N):
      return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

   ret0 = dfs(cur + 1, a, b, c)
   ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
   ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
   ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
   return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
n=gets.to_i
ab=n.times.map{gets.split.map(&:to_i)}
ans=0
plus=0
ab.reverse_each do |a,b|
  new_a=a+plus
  cur= new_a%b==0 ? 0:b-new_a%b
  ans+=cur
  plus+=cur
end
puts ans


Measured memory_bytes: 9596
#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(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	string ans = "NA";
	int X = int(S[0]-'0')*10 + int(S[1]-'0');
	int Y = int(S[2]-'0')*10 + int(S[3]-'0');
	if(0<X&&X<=12){
		if(0<Y&&Y<=12){
			ans = "AMBIGUOUS";
		}
		else{
			ans = "MMYY";;
		}
	}
	else if(X==0){
		if(0<Y&&Y<=12){
			ans = "YYMM";
		}
	}
	else{
		if(0<Y&&Y<=12){
			ans = "YYMM";
		}
		else{
			ans = "NA";
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll k,sum;
vector<vector<ll> > mul(vector<vector<ll> > v1, vector<vector<ll> > v2){
    vector<vector<ll> > res(k,vector<ll> (k));
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            sum=0;
            for(int n=0;n<k;n++){
                sum+=(v1[i][n]*v2[n][j]);
                sum%=mod;
            }
            res[i][j]=sum;
        }
    }
    return res;
}

vector<vector<ll> > matpow(vector<vector<ll> > a,ll n) {
    vector<vector<ll> > res(k,vector<ll> (k,0));
    for(int i=0;i<k;i++){
        res[i][i]=1;
    }
    while(n>0) {
        if (n&1)res=mul(res,a);
        a=mul(a,a);
        n>>=1;
    }
    return res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>k>>n;
    vector<vector<ll> > v(k);
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            cin>>x;
            v[i].pb(x);
        }
    }
    v=matpow(v,n);
    ll ans=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            ans+=v[i][j];
            ans%=mod;
        }
    }
    cout << ans<<endl;
    return 0;

}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    int n;
    double x[10], total = 0;
    char u[11][4];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%lf %s", &x[i], u[i]);
    }
    for(int i = 0; i < n; i++) {
        if(u[i][0] == 'J') total += x[i];
        else total += x[i]*380000;
    }
    printf("%f\n", total);
    return 0;
}


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


int main() {
	int v[3];
	cin >> v[0] >> v[1] >> v[2];
	sort(v, v+3);
	cout<<v[0]<<" "<<v[1] << " " <<v[2] <<endl;
	return(0);
}

Measured memory_bytes: 3136
#include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n; cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		if (isprime(a))sum++;
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll solve(int n,int* t,int* a){
    int maxh[100000],h[100000];
    fill(maxh,maxh+100000,0);
    fill(h,h+100000,0);
    ll res = 1;
    bool isP = 1;

    h[0] = t[0];
    for(int i = 1;i < n;i ++){
        if(t[i]!=t[i-1]) h[i] = t[i];
        else maxh[i] = t[i];
    }
    for(int i = n-1;i >=0;i --){
        if(i==n-1||a[i]!=a[i+1]){
            if(h[i] && a[i]!=h[i]) {isP = 0;break;}
            else h[i] = a[i];

            if(maxh[i] && h[i] > maxh[i]) {isP = 0;break;}
        }else{
            if(a[i]<h[i]) {isP = 0;break;}
            else maxh[i] = min(a[i],maxh[i]);
        }
    }
    if(!isP) return 0;
    else{
        for(int i = 0;i < n;i ++){
            if(!h[i]) res = (res*maxh[i])%mod;
        }
    }
    return res;
}

int main(){
    int n,t[100000],a[100000];
    cin >> n;
    for(int i = 0;i < n;i ++){
        cin >> t[i];
    }
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    cout << solve(n,t,a) << endl;
    return 0;
}

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

int main()
{
  uint64_t a, b;
  cin >> a >> b;
  if (a > 0) a--;
  uint64_t x[] {a, 1, a + 1, 0};
  uint64_t y[] {b, 1, b + 1, 0};
  cout << (x[a % 4] xor y[b % 4]) << endl;
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  string s; cin >> s;

  function< int(string) > rec =
  [&](string s){
    int res = 0;
    string pre; pre += s[0];
    for(int i = 1; i < s.size(); i++){
      string t; t += s[i];
      if(pre == t){
        t += s[++i];
      }
      pre = t;
      if(i < s.size()) res++;
    }
    return res + 1;
  };

  int res1 = rec(s);
  reverse(s.begin(),s.end());
  int res2 = rec(s);
  cout << max(res1,res2) << endl;

  return 0;
}


Measured memory_bytes: 772
t1, t2, r1, r2 = map(int, input().split())
if r1 != -1 and r2 != -1 :
    if r1 > r2 :
        print("Alice")
    elif r1 < r2 :
        print("Bob")
    else :
        print("Draw")
else :
    if t1 < t2 :
        print("Alice")
    elif t1 > t2 :
        print("Bob")
    else :
        print("Draw")


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int n;
    cin >> n;
    vi h(n);
    for(int i=0; i<n; i++)
        cin >> h[i];
    int currmax = h[0];
    bool check = true;
    for(int i=1; i<n; i++){
        if(h[i]>currmax)
            currmax = h[i];
        if(h[i]<currmax-1){
            check = false;
            break;
        }
    }
    if(check)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 640
using System;
class aoj
{
    static void Main()
    {
        int[, , ] k = new int[50, 11, 11];
        int[] m = new int[50];
        int s = 0;
        for (;;)
        {
            string a = Console.ReadLine();
            if (a == "0")
            {
                break;
            }
            int b = int.Parse(a);
            int[,] d = new int[b+1,b+1];
            for(int i = 0; i < b; i++)
            {
                int e = 0;
                string[] c = Console.ReadLine().Split(' ');
                for(int j = 0; j < b; j++)
                {
                    d[i, j] = int.Parse(c[j]);
                    k[s, i, j] = d[i, j];
                    e += d[i, j];
                }
                d[i, b] = e;
                k[s, i, b] = e;
            }
            int h = 0;
            for (int i = 0; i <= b; i++)
            {
                int e = 0;
                for (int j = 0; j < b; j++)
                {
                    e += d[j, i];
                }
                d[b,i] = e;
                k[s, b, i] = e;
                h += e;
            }
            h = h / 2;
            d[b, b] = h;
            m[s] = b;
            k[s, b, b] = d[b, b];
            s++;
           
        }
        for(int i = 0; i < s; i++)
        {
            for(int j = 0; j <= m[i]; j++)
            {
                for(int x = 0; x <= m[i]; x++)
                {
                    Console.Write("{0,5}" , k[i, j, x]);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9316
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	if (n % 2) {
		cout << 0 << E;
	}
	else {
		long long cnt = n / 2;
		long long sum2 = 0;
		while (cnt) {
			sum2 += cnt;
			cnt /= 2;
		}
		cnt = n / 2;
		long long sum5 = 0;
		cnt /= 5;
		while (cnt) {
			sum5 += cnt;
			cnt /= 5;
		}
		cout << min(sum2, sum5) << E;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

pub fn scan() -> String {
    let mut buf = String::new();
    let _ = io::stdin().read_line(&mut buf).unwrap();

    buf
}

fn main() {
    let s = scan();
    let s: Vec<&str> = s.split(" ").collect();
    let l = i32::from_str(s[0].trim()).unwrap();
    let k = i32::from_str(s[1].trim()).unwrap();

    let mut dp = vec![0 as i64; (l + 1) as usize];
    if 1 <= l {
        dp[1] = 1
    };
    if k <= l {
        dp[k as usize] = 1
    };

    let a = 1 + 1;
    let b = 1 + k;

    for i in 0..(l + 1) {
        if i >= a {
            dp[i as usize] += dp[(i - a) as usize];
        }
        if i >= b {
            dp[i as usize] += dp[(i - b) as usize];
        }
    }

    let mut sum: i64 = 0;
    for v in dp {
        sum += v;
    }

    println!("{}", sum);
}



Measured memory_bytes: 5068
import itertools
n,w = map(int,input().split())

d = dict()
p = dict()
for i in range(n):
    u,v = map(int,input().split())
    if d.__contains__(u):
        d[u]+=1
    else:
        d[u]=1
    if p.__contains__(u):
        p[u].append(v)
    else:
        p[u]=[v]

for k in p.keys():
    p[k].sort(reverse=True)
    acc = [0]
    for c in p[k]:
        acc.append(acc[-1]+c)
    p[k]=acc

d = list(d.items())
p = [p[item[0]] for item in d]
g = [item[0] for item in d]
d = [range(item[1]+1)for item in d]
res = 0
for t in itertools.product(*d):
    if(sum([g[i]*t[i] for i in range(len(t))])<=w):
        res = max(res,sum([p[i][t[i]] for i in range(len(t))]))
print(res)



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	string S; cin >> S;
	
	int ans = 0;
	FOR(i,1,N-1){
		map<char, int> left;
		map<char, int> right;
		REP(j,N){
			if(j < i) left[S[j]] = 1;
			else right[S[j]] = 1;
		}

		int cnt = 0;
		for(char s='a';s<='z';s++){
			if(left[s] == 1 and right[s] == 1) cnt++;
		}

		ans = max(ans, cnt);
	}


	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

int main() {
  string S;
  string K;
  string L;
  int N;
  cin >> N >> S;
  for(int i = 0; i < N/2; i++){
    K += S[i];
  }
  for(int j = N/2; j < N; j++){
    L += S[j];
  }

  if(K == L){
    cout << "Yes" <<endl;
    
    }
    else{
      cout << "No" <<endl;
    }
  }

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int[] h = new int[a];
    int minIndex=0;
    int sum=0;
    
    for(int i=0;i<a;i++){
      h[i] = sc.nextInt();
    }
    
    for(int i=0;i<a;i++){
      if(h[minIndex] <= h[i]){
        sum+=1;
        minIndex = i;
      }
    }
    System.out.println(sum);
  }
}
    

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ld>p(n);
  rep(i,0,n)cin>>p[i];
  auto dp=vec(n+1,n+1,ld(0));
  dp[0][0]=1;
  rep(i,0,n)rep(j,0,n+1){
    dp[i+1][j]+=dp[i][j]*(1-p[i]);
    if(j<n)dp[i+1][j+1]+=dp[i][j]*p[i];
  }
  ld ret=0;
  rep(i,(n+1)/2,n+1){
    ret+=dp[n][i];
  }
  cout lfs ret<<endl;
  return 0;
}

Measured memory_bytes: 141056
#include<stdio.h>	
int main(void)
{
		int n,a,b,c;
		scanf("%d",&n);
		scanf("%d",&a);
		scanf("%d",&b);
		c=n*a;
		if(c<b) {
		printf("%d\n",c);
		}
		else {
		printf("%d\n",b);
		}
		return 0;
}		

Measured memory_bytes: 128
n, m = map(int,input().split())
height = list(map(int,input().split()))

a = []
b = []
for i in range(m):
  tmp = list(map(int,input().split()))
  a.append(tmp[0])
  b.append(tmp[1])
  
atta = [1]*n
for j in range(m):
  if height[a[j]-1] == height[b[j]-1]:
    atta[a[j]-1] = 0
    atta[b[j]-1] = 0
  elif height[a[j]-1] < height[b[j]-1]:
    atta[a[j]-1] = 0
  elif height[a[j]-1] > height[b[j]-1]:
    atta[b[j]-1] = 0
  #print(j,atta)

print(atta.count(1))


Measured memory_bytes: 22232
#include <bits/stdc++.h>
 #define len length
// smile :)
using namespace std;
typedef long long ll;

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

int n,m,cnt=0;
cin>>n>>m;
int h[n];
int arr[n]={0};
for(int i=0;i<n;i++) cin>>h[i];

for(int i=0;i<m;i++)
{
    int a,b;
    cin>>a>>b;
    a--;
    b--;
  arr[a]=max(arr[a],h[b]);
  arr[b]=max(arr[b],h[a]);
}
// هل العنصر أكبر ولا قابل ارتفاع أكبر


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

    if(h[i]>arr[i])
    {
       cnt++;
    }

}

cout<<cnt;

 return 0;
}


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

string s[2];

int xa[3]={1,-1,0};

int n;

long long int ans = 0;

vector<int> v;//0が縦1つ,1が横に並んでいるドミノが2つ

int vsize;

//1r 2g 3b 4rg 5rb 6gr 7gb 8br 9bg

/*
void rep(vector<int> vec,int index){

    if(index == vsize){
        ans++;
        ans %= 1000000007;
        return;
    }
    if(v[index]==0){
        if(vec[index-1]!=1 && vec[index-1]!=4 && vec[index-1]!=5 && vec[index-1]!=6 && vec[index-1]!=8){
            vec[index] = 1;
            rep(vec,index+1);
        }
        if(vec[index-1]!=2 && vec[index-1]!=4 && vec[index-1]!=6 && vec[index-1]!=7 && vec[index-1]!=9){
            vec[index] = 2;
            rep(vec,index+1);
        }
        if(vec[index-1]!=3 && vec[index-1]!=5 && vec[index-1]!=7 && vec[index-1]!=8 && vec[index-1]!=9){
            vec[index] = 3;
            rep(vec,index+1);
        }
    }
    else{
        if(vec[index-1]!=1 && vec[index-1]!=2 && vec[index-1]!=4 && vec[index-1]!=5 && vec[index-1]!=9){
            vec[index] = 4;
            rep(vec,index+1);
        }

        if(vec[index-1]!=1 && vec[index-1]!=3 && vec[index-1]!=4 && vec[index-1]!=5 && vec[index-1]!=7){
            vec[index] = 5;
            rep(vec,index+1);
        }

        if(vec[index-1]!=1 && vec[index-1]!=2 && vec[index-1]!=6 && vec[index-1]!=7 && vec[index-1]!=8){
            vec[index] = 6;
            rep(vec,index+1);
        }

        if(vec[index-1]!=2 && vec[index-1]!=3 && vec[index-1]!=5 && vec[index-1]!=6 && vec[index-1]!=7){
            vec[index] = 7;
            rep(vec,index+1);
        }

        if(vec[index-1]!=1 && vec[index-1]!=3 && vec[index-1]!=6 && vec[index-1]!=8 && vec[index-1]!=9){
            vec[index] = 8;
            rep(vec,index+1);
        }

        if(vec[index-1]!=2 && vec[index-1]!=3 && vec[index-1]!=4 && vec[index-1]!=8 && vec[index-1]!=9){
            vec[index] = 9;
            rep(vec,index+1);
        }
    }
}
*/


int main() {

    cin >> n;

    cin >> s[0] >> s[1];



    for(int i=0;i<s[0].size();i++){
        if(s[0][i] == s[1][i]){
            v.push_back(0);
        }
        else{
            v.push_back(1);
            i++;
        }
    }

    vsize = v.size();

    if(v[0]==0){
        ans = 3;
    }
    else{
        ans = 6;
    }



    for (int i = 1; i<vsize; i++) {
        if(v[i-1]==v[i]){
            if(v[i-1] == 0){
                ans *= 2;
            }
            else{
                ans *= 3;
            }
        }
        else{
            if(v[i-1] == 0){
                ans *= 2;
            }
            else{
                ans *= 1;
            }
        }
        ans %= 1000000007;
    }
/*
    vector<int> v1(vsize);

    for(int i=1;i<=3;i++){
        v1[0] = i;
        rep(v1,1);
    }
*/
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int N;
long long int A[200005];
long long int MOD = 1000000007;



int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	long long int sum = 0;

	long long int ans = 0;

	for (int i = 1; i <= N; i++) {
		ans += sum*A[i]; ans %= MOD;
		sum += A[i]; sum %= MOD;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int p,q,s,t,u;
    string r;
    while(cin>>p>>q)
    {
        cin>>r;
        for(u=0;u<r.size();u++)
        {
            if(u+1==q)
            {
                r[u]=r[u]+32;
            }
        }
        cout<<r<<endl;
    }









    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,M;
    string S;
    cin >> N>>M;
    ll ans = 0;
    /*if(N){

    }
    else */if(N*2>=M){
        ll ans = M / 2;
        cout << ans << endl;
    }
    else{
        ans += N;
        M -= 2 * N;
        if(M<0){
            cout << 0 << endl;
        }
        else{
            ans += M / 4;
            cout << ans << endl;
        }

    }
}


Measured memory_bytes: 256
n_a,n_b,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
price=[]
for i in range(M):
    X=list(map(int,input().split()))
    price.append(A[X[0]-1]+B[X[1]-1]-X[2])
price.append(min(A)+min(B))
print(min(price))

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u) {
    cout << (a - 1) << " " << b;
  }
  else {
    cout << a << " " << (b - 1);
  }
}


Measured memory_bytes: 256
import Control.Applicative

convert :: String -> Int
convert x =
  case x of
    "A" -> 10
    "B" -> 11
    "C" -> 12
    "D" -> 13
    "E" -> 14
    "F" -> 15
    _   -> error "A-F"

main :: IO ()
main = do
  [x,y] <- map convert . words <$> getLine
  putStrLn $ solve x y
  where
    solve x' y'
     | x' > y' = ">"
     | x' < y' = "<"
     | otherwise = "="


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

using namespace std;

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

  // First +
  long long operation = 0, sum = a[0];
  if (sum <= 0) {
    operation += abs(sum) + 1;
    sum = 1;
  }
  for (int i = 1; i < n; i++) {
    long long tmp = sum + a[i];
    if (sum < 0) {
      if (tmp <= 0) {
	operation += abs(tmp) + 1;
	sum = 1;
      }
      else sum = tmp;
    }
    else {
      if (tmp >= 0) {
	operation += tmp + 1;
	sum = -1;
      }
      else sum = tmp;
    }
  }

  long long firstOperation = operation;
  
  // First -
  operation = 0, sum = a[0];
  if (sum >= 0) {
    operation += abs(sum) + 1;
    sum = -1;
  }
  for (int i = 1; i < n; i++) {
    long long tmp = sum + a[i];
    if (sum < 0) {
      if (tmp <= 0) {
	operation += abs(tmp) + 1;
	sum = 1;
      }
      else sum = tmp;
    }
    else {
      if (tmp >= 0) {
	operation += tmp + 1;
	sum = -1;
      }
      else sum = tmp;
    }
  }


  cout << min(firstOperation, operation) << endl;
  return 0;
}


Measured memory_bytes: 640
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
string X;

vector<LL> ans;

//xのうち、立っているbitの数を数える
LL calc_bit(LL x){
    LL target = x;
    LL res = 0;
    for(int i=0;i<=18;i++){
        res += (target)&1;
        target = (target>>1);
    }
    return res;
}

//xに操作を施したとき、何回で操作が終わるかをcounter[i]とする
vector<LL> counter;
//xに操作を施したとき、何回で操作が終わるかを返す
LL calc_counter(LL x){
    if(counter[x]!=-1) return counter[x];
    LL numof_bit = calc_bit(x);
    return calc_counter(x%numof_bit) + 1LL;
}

void solve(){
    //xに操作を施したとき、何回で操作が終わるかをcounter[i]とする
    counter = vector<LL>(200001,-1);
    counter[0] = 0;
    counter[1] = 1;
    counter[2] = 1;
    for(int i=2;i<=200000;i++){
        counter[i] = calc_counter(i);
    }

    //i桁目をビット反転したときの結果をans[i]とする
    ans = vector<LL>(N,0);

    LL numof_1 = 0;
    for(int i=0;i<N;i++) numof_1 += (X[i]-'0');

    if(numof_1==0){
        for(int i=0;i<N;i++){
            ans[i] = 1;
        }
        return;
    }

    //2のi乗をnumof_1-1で割ったあまりをpow2[i][0]
    //2のi乗をnumof_1+1で割ったあまりをpow2[i][1]
    //とおく
    vector<vector<LL>> pow2(200001,vector<LL>(2,1));
    for(int i=1;i<=200000;i++){
        if(numof_1-1>=1) pow2[i][0] = (pow2[i-1][0]*2LL)%(numof_1-1);
        pow2[i][1] = (pow2[i-1][1]*2LL)%(numof_1+1);
    }

    //Xをnumof_1-1で割ったあまりをX_div_numof_10とおく
    LL X_div_numof_10 = 0;
    if(numof_1-1>=1){
        for(int i=0;i<N;i++){
            if(X[i]=='1') X_div_numof_10 = (X_div_numof_10 + pow2[N-i-1][0])%(numof_1-1);
        }
    }
    //Xをnumof_1+1で割ったあまりをX_div_numof_11とおく
    LL X_div_numof_11 = 0;
    for(int i=0;i<N;i++){
        if(X[i]=='1') X_div_numof_11 = (X_div_numof_11 + pow2[N-i-1][1])%(numof_1+1);
    }

    for(int i=0;i<N;i++){
        if(X[i]=='0'){
            //numof_1+1を使う
            LL now = (X_div_numof_11 + pow2[N-i-1][1])%(numof_1+1);
            //この時点でnowはXのiビット目を1にしたものを(numof_1+1)で割ったあまりになっている
            ans[i] = counter[now] + 1;
        }
        if(X[i]=='1'){
            if(numof_1==1){
                ans[i] = 0;
            }else{
                //numof_1-1を使う
                LL now = (X_div_numof_10 - pow2[N-i-1][0] + (numof_1-1))%(numof_1-1);
                //この時点でnowはXのiビット目を0にしたものを(numof_1-1)で割ったあまりになっている
                ans[i] = counter[now] + 1;
            }
        }
    }
}

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

    solve();

    for(int i=0;i<N;i++)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 16972
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  string s,t;
  int count = 1;
  cin >> s;

  for (auto it = s.begin(); it != s.end(); ++it) {
    if (count%2 == 1)
      t += *it;
    ++count;
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,m,a[10000],b[10000];
int main(){
    scanf("%d",&n);
    if(n&1){
        for(int i=1;i<n;++i)a[++m]=i,b[m]=n;
        --n;
    }
    for(int i=1;i<=n/2;++i)
        for(int j=i+1;j<n-i+1;++j){
            a[++m]=i,b[m]=j;
            a[++m]=j,b[m]=n-i+1;
        }
    printf("%d\n",m);
    for(int i=1;i<=m;++i)printf("%d %d\n",a[i],b[i]);
}


Measured memory_bytes: 256
n = int( input() )
a = list( map( int, input().split() ) )
a = [ a[-1] ] + a + [ a[0] ]

x = [ 0 ] * ( n+1 )

for i in range( 1, n+1 ):
    x[n] = x[n] + a[i]

for k in range( 1, n//2+1 ):
    x[n] = x[n] - 2*a[ 2*k - 1 ]

for i in reversed( range( 1, n ) ):
    x[i] = 2*a[i] - x[i+1]

x = list( map( str, x ) )

print( " ".join( x[1:n+1] ) )

Measured memory_bytes: 18836
#include <iostream>

long long f(long long n)
{
    long long n_one = 0;
    long long x = 0, y = 0;
    long long ret = 0LL;
    if(n % 2 == 0){
        n_one = n / 2;
        x = n;
    }else{
        n_one = (n-1) / 2;
        x = n;
        y = n - 1;
    }
    if(n_one % 2 == 0){
        ret = x ^ y ^ 0LL;
    }else{
        ret = x ^ y ^ 1LL;
    }
    return ret;
}

int main(int argc, char **argv)
{
    long long A, B;
    std::cin >> A >> B;

    long long ans = A;
//    std::cout << "msb: " << msb << std::endl;
//    for(long long i = A+1; i <= B; i++){
//        ans ^= i;
//    }

    ans = f(A-1) ^ f(B);

    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 2e3 + 5;
const long long mod = 1e9 + 7;
using namespace std;

char s[maxn];
int x,y,a,b,c,t;
priority_queue<int , vector<int>,less<int> >q1;
priority_queue<int , vector<int>,less<int> >q2;
priority_queue<int , vector<int>,less<int> >q3;
priority_queue<int , vector<int>,greater<int> >aa;
priority_queue<int , vector<int>,greater<int> >bb;
long long ans;

int main(){
	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for(int i = 1; i <= a; i++){
		scanf("%d", &t);
		q1.push(t);
	}
	for(int i = 1; i <= b; i++){
		scanf("%d", &t);
		q2.push(t);
	}
	for(int i = 1; i <= c; i++){
		scanf("%d", &t);
		q3.push(t);
	}
	while(x--){
		aa.push(q1.top());q1.pop();
	}
	while(y--){
		bb.push(q2.top());q2.pop();
	}
	int mx,mn;
	while(!q3.empty()){
		mx = max(aa.top(),bb.top());
		mn = min(aa.top(),bb.top());
		//printf("%d %d\n",mx,mn);
		aa.pop();bb.pop();
		if(q3.top() > mn){aa.push(q3.top());bb.push(mx);q3.pop();}
		else{
			aa.push(mx);bb.push(mn);
			break;
		}
	}
	while(!aa.empty()){
		ans += aa.top();aa.pop();
	}
	while(!bb.empty()){
		ans += bb.top();bb.pop();
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2552
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
maximam=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    maximam=max(maximam,b-r)
print(maximam)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define EPS 1e-9
constexpr double PI = acos(-1);
int main() {
	struct Point {
		double x;
		double y;
	};
	int n = ri(), k = ri();
	Point pts[n];
	int c[n];
	for (int i = 0; i < n; i++) pts[i].x = ri(), pts[i].y = ri(), c[i] = ri();
	if (k == 1) {
		puts("0");
		return 0;
	}
	double l = 0, r = 300000;
	for (int i = 0; i < 40; i++) {
		double m = (l + r) / 2;
		double radius[n];
		for (int j = 0; j < n; j++) radius[j] = m / c[j];
		auto dist = [] (Point p0, Point p1) { return std::hypot(p0.x - p1.x, p0.y - p1.y); };
		Point res0, res1;
		int max = 0;
		auto kosa = [&] (Point p0, double r0, Point p1, double r1) {
			if (dist(p0, p1) > r0 + r1) return false;
			double base_atan2 = std::atan2(p1.y - p0.y, p1.x - p0.x);
			if (base_atan2 < 0) base_atan2 += 2 * PI;
			auto pos = [&] (double kakudo) {
				return Point{p0.x + std::cos(kakudo) * r0, p0.y + std::sin(kakudo) * r0};
			};
			auto opp = pos(base_atan2 + PI);
			if (dist(opp, p1) <= r1) return false;
			
			double upper, lower;
			{
				double l = base_atan2;
				double r = base_atan2 + PI;
				for (int i = 0; i < 20; i++) {
					double m = (l + r) / 2;
					if (dist(pos(m), p1) <= r1) l = m;
					else r = m;
				}
				upper = l;
			}{
				double l = base_atan2 - PI;
				double r = base_atan2;
				for (int i = 0; i < 20; i++) {
					double m = (l + r) / 2;
					if (dist(pos(m), p1) <= r1) l = m;
					else r = m;
				}
				lower = l;
			}
			res0 = pos(upper);
			res1 = pos(lower);
			return true;
		};
		auto try_pt = [&] (Point pt) {
			int cnt = 0;
			for (int i = 0; i < n; i++) if (dist(pts[i], pt) <= radius[i] + EPS) cnt++;
			max = std::max(max, cnt);
		};
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++) {
				if (kosa(pts[j], radius[j], pts[k], radius[k])) try_pt(res0), try_pt(res1);
			}
		}
		for (int j = 0; j < n; j++) try_pt(pts[j]);
		if (max >= k) r = m;
		else l = m;
	}
	printf("%.11f\n", l);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	int t=1;
	//cin>>t;
	
	while(t--)
	{
		ll n,w;
		cin>>n>>w;
		
		ll *wt=new ll[n];
		ll *val=new ll[n];
		
		for(ll i=0;i<n;i++)
		{
			cin>>wt[i]>>val[i];
		}
		
		ll **k=new ll*[n+1];
		for(ll i=0;i<=n;i++)
		{
			k[i]=new ll[w+1];
		}
		
		for(ll i=0;i<=n;i++)
		{
			for(ll j=0;j<=w;j++)
			{
				if(i==0||j==0)
				{
					k[i][j]=0;
				}
				else if(wt[i-1]<=j)
				{
					k[i][j]=max(k[i-1][j] , val[i-1] + k[i-1][j-wt[i-1]]);
				}else
				{
					k[i][j]=k[i-1][j];
				}
			}
		}
		cout<<k[n][w]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 82764