akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto N = ri;
	long res;
	foreach(i; 0..N+1) {
		if(i % 5 != 0 && i % 3 != 0) res += i; 
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2700
using System;


namespace _121_ABC
{
    class Program02
    {
        static void Main(string[] args)
        {
            string[] Input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(Input1[0]);
            int M = int.Parse(Input1[1]);
            int C = int.Parse(Input1[2]);

            string[] Input2 = Console.ReadLine().Split(' ');
            int[] B = new int[M];

            int Ans = 0;

            for(int i = 0; i < Input2.Length; i++)
            {
                B[i] = int.Parse(Input2[i]);
            }

            for (int i = 0; i < N; i++)
            {
                int sum = 0;
                string[] Input3 = Console.ReadLine().Split(' ');

                for (int j = 0; j < M; j++)
                {
                    sum += B[j] * int.Parse(Input3[j]);
                }

                sum += C;

                if(sum > 0)
                {
                    Ans++;
                }
            }

            Console.WriteLine(Ans);

        }
    }
}


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

static const int N = 100;

int main() {
	int n, p[N + 1], m[N + 1][N + 1];
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> p[i - 1] >> p[i];
	}
	
	for(int i = 1; i <= n; i++) m[i][i] = 0;
	for(int l = 2; l <= n; l++){
		for(int i = 1; i <= n - l + 1; i++){
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for(int k = i; k <= j - 1; k++){
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k]* p[j]);
			}
		}
	}
	
	cout << m[1][n] << endl;
	
	return 0;
}

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

int mat[114][114];

int main() {
  scanf("%d%d%d", &mat[0][0], &mat[0][1], &mat[1][1]);
  for (int sum=-10000000; sum<=10000000; sum++) {
    mat[0][2] = sum - mat[0][0] - mat[0][1];
    mat[2][2] = sum - mat[0][0] - mat[1][1];
    mat[2][1] = sum - mat[0][1] - mat[1][1];
    mat[1][2] = sum - mat[0][2] - mat[2][2];
    mat[1][0] = sum - mat[1][1] - mat[1][2];
    mat[2][0] = sum - mat[2][1] - mat[2][2];
    if (mat[2][0] + mat[1][0] + mat[0][0] == sum) {
      if (mat[2][0] + mat[1][1] + mat[0][2] == sum) break;
    }
  }

  for (int i=0; i<3; i++) {
    printf("%d", mat[i][0]);
    for (int j=1; j<3; j++) {
      printf(" %d", mat[i][j]);
    }
    puts("");
  }
}


Measured memory_bytes: 384
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    root = 1
    if A[0] == 1:
        if N == 0:
            print(1)
        else:
            print(-1)
        return
    B = A[::-1]
    low = high = B[0]
    # Low = []
    Hight = [high]
    
    for b in B[1:]:
        low = max(1, (low+1)//2) + b
        high = high + b
        Hight.append(high)
    if low > 1:
        print(-1)
        return
    ans = 1
    now = 1
    BHight = Hight[::-1]
    for i in range(1,N+1):
        if now == 0:
            print(-1)
            return
        h = BHight[i]
        leaf = A[i]
        # print("h",h)
        now = min(h, now*2)
        ans += now
        now -= leaf
        if now < 0:
            print(-1)
        # print(now)
    print(ans)
if __name__ == '__main__':
    main()


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

int main() {
    int N, K;
    cin >> N >> K;
    int H[N];
    rep(i, N) cin >> H[i];

    sort(H, H + N, greater<int>());
    int64_t ans = 0;
    rep(i, N - K) {
        ans += H[i + K];
    }
    cout << ans << endl;
}

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

int main() {
  
  char c;
  cin >> c;
  if(c=='a'||c=='i')
    cout<< "vowel"<< endl;
  else if(c=='u'||c=='e')
    cout<< "vowel"<< endl;
  else if(c=='o')
    cout<<"vowel"<< endl;
  else
    cout << "consonant" <<endl;
}



Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
new_list = []
ans = 0
while True:
    for i in a_list:
        if i % 2 == 1:
            break
        else:
            a = i // 2
            new_list.append(a)
    if len(new_list) < n:
        break
    ans += 1
    a_list = new_list
    new_list = []

print(ans)

Measured memory_bytes: 9064
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  if(str=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(str=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
  return(0);
}


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

int main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes\n";
	}
	else cout << "No\n";
}

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

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n, p_2[600];
    rep(i, 9) p_2[1 << i] = i + 1;
    cin >> n;
    rep(i, n - 1) {
        FOR(j, i + 1, n) cout << p_2[(i ^ j) & -(i ^ j)] << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
def main():
	n,m=map(int,input().split())
	inf=10**15
	dis=[[inf for _ in range(n)]for _ in range(n)]
	for i in range(n):
		dis[i][i]=0
	node=[]
	for i in range(m):
		a,b,c=map(int,input().split())
		dis[a-1][b-1]=c
		dis[b-1][a-1]=c
		node.append((a-1,b-1,c))
	for i in range(n):
		for j in range(n):
			for k in range(n):
				dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k])
	ans=0
	for x in node:
		f=0
		for i in range(n-1):
			if f:
				break
			for j in range(i+1,n):
				if dis[i][j]==dis[i][x[0]]+x[2]+dis[x[1]][j]:
					f=1
					break
				elif dis[i][j]==dis[i][x[1]]+x[2]+dis[x[0]][j]:
					f=1
					break
		if f==0:
			ans+=1
	print(ans)
