akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

long read();
long think(long);
void write(long);

bool isPrime(long);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(input);
  write(output);

  return 0;
}

long read() {
  long n;

  cin >> n;
  return n;
}

long think(long input) {
  if (isPrime(input)) {
    return input - 1;  // from (1, 1) to (1, n) is the least. so distance is (n - 1)
  }

  long ceiling = ceil(sqrt(input)) + 1;
  for (long i = ceiling; i > 1; i--) {
    if (input % i == 0) {
      long j = input / i;
      return (i - 1) + (j - 1);  // from (1, 1) to (i, j) is the least. so distance is (i - 1) + (j - 1)
    }
  }

  return 0;
}

void write(long output) {
  cout << output << endl;
}

bool isPrime(long x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  if (x % 2 == 0) {
    return false;
  }

  long ceiling = ceil(sqrt(x)) + 1;
  for (long i = 3; i <= ceiling; i += 2) {
    if (x == i) {
      return true;
    }
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LONG_LONG_MIN
#define     INF         LONG_LONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> v,r;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.pb(a);
        r.pb(b);
    }
    sort(all(v));
    sort(all(r));
    if(n%2==1){
        cout<<abs(r[n/2]-v[n/2])+1<<endl;
    }
    else{
        ll x=v[n/2]+v[n/2-1];
        ll y=r[n/2-1]+r[n/2];
        cout<<abs(x-y)+1<<endl;
    }
    return 0;
}



















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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    string s;
    cin1(s);
    string prev = s.substr(0, 1);
    string cur = "";
    lli ans = 1;
    REP(i, 1, s.length()) {
        cur += s[i];
        //cout1(prev);
        //cout1(cur);

        if (prev == cur) {
        }
        else {
            prev = cur;
            ans++;
            cur = "";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string> 
using namespace std;
int main()
{
	string a;
	cin>>a;
	int sum=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='1')
		sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1100031;

int n,k;

long double ans;

int solver(int x){
	int res=0;
	while (x<k)
		x*=2,
		res++;
	return res;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n>>k;

    for (int i=1;i<=n;i++){
    	int here=solver(i);
    	double t=pow(1.0/2.0,here);
    	ans+=t*1.0/n;
    }
    cout.precision(12);
    cout<<fixed<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 256
/*
ID: jerrywcy
TASK:
LINK:
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int main(){
  int i,j;
  int M, N, Q;
  int p,q;
  int **LR;
  int acc;
  scanf("%d %d %d", &N, &M, &Q);
  LR = new int*[N];
  for (i=0 ; i<N; i++){
    LR[i] = new int[N-i]();
  }
  
  for (i=0; i<M; i++){
    scanf("%d %d", &p, &q);
    LR[p-1][q-p] += 1;
  }

  for (i=N-2; 0<=i; i--){
    acc = 0;
    for (j=0; j<N-i; j++){
      acc += LR[i][j];
      LR[i][j] = acc + LR[i+1][j-1];
    }
  }
  
  for (i=0 ; i<Q; i++){
    scanf("%d %d", &p, &q);
    printf("%d\n", LR[p-1][q-p]);
  }
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define toRad(deg) (deg*M_PI/180.0)
#define EPS (1e-5)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }

int main() {
  double d;
  cin >> d;
  double maxi = d;
  maxi = max(maxi,sqrt(2.0)*d);
  double x = (int)d;
  if( LT(sqrt(d*d-x*x),1.0) ) maxi = max(maxi,x+1.0);
  printf("%.10f\n",maxi);
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    map<string, int> mp;
    vector<string> s(n);
    REP(i, n) {
        cin >> s[i];
        mp[s[i]]++;
    }

    int tmp = 0;
    for(auto v : mp) {
        chmax(tmp, v.second); 
    }
    for(auto v : mp) {
        // cout << v.first << v.second << endl;        
        // if (tmp == 0) tmp = v.second;
        if (tmp == v.second) cout << v.first << endl;
    }    
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <string>

#define J 0
#define O 1
#define I 2
#define UNDEF -1

using namespace std;

string buf;
int M,N,MAP[1000][1000],EM[2][2];

int getmap(int x,int y)
{
	if(x >= 0 && y >= 0 && x < N && y < M)
		return MAP[x][y];
	else
		return UNDEF;
}

bool match(int x,int y)
{
	return ((getmap(x,y) == EM[0][0]) && (getmap(x+1,y) == EM[1][0]) && (getmap(x,y+1) == EM[0][1]) && (getmap(x+1,y+1) == EM[1][1]));
}

int main(void)
{
	cin >> M >> N;
	for(int i = 0;i < M;i++)
	{
		cin >> buf;
		for(int ii = 0;ii < N;ii++)
		{
			if(buf[ii] == 'J')
				MAP[ii][i] = J;
			else if(buf[ii] == 'O')
				MAP[ii][i] = O;
			else
				MAP[ii][i] = I;
		}
	}
	for(int i = 0;i < 2;i++)
	{
		cin >> buf;
		for(int ii = 0;ii < 2;ii++)
		{
			if(buf[ii] == 'J')
				EM[ii][i] = J;
			else if(buf[ii] == 'O')
				EM[ii][i] = O;
			else
				EM[ii][i] = I;
		}
	}
	int maxadd = 0;
	int sum = 0;
	for(int y = 0;y < M;y++)
	{
		for(int x = 0;x < N;x++)
		{
			if(match(x,y))
				sum++;
		}
	}
	for(int y = 0;y < M;y++)
	{
		for(int x = 0;x < N;x++)
		{
			int a[3] = {0,0,0};
			int o = 0;
			int org = MAP[x][y];
			for(int oy = -1;oy < 1;oy++)
			{
				for(int ox = -1;ox < 1;ox++)
				{
					if(match(x+ox,y+oy))
						o++;
				}
			}
			for(int i = 0;i < 3;i++)
			{
				MAP[x][y] = i;
				for(int oy = -1;oy < 1;oy++)
				{
					for(int ox = -1;ox < 1;ox++)
					{
						if(match(x+ox,y+oy))
							a[i]++;
					}
				}
			}
			MAP[x][y] = org;
			maxadd = max(maxadd,max(a[0],max(a[1],a[2])) - o);
		}
	}
	cout << maxadd + sum << endl;	
}

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

int main(){
    int X, Y;
    cin >> X >> Y;
    string ans = "No";
    for(int i = 0; i <= X; i++){
        if(i*2 + (X-i)*4 == Y){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int D; 
int c[30];
int s[400][30];
int t[400];


ll cal_score(int temp[]){
    int last[30] = {0};
    ll score = 0;
    for(int d=1;d<=D;++d){
        int i = temp[d];
        score += s[d][i];
        last[i] = d;
        for(int j=1;j<=26;++j){
            score -= c[j]*(d-last[j]);
        }
        //cout << score << "\n";
    }
    return score;
}

int main(){
    cin >> D;
    for(int i=1;i<=26;++i){ cin >> c[i]; }
    for(int d=1;d<=D;++d){ for(int i=1;i<=26;++i){ cin >> s[d][i]; } }
    
    int score_max = 0;
    
	random_device rand_d;
    default_random_engine e1(rand_d());
    uniform_int_distribution<int> uniform_dist(1, 26);   
    
    REP(count,20000){
        int temp[400];
        for(int d=1;d<=D;++d){
            temp[d] = uniform_dist(e1);
            for(int i=1;i<=26;++i){
                if((double)s[d][i]>(double)s[d][temp[d]]*5){
                    temp[d] = i;
                }
            }
        }
        if(cal_score(temp)>score_max){
            for(int d=1;d<=D;++d){
                t[d] = temp[d];
            }
        }
    }
    for(int d=1;d<=D;++d){
        cout << max(t[d]%27,1) << "\n";
    }
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
int main()
{
	int n,k;
	cin>>n>>k;
	ll h[n+1];
	fr(i,1,n)
	cin>>h[i];
	ll dp[n+1];
	fr(i,0,n)
	{
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	fr(i,2,n)
	{
		for(int j=i-1;j>=max(1,i-k);j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n];
    return 0;
}





Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

ll a,b,c,k;

int main()
{
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(k <= (a+b)) cout << a << endl;
  else cout << a-(k-b-a) << endl;
}

Measured memory_bytes: 3632
/*  Author:  Hariom_Pandey
    Created: 8/22/2020 11:10:35 AM
*/

#include <bits/stdc++.h>
using namespace std;
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())
#define ll              long long int  

int32_t  main(){
   
   string str; cin>>str;
   int cnt=0;
   for(int i=0; i<3; i++){
       if(str[i]=='R'){
           cnt+=1;
       }
       else if(str[i]=='S' and i==1) {
           if(str[0]=='S' and str[2]=='R') {
               cnt+=1;
               break;
           }
           else break;
       }
       else {
           continue;
       }
       
   }
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define lowbit(x) ((x) & -(x))
using namespace std;

int n, q;
long long a[500010];

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		for (int j = i; j <= n; j += lowbit(j))
			a[j] += x;
	}
	while (q--) {
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		if (t) {
			long long sum = 0;
			for (int i = y; i > 0; i -= lowbit(i))
				sum += a[i];
			for (int i = x; i > 0; i -= lowbit(i))
				sum -= a[i];
			printf("%lld\n", sum);
		}
		else
			for (int i = x + 1; i <= n; i += lowbit(i))
				a[i] += y;
	}
	return 0;
}



Measured memory_bytes: 8212
H,W = map(int,input().split())
S = [input() for i in range(H)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(H*W)
for i in range(H):
    for j in range(W):
        if i < H-1 and S[i][j] != S[i+1][j]:
            uf.unite(i*W+j, (i+1)*W+j)
        if j < W-1 and S[i][j] != S[i][j+1]:
            uf.unite(i*W+j, i*W+j+1)
for i in range(H*W):
    uf.root(i)

from collections import defaultdict
bl = defaultdict(lambda: 0)
wh = defaultdict(lambda: 0)
for i in range(H):
    for j in range(W):
        v = i*W+j
        r = uf.root(v)
        if S[i][j]=='#':
            bl[r] += 1
        else:
            wh[r] += 1

ans = 0
for k in bl.keys():
    ans += bl[k] * wh[k]
print(ans)

Measured memory_bytes: 35504
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define LL long long
using namespace std;
const int N=1e5+7;

vector<int > ve[N];
priority_queue<int > q; 
int main()
{
	int n,m;
	cin>>n>>m;
	int a,b;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		ve[a].push_back(b); 
	}
	LL sum=0;
	for(int i=1;i<=m;i++){
		
		for(int j=0;j<ve[i].size() ;j++)
		q.push(ve[i][j]);
		if(!q.empty() ){
			sum+=q.top();
			q.pop() ;
		}  
	}
	cout<<sum<<endl;
	return 0;
 } 


Measured memory_bytes: 5632
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next()
    val p = S.count(_ == '+')
    val m = 4 - p
    val ans = p - m
    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25292
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
//ll a[N];
//ll sum[N];
////ll ans[N];
//set<ll> ans;
int main(void){
//    ios::sync_with_stdio(false);
//    cin.tie(0);cout.tie(0);

    ll a,b;
    cin >>a >>b;
    cout <<abs((a-2)*(b-2));
//    for(n=1;n<=10;n++){
//        for(k=1;k<=1;k++){
//            ll cnt=0;
//            for(ll a=1;a<=n;a++){
//                for(ll b=1;b<=n;b++){
//                    if(a%b>=k)  cnt++;
//                }
//            }
//            printf("ans[%lld][%lld]=%lld\n",n,k,cnt);
////            cout <<
//        }
//    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int n;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		m[x]++;
	}
	int ans=0;
	for (auto i:m)
	if (i.first<=i.second) ans+=i.second-i.first;
		else ans+=i.second;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;
 
public class Main {
	  public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
 
 
		    String str1 = scanner.next();
            String str2 = scanner.next();
 
            int A = Integer.parseInt(str1);
            int B = Integer.parseInt(str2);
 
           if(A + B == 15)
           {
        	   System.out.println("+");
           }
           else if(A * B == 15)
           {
        	   System.out.println("*");
           }
           else 
           {
        	   System.out.println("x");
           }
        	scanner.close();}
		  }

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define F first
#define S second
typedef vector<pli> vpli;
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end() 
#define tests int t; cin>>t; while(t--)
#define take(a,b,c) for(b=0;b<c;b++) cin>>a[b];
#define INF 1e18
// https://codeforces.com/problemset/page/3?tags=1500-1800
int main()
{	
  //auto start = std::chrono::high_resolution_clock::now();
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(k,a);
    k-=a;
    k=max(0,k);
    ans+=min(k,b)*0;
    k-=b;
    k=max(k,0);
    ans-=min(k,c);
    cout<<ans<<'\n';
  //auto stop = std::chrono::high_resolution_clock::now(); 
  //auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
  //cout << duration.count() << endl; 

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int n;
  cin>>n>>s;
  for(int i=0;i<s.length();i++)
  {
      if(s[i]+n > 90)
      {
          cout<<char(64+s[i]+n-90);
      }
      else
      cout<<char(s[i]+n);
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int n, a[100];
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for(int i = n-1; i >= 0; --i) {
    printf("%d", a[i]);
    if(i != 0) {
      printf(" ");
    } else {
      printf("\n");
    }
  }
 
  return 0;
}


Measured memory_bytes: 2064
#include<iostream>
using namespace std;
const int N=100000005;
bool Prime(int a)
{
    for(long long i=2;i*i<=a;i++)
    {
        if(a%i==0)return true;
    }
    return false;
}
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(!Prime(a))ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3100
package main

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

func main() {
	run()
}

func run() {
	setSpace()
	a, b, c := readN(), readN(), readN()
	if m := b / a; m < c {
		fmt.Println(m)
		return
	}
	fmt.Println(c)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 640
""" AtCoder """

S = [input() for _ in range(3)]

t = 0

while True:
    if len(S[t]) == 0:
        if t == 0:
            print('A')
        elif t == 1:
            print('B')
        else:
            print('C')
        exit()
    if S[t][0] == 'a':
        tmp = 0
    elif S[t][0] == 'b':
        tmp = 1
    else:
        tmp = 2
    S[t] = S[t][1:]
    t = tmp



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

int N;
vector<vector<int>> G;
int ans;

void dfs(int v, vector<int> V) {
  V.at(v) = 1;
  if (accumulate(V.begin(), V.end(), 0) == N) {
    ans++;
    return;
  }
  for (auto g : G.at(v)) if (!V.at(g)) dfs(g, V);
}

int main() {
  int M;
  cin >> N >> M;
  G.resize(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b), G.at(b).push_back(a);
  }
  vector<int> V(N);
  dfs(0, V);
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    println(problem162d(n, s))
}

fun problem162d(n: Int, s: String): Long {

    val rs = IntArray(n + 1) { 0 }
    for (i in 0 until n) {
        rs[i + 1] = rs[i] + if (s[i] == 'R') 1 else 0
    }
    val gs = IntArray(n + 1) { 0 }
    for (i in 0 until n) {
        gs[i + 1] = gs[i] + if (s[i] == 'G') 1 else 0
    }
    val bs = IntArray(n + 1) { 0 }
    for (i in 0 until n) {
        bs[i + 1] = bs[i] + if (s[i] == 'B') 1 else 0
    }
    val all = rs.last() * gs.last() * bs.last().toLong()
    var sub = 0L;
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            if (s[i] == s[j]) continue
            val k = j * 2 - i
            if (k >= n || s[k] == s[i] || s[k] == s[j]) continue
            sub++
        }
    }

    return all - sub
}

