akhauriyash/Code-Regression huggingface dataset:
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n;
	cin>>n;
	vvi G(n);
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;
		G[a].pb(c);
		G[b].pb(c);
	}
	map<int,int>ma;
	rep(i,n){
		int x=0;
		rep(j,G[i].size())x^=G[i][j];
		if(x)ma[x]++;
	}
	int m=0,out=0;
	FOR(a,ma){
		out+=a.second/2;
		if(a.second%2)m+=1<<a.first;
	}
	vi dp(1<<15,inf);
	dp[0]=0;
	m/=2;
	rep(i,1<<15){
		rep(j,15)if((i&1<<j)==0)cmin(dp[i|1<<j],dp[i]+1);
		int t=1<<15;
		t-=1+i;
		for(int j=t;j>0;j=(j-1)&t){
			int x=0,c=0;
			rep(k,15)if(j&1<<k)x^=1+k,c++;
			if(x)continue;
			cmin(dp[i|j],dp[i]+c-1);
		}
	}
	cout<<out+dp[m]<<endl;
}















Measured memory_bytes: 6772
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
a_sum = 0
for i in C.values():
    a_sum += i*(i-1)//2

for a in A:
    k = C[a]
    print(a_sum-(k*(k-1)//2)+((k-1)*(k-2)//2))


Measured memory_bytes: 26772
n,m = (int(x) for x in input().split())
list = list(map(int,input().split()))
su1 = sum(list)
su2 = 0
for i in range(n):
    if list[i]>=su1/(4*m):
        su2+=1
if su2>=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 配列
        int x = sc.nextInt();
        int n = sc.nextInt();

        if(n == 0) {
            System.out.println(x);
            return;
    }
        ArrayList<Integer> p = new ArrayList<Integer>();
        for(int i=1;i<=n;i++){
            p.add(sc.nextInt());
        }

        Integer t = Integer.valueOf(0);
        for(int i = 0; ;i++) {
            t = Integer.valueOf(x - i);
            if(!p.contains(t)) {
                System.out.println(t.toString());
                return;
            } 
            t = Integer.valueOf(x + i);
            if(!p.contains(t)) {
                System.out.println(t.toString());
                return;
            } 
        }
    }
}


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