if __name__ == '__main__':
	main()


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

int main() {
  int N;
  cin >> N;
  
  for(int i=0; i < N;i++){
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N-1){
      cout << "Three" << endl;
    }
  }
}  

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);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--)


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	//小文字repは初期値指定なし #やむどぅめも
	int N;
	string A, B, C;
	cin >> N >> A >> B >>C;
	int ans = 0;
	rep(i, N) {
		if (A[i] == B[i] && B[i] == C[i]) continue;
		else if (A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) {
			ans += 2;
		}
		else if ((A[i] == B[i] && B[i] != C[i]) ||
			(A[i] != B[i] && B[i] == C[i]) ||
			(A[i] == C[i] && B[i] != C[i])
			)
		{
			ans += 1;
		}

			
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;

	double x, ans = 0;
	string s;

	for (int i = 0; i < n; ++i)
	{
		cin >> x >> s;
		if (s[0] == 'J')
			ans += x;
		else
			ans += x * 380000;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using std::vector;
vector<int>g[100005];
int vis[100005];

void dfs(int u){
    vis[u] = 1;
    for(int v: g[u]){
        if(!vis[v]) dfs(v);
    }
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            cnt++;
            dfs(i);
        }
    }
    printf("%d\n",cnt-1);
    return 0;
}


Measured memory_bytes: 9564
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int check_stable(int B1[9][4],int B2[9][4]){
	for(int i=0;i<9;i++){
		for(int j=0;j<4;j++){
			if(B1[i][j]!=B2[i][j]){
				return -1;
			}
		}
	}
	return 1;
}