Measured memory_bytes: 40968
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i,n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4016
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A = [[0 for j in range(3)] for i in range(3)]

for i in range(3):
    A[i][0],A[i][1],A[i][2] = MI()

N = I()
B = []
for i in range(N):
    B.append(I())

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = True


ans = "No"
for i in range(3):
    if A[0][i] is True and A[1][i] is True and A[2][i] is True:
        ans = "Yes"

    if A[i][0] is True and A[i][1] is True and A[i][2] is True:
        ans = "Yes"
    
if A[0][0] is True and A[1][1] is True and A[2][2] is True:
    ans = "Yes"

if A[2][0] is True and A[1][1] is True and A[0][2] is True:
    ans = "Yes"

print(ans)

Measured memory_bytes: 27120
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

N = int(input())
S = Counter()
for n in range(N):
    s = input()
    if s[0] in 'MARCH':
        S[s[0]] += 1

if len(S) < 3:
    print(0)
else:
    keys = S.keys()
    ans = 0
    for comb in combinations(keys, 3):
        ans += S[comb[0]] * S[comb[1]] * S[comb[2]]
    print(ans)


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

#define int long long

int N, M;
vector<int> G[100001];
int s, t;
const int INF = 1e15;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);  

  cin >> N >> M;
  for ( int i = 0; i < M; i++ ) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);    
  }

  cin >> s >> t;
  s--; t--;

  int dist[100001][3];
  fill_n(*dist, 100001*3, INF);
  using P = pair<int, int>;
  queue<P> Q;
  int ans = -1;  
  Q.push(P(s, 0));
  while ( !Q.empty() ) {
    P p = Q.front(); Q.pop();
    int v = p.first, c = p.second;

    if ( v == t && c%3 == 0 ) {
      ans = c/3;
      break;      
    }

    if ( dist[v][c%3] != INF ) continue;
    dist[v][c%3] = c;

    for ( int u : G[v] ) {
      Q.push(P(u, c+1));      
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 9344
#include"bits/stdc++.h"
using namespace std;

int main() {
  int K;
  cin >> K;
  vector<int> vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  cout << vec[K - 1] << endl;
}


Measured memory_bytes: 256
from collections import Counter
import bisect
n = int(input()) #リストの要素数
a = list(map(int, input().split())) #リストの要素
cnt = Counter(a) #aの要素数についての辞書
a.sort()#aを小さい順にソート
ans = 0
mx = 10 ** 6
p = [0] * (mx + 1)
for i in a:
    if p[i] == 0:
        for j in range(mx + 1):
            x = i * j
            if x > mx:
                break
            p[x] = 1 #pの中でaの要素iの倍数として表現できるものに１
        if cnt[i] == 1:
            ans += 1 #pの中で任意のiの倍数として表現できず、かつ１つのみ存在するものをカウント
print(ans)

Measured memory_bytes: 38676
#include <stdio.h>
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if (k&1)
    {
        long long ans=n/k;
        printf("%lld\n",ans*ans*ans);
    }
    else
    {
        long long ans=n/(k/2),odd=ans/2+ans%2,even=ans/2;
        printf("%lld\n",odd*odd*odd+even*even*even);
    }
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}
int N;
vector<vector<char>> square;
bool ok(int j,int i, int mid){
  REP(l,i,N){
    rep(k,mid){
      if(value(j+k,l,N,N)){
        if(square[j+k][l] == '*'){
          return false;
        }
      }
    }
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> N){
    if(N == 0) break;
    int ans = -1;
    square = vector<vector<char>>(N,vector<char>(N));
    vector<vector<int>> imos(N+5,vector<int>(N+5));
    rep(i,N){
      rep(j,N){
        cin >> square[j][i];
        if(square[j][i] != '.'){
          imos[j+1][i+1] = 1;
        }
      }
    }
    rep(i,N+1){
      rep(j,N+1){
        imos[j+1][i] += imos[j][i];
      }
    }
    rep(j,N+1){
      rep(i,N+1){
        imos[j][i+1] += imos[j][i];
      }
    }
    REP(j,1,N+1){
      REP(i,1,N+1){
        if(imos[i][j] == 0){
          ans = max(0,ans);
        }
        int lb=0,ub = N+1;
        rep(k,15){
          int mid = (lb+ub)/2;
          if(mid == lb) break;
          if(mid+i >= N+1 || mid+j >= 1+N){
            mid = N - max(i,j);
          }
          if(imos[mid+i][mid+j] + imos[i-1][j-1] - imos[mid+i][j-1] -imos[i-1][mid+j] == 0){
            //               cout << mid << " " << i << " " << j << endl;
            lb = mid;
            ans = max(ans,mid);
          }
          else{
            ub = mid;
          }
        }
      }
    }
    cout << ans +1<< endl;
  }
  return 0;
}

Measured memory_bytes: 7728
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6)cout<<b/2<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
from fractions import Fraction
from collections import defaultdict
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

