akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

//const int mod = 998244353;
const int mod = 1000000007;


struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int MAX_N = 100005;
mint dp[MAX_N][13] = {0};   //右からi桁目まででみて、13で割った余りがjである数の個数

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(),s.end());

    int ten = 1;
    dp[0][0] = 1;
    for(int i=0;i<n;i++){

        for(int j=0;j<13;j++){
            for(int digit=0;digit<10;digit++){
                int d = s[i]-'0';
                if(0<=d && d<=9 && d!=digit) continue;
                int bj = (j-((ten*digit)%13)+13)%13;
                dp[i+1][j] += dp[i][bj];
            }
        }
        ten *= 10; ten %= 13;
    }
    /*
    for(int i=0;i<=n;i++){
        for(int j=0;j<13;j++) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <stack>

int main(void)
{
    std::stack<int> n;
    int m;

    while(std::cin >> m)
    {
        if(m == 0)
        {
            std::cout << n.top() << std::endl;
            n.pop();
        }

        else
        {
            n.push(m);
        }
    }

    return 0;
}

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

const int MOD = 1000000007;

int main(){
  string S;
  cin>>S;
  ll N=S.size(),after=0,before=0,nw=0;

  rep(i,N) if(S[i]=='W') nw++;  
  after=(nw-1)*nw/2;
  
  rep(i,N) if(S[i]=='W') before+=i;  
  
  cout<<before-after<<endl;
  
  return 0;
  
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	int M;
	cin >> M;
	vector<lint>B(M);
	rep(i, M) {
		cin >> B[i];
	}
	vector<lint>C;
	rep(i, N) {
		C.push_back(A[i]);
	}
	rep(i, M) {
		C.push_back(B[i]);
	}
	sort(C);
	C.push_back(-1);
	reverse(C);
	C.push_back(-1);
	reverse(C);
	for (int i = 1; i < C.size() - 1; i++) {
		if (C[i - 1] != C[i] && C[i] != C[i + 1]) {
			cout << C[i] << endl;
		}
	}
}




Measured memory_bytes: 10204
#include<stdio.h>
int main(){
	int s[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
	int t[]={15,14,13,12,11,10,6,7,8,9};
	int n,a,b,i;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&a,&b);
		if(a<b){
			for(i=a;i<=b;i++)printf("%d%s",s[i],(i==b)?"\n":" ");
		}else{
			if(a<6 || b<6)for(i=t[a];i<=t[b];i++)printf("%d%s",s[i],(i==t[b])?"\n":" ");
			else for(i=t[a];i<=15+t[b];i++)printf("%d%s",s[i],(i==15+t[b])?"\n":" ");;
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Process struct {
	Name string
	Time int
}

type Queue struct {
	xs   [200000]*Process
	head int
	tail int
}

func (q *Queue) enqueue(x *Process) {
	q.xs[q.tail] = x
	if q.tail >= len(q.xs)-1 {
		q.tail = 0
	} else {
		q.tail++
	}
}

func (q *Queue) dequeue() *Process {
	x := q.xs[q.head]
	if q.head >= len(q.xs)-1 {
		q.head = 0
	} else {
		q.head++
	}
	return x
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func nextStr(sc *bufio.Scanner) string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	q := nextInt(sc)

	var queue Queue
	for i := 0; i < n; i++ {
		queue.enqueue(&Process{
			Name: nextStr(sc),
			Time: nextInt(sc),
		})
	}

	sum := 0
	for n > 0 {
		p := queue.dequeue()
		if p.Time > q {
			sum = sum + q
			p.Time = p.Time - q
			queue.enqueue(p)
		} else {
			sum = sum + p.Time
			n--
			fmt.Print(p.Name)
			fmt.Print(" ")
			fmt.Println(sum)
		}
	}
}



Measured memory_bytes: 5948
#include <iostream>

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    int already_space = z, count = 0;

    for (int i = 0; already_space < x; i++)
    {
        already_space += y + z;
        count++;
    }
    if (already_space > x) count--;
    cout << count << endl;
    return (0);
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))

# 選ぶ数・和
ans = 0
for i in range(K, N + 2):
    # i こ選ぶときの和
    l = (i - 1) * i // 2
    r = (N - i + 1 + N) * i // 2
    ans += r - l + 1
print(ans % MOD)


Measured memory_bytes: 27172
#include <iostream>
using namespace std;
int main()
{
    int a,b;cin>>a>>b;
    if (a>=13)
    {
        cout<<b<<endl;
    }
    else if (a<=12 && a>=6)
    {
        cout<<(0.5)*b<<endl;

    }
    else {cout<<"0"<<endl;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
    string a,b;
    cin>>a>>b;
    char c,d,e,f,g,h;
    c=a[0];
    d=a[1];
    e=a[2];
    f=b[2];
    g=b[1];
    h=b[0];
    if(c==f && d==g && e==h){
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}

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

using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

map <ll,int> M;
int n; ll sum,Ans;
int main()
{
	M[0]++;	cin >> n; for(int i=1;i<=n;i++)
	{
		sum+=read(); M[sum]++;
		int x=M[sum]; Ans+=x-1;
	}
	cout << Ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a1(N);
  vector<int> s1(N+1,0);
  vector<int> a2(N);
  vector<int> s2(N+1,0);
  for (int i=0;i<N;i++){
    cin >> a1.at(i);
    s1.at(i+1)=s1.at(i)+a1.at(i);
  }
  for (int i=0;i<N;i++){
    cin >> a2.at(i);
    s2.at(i+1)=s2.at(i)+a2.at(i);
  }
  int ans=0;
  for (int i=0;i<N;i++){
    if(s1.at(i+1)+s2.at(N)-s2.at(i)>ans)
      ans=s1.at(i+1)+s2.at(N)-s2.at(i);
  }
  cout << ans << endl;

}

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

#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 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, tal[100001], ran[100001], l[200001], r[200001], d[200001], table[100001], tmp;
bool fl[100001];
long long int pl[100001];
vector<int> v[100001];
queue<int> q, ll[100001];

int main(){
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		cin >> l[i] >> r[i] >> d[i];
		v[l[i]].push_back(r[i]);
		ll[l[i]].push(i);
        table[r[i]]++;
        tal[l[i]]++;
	}
	if(m<3){
		cout << "Yes" << endl;
		return 0;
	}
	int flag=0;
    for(int i=1;i<=n;i++){
    	if(table[i]!=tal[i]){
    		flag=1;
    	}
        if(table[i]==0){
        	if(tal[i]!=0){
	            q.push(i);	
        	}else{
        		table[i]=-1;
        	}
        }
    }
    if(!flag){
    	cout << "No" << endl;
    	return 0;
    }
    int k=1;
    while(!q.empty()){
        tmp = q.front();
        q.pop();
        ran[k]=tmp;
        k++;
        for(int i=0;i<v[tmp].size();i++){
            table[v[tmp][i]]--;
            if(table[v[tmp][i]] == 0){
                q.push(v[tmp][i]);
            }
        }
    }
    for(int i=1;i<=n;i++){
    	if(i==1){
    		pl[ran[i]] = 1;
    	}
    	while(!ll[ran[i]].empty()){
    		int da = ll[ran[i]].front();
    		ll[ran[i]].pop();
    		if(pl[r[da]]==0){
    			pl[r[da]] = pl[ran[i]] + d[da];
    		}else if(pl[r[da]]!=pl[ran[i]] + d[da]){
    			cout << "No" << endl;
    			return 0;
    		}
    	}
    }
    cout << "Yes" << endl;
	return 0;
}


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

int main()
{
	int n = 0;
	int s = 0;
	
	cin >> n;
	
	vector <int> b;
	
	for (int i = 0; i < n - 1; i++) {
		cin >> s;
		b.push_back(s);
	}
	int result = b[0];
	for (int i = 1; i < n - 1; i++) {
		result += min(b[i - 1], b[i]);
	}
	result += b[n - 2];
	cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	int n;
	cin >> n;
	vector <ll> d(n);
	for(int i = 0; i < n; i++)
		cin >> d[i];
		
	ll ans = 0;
	ll mod = 1e9 + 7;
	ll sum = 0;
	for(int i = 1; i < n; i++)
		sum += d[i];
	
	for(int i = 0; i < n-1; i++){
		ans = (ans + ((sum % mod) * d[i]) % mod) % mod;
		sum -= d[i+1];
	}
	
	cout << ans << endl;
	return 0;
}


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

char s[100100];
int a[100100], fa[100100], l, r, m;

int Get(int x) {
	return x == fa[x] ? x : fa[x] = Get(fa[x]);
}

int main(void) {
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 0; i < n; i++)
		a[i + 1] = s[i] - 'a';
	a[0] = a[n + 1] = 0;
	for(int i = 0; i <= n; i++) {
		a[i] = (a[i + 1] - a[i] + 26) % 26;
		fa[i] = i;
	}
		
	scanf("%d", &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &l, &r); 
		l--;
		int fx = Get(l), fy = Get(r);
		if(fx != fy) {
			fa[fx] = fy;
			a[fy] = (a[fy] + a[fx]) % 26;
		}
	}
	for(int i = 0; i <= n; i++) {
		int fx = Get(i), fy = Get(n - i);
		if(fx != fy) {
			fa[fx] = fy;
			a[fy] = (a[fy] + a[fx]) % 26;
		}
	}
	for(int i = 0; i <= n; i++)
		if(fa[i] == i && a[i]) {
			puts("NO");
			return 0;
		} 
	puts("YES");
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001];

string lcs(string&s,string &t, int len){
	string ns;
	int i=0;
	int j=0;
while(len>0){
	if(s[i]==t[j]){
		ns.push_back(s[i]);
		i++;
		j++;
		len--;
	}
	else{
		if(dp[i+1][j]>dp[i][j+1]){
			i++;
		}
		else{
			j++;
		}
	}
}
return ns;
	
}
int getlcslen(string& s,string& t,int i, int j){
	if(i>=s.length()||j>=t.length()){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(s[i]==t[j]){
		return dp[i][j]=1+getlcslen(s,t,i+1,j+1);
	}
	else{
		return dp[i][j]=max(getlcslen(s,t,i+1,j),getlcslen(s,t,i,j+1));
	}
}
int main(){
	string s,t;
	cin>>s>>t;
	memset(dp,-1,sizeof dp);
	int len = getlcslen(s,t,0,0);
	//cout<<len<<endl;
cout<<lcs(s,t,len)<<endl;
	return 0;
}

Measured memory_bytes: 35968
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main()
{
	int num[5] = { 0 }, s[5] = { 0 };
	for (int i = 0; i < 5; i++) { cin >> num[i]; }
	int h[5], j[5], n[5], sa[5];
	for (int i = 0; i < 5; i++) {
			n[i] = num[i] % 10;
			num[i] = num[i] / 10;
			j[i] = num[i] % 10;
			num[i] = num[i] / 10;
			h[i] = num[i] % 10;
	}


	for (int i = 0; i < 5; i++) {
		if (h[i] == 1) {
			if (n[i] == 0) {
				s[i] = 100 + 10 * j[i];
				sa[i] = s[i] - 100 * h[i] - 10 * j[i] - n[i];
			}
			else {
				s[i] = 110 + 10 * j[i];
				sa[i] = s[i] - 100 * h[i] - 10 * j[i] - n[i];
			}
		}


		else {
			if (n[i] == 0) {
				s[i] = j[i] * 10;
				sa[i] = s[i] - 100 * h[i] - 10 * j[i] - n[i];
			}
			else {
				s[i] = 10 + j[i] * 10;
				sa[i] = s[i] - 100 * h[i] - 10 * j[i] - n[i];
			}
		}
	}
	sort(sa, sa + 5);
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		ans = ans + s[i];
	}
	cout << ans - sa[4] << endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect as list_bisect
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,M,V,P = map(int,input().split())
A = sorted(map(int,input().split()))

k = N-P
def judge(i):
    if i >= k:
        return True
    a = A[i]
    if a+M < A[k]:
        return False

    r = 0
    for v in A[i+1:k+1]:
        r += a+M-v
    return r >= (V-P-i)*M

i = bisect(-1,N-1,judge)
print(N-i)

Measured memory_bytes: 20416
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9+7;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
 
ll power(ll n,ll k,ll m){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%m;
        k/=2;
        n=(n*n)%m;
    }
    return ans;
}



int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll T=1;//cin>>T;
    
    while(T--){
        string s;cin>>s;
        ll n=s.length();
        if(s.length()<6){cout<<"No\n";continue;}
        if(s[2]==s[3] and s[4]==s[5])cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


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

int main() {
  int N; cin>> N;
  if ( N == 1 ) {
  cout << "Hello World" << endl;
  }else if ( N == 2 ) {
    int A,B; cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=100100;
int n,k,ans,a[maxn];
vector<int> G[maxn];

int dfs(int u){
	int nw=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		nw=max(nw,dfs(v));
	}
	nw++;
	if(nw==k && a[u]!=1) ans++,nw=0;
	return nw;
}

void work(){
	n=read(),k=read();
	rep(i,1,n){
		int x=read();
		a[i]=x;
		if(i==1){
			if(x!=1) ans++;
			a[i]=1;
		}
		else G[x].pb(i);
	}
	dfs(1);
	cout<<ans<<endl;
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif
	
	work();
	
	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


Measured memory_bytes: 10752
#include <iostream>
using namespace std;
int main(){
  bool tr[4][13];//SHCD
  for(int i = 0; 4 > i; i++){
      for(int j = 0; 13 > j; j++)tr[i][j] = false;
  }
  int n;cin>>n;
  for(int i = 0; n > i; i++){
    char s;int k;
    cin>>s>>k;k--;
    if(s == 'S'){
      tr[0][k] = true;
    } else if(s == 'H'){
      tr[1][k] = true;
    } else if(s == 'C'){
      tr[2][k] = true;
    } else{
      tr[3][k] = true;
    }
  }
  for(int i = 0; 4 > i; i++){
    for(int j = 0; 13 > j; j++){
      if(!tr[i][j]){
        if(i == 0)cout << "S";
        else if(i == 1)cout << "H";
        else if(i == 2)cout << "C";
        else if(i == 3)cout << "D";
        cout << " " << j+1 << endl;
      }
    }
  }
}


Measured memory_bytes: 3084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  if(X>Y) cout << min(C*X*2,min(C*Y*2+A*(X-Y),A*X+B*Y));
  else cout  << min(C*Y*2,min(C*X*2+B*(Y-X),A*X+B*Y));

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int v[n];
    REP(i,n){
        cin >> v[i];
    }
    sort(v, v + n);
    double ans = v[0];
    REP(i,n - 1){
        ans = (ans + (double)v[i + 1]) / 2;
    }
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  @scala.annotation.tailrec
  def isPrime(x: Int, count: Int): Boolean =
    if (x < count * count) true
    else if (x % count == 0) false
    else isPrime(x, count + 1)
  @scala.annotation.tailrec
  def loop(i: Int): Int = if (isPrime(i, 2)) i else loop(i + 1)
  val sc = new java.util.Scanner(System.in)
  val x = sc.nextInt()
  println(loop(x))
}


Measured memory_bytes: 55408
#include <cstdio>
using namespace std;
int minn(int a,int b)
{
	if(a>=b) return b;
	else return a;
}
int main()
{
	int ans=1,n,k,i;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++) ans+=minn(ans,k);
	printf("%d",ans);
	return 0; 
}

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

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

  string S; cin >> S;
  string T; cin >> T;
  ll N = S.length(), M = T.length();
  ll ans = M;
  for (ll i = 0; i <= N - M; i++) {
    ll cnt = 0;
    for (ll j = 0; j < M; j++) {
      if (S[i + j] != T[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int f[101];
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	f[a]++;
	f[b]++;
	f[c]++;
	int ans=0;
	for(int i=0;i<=100;i++)
		if(f[i]!=0)
		ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int k;
  cin >> k;
  int ans = 0;
  vector<bool> vis(k);
  vis[0] = true;
  int cur = 0;
  while (true) {
    cur = (cur * 10 + 7) % k;
    ans++;
    if (cur == 0) break;
    if (vis[cur]) {
      cout << -1 << endl;
      return 0;
    }
    vis[cur] = true;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e18;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 305;

ll adj[N][N];
int par[N][N];
vector<int> path;
int n;

void floyd(){
    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(adj[i][k] + adj[k][j] < adj[i][j]){
                    adj[i][j] = adj[i][k] + adj[k][j];
                    //par[i][j] = par[k][j];
                }
            }
        }
    }
}

void findPath(int st, int en){
    path.pb(en);
    if(st == en) return;
    findPath(st, par[st][en]);
}

int main(){
    fIO

    int m;
    ll l;
    cin >> n >> m >> l;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            adj[i][j] = oo;
            par[i][j] = i;
        }
        //adj[i][i] = 0LL;
    }

    int x, y;
    ll w;
    for(int i = 0; i < m; i++){
        cin >> x >> y >> w;
        x--; y--;
        if(w > l) continue;
        adj[x][y] = adj[y][x] = w;
    }

    floyd();

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            if(adj[i][j] <= l){
                adj[i][j] = 1;
            }
            else{
                adj[i][j] = oo;;
            }
        }
    }
    floyd();

    int q;
    cin >> q;

    for(int i = 0; i < q; i++){
        cin >> x >> y;
        x--; y--;

        if(adj[x][y] == oo) cout << -1 << "\n";
        else cout << adj[x][y] - 1 << "\n";
    }
}








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

#define BUFF_SIZE 1024
char buffer[1024];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    int i;
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

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

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }

    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 356
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=410000;
int n,m;
int l[N],r[N],sum[N];
int san[N],tot=0;
void Init()
{
	tot=0;
	for(int i=1;i<=n;i++) san[++tot]=l[i],san[++tot]=r[i];
	sort(san+1,san+tot+1); 
	tot=unique(san+1,san+tot+1)-(san+1);
	for(int i=1;i<=n;i++)
	{
		l[i]=lower_bound(san+1,san+tot+1,l[i])-san;
		r[i]=lower_bound(san+1,san+tot+1,r[i])-san;
	}
	return;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&l[i],&r[i]);
	Init();
	for(int i=1;i<=n;i++)
	{
		sum[l[i]]++;
		sum[r[i]+1]--;
	}
	for(int i=1;i<=tot;i++) sum[i]+=sum[i-1];
	int cnt=0;
	for(int i=1;i<=tot;i++) cnt=max(cnt,sum[i]);
	int las,det;
	if(cnt%2==0) reverse(sum+1,sum+tot+1);
	las=0;
	det=m+1;
	for(int i=1;i<=tot;i++) if(sum[i]==cnt) las=max(las,i);
	if(cnt%2==0) las=tot+1-las;
	for(int i=1;i<=n;i++)
	{
		if(l[i]<=las&&las<=r[i])
		{
			if(cnt%2==0) det=min(det,m-san[l[i]]);
			else det=min(det,san[r[i]]);
		}
	}
	printf("%lld\n",(cnt-1)*m+det);
	return 0;
}


Measured memory_bytes: 12648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/















int H, W; string S[101];
int dp[101][101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W;
	rep(y, 0, H) cin >> S[y];

	rep(y, 0, H) rep(x, 0, W) dp[y][x] = inf;
	dp[0][0] = 0;
	if (S[0][0] == '#') dp[0][0] = 1;

	rep(y, 0, H) rep(x, 0, W) {
		if (y + 1 < H) {
			if (S[y][x] == '.' && S[y + 1][x] == '#') chmin(dp[y + 1][x], dp[y][x] + 1);
			else chmin(dp[y + 1][x], dp[y][x]);
		}
		if (x + 1 < W) {
			if (S[y][x] == '.' && S[y][x + 1] == '#') chmin(dp[y][x + 1], dp[y][x] + 1);
			else chmin(dp[y][x + 1], dp[y][x]);
		}
	}

	cout << dp[H - 1][W - 1] << endl;
}







Measured memory_bytes: 384
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;

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

const int MAXN = 1e5 + 1;



int main() {
	ios_base::sync_with_stdio(0);
	
	int n, k;
	cin >> n >> k;
	int m = (n-1)*(n-2) / 2;
	if(k > m) {
		cout << "-1\n";
		return 0;
	}
	cout << n*(n-1)/2 - k << '\n';
	for(int v = 2; v <= n; v++) {
		cout << "1 " << v << '\n';
	}
	int v = 2;
	int w = 3;
	for(; k < m; k++) {
		cout << v << ' ' << w << '\n';
		w++;
		if(w > n) {
			v++;
			w = v+1;
		}
	}

	return 0;
}

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

int main() {
	int k,n;
  	cin >> k >> n;

  	vector<int> houses(n*2);
  	for (int i=0;i<n;i++) cin >> houses.at(i);
  	for (int i=0;i<n;i++) houses.at(i+n) = houses.at(i) + k;
  	
  
  	int shortest=k;
  	for (int i=0;i<n;i++) {
    	if (houses.at(i+n-1) - houses.at(i) < shortest) shortest = houses.at(i+n-1) - houses.at(i);
    }
    
  	cout << shortest << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, tmp, res = 0, cnt_a = 0, cnt_b = 0, cnt = 0;
    string s;
    in(n);
    rep(i, n){
        in(s);
        rep(i, 1, s.size()){
            if(s[i] == 'B' && s[i - 1] == 'A'){
                res++;
            }
        }
        if(s[s.size() - 1] == 'A' && s[0] == 'B'){
            if(cnt){
                res++;
            }else{
                cnt++;
            }
        }else if(s[s.size() - 1] == 'A'){
            cnt_a++;
        }else if(s[0] == 'B'){
            cnt_b++;
        }
    }
    if(cnt && (cnt_a || cnt_b)){
        cnt_a++;
        cnt_b++;
    }
    print(res + min(cnt_a, cnt_b));
}


Measured memory_bytes: 256
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NM_MAX = 502;

int n, m;

int a, b;

int ma[NM_MAX][NM_MAX];

ll sum;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> a >> b;
    if(n % a == 0 && m % b == 0)
    {
        cout << "No\n";
        return 0;
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(i % a == 0 && j % b == 0)
                ma[i][j] = -1000000000;
            else if((i % a == 1 || a == 1) && (j % b == 1 || b == 1))
                ma[i][j] = 999999999;
            else
                ma[i][j] = 0;
            sum += ma[i][j];
        }
    if(sum <= 0)
        cout << "No\n";
    else
    {
        cout << "Yes\n";
        for(int i = 1; i <= n; i++, cout << "\n")
            for(int j = 1; j <= m; j++)
                cout << ma[i][j] << " ";
    }
    return 0;
}


Measured memory_bytes: 4596
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let (a, b): (usize, usize) = input();
    println!("{}", (a-1)*(b-1));;
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

r_point = t.count('s') * r
s_point = t.count('p') * s
p_point = t.count('r') * p

sum_point = r_point+s_point+p_point

for i, moji in enumerate(t):
    if i+k >= len(t):
        break
    if t[i] == 'r' and t[i+k] == 'r':
        sum_point -= p
        t[i+k] = 'x'
    if t[i] == 's' and t[i+k] == 's':
        sum_point -= r
        t[i+k] = 'x'
    if t[i] == 'p' and t[i+k] == 'p':
        sum_point -= s
        t[i+k] = 'x'

print(sum_point)


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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
m, d = [int(i) for i in input().split()]

count = 0

for i in range(1, m + 1):
    for j in range(10, d + 1):
        d10 = int(str(j)[0])
        d1 = int(str(j)[1])
        if (d10 >= 2 and d1 >= 2 and i == d10 * d1):
            count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;int i=0;
  for(int j=0;j<n;j++){
    if(i!=1){
      i=a[i]-1;
      cnt++;
    }
    else if(i==1) {
      cout<<cnt<<endl;
      return 0;
    }
    
      }

  cout<<-1<<endl;
  
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
const int mod = 1e9 + 7;
char s[maxn];
int main() {
    cin>>s;
    int vis[4]={0};
    for (int i=0; s[i]; i++) {
        switch (s[i]) {
            case 'S':
                vis[0]=1;
                break;
            case 'E':
                vis[1]=1;
                break;
            case 'N':
                vis[2]=1;
                break;
            case 'W':
                vis[3]=1;
                break;
                
            default:
                break;
        }
    }
    if (vis[0]!=vis[2] || vis[1]!=vis[3]) {
        puts("No");
    } else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    string s;
    cin>>s;
    int b=0;
    int w=0;
    for(int i = 0;i<s.size();i++){
        if(s[i]=='0') b++;
        else w++;
    }
    cout<<min(b,w)*2<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int PizaA = X, PizaB = Y, PizaC = 0;

	while ((A + B) > C * 2 && PizaA > 0 && PizaB > 0) {
		PizaA--;
		PizaB--;
		PizaC += 2;
	}

	while (A > C * 2 && PizaA > 0) {
		PizaA--;
		PizaC += 2;
	}

	while (B > C * 2 && PizaB > 0) {
		PizaB--;
		PizaC += 2;
	}

	cout << A * PizaA + B * PizaB + C * PizaC << endl;

	return 0;
}


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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int n; cin >> n;
	vector< vector<bool> > a(n, vector<bool>(n));
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < n; j++) a[i][j] = (s[j] == 'Y');
	}
	int m = 0;
	union_find uf(n);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (a[i][j]) {
				m++;
				uf.unite(i, j);
			}
	int x = n * (n - 1) / 2 - m;
	if (n % 2 == 0) {
		int y = 0, e = 0, o = 0;
		for (int i = 0; i < n; i++)
			if (uf.find(i) == i) {
				int k = uf.size(i);
				y += k * (k - 1) / 2;
				if (k % 2 == 0) e++;
				else o++;
			}
		y -= m;
		if (x % 2 == 0) cout << ((e == 0 && y % 2 == 1) || e == 1 ? "Taro" : "Hanako") << endl;
		else cout << ((e == 0 && y % 2 == 1) || e >= 1 ? "Taro" : "Hanako") << endl;
	}
	else cout << (x % 2 == 0 ? "Hanako" : "Taro") << endl;
}

Measured memory_bytes: 1380
#include <stdio.h>
#include <ctype.h>

int main(void) {
	char alpha[4];
	int mofu;
	if (scanf("%3s", alpha) != 1) return 1;
	mofu = (unsigned char)alpha[0];
	putchar(isupper(mofu) ? 'A' : (islower(mofu) ? 'a' : '?'));
	return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n+1);
  rep(i, 0, n+1){
    v[i] = i;
  }
  unordered_set<long long > st;
  vector<long long> s(n+1);
  s[0] = 0;
  rep(i, 1, n){
    s[i] = s[i-1] + v[i];
    // cout << s[i] << endl;
  }

  long long ans = 0;
  long long L, R;
  for (long long i=k; i<=n+1; i++){
    L = i * (i-1) / 2;
    R = i * (2 * n - i + 1) / 2;
    ans += (R - L + 1);
    ans %= mod;
  }
  cout << ans << endl;
}


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

int main(){
    ll n,i,sum;

    cin>>n;
    sum=0;
    for(i=0;i<n;i++){
        ll a;
        cin>>a;
        sum^=a;
    }
    cout<<(sum==0 ?"Yes" : "No")<<endl;

return 0;
}


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

typedef long long ll;

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

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

Measured memory_bytes: 13516
// おまじない
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,l;
  cin>>n>>l;
  int sum=n*(2*l+n-1)/2;
  if(l<=0 && l+n-1>=0){
    cout<<sum<<endl;}
  else if(l>0){
    cout<<sum-l<<endl;}
  else{
    cout<<sum -(l+n-1)<<endl;}
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
struct po { double x, y; };
void koch(int n,po a, po b) {
    if (n == 0) 
        return;
    po s, t, u; double th = 60.0 * (acos(-1) / 180.0);
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    koch(n - 1, a, s);
    cout << fixed << setprecision(10) << s.x << " " << s.y << endl;
    koch(n - 1, s, u);
    cout << fixed << setprecision(10) << u.x << " " << u.y << endl;
    koch(n - 1, u, t);
    cout << fixed << setprecision(10) << t.x << " " << t.y << endl;
    koch(n - 1, t, b);
}
int main() {
    int n; cin >> n;
    po a, b;
    a.x = 0; a.y = 0; b.x = 100; b.y = 0;
    cout << fixed << setprecision(10) << a.x << " " << a.y << endl;
    koch(n, a, b);
    cout << fixed << setprecision(10) << b.x << " " << b.y << endl;
}


Measured memory_bytes: 3264
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int y = scanner.nextInt();
		int x = scanner.nextInt();
		for(int i=0; i<x+2; i++){
			System.out.printf("#");
		}
		System.out.printf("\n");
		for(int i=0;i<y;i++){
			String l = scanner.next();
			System.out.println("#"+l+"#");
		}
		for(int i=0; i<x+2; i++){
			System.out.print("#");
		}
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <set>

template <typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int64_t a, b;
    std::cin >> a >> b;

    int64_t g = gcd(a, b);

    std::set<int64_t> primes;
    primes.insert(1);
    for (int64_t i = 2; i * i <= g; i++) {
        while (g % i == 0) {
            primes.insert(i);
            g /= i;
        }
    }
    if (g > 1) {
        primes.insert(g);
    }

    std::cout << primes.size() << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string S; cin>>S;
  int K;cin>>K;
  if(S.size()==1){cout<<K/2<<endl;return 0;}
  int ans=0;
  for(int i=1;i<S.size();i++)if(S.at(i)==S.at(i-1)){ans++;i++;}
  if(S.at(0)!=S.at(S.size()-1)){cout<<ans*K<<endl;return 0;}
  int a=0,b=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)==S.at(0))a++;
    else break;
    if(i==S.size()-1){cout<<S.size()*K/2<<endl;return 0;}
  }
  for(int i=S.size()-1;i>=0;i--){
    if(S.at(i)==S.at(0))b++;
    else break;
  }
  cout<<ans*K-(a/2+b/2-(a+b)/2)*(K-1)<<endl;
}

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

inline int add(int a, int b, int c)
{
	return 10*a+b+c;
}

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

	cout<<max(add(a,b,c), max(add(a,c,b), max(add(b,a,c), max(add(b,c,a), max(add(c,a,b), add(c,b,a))))));
	return 0;

}

Measured memory_bytes: 256
from sys import stdin

def main():
    nums = [int(n) for n in stdin]

    primes = list(filter(is_prime, nums))
    print(len(primes))

def is_prime(n):
    if 1 == n:
        return False

    if 2 == n:
        return True

    if 0 == n % 2:
        return False

    for i in range(3, n, 2):
        if not i <= int(n/i):
            break

        if 0 == n % i:
            return False

    return True

if __name__ == '__main__':
    main()

Measured memory_bytes: 8024