void BubbleSort(char **A,int n){
	char tmp[3];
	for(int i=0;i<(n-1);i++){
		for(int j=(n-1);j>i;j--){
			if(A[j-1][1]>A[j][1]){
				strcpy(tmp,A[j-1]);
				strcpy(A[j-1],A[j]);
				strcpy(A[j],tmp);
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("%s",A[i]);
		if(i==(n-1)){
			printf("\n");
		}else{
			printf(" ");
		}
	}
	printf("Stable\n");
}

void SelectionSort(char **A,int n){
	char tmp[3];
	int min;
	int B[9][4],B2[9][4];
	int c[9],c2[9],x;

	for(int i=0;i<9;i++){
		c[i]=0;
		c2[i]=0;
		for(int j=0;j<4;j++){
			B[i][j]=-1;
			B2[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		if(A[i][0]=='S'){
			x=0;
		}else if(A[i][0]=='H'){
			x=1;
		}else if(A[i][0]=='C'){
			x=2;
		}else{
			x=3;
		}
		B[A[i][1]-'0'-1][c[A[i][1]-'0'-1]++]=A[i][0];
	}

	for(int i=0;i<n;i++){
		min=i;
		for(int j=i;j<n;j++){
			if(A[j][1]<A[min][1]){
				min=j;
			}
		}
		strcpy(tmp,A[i]);
		strcpy(A[i],A[min]);
		strcpy(A[min],tmp);
	}

	for(int i=0;i<n;i++){
		if(A[i][0]=='S'){
			x=0;
		}else if(A[i][0]=='H'){
			x=1;
		}else if(A[i][0]=='C'){
			x=2;
		}else{
			x=3;
		}
		B2[A[i][1]-'0'-1][c2[A[i][1]-'0'-1]++]=A[i][0];
	}
	
	for(int i=0;i<n;i++){
		printf("%s",A[i]);
		if(i==(n-1)){
			printf("\n");
		}else{
			printf(" ");
		}
	}
	if(check_stable(B,B2)==1){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
}

int main(){
    int n;
	char **A,**A2;
	
	scanf("%d",&n);
	A=(char**)malloc(sizeof(char*)*n);
	A2=(char**)malloc(sizeof(char*)*n);
	for(int i=0;i<n;i++){
		A[i]=(char*)malloc(sizeof(char)*3);
		A2[i]=(char*)malloc(sizeof(char)*3);
		scanf("%s",A[i]);
		strcpy(A2[i],A[i]);
	}

	BubbleSort(A,n);
	SelectionSort(A2,n);

	return 0;
}


Measured memory_bytes: 2756
n, x, y = map(int, input().split())

ans = [0]*(n+1)
for i in range(1,n+1):
  for j in range(i+1, n+1):
    d = min(abs(i-j), abs(y-j)+abs(x-i)+1, abs(y-i)+abs(x-j)+1)
    ans[d] += 1

for a in ans[1:-1]:
  print(a)

Measured memory_bytes: 3572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int aa=max(a,b),bb=min(a,b);
    for(int i=bb;i<=aa;i++)
    {
        if(a*b*i%2==1)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	int n;
	cin >> n;
	while (n > 0) {
		n -= 1000;
	}
	cout << -n;
}
	

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<climits>

using namespace std;

#define int long long

//int sqrtN;
int N,K;
const int sqrtN=512;
vector<int> data;
vector<int> bucketadd;

void init(){
	K=(N+sqrtN-1)/sqrtN;
	data.assign(K*sqrtN,0);
	bucketadd.assign(K,0);
}

void add(int s,int t,int x){
	for(int k=0;k<K;k++){
		int l=k*sqrtN;
		int r=(k+1)*sqrtN;
		if(r<=s || t<=l) continue;
		if(s<=l && r<=t) bucketadd[k]+=x;
		else{
			for(int i=max(s,l);i<min(t,r);i++){
				data[i]+=x;
			}
		}
	}
}

void get_i(int i){
	int k=i/sqrtN;
	//printf("%lld\n",data[i]+bucketadd[k]);
	printf("%lld\n",data[i]+bucketadd[k]);
}

signed main(){
	int q,com;
	int s,t,x;
	scanf("%lld %lld",&N,&q);
	//sqrtN = (int)sqrt(N);
	//printf("sqrt(N)=%lld\n",sqrtN);
	init();
	for(int i=0;i<q;i++){
		scanf("%lld",&com);
		if(com==0){
			scanf("%lld %lld %lld",&s,&t,&x);
			add(s,t+1,x);//[s,t)
		}
		else{
			scanf("%lld",&x);
			get_i(x);
		}
	}
}


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

bool isACGT(char s){
    switch(s){
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            return true;
        default:
            return false;
    }
    
    return false;
}

int main(void){
    string S;
    std::cin >> S;
    
    unsigned int ret = 0, tmp = 0;
    
    
    for(int i=0; i<S.length(); i++){
        if(isACGT(S[i]))
            tmp++;
        else{
            if(ret < tmp)
                ret = tmp;
            tmp = 0;
        }
    }
    
    if(ret < tmp)
        ret = tmp;
    
    std::cout << ret << std::endl;
        
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

import fractions
left, right = [], []
for arr, l in zip([a, a[::-1]], [left, right]):
    l.append(arr[0])
    for i in range(1, n):
        l.append(fractions.gcd(l[-1], arr[i]))

left = [right[-1], right[-2]] + left
right = right[::-1] + [left[-2], left[-1]]

ans = 0
for (l, r) in zip(left, right):
    ans = max(ans, fractions.gcd(l, r))

print(ans)


Measured memory_bytes: 93800
package main

import (
	"fmt"
	"sort"
)


func main() {
	var n, alice,bob int
	fmt.Scan(&n)
	cards := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&cards[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cards)))
	
	for i := 0; i < n; i += 2 {
		alice += cards[i]
		if i +1 < n {
			bob += cards[i+1]
		}
	}

	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !

int n, x, a[100000];
int main() {
	cin >> n >> x;
	rep(i, n) {
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	for (int i = 1;i < n;i++) {
		a[i] = gcd(a[i - 1], a[i]);
	}
	cout << a[n - 1] << endl;

	return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

const int inf=100000000;



int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int a,p; cin>>a>>p;
    int v=3*a+p;
    cout<<v/2<<endl;
    
}

Measured memory_bytes: 256
s=input()
t=input()
st={}
ts={}

for x,y in zip(s,t):
  if x not in st:
    st[x]=y
  else:
    if st[x]!=y:
      print("No")
      exit()
  if y not in ts:
    ts[y]=x
  else:
    if ts[y]!=x:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3760
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    double N,M;
    cin >> N >> M;
    double x = 100 * N + 1800 * M;
    double M_2 = pow(2, M);
    double siguma = 0;
    for(int i = 1; i < 10000; i++){
        siguma += i * pow((M_2-1)/M_2, i-1);
    }
    cout << x * siguma / M_2 << endl;
}


Measured memory_bytes: 640
n = input()
n2 = [int(i) for i in n[::-1]]
ans = [sum(n2)]
for i in range(len(n2)-1):
    n2[i] = 9
    n2[i+1] -= 1
    ans.append(sum(n2))
ans.append(sum(n2))
print(max(ans))


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

template<class INT_T> vector<INT_T> divisors(INT_T n)
{
    vector<INT_T> divs;
    for (INT_T d=1; d*d <= n; d++) {
        if (n%d==0) {
            divs.push_back(d);
            INT_T q = n/d;
            if (q != d) divs.push_back(q);
        }
    }
    sort(divs.begin(), divs.end());
    return divs;
}

int main()
{
    int N, M; cin >>N>>M;
    vector<int> divs = divisors(M);
    int g_max = M/N;

    int ans = -1;
    for (int i = divs.size()-1; i >= 0; i--) {
        if (divs[i]>g_max) continue;
        if ((M - divs[i] * (N-1)) % divs[i] == 0) {
            ans = divs[i];
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main( )
{
	int n;
	cin>>n;
	vector<int> elems(n);
	for( int i=0; i<n; i++ ) {
		cin>>elems.at( i );
		cout<<elems.at( i );
		if( i< n-1 ) { cout<<' '; } else { cout<<'\n'; }
	}
	
	int key, j;
	for( int i=1; i<n; i++ ) {
		key = elems.at( i );
		j = i - 1;
		while( 0 <= j and key < elems.at( j ) ) {
			elems.at( j+1 ) = elems.at( j );
			j--;
		}
		elems.at( j+1 ) = key;
		
		for( int k=0; k<elems.size( ); k++ ) {
			cout<<elems.at( k );
			if( k < n-1 ) { cout<<' '; } else { cout<<'\n'; }
		}
	}
	
	return 0;
}

Measured memory_bytes: 1196
// Author : Chi
// created :

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef struct item{
    int a,b;
}I;
ll rec(I s[],int W,int in,int n){
    int maxn=100000;
    int dp[maxn+1][n+1];
    for(int i=0;i<=n;i++)
        dp[0][i]=0;
    for(int i=1;i < maxn+1; i++){
        for(int j=1;j<=n;j++){

        }
    }
}
void solve(){
    int n,w;
    cin>>n>>w;
    I t[n+1];
    r1n(i,n)
    cin>>t[i].a>>t[i].b;
    int maxval=n*1000;
    int dp[n+1][maxval+1];
    for(int val=0;val<=maxval;val++)
        dp[1][val]=1e9+1;
    dp[1][0]=0;
    dp[1][t[1].b]=t[1].a;
    for(int i=2;i<=n;i++)
    for(int v=0;v<=maxval;v++){
        dp[i][v]=dp[i-1][v];
        if(t[i].b>v)
            continue;
        dp[i][v]=min(dp[i][v],t[i].a+dp[i-1][v-t[i].b]);
    }
    int ans=0;
    for(int x=0;x<=maxval;x++){
        if(dp[n][x]<=w)
            ans=x;
    }
    cout<<ans;
}

// Driver Code
int main(){
    TEST1
    return 0;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void dfs(vector<int> graph[],bool visited[],int dp[],int Node){
    visited[Node] = true;
    for(int i=0;i<graph[Node].size();i++){
        if(!visited[graph[Node][i]]){
            dfs(graph,visited,dp,graph[Node][i]);
        }
        dp[Node] = max(dp[Node],1+dp[graph[Node][i]]);
    }
    
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   int N,M;
   cin>>N>>M;
   vector<int> graph[N+1];
   for(int i=0;i<M;i++){
       int temp,temp1;
       cin>>temp>>temp1;
       graph[temp].push_back(temp1);
   }
   int dp[N+1];
   memset(dp,0,sizeof(dp));
   bool visited[N+1];
   memset(visited,false,sizeof(visited));
   int ans = INT_MIN;
   for(int i=1;i<=N;i++){
       if(!visited[i]){
           dfs(graph,visited,dp,i);
       }
    ans = max(ans,dp[i]);
   }
  
//   for(int i=1;i<=N;i++){
   
//   }
   cout<<ans;
   
  
}

Measured memory_bytes: 9600
n = gets.to_i
a = gets.split.map(&:to_i)
sum = a.inject(:+)
min_diff = 10000
min_diff_i = -1
a.each_with_index do |v, i|
  diff = (v * n - sum).abs
  if diff < min_diff
    min_diff = diff
    min_diff_i = i
  end
end
puts min_diff_i


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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vector<ll> A(n);
    for(auto &a : A) cin>>a;
    sort(A.begin(),A.end());
    ll ret = 0ll;
    for(int i=0;i<n;++i){
        (ret += comb(i,k-1)*A[i]%mo)%=mo;
        (ret -= comb(n-i-1,k-1)*A[i]%mo)%=mo;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
      count++;
    }
  }
  cout << count << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 3e5+10;
const int MOD = 1e9+7;

int N;
ll A[MAX];

ll count(int bit) {
    ll ones = 0, zeros = 0;
    REP (i, N) {
        if ((A[i] >> bit) & 1) ones++;
        else zeros++;
    }
    return ones * zeros;
}

int solve() {
    ll ans = 0;
    REPR (b, 62) ans = (ans * 2 + count(b)) % MOD;
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 2560
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
double pi = acos(-1) ;
ll z =  1000000000 ;
ll inf = 6000000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n

void solve()
{
	ll n , m ;
	cin >> n >> m ;
	fo(i , m)
	{
		ll u ;
		cin >> u ;
		n -= u ;
	}
	cout << max(-1 , n) << endl ;
	return ;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
    
    ll t ;
    //cin >> t ;
    t = 1 ;

    while(t--)
    {
        solve() ;
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3700
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,tmp,pans=0,qans=0,jd;
std::vector<int> qdata,pdata;

int facctorialMethod(int k){
        int sum = 1;
        for (int i = 1; i <= k; ++i)
        {
                sum *= i;
        }
        return sum;
}

void solve(){
        rep2(i,1,n){
                rep2(j,1,n){
                        jd=0;
                        if(pdata.at(i-1)>j) {
                                rep(k,i){
                                        if(pdata.at(k)==j) {
                                                jd=1;
                                        }
                                }
                                if(jd==1) {
                                        continue;
                                }
                                pans+=facctorialMethod(n-i);;
                        }
                }
        }
        rep2(i,1,n){
                rep2(j,1,n){
                        jd=0;
                        if(qdata.at(i-1)>j) {
                                rep(k,i){
                                        if(qdata.at(k)==j) {
                                                jd=1;
                                        }
                                }
                                if(jd==1) {
                                        continue;
                                }
                                qans+=facctorialMethod(n-i);;
                        }
                }
        }
        cout<<abs(pans-qans)<<endl;
}

int main(){
        cin>>n;
        rep(i,n){
                cin>>tmp;
                pdata.push_back(tmp);
        }
        rep(i,n){
                cin>>tmp;
                qdata.push_back(tmp);
        }

        solve();
        return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

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

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

    int a, b, c, d; cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes";
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No";
            break;
        }
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>

using namespace std;

void solve()
{
	string str;
	getline(cin, str);
	string word[1000];

	int pos = 0;
	int n = str.size();
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			pos++;
		}
		else
		{
			word[pos] += str[i];
		}
	}
	pos++;
	map<string, int> Map;
	for(int i = 0; i < pos; ++i)
	{
		Map[word[i]]++;
	}
	int frequency = 0;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency < (*Ite).second)
		{
			frequency = (*Ite).second;
		}
	}
	int max_length = 0;
	for(int i = 0; i < pos; ++i)
	{
		if(max_length < word[i].size())
		{
			max_length = word[i].size();
		}
	}
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency == (*Ite).second)
		{
			cout << (*Ite).first << " ";
			break;
		}
	}
	for(int i = 0; i < pos; ++i)
	{
		if(max_length == word[i].size())
		{
			for(int j = 0; j < max_length; ++j)
			{
				cout << word[i][j];
			}
			cout << endl;
			break;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    map<int,int> mp;
    mp[0] = 1;
    vector<int> cusum(n);
    cusum[0] = a[0];
    mp[cusum[0]]++;
    for(int i = 1; i < n; i++){
        cusum[i] = cusum[i-1] + a[i];
        mp[cusum[i]]++;
    }

    int ans = 0;
    for(auto i : mp){
        int x = i.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: i64 = itr.next().unwrap().parse().unwrap();
    let b: i64 = itr.next().unwrap().parse().unwrap();
    
    if a % 2 == 0 {
        let c = (b - a) % 4;
        if c == 0 {
            println!("{}", b);
        } else if c == 1 {
            println!("1");
        } else if c == 2 {
            println!("{}", b + 1);
        } else {
            println!("0");
        }
    } else {
        let c = (b - (a + 1)) % 4;
        if c == 0 {
            println!("{}", a ^ b);
        } else if c == 1 {
            println!("{}", a ^ 1);
        } else if c == 2 {
            println!("{}", a ^ (b + 1));
        } else {
            println!("{}", a);
        }
    }
}


Measured memory_bytes: 4352
N = gets.to_i
As = gets.split.map(&:to_i)
Bs = gets.split.map(&:to_i)
ans = 0
Bs.each.with_index{|b,i|
    if As[i] <= b
        ans += As[i]
        rest = b - As[i]
        if As[i+1] <= rest
            ans += As[i+1]
            As[i+1] = 0
        else
            ans += rest
            As[i+1] -= rest
        end
    else
        ans += b
    end
}

puts ans


Measured memory_bytes: 15508
//Bismillahir Rahmanir Raheem
//In the name of Allah , Most Gracious , Most Merciful

/*

  * * * * * * *   * * * * * * *   *           *   * * *   * * * * * *
              *   *           *   *           *     *     *           *
              *   *           *   *           *     *     *             *
              *   *           *   *           *     *     *             *
              *   * * * * * * *   * * * * * * *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *             *
  *           *   *           *   *           *     *     *           *
  * * * * * * *   *           *   *           *   * * *   * * * * * *

*/

#include<bits/stdc++.h>
using namespace std;

#define BOOST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define DEBUG freopen("input.txt","r",stdin)


int main()
{
    BOOST;
    //DEBUG;
    int n,m,s=0,x;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x;
        s+=x;
    }
    if(n==s || n>s)cout<<n-s<<endl;
    else cout<<-1<<endl;
    return 0;

}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int a,b,x,y,z;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if(x>=y&&x>=z){
		printf("%d\n",x);
	}
	else if(y>x&&y>z){
		printf("%d\n",y);
	}
	else{
		printf("%d\n",z);
	}
	return 0;
}


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

typedef long long int LLI;

bool prime[1000007];
vector<LLI>v;

void SieveOfEratosthenes(LLI n) 
{
    memset(prime, true, sizeof(prime));  
    for (LLI p=2; p*p<=n; p++) if (prime[p] == true) for (LLI i=p*p; i<=n; i += p) prime[i] = false;
    for(LLI p=2;p<=n;++p) if(prime[p]) v.emplace_back(p);
}

LLI M(LLI k) {
    LLI i;
    for (i = 1; ; i++) {
        if (k < i) return i - 1;
        else k -= i;
    }
}

void solve()
{
    LLI n,num;
    cin>>n;
    num=n;
    LLI s=0;
    for(LLI p:v){
        if(p*p>n) break;
        if(n%p==0){
            LLI cnt=0;
            while(n%p==0) n/=p,cnt++;
            s+=M(cnt);
        }
    }
    if(n>1) s++;
    cout<<s;
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    SieveOfEratosthenes(1000005); 
    solve();
}

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

int main()
{
    vector<int> v(9);
    for (int i = 0; i < 9; i++)
    {
        cin >> v[i];
    }
    int a = v[0] + v[4] + v[8];
    int b = v[0] + v[5] + v[7];
    int c = v[1] + v[3] + v[8];
    int d = v[1] + v[5] + v[6];
    int e = v[2] + v[3] + v[7];
    int f = v[2] + v[4] + v[6];
    if (a == b && b == c && c == d && d == e && e == f)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, X;
	cin >> N >> X;
	
	if (X == 1 || X == 2*N-1) {
		cout << "No" << endl;
		return 0;
	}
	
	vector<bool> a(2*N-1);
	vector<int> b(2*N-1, -1);
	b[N-2] = X-1;
	b[N-1] = X;
	b[N] = X+1;
	a[X-2] = true;
	a[X-1] = true;
	a[X] = true;
	int p = 0;
	for (int i = 0; i < 2*N-1; ++ i) if (b[i] < 0) {
		while (a[p]) ++ p;
		b[i] = p+1;
		a[p] = true;
	}
	cout << "Yes" << endl;
	for (auto x : b) cout << x << endl;

	/*
	for (auto x: b) cout << x;

	while (b.size() > 1) {
		vector<int> c;
		for (int i = 2; i < b.size(); ++ i) {
			vector<int> d = {b[i-2], b[i-1], b[i]};
			sort(d.begin(), d.end());
			c.push_back(d[1]);
		}
		b = c;
	}
	cout << " " << b[0] << endl;
	*/
}


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

int main(void)
{	
	int point_taro = 0;
	int point_hana = 0;
	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char card_taro[101] = "\0";
		char card_hana[101] = "\0";
		cin >> card_taro;
		cin >> card_hana;
		
		int cmp = strcmp(card_taro, card_hana);
		if (cmp > 0) {
			point_taro += 3;
		} else if (cmp < 0) {
			point_hana += 3;
		} else {
			point_taro++;
			point_hana++;
		}
	}
	
	cout << point_taro << " " << point_hana << endl;
	
	return 0;
}

Measured memory_bytes: 3104
"""
"""
n,x,y=map(int,input().split())
ret=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ret[min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))-1]+=1
for r in ret:
    print(r)




Measured memory_bytes: 3444
import math
N = int(input())
lst = [list(map(int, input().split())) for i in range(N-1)]
ans = []
for i in range(N-1):
  t = lst[i][0] + lst[i][1]
  for j in range(i+1, N-1):
    if (t >= lst[j][1]):
      if (t % lst[j][2] == 0):
        t += lst[j][0]
      else:
        n = math.ceil((t - lst[j][1]) / lst[j][2])
        t = lst[j][1] + lst[j][2] * n + lst[j][0]
    else:
      t = lst[j][1] + lst[j][0]
  ans.append(t)
ans.append(0)

for i in ans:
  print(i)

Measured memory_bytes: 3188
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int re = Math.max(a * b, Math.max(a + b, a - b));
    System.out.println(re);
  }
}

Measured memory_bytes: 22868
#include <iostream>
using namespace std;
int main(){
	int N,W;
	cin>>N>>W;
	int v[N],w[N];
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	
	int DP[N+1][W+1];

	for(int i=0;i<W+1;i++){
		for(int j=0;j<N+1;j++){
			DP[j][i]=0;
		}
	}

	for(int i=1;i<=N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i-1]){
				DP[i][j]=DP[i-1][j];
			}
			else{
				if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1]){
					DP[i][j]=DP[i-1][j];
				}
				else{
					DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
				}
			}
		}
	}
	cout<<DP[N][W]<<endl;

	return 0;
}