if N<=2:
    print(1)
    exit()


def calc(p,q):
    result = defaultdict(set)
    for x,y in XY:
        result[x].add(y)

    count = 0
    for x in result.keys():
        for y in result[x]:
            if x-p in result and y-q in result[x-p]:
                continue
            count +=1

    return count


ans = 5000

for i in range(N-1):
    for j in range(i+1,N):
        p = XY[i][0] - XY[j][0]
        q = XY[i][1] - XY[j][1]
        # print(p,q,calc(p,q))
        ans = min(ans,calc(p,q))

if ans == 5000:
    raise ValueError
print(ans)

Measured memory_bytes: 69096
import sys
sys.setrecursionlimit(10**5)

class UnionFind:
    def __init__(self, n):
        self.group = list(range(n))
    
    def find(self, x):
        cv = self.group[x]
        if cv != x:
            self.group[x] = self.find(cv)
        return self.group[x]
    
    def union(self, x, y):
        self.group[self.find(x)] = self.find(y)

N, M = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]

uf = UnionFind(N + 1)
group_size = dict([(i, 1) for i in range(N+1)])
cur = N * (N-1) // 2
ans = [cur]
for a, b in reversed(AB):
    x = uf.find(a)
    y = uf.find(b)
    if x != y:
        cur -= group_size[y] * group_size[x]
        uf.union(a, b)
        group_size[y] += group_size[x]
        del group_size[x]
    ans.append(cur)