int main(){
	int n; cin >> n;
	int a[n][3];

	for(int i=0;i<n;i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	// int dp[n][3];

	// dp[0][0] = a[0];
	// dp[0][1] = b[0];
	// dp[0][2] = c[0];

	for(int i=1;i<n;i++){
		a[i][0] = max(a[i-1][1], a[i-1][2]) + a[i][0];
		a[i][1] = max(a[i-1][0], a[i-1][2]) + a[i][1];
		a[i][2] = max(a[i-1][0], a[i-1][1]) + a[i][2];
	}
	cout << max(a[n-1][0], max(a[n-1][1], a[n-1][2])) << endl;
}


// int main(){
// 	int n; cin >> n;
// 	int a[n], b[n], c[n];

// 	for(int i=0;i<n;i++){
// 		cin >> a[i] >> b[i] >> c[i];
// 	}
// 	int dp[n][3];

// 	dp[0][0] = a[0];
// 	dp[0][1] = b[0];
// 	dp[0][2] = c[0];

// 	for(int i=1;i<n;i++){
// 		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
// 		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
// 		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
// 	}
// 	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
// }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

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

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int n;
string s;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    int ans = 0;
    REP(i, n){
        map<char, int> mp;
        for(int j = 0; j < i; j++){
            mp[s[j]]++;
        }
        int cnt = 0;
        for(int j = i; j < n; j++){
            if(mp[s[j]] > 0){ cnt++; mp[s[j]] = 0;}
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
class Shop:
    def __init__(self, price: int, limit: int):
        self.price = price
        self.limit = limit

    def __lt__(self, other):
        return self.price < other.price


N, M = map(int, input().split())
shops = []
for _ in range(N):
    a, b = map(int, input().split())
    shops.append(Shop(a, b))

shops.sort()

ret = 0
for s in shops:
    if s.limit > M:
        ret += s.price * M
        break
    ret += s.price * s.limit
    M -= s.limit

print(ret)


Measured memory_bytes: 27160
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<char> vc;
#define mp make_pair
#define pb push_back
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define f(i,n) for(i=0;i<n;i++)
#define F(i,n) for(i=1;i<=n;i++)
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( ((//(//(a - b ) % m = ( (a % m - b % m ) + m ) %m
// a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}
void solve(){
	ll i,j,n,k,m;
	cin>>n>>k;
	ll ar[n+1]={0};
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	ll pre[n+1]={0};
	for(i=1;i<=n;i++){
		pre[i]=pre[i-1]+ar[i];
	}
	for(i=k+1;i<=n;i++){
		ll pp=pre[i]-pre[i-k];
		ll qq=pre[i-1]-pre[i-k-1];
		if(pp>qq){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
}
int main(){
	// freopen("input.txt","r",stdin);
	solve();
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 6692
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque

inf = 10**18
mod = 10**9+7

dic = {}

# mod で割り算(フェルマー、逆元利用)
mod = 10**9+7

N = 10**6+1
inv_t = [0]+[1]

for i in range(2,N):
    inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def moddiv(a, b):
    return a*inv_t[b]%mod

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
a = list(map(int, input().split()))
j = []
for num in a:
    tmp = factorization(num)
    j.append(tmp)
    for p,x in tmp:
        if p in dic:
            dic[p] = max(dic[p],x)
        else:
            dic[p] = x
gc = 1
for k,v in dic.items():
    gc*=(k**v)%mod
ans = 0
for num in a:
    ans += moddiv(gc, num)
    ans %= mod
print(ans)


Measured memory_bytes: 74124
#n=int(input())
n,m=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

acdic={}
wadic={}
for i in range(n):
    acdic[i+1]=False
    wadic[i+1]=0

acnum=0
wanum=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="AC" and acdic[p]==False :
        acnum+=1
        acdic[p]=True
        wanum+=wadic[p]
    else:
        wadic[p]=wadic[p]+1

print("{0} {1}".format(acnum,wanum))



Measured memory_bytes: 64244
#include <stdio.h>
int main(void){
	char s[100],p[100];
	int i,j,n,fin=0,poss=0,posp=0;
	scanf("%s",&s);
	for(i=0;i<100;i++){
		if(s[i]=='\0')break;
		poss++;
	}
	scanf("%s",&p);
	for(i=0;i<100;i++){
		if(p[i]=='\0')break;
		posp++;
	}
	for(i=0;i<poss;i++){
		for(j=0;j<posp;j++){
			n=i+j;
			if(n>=poss) n=n-poss;
			if(s[n]==p[j]){
				if(j+1==posp){
				fin++;
				}
			}
			else break;
		}
	}
	if(fin>0)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}


Measured memory_bytes: 1808
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  string s;
  int idx=0;
  REP(3){
    cin >> s;
    cout << s[idx++];
  }

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,di=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int d[1000][1000];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];



unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい

int main()
{
	cin >> n >> a >> b >> c >> di >> e;
	mini = std::min({ a,b,c,di,e });
	if (mini <= n) {
		if (n%mini == 0) {
			cout << 4 + n / mini << endl;;
		}
		else {
			cout << 5 + n / mini << endl;
		}
	}
	else {
		cout << 5 << endl;
	}
}


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

int main() {
   string N;
   int ans = 0;
   cin >> N;
   for(int i=1; i<N.size(); i++){
     if(N[i-1] == N[i] && N[i-1] == '1'){
       N[i] = '0';
       ans++;
     }
     else if(N[i-1] == N[i] && N[i-1] == '0'){
       N[i] = '1';
       ans++;
     }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>

using std::cout;
using std::endl;

bool isLeapYear(int year);

int main()
{
    int start, end;
    while (true) {
        std::cin >> start >> end;

        if (start == 0 && end == 0) {
            break;
        }

        static bool first_output = true;
        if (!first_output) {
            cout << endl;
        }
        first_output = false;

        int cnt = 0;
        for (int year = start; year <= end; year++) {
            if (isLeapYear(year)) {
                cout << year << endl;
                cnt++;
            }
        }
        if (cnt == 0) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

bool isLeapYear(int year)
{
    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else {
        return (year % 4 == 0);
    }
}

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

using PP = pair<long, long>;

int n;
vector<PP> ps;

bool less_pi(PP p) {
  long x = p.first;
  long y = p.second;
  return y > 0 || y == 0 && x > 0;
}

bool comp_arg(PP a, PP b) {
  if (less_pi(a) && !less_pi(b)) return true;
  if (!less_pi(a) && less_pi(b)) return false;
  return a.first * b.second - a.second * b.first > 0;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) continue;
    ps.push_back(PP(x, y));
  }
  n = ps.size();
  sort(ps.begin(), ps.end(), comp_arg);
  
  long mx = 0;
  for (int l = 0; l < n; ++l) {
    for (int r = l + 1; r <= n + l; ++r) {
      PP sum(0, 0);
      
      for (int si = l; si < r; ++si) {
        int i = si % n;
        sum.first += ps[i].first;
        sum.second += ps[i].second;
      }
      
      mx = max(mx, sum.first * sum.first + sum.second * sum.second);
    }
  }
  cout << setprecision(16) << fixed << sqrt(mx) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long LL;

int cnt(int n)
{
	int c = 0;
	for(int p=1; p<=n; ++p)
		if(n%p==0)
			++c;
	return c;
}

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for(int n=1; n<=N; n+=2)
		if(cnt(n)==8)
			ans++;
	cout << ans << endl;
}




Measured memory_bytes: 256
import math
N = int(input())

keta = int(math.log10(N) + 1)
res = 0
while True:
    if keta % 2 == 0:
       N = N - (N % 10 ** (keta-1)) - 1
    else:
       res += N - 10 ** (keta - 1) + 1
       N = 10 ** (keta - 1) - 1
    if N <= 0:
        break
    keta = int(math.log10(N) + 1)
print(res)

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

bool ok(const string &a,const string &b){
  cout<<a<<endl<<b<<endl<<flush;
  string s;
  cin>>s;
  if(s=="end") exit(0);
  if(s=="F") return 0;
  return 1;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  string cs=".#";
  string a,b;
  while(a.size()<n){
    int f=1;
    rep(i,2*f)rep(j,2){
      if(ok(a+cs[i],b+cs[j])){
	f=0;
	a+=cs[i];
	b+=cs[j];
	break;
      }
    }
    if(f || a.size()==n) break;
  }
  while(a.size()<n){
    int f=1;
    rep(i,2*f)rep(j,2){
      if(ok(cs[i]+a,cs[j]+b)){
	f=0;
	a=cs[i]+a;
	b=cs[j]+b;
	break;
      }
    }
    if(f || a.size()==n) break;
  }
  return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T>
T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T>
T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

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

ll sx, sy;
ll gx, gy;

int main()
{
    cin >> n >> m;
    if(n==1){
        if(m==1){
            cout << 1 << endl;
        }else if(m==2){
            cout << 0 << endl;
        }else{
            cout << m - 2 << endl;
        }
    }else if(n==2){
        cout << 0 << endl;
    }else{
        if(m==1){
            cout << n - 2 << endl;
        }else{
            cout << (m - 2) * (n - 2) << endl;
        }
    }
    // REP(i, m)
    // {
    //     REP(j, n)
    //     {
    //         if(i==0||i==m-1||j==0||j==n-1){
    //             REP(t, 9)
    //             {
    //                 ll nx = i + dx[t];
    //                 ll ny = j + dy[t];
    //                 if (0 <= nx && nx < m && 0 <= ny && ny < n)
    //                 {
    //                     cnt++;
    //                 }
    //             }
    //             if (cnt % 2 != 0)
    //             {
    //                 ans++;
    //             }
    //             cnt = 0;
    //         }
    //     }
    // }
    // if(n-2>0&&m-2>0){
    //     ans += (n - 2) * (m - 2);
    // }
    // cout << ans << endl;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 170B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 X          PIC 9(03).
01 Y          PIC 9(03).
01 I          PIC 9(03).
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO X Y.
*>
  PERFORM VARYING I FROM 1 BY 1 
            UNTIL I > X OR I * 2 + (X - I) * 4 = Y OR I * 4 + (X - I) * 2 = Y
  END-PERFORM.
*>
  IF (I <= X)
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF.
*>
  STOP RUN.


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

int main(){
	int n;
	int v;
	long long int min,max,sum;
	cin>>n;
	
	int i;
	min=99999999;
	max=-99999999;
	sum=0;
	for(i=0 ; i<n ; i++)
	{
		cin>>v;
		if(v<min)
		{
			min=v;
		}
		if(v>max)
		{
			max=v;
		}
		sum+=v;
	}
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}



Measured memory_bytes: 3212
using System.Text;
public partial class IntroductionToProgramming{
    public static void Main(){
        string[] line = System.Console.ReadLine().Split(' ');
        int r = int.Parse(line[0]);
        int c = int.Parse(line[1]);
 
        int[,] cell = new int[r + 1, c + 1];
        int sum = 0;
 
        for (int i = 0; i < r; i++)
        {
            string[] line2 = System.Console.ReadLine().Split(' ');
            for (int j = 0; j < c; j++)
            {
                int n = int.Parse(line2[j]);
                cell[i, j] = n;
                cell[r, j] += n;
                cell[i, c] += n;
                sum += n;
            }
        }
        cell[r, c] = sum;
 
        for (int i = 0; i < r + 1; i++)
        {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < c + 1; j++)
            {
                sb.Append(cell[i, j].ToString() + " ");
            }
            System.Console.WriteLine(sb.ToString().Trim());
        }
    }
}

Measured memory_bytes: 19960
<?php
    list($S,$T) = array_map(null,explode(" ",trim(fgets(STDIN))));
    list($A,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $line = trim(fgets(STDIN));
    
    if($S==$line){
        $A = $A - 1;
    }else{
        $B = $B - 1;
    }
    
    echo $A." ".$B."\n";
?>

Measured memory_bytes: 16160
n = int(input())
i = 1
while 1:
    x = i
    if x % 3 ==0:
        print(' ', i, sep='', end='')
    else:
        while x:
            if x % 10 == 3:
                print(' ', i, sep='', end='')
                break
            x //= 10
    if i >= n:
        break
    else:
        i += 1
print()


Measured memory_bytes: 6160
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        double v;
        string c;
        cin >> v;
        cin >> c;
        if (c == "BTC") v *= 380000;
        sum += v;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  int x,y,z;
  x=a-c;
  if(x<0)x*=-1;
  if(x<=d){cout<<"Yes"<<endl;}
  else{
    
    vector <int> aaa={a,b,c};
    sort(aaa.begin(),aaa.end());
    
   if(aaa.at(2)-aaa.at(1)<=d&&aaa.at(1)-aaa.at(0)<=d) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi a(n),b(n);
    rp(i,n){
        cin >> a.at(i) >> b.at(i);
    }
    sort(all(a));
    sort(all(b));
    if(n&1){
        print(b[n/2]-a[n/2]+1);
    }
    else{
        print(b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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


using namespace std;

#define ll long int
#define ull unsigned long long int

#define I_read()  freopen("input.tex","r",stdin);

#define O_write() freopen("output.txt","w",stdout);

#define fast() ios_base::sync_with_stdio(false); cin.tie(0);


int main(){

	fast();	
#ifdef _DEBUG

//	  I_read();
//        O_write();

#endif
int h1,h2,m1,m2,k;

cin>>h1 >>m1 >>h2 >>m2 >>k;

cout<<(60*(h2 - h1) - m1 + m2 - k)<<endl;	

 return 0;	
}



Measured memory_bytes: 3640
x = int(input())

ans = 0
max = 100005
prime_list = []
is_prime = [True for _ in range(max)]
is_prime[0] = False
is_prime[1] = False

for i in range(2, max):
    if is_prime[i]:
        if i >= x:
            #print(is_prime)
            ans = i
            break
        for j in range(2*i, max, i):
            is_prime[j] = False

print(ans)


Measured memory_bytes: 44784
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
typedef long long int lli;
const long long int MaxN=1000105;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}

int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli N;
	cin>>N;
	N=N%10;
	if(N==2||N==4||N==5||N==7||N==9){
		cout<<"hon";
	}
	if(N==0||N==1||N==6||N==8){
		cout<<"pon";
	}
	if(N==3){
		cout<<"bon";
	}
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    set<char> se;
    rep(i, s.size()) se.insert(s[i]);
    for(char i = 'a'; i<='z'; i++) {
        if(!se.count(i)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

int main() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if ((n | k) == 0) {
            break;
        }
        int* s = new int [k];
        for (int j = 0; j < k; j++) {
            cin >> s[j];
        }
        int** b = new int* [n];
        for (int i = 0; i < n; i++) {
            b[i] = new int [k];
            for (int j = 0; j < k; j++) {
                cin >> b[i][j];
            }
        }
        bool enoughBlood = true;
        for (int j = 0; j < k; j++) {
            int sum = 0;
            for (int i = 0; i < n; i++) {
                sum += b[i][j];
            }
            if (s[j] < sum) {
                enoughBlood = false;
                break;
            }
        }
        if (enoughBlood) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        delete[] s;
        for (int i = 0; i < n; i++) {
            delete[] b[i];
        }
        delete[] b;
    }
}

Measured memory_bytes: 932
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
//pragma GCC optimize("Ofast")
//pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native" )
#include <queue>
#define endl "\n";
#define int long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;

void solve() {
	int x, y;
	cin >> x >> y;
	while (x * 2 != y and x > 0) {
		x--;
		y -= 4;
	}
	if (x * 2 == y) cout << "Yes";
	else cout << "No";
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int t;
	t = 1;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, p[100010] = {};
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> p[i];

    int cnt = 0;
    int ans = 0;
    bool last = false;
    for (int i=0; i<=n; i++) {
        if (p[i] == i+1) {
            cnt++;
        }
        else {
            ans += ceil(cnt/2.0);
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int a,b,c,d;
ll k;
string s;

int main() {
	cin >> a >> b >> c >> d;
	REP(i, c - a) cout << "R";
	REP(i, d - b) cout << "U";
	REP(i, c - a) cout << "L";
	REP(i, d - b) cout << "D";
	cout << "D";
	REP(i, c - a + 1) cout << "R";
	REP(i, d - b + 1) cout << "U";
	cout << "LU";
	REP(i, c - a + 1) cout << "L";
	REP(i, d - b + 1) cout << "D";
	cout << "R";
	cout << endl;
}


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

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

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

    if(S.length() % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < S.length();i+=2)
    {
        if(S[i] != 'h' || S[i+1] != 'i')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  int ans = 1;
  repp(i, 2, X - 1) {
    repp(j, 2, 10) {
      int p = pow(i, j);
      if (p <= X) chmax(ans, p);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
l = []
r = []
m.times do
  l_i, r_i = gets.chomp.split(" ").map(&:to_i)
  l << l_i
  r << r_i
end

answer = (r.min > n ? n : r.min) - l.max + 1
puts answer < 0 ? 0 : answer


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
double temp(int at,int ac,int bt,int bc)
{
  return (double)(at*ac+bt*bc)/(double)(ac+bc);
}
bool suit(int ac,int bc,int d)
{
  return (1<=(ac+bc) && (ac+bc)<=d);
}
int main(void)
{
  int t,d,at,bt,ad,bd;
  cin >> t >> d;
  cin >> at >> bt;
  cin >> ad >> bd;
  double answer=1000.0;
  REP(i,d/ad+1) REP(j,d/bd+1){
    int ac=ad*i,bc=bd*j;
    if(suit(ac,bc,d)){
      answer=min(answer,abs(temp(at,ac,bt,bc)-t));
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>

using namespace std;
typedef pair<int, int> int_p;

int main(){

  int N;
  int_p red[100], blue[100];
  cin >> N;
  for (int i = 0; i < N; ++i){
    cin >> red[i].first >> red[i].second;
  }
  for (int i = 0; i < N; ++i){
    cin >> blue[i].first >> blue[i].second;
  }

  sort(blue, blue + N, [](int_p l, int_p r){return l.first < r.first;});
  bool used[100]{false};

  for (int i = 0; i < N; ++i){
    int ymax = -1;
    int index = -1;
    for (int j = 0; j < N; ++j){
      if (used[j]) continue;
      if (blue[i].first > red[j].first && blue[i].second > red[j].second && red[j].second > ymax){
        ymax = red[j].second;
        index = j;
      }
    }
    if (index != -1){
      used[index] = true;
    }
  }

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

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, P = map(int, input().split())
cnt = defaultdict(int)
for i in range(2, int(P**0.5)+1):
    while P % i == 0:
        cnt[i] += 1
        P //= i
if P > 1:
    cnt[P] += 1
ans = 1
for k in cnt.keys():
    if cnt[k] >= N:
        ans *= k**(cnt[k]//N)
print(ans)

Measured memory_bytes: 40172
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll f(ll b, ll n) {
  if (n < b) return n;
  return f(b, n/b) + n % b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,s;
  cin>>n>>s;
  if (s > n) {
    cout << -1 << endl;
    return 0;
  } else if (s == n) {
    cout << n+1 << endl;
    return 0;
  }
  FOR(i,2,400000) {
    if (f(i,n) == s) {
      cout<<i<<endl;
      return 0;
    }
  }
  ll d = n - s;
  set<ll> candi;
  for (ll i = 1; i*i <= d; ++i) {
    if (d % i == 0) {
      candi.insert(i+1);
      candi.insert(d/i+1);
    }
  }
  for (auto&& b : candi) {
    if (b < 400000) continue;
    if (f(b, n) == s) {
      cout<<b<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 512
/**
 * Koch Curve
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=ja
 */

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

struct Point {
  double x;
  double y;
};

void printPoint(Point p) {
  printf("%.8f %.8f", p.x, p.y);
  cout << endl;
}

void koch(int n, Point p1, Point p2) {
  if (n == 0) {
    return;
  }

  // 度からラジアンへ単位を変換
  double th = M_PI * 60.0 / 180.0;

  Point s, t, u;
 	s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
	s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;

	t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
	t.y = (1.0 * p1.y + 2.0 * p2.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;

  // p1とsの間にコッホ曲線を描く
  koch(n - 1, p1, s);
  printPoint(s);
  // sとuの間にコッホ曲線を描く
  koch(n - 1, s, u);
  printPoint(u);
  // uとtの間にコッホ曲線を描く
  koch(n - 1, u, t);
  printPoint(t);
  // tとp2の間にコッホ曲線を描く
  koch(n - 1, t, p2);
}

int main() {
  // 深さn
  int n;
  cin >> n;

  Point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  // 始点の出力
  printPoint(a);
  koch(n, a, b);
  // 終点の出力
  printPoint(b);
}



Measured memory_bytes: 3252
n = int(input())
A = [int(i) for i in input().split()]

def parent(i):
    i += 1
    return int(i/2) -1

def left(i):
    i += 1
    return 2*i -1

def right(i):
    i += 1
    return 2*i + 1 -1

def maxHeapify(A, i):
    l = left(i)
    r = right(i)
    
    largest = i
    if(l < len(A) and A[l] > A[i] ):
        largest = l
    
    if(r < len(A) and A[r] > A[largest]):
        largest = r
    
    if(largest != i):
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest)
#         print(A)
    
    return A
        
def buildMaxHeap(A):
    for i in range(int(len(A)/2)-1, -1, -1):
        A = maxHeapify(A, i)
    return A

A = buildMaxHeap(A)

print(" {}".format(" ".join([str(i) for i in A])))


Measured memory_bytes: 63996
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let k: i64 = read();

    if k <= a {
        println!("{}", k);
    } else if k <= a + b {
        println!("{}", a);
    } else {
        println!("{}", a - (k - a - b));
    }

}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int, int> pi;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MKP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
const int INF = 999999;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll MOD = 1000000007;


int main(){
  ll N;
  cin >> N;
  if(N%2){
    cout << N * 2 << endl;
  }else{
    cout << N << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dp[1000200],dp1[1000200];

signed main(){
	vector<int>v;
	FOR(i,1,10000){
		int t = i * (i + 1) * (i + 2) / 6;
		if(t > 1000000)break;
		v.emplace_back(t);
	}
	REP(i,1000200)dp[i] = dp1[i] = INF;
	dp[0] = dp1[0] = 0;
	REP(i,v.size()){
		REP(j,1000001){
			if(v[i] % 2){
				if(j + v[i] <= 1000000)CHMIN(dp1[j+v[i]],dp1[j]+1);
			}
			if(j + v[i] <= 1000000)CHMIN(dp[j+v[i]],dp[j]+1);
		}
	}
	int N;
	while(cin >> N,N){
		out(dp[N],dp1[N]);
	}
}


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

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

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  else ans(s[0]=='C',"Rainy","Sunny");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    long long int days;
    long long int M;
    long long int a;
    cin >> days;
    cin >> M;
    vector<int>A(M);
    a = 0;
    for(int i =0; i<=M-1; i++){
    cin >> A[i];
    a = a + A[i];
    }
    if(days>=a){
    cout << (days - a);
    }
    else{
    cout << -1;
    }
    return 0;
}

Measured memory_bytes: 3668
s = gets.chomp

ary = s.split('')
stack = []
p = s[0]
count = 0
ary.each do |c|
  if c == p
    stack.push c
  else
    if stack.size > 0
      stack.pop
      count += 1
    else
      stack.push c
      p = c
    end
  end
end
puts count * 2


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

int main()
{
  int N;                       // data num
  int v[4][3][10];    // People in [b][f][r]
  int p; // Enter or Exit
  int b,f,r;

  // initialize
  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
	v[i][j][k] = 0;
      }}}
  
  // input
  cin >> N;
  for(int x=1; x<=N; x++){
    cin >> b >> f >> r >> p;
  v[b-1][f-1][r-1] = v[b-1][f-1][r-1] + p;
  }

  // output
  for(int l=0; l<4; l++){
    for(int m=0; m<3; m++){
      for(int n=0; n<10; n++){
  	cout << " " << v[l][m][n] ;}
      cout << endl;}
    if(l != 3)
      {cout << "####################" << endl;}}

 return 0;
}


Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b){
		cout << c << endl;
	}else if(b == c){
		cout << a << endl;
	}else if(a == c){
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	max := largest(a, b, c)
	sum := a + b + c

	diff := 3*max - sum
	if diff%2 == 1 {
		diff += 3
	}
	ans := diff / 2
	fmt.Println(ans)
}


Measured memory_bytes: 512
from collections import Counter
n = int(input())
s = [''] * n
for i in range(n):
	s[i] = input()

r = s[0]
for i in range(1, n):
	set_c = set(r) & set(s[i])
	if len(set_c) == 0:
		print('')
		exit()
	next_r = ''
	cnt_r = Counter(r)
	cnt_s = Counter(s[i])
	for c in set_c:
		next_r += c * min(cnt_r[c], cnt_s[c])
	r = next_r
print(''.join(sorted(r)))

Measured memory_bytes: 9408
class Point(object):
    x = 0.0
    y = 0.0
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __sub__(left, right):
        return Point(left.x - right.x, left.y - right.y)
    #cross
    def __mul__(left, right):
        return left.x * right.y - left.y * right.x
def f(n):
    return n<0
while True:
    try:
        (xa,ya,xb,yb,xc,yc,xd,yd) = [float(i) for i in raw_input().split(',')]
        a = Point(xa,ya)
        b = Point(xb,yb)
        c = Point(xc,yc)
        d = Point(xd,yd)
        ab = a - b
        bc = b - c
        cd = c - d
        da = d - a
        if((f(ab*bc) + f(bc*cd)) + (f(cd*da) + f(da*ab)) in (0,4)):
            print 'YES'
        else:
            print 'NO'
    except:
        break

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


int main() {
  
  int N;
  cin  >> N;
  
  vector<int> blue(N);
  
  rep(i,N){
    cin >> blue.at(i);
  }
  
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int K;
      
      if(blue.at(i) < blue.at(j)){
        K=blue.at(i);
        blue.at(i)=blue.at(j);
        blue.at(j)=K;
      }
    }
  }
  
  int sumA,sumB;
  
  rep(i,N){
    if(!(i%2))
      sumA+=blue.at(i);
    else
      sumA-=blue.at(i);
  }
  cout << sumA <<endl;
  
  
}

Measured memory_bytes: 256