Measured memory_bytes: 7020
import std.stdio,std.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array,std.numeric;

T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?e[1..$]:[];return tp;}}
struct Stack(T){T[]e;auto push(T t){e~=t;}auto push(T[]ts){e~=ts;}T pop(){T tp=e[$-1];e=e.length>1?e[0..$-1]:[];return tp;}}

//END OF TEMPLATE

void main(){
    ((readarr[0]+1)/2).writeln;
}


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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int n;
    cin>>n;
    int p[n];
    int q[n];
    int temp[n];
    for(int i=1;i<=n;i++)
    {
        temp[i-1]=i;
    }
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>q[i];
    }
    int i1=-1;
    int i2=-1;
    int c=0;
    do{
        c++;
        int k=0;
        for(int i=0;i<n;i++)
        {
            if(temp[i]!=p[i])
            {
                k=1;
                break;
            }
        }
        if(k==0)
        i1=c;
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(temp[i]!=q[i])
            {
                flag=1;
                break;
            }
        }
        if(!flag)
        i2=c;
    }while(next_permutation(temp,temp+n));
    cout<<abs(i1-i2);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
const long long N = 3e3+5 , M = 998244353, OO = 0x3f3f3f3f;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const double Pii = 3.14159265359;
ll n, m;
ll mem[N][N];
ll a[N];
ll solve(int idx, int su)
{
    if(idx == n)
    {
        if(su == m) return 1;
        return 0;
    }
    if(mem[idx][su]!=-1) return mem[idx][su];
    ll op1 = 0, op2 = 0;
    if(su + a[idx] <= m) op1 = solve(idx+1, su+a[idx]);
    op2 = (solve(idx+1, su)*2);
    return mem[idx][su] = (op1 + (op2%M))%M;
}

int main()
{
    FIO
    cin >> n >> m;
    for(int i=0; i<n; ++i) cin >> a[i];
    memset(mem, -1, sizeof mem);
    ll ans = solve(0, 0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 74284
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
v = [[] for _ in [None] * 10**5]
for a, b in t:
    v[a - 1] += b,
z = 0
q = []
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    if q:
        z += -heappop(q)
print(z)

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

int main(){
    ll n,x,a[100005],q,b,c,ans=0,k;
    cin >> n ;
    rep(i,100005){
        a[i]=0;
    }
    rep(i,n){
        cin >> x;
        a[x]++;
    }
  rep(i,100005){
            ans+=i*a[i];
        }
  cin >> q;
    rep(i,q){
        cin >> b >>c;
      k=a[b];
        a[c]+=a[b];
        a[b]=0;
        ans=ans+(c-b)*k;
            cout << ans <<endl;

    }
    
    
}

Measured memory_bytes: 4392