for n in reversed(ans[:-1]):
    print(n)

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

signed main(){
    int N,M; cin>>N>>M;
    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    vector<int> ans(N,-1);
    ans[0]=0;
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv : G[v]){
            if(ans[nv]!=-1)continue;
            ans[nv]=v+1;
            que.push(nv);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<N;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 12952
from itertools import*
n,a,b,c,*l=map(int,open(0).read().split())
d=[a,b,c]
ans=float("inf")
for i in product(range(4),repeat=n):
    take=[[],[],[]]
    for k,j in enumerate(i):  #0を捨てる
        if j!=0:
            take[j-1].append(l[k])
    if all(take):
        take2=list(map(sum,take))
        #print(sum(abs(s-t)for s,t in zip(d,take2)),(sum(map(len,take))-3)*10)
        ans=min(ans,sum(abs(s-t)for s,t in zip(d,take2))+(sum(map(len,take))-3)*10)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
	int N;
	int Y;
	cin>>N>>Y;
	Y/=1000;
	REP(i,N+1){
		REP(j,N+1){
			int X=i*10+5*j;
			if(X>Y)continue;
			int now=Y-X;
			if(i+j+now==N){
				cout<<i<<" "<<j<<" "<<now<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdint>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, A, B; std::cin >> N >> A >> B;
  if(A+B-1 > N) fin(-1);
  if((int64_t)A*B < N) fin(-1);
  if(B==1) {
    for(int i = 1; i < N; ++i) std::cout << i << " ";
    fin(N);
  }
  int n = 0, k=0;
  while(k+1+N-n-B > A) {
    n += B; ++k;
    for(int i = n; i > n-B; --i) std::cout << i << " ";
  }
  int l = k+N-n-A+1;
  if(n+l == N) {
    for(int i = n+l; i > n+1; --i) std::cout << i << " ";
    fin(n+1);
  }
  for(int i = n+l; i > n; --i) std::cout << i << " ";
  for(int i = n+l+1; i < N; ++i) std::cout << i << " ";
  fin(N);
  return 0;
}


Measured memory_bytes: 2176
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if 0 in a :
    ans  = 0
    print(ans)
else :
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18 :
            print(-1)
            break
if ans <= 10**18 and ans != 0 :
    print(ans)


Measured memory_bytes: 21676
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}


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

int num[3];
int count(){
  sort(num,num+3);
  int ans=0;
  ans+=(num[2]-num[1])/2;
  ans+=(num[2]-num[0])/2;
  return ans;
}
int main(){
  bool f[3]; //true 偶数
  for(int i=0;i<3;i++)
  {
    cin>>num[i];
  }
  int odd=0,even=0;
  for(int i=0;i<3;i++)
  {
    if(num[i]%2==0)
    {
      even++;
      f[i]=true;
    }else{
      odd++;
      f[i]=false;
    }
  }
  int ans,temp=0;
  if(even==3 || odd==3)
  {
    ans=count();
    cout<<ans<<"\n";
  }else{
    if(even==2)
    {
      for(int i=0;i<3;i++)
      {
        if(f[i]) num[i]+=1;
      }
    }else{
      for(int i=0;i<3;i++)
      {
        if(!f[i]) num[i]++;
      }
    }
    ans=count();
    cout<<ans+1<<"\n";
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2;
}

Polygon reflect(Line l,Polygon p){
  FOR(i,0,p.size())p[i]=reflect(l,p[i]);
  return p;
}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

bool intersecto(Line l,Segment s){
  if(ccw(l.p1,l.p2,s.p1)*ccw(l.p1,l.p2,s.p2)<0)return true;
  return false;
}

int n;
Point s;
bool used[10]={};

int check(vector<Segment> vs){
  FOR(i,1,vs.size()){
    FOR(j,0,i){
      if(intersecto(Line(s,vs[j].p1),vs[i]))continue;
      if(intersecto(Line(s,vs[j].p2),vs[i]))continue;
      if(intersecto(Line(s,vs[i].p1),vs[j]))continue;
      if(intersecto(Line(s,vs[i].p2),vs[j]))continue;
      return 0;
    }
  }
  return 1;
}

int rec(Polygon p,vector<Segment> vs){
  if(vs.size()==p.size())return check(vs);
  int res = 0;
  FOR(i,0,p.size()){
    if(used[i])continue;
    used[i]=true;
    Segment e(p[i],p[(i+1)%p.size()]);
    vs.pb(e);
    res+=rec(reflect(e,p),vs);
    vs.pop_back();
    used[i]=false;
  }
  return res;
}

int main()
{
  while(cin>>n && n){
    Polygon p;
    vector<Segment> vs;
    cin>>s.x>>s.y;
    FOR(i,0,n){
      int x,y;
      cin>>x>>y;
      p.pb(Point(x,y));
    }
    cout<<rec(p,vs)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

class Dice{
public:
    int face[6];

    Dice(int m[]){
        for (int i = 0; i < 6; ++i)
        {
            face[i] = m[i];
        }
    };
    void swap4(int a, int b, int c, int d){
        int s;
        s = face[a]; face[a] = face[b]; face[b] = face[c]; face[c] = face[d]; face[d] = s;
    }
    void move(char direction){
        if(direction == 'N') swap4(0,1,5,4);
        if(direction == 'W') swap4(0,2,5,3);
        if(direction == 'S') swap4(0,4,5,1);
        if(direction == 'E') swap4(0,3,5,2);
    }
};



int main(int argc, char const *argv[])
{
    int input[6];
    char ch;
    for (int i = 0; i < 6; ++i)
    {
        cin >> input[i];
    }
    Dice dice(input);
    while(scanf("%c", &ch) != EOF) {
        dice.move(ch);
    }
    printf("%d\n", dice.face[0]);
    return 0;
}

Measured memory_bytes: 1180
import Foundation


func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}


func main() {
    let line = readInt()
    let N = line[0]
    let M = line[1]

    var graph = (0...N).map { _ in [Int]() }
    for _ in (1...M) {
        let ab = readInt()
        let a = ab[0]
        let b = ab[1]
        graph[a].append(b)
        graph[b].append(a)
    }

    var ans = [Int](repeating: -1, count: N + 1)
    var q = [1]
    while !q.isEmpty {
        var q_ = [Int]()
        for u in q {
            for v in graph[u] {
                guard ans[v] == -1 else { continue }
                ans[v] = u
                q_.append(v)
            }
        }
        q = q_
    }
    print("Yes")
    for i in ans[2...] {
        print(i)
    }
}

main()

Measured memory_bytes: 24268
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>

namespace test {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}

using namespace std;



int main(void) {
  int x, a,b; cin >> x >> a >> b;
  cout << ( abs(x - a) < abs(x - b) ? "A" : "B" ) << endl;

  return 0;
}

Measured memory_bytes: 256