akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
// using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

typedef pair<ll, ll> P;
#define x first
#define y second
#define MAX_N 1000
#define MAX_M 1000
string maze[MAX_N];
P start, goal;
ll N, M, D[MAX_N][MAX_M];
ll dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
ll BFS() {
    queue<P> Q;
    rep(i, N) rep(j, M) D[i][j] = INF;
    Q.push(start);
    D[start.x][start.y] = 0;
    while (!Q.empty()) {
        P now = Q.front();
        Q.pop();
        if (now.x == goal.x && now.y == goal.y) break;
        rep(i, 4) {
            P next = make_pair(now.x + dx[i], now.y + dy[i]);
            if (0 <= next.x && next.x < N && 0 <= next.y && next.y < M)
                if (maze[next.x][next.y] != '#' && D[next.x][next.y] == INF) {
                    Q.push(next);
                    D[next.x][next.y] = D[now.x][now.y] + 1;
                }
        }
    }
    return D[goal.x][goal.y];
}

ll counter;
signed main() {
    queue<P> Q;
    cin >> N >> M;
    start = make_pair(0, 0), goal = make_pair(N - 1, M - 1);
    rep(i, N) cin >> maze[i];
    rep(i, N) rep(j, M) {
        if (maze[i][j] == '#') {
            counter++;
        }
    }
    ll res = BFS();
    cout << (res == INF ? -1 : N * M - res - counter - 1) << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17

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

int main(){
    int n,m;
    cin>>n;
    string s[n];
    rep(i,n)cin>>s[i];
    cin>>m;
    string t[m];
    rep(i,m)cin>>t[i];
    
    map<string,int>a;
    rep(i,n){
        a[s[i]]++;
    }
    rep(i,m){
        a[t[i]]--;
    }
    int maxi=0;
    rep(i,n)maxi=max(a[s[i]],maxi);
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int dp[1000][1000];
int main(){
	int n;
	char z;
	while(true){
	cin>>n;
	int best=0;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>z;
			if(i==0||j==0){
				if(z=='.')
				    dp[i][j]=1;
				else
					dp[i][j]=0;
			}
			else{
				if(z=='.')
				    dp[i][j]=1+min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]));
				else
					dp[i][j]=0;
			}
			best=max(best,dp[i][j]);
		}
	}
	cout<<best<<endl;
	}
	return 0;
}

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

typedef long long int lli;
typedef long int li;

long double mod = 1e18;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<lli> a(n);
    for(auto& it: a) cin >> it;
    sort(a.begin(), a.end());
    lli pro = 1;
    bool b = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            pro = 0;
            break;
        }
        if((long double) a[i] > mod / pro){
            b = 0;
            break;
        }
        pro *= a[i]; 
    }
    if(b) cout << pro << '\n';
    else cout << "-1\n";
} 

/*
  check for corner cases.
  When using log check for zeros.
  Use queues and stacks if they are helping.           
                            
    (___)           
    . . )____________ 
   _|__/\           |\
  (o_o_) \__________| \
           /|     ||   )     
          < |     ||  
*/



Measured memory_bytes: 3964
using System;
using System.Collections.Generic;
using System.Linq;

namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = new List<int>();
            for (int i = 0; i < 3; i++)
            {
                var par = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                input.Add(par[0]);
                input.Add(par[1]);
            }

            input.Sort();
            foreach (var item in input)
            {
                if (input.Where(x => x == item).Count() >= 3)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

int main(){

    int H, W = -1;

    queue<int> que_h;
    queue<int> que_w;

    while(1){
        if((H == 0) && (W == 0)){
            break;
        }
        cin >> H >> W;
        que_h.push(H);
        que_w.push(W);
    }
    H, W = -1;

    while(1){
        
        H = que_h.front();
        W = que_w.front();

        if((H == 0) && (W == 0)){
            break;
        }

        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;

        que_h.pop();
        que_w.pop();
    }


    return  0;
}

Measured memory_bytes: 3096
#include<stdio.h>
int main()
{
    long int i, m=0;
    char s[100005];
    scanf("%s", &s);
    for(i=0; i<strlen(s); i++)
    {
       if(s[i]==s[i+1])
       {
           m++;
           if(s[i+1]=='0')
           {
               s[i+1]='1';
           }
           else
           {
               s[i+1]='0';
           }
       }
    }
    printf("%ld", m);
    return 0;
}

Measured memory_bytes: 1824
n=int(input())

import random
def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True



#test
while True:
     if is_prime3(n):
         break
     n+=1
print(n)

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

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  double S=0;
  for (int i=0; i<N; i++) {
    cin >> V[i];
    S+=1/V[i];
  }
  cout << 1/S << endl;
  
}

Measured memory_bytes: 3820
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val W, H, x, y = sc.nextLong()

    val flag = if (x * 2 == W && y * 2 == H) 1 else 0
    println(s"${W * H / 2.0} $flag")
  }

}



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

int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    rep(i, n) cin >> x.at(i);
    rep(i, n) cin >> y.at(i);

    int sum=0;
    rep(i, n) {
        sum+= abs(x.at(i) - y.at(i));
    }
    printf("%.6f\n", (double)sum);
    sum=0;
    rep(i, n) {
        sum+= pow(abs(x.at(i) - y.at(i)), 2);
    }
    printf("%.6f\n", (double)sqrt(sum));

    sum=0;
    ll suml = 0;
    rep(i, n) {
        suml+= pow(abs(x.at(i) - y.at(i)), 3);
    }
    //cout << suml << endl;
    printf("%.6f\n", (double)pow((double)suml,((double)1/3)));

    int maxv = 0;
    rep(i, n) {
        maxv = max(maxv, abs(x.at(i)-y.at(i)));
    }
     printf("%.6f\n", (double)maxv);
}


Measured memory_bytes: 3348
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int x,y;
	cin >> x >> y;
	int ans=0;
	if(x==y and x==1)
		ans+=400000;
	if(x==1)
		ans+=300000;
	if(x==2)
		ans+=200000;
	if(x==3)
		ans+=100000;
	if(y==1)
		ans+=300000;
	if(y==2)
		ans+=200000;
	if(y==3)
		ans+=100000;



	cout << ans << endl;





}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int d[n];
    for(int i=0;i<n;i++)scanf("%d",&d[i]);
    long long int rslt = 0;

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            rslt += d[i]*d[j];
        }
    }

    printf("%lld\n",rslt);
    return 0;
}


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

#define ll unsigned long long int
#define endl '\n'
#define inf 1e18


void testCase()
{
    //ll t; cin>>t; while(t--)
    {
      double d,t,s;
      cin>>d>>t>>s;
    double x=d/s;
    //cout<<x;
    if(x<=t)
    cout<<"Yes\n";
    else
    cout<<"No\n";

    } 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX_N = 1e6+5;
int prime[MAX_N];
bool is_prime[MAX_N];
int sieve(){
    memset(is_prime, true, sizeof(is_prime));
    int p = 0;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2;i < MAX_N;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i;j < MAX_N;j+=i){
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int main(){
    int n;

    while(~scanf("%d",&n)){
            int p = sieve();
//        printf("test :\n");
//        for(int i = 0;i < 10;i++){
//            printf("%d ",prime[i]);
//        }
//        cout <<endl;
        int num = upper_bound(prime, prime + p, n) - prime;
        printf("%d\n",num);
    }
}

Measured memory_bytes: 4484
#include<bits/stdc++.h>
using namespace std;
bool PN(int x) {
  if (x <= 1) return false;
  if (x == 2) return true;
  for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false;
  return true;
}

void solve(){
  int w, a, b;
  cin >> w >> a >> b;
  if(abs(b-a) <= w) cout << 0 << endl;
  else {
    cout << abs(b-a)-w << endl;
  }
}

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

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(m);
        vllin2(l,r,m);
        rSORT(l);
        SORT(r);
        sal(r[0]-l[0]+1>0?r[0]-l[0]+1:0);
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	ll A, B;

	cin >> A >> B;

	cout << A * B / __gcd(A, B) << '\n';



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
nums = list(map(int, input().split()))
hp = []
for i in range(N):
  heapq.heappush(hp, -nums[i])
ans = sum(nums)
for _ in range(M):
  num = -heapq.heappop(hp)
  t = num//2
  ans -= num-t
  heapq.heappush(hp, -t)
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    int res=(a+b)/2; res += (a+b)%2;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
using ll = long long;
ll dp[maxn];
ll w[maxn],v[maxn];
int main()
{
   ll n,m,mm;
   cin>>n>>mm;
   m=0;
   memset(dp,0x3f,sizeof(dp));
   for(int i=1;i<=n;++i){
       cin>>w[i]>>v[i];
       m+=v[i];
   }
   dp[0]=0;
   for(int i=1;i<=n;++i){
       for(ll j=m;j>=0;--j){
           if(j-v[i]>=0) dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
          // cout<<dp[j]<<endl;
       }
   }
   for(int i=m;i>=0;--i){
       if(dp[i]<=mm){
           cout<<i<<endl;
           break;
       }
   }
   return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: ",i);
    printf("key = %d, ",A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(left(i)<H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,ans=0;
  cin >> n;
  vector<int> a(n);
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++){
    if(a[a[i]]==i) ans++;
  }
  cout << ans/2 << endl;
  return 0;
}


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

using namespace std;

#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define sz(c) int((c).size())

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
   int h, w; cin >> h >> w;

   vector<vector<int> > A(h, vector<int>(w, 0));
   	pi topleft(1, 1);
   	vector<pi> pairs;
   	vector<pair<pi, pi> > ans;
   for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
   	pi p(i+1, j+1); 
   	int a;
   	cin >> a;
   	A[i][j] += a;
   	if(A[i][j] % 2) {
   		if (i + 1 < h) {
   			ans.pb(pair<pi, pi>(pi(i + 1, j + 1), pi(i + 2, j + 1)));
   			A[i+1][j]++;
   		}
   		else if (j + 1 < w) {
   			ans.pb(pair<pi, pi>(pi(i + 1, j + 1), pi(i + 1, j + 2)));
   			A[i][j+1]++;
   		}
   	}
   }

   cout << ans.size() << endl;
   for(int i = 0; i < ans.size(); i++) {
   	cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
   }

    return 0;
}

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


int main() {
	int N; long long L, T;
	cin >> N >> L >> T;
	vector<long long> X(N);
	vector<int> W(N);
	for (int i = 0; i < N; ++i) cin >> X[i] >> W[i];
	
	vector<long long> tmp(N);
	for (int i = 0; i < N; i++) {
		if (W[i] == 1) tmp[i] = (X[i] + T) % L;
		else tmp[i] = ((X[i] - T) % L + L) % L;
	}
	sort(tmp.begin(), tmp.end());
	
	long long cnt = 0;
	for (int i = 0; i < N; i++) {
		if (W[i] == 1) cnt -= (T - (L - X[i]) + L) / L;
		else cnt += (T - (X[i] + 1) + L) / L;
	}
	cnt = (cnt % N + N) % N;
	vector<long long> res(N);
	for (int i = 0; i < N; i++) res[(i + cnt) % N] = tmp[i];
	for (int i = 0; i < N; i++) cout << res[i] << endl;

	return 0;
}

Measured memory_bytes: 5852
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int[] n = new int[3];
		int[] num = {0,0};
		Main app = new Main();
		while(scan.hasNext()){
			app.input(n,scan);
			app.judge(n,num);
		}
		System.out.println(num[0]);
		System.out.println(num[1]);
	}
	
	public void judge(int[] n,int[] num){
		if(n[0]<=n[2] && n[1]<=n[2]){
			if((n[0]*n[0]+n[1]*n[1])==(n[2]*n[2])){
				num[0]++;
			}else{
				num[1]++;
			}
		}
	}
	
	public void input(int[] n,Scanner s){
		String[] splitLine = s.nextLine().split(",");
		for(int i=0;i<3;i++){
			n[i] = Integer.parseInt(splitLine[i]);
		}
	}
}

Measured memory_bytes: 17128
#include <iostream>

using namespace std;

const int MAX = 210;
const int INF = (int)1e9;

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

	int n;
	int a[MAX];

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

	int c = INF;
	for (int i = 0; i < n; i++) {
		int d = 0;
		while (a[i]%2 == 0) {
			a[i] >>= 1;
			d++;
		}

		c = min(c, d);
	}

	cout << c << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

const ll inf = 1LL << 55;

ll f(ll b, ll n)
{
  if(b < 2) return inf;
  ll ret = 0;
  while(n >= b) ret += n % b, n /= b;
  return ret + n;
}

int main()
{
  ll n, s;
  cin >> n >> s;
  if(n == s) {
    cout << n+1 << endl;
    return 0;
  }
  for(int i = 2; i <= sqrt(n); i++) {
    if(f(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }
  ll ans = inf;
  for(int i = 1; i <= sqrt(n); i++) {
    if(f((n-s)/i+1, n) == s) ans = min(ans, (n-s)/i+1);
  }
  cout << (ans == inf ? -1:ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A.at(i);
	A.push_back(0);
	long all_price = abs(A.at(0));
	for (int i = 0; i < N; i++) all_price += abs(A.at(i+1) - A.at(i));
	int pre = 0;
	for (int i = 0; i < N; i++){
		long ans = all_price - abs(A.at(i) - pre) - abs(A.at(i+1) - A.at(i)) + abs(A.at(i+1) - pre);
		cout << ans << endl;
		pre = A.at(i);
	}
}


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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    int ans = X;
    for(auto a : A) {
        for(int i = 1; i <=D; i+=a) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void A_task();

int main()
{
	A_task();

	fflush(stdout);
	return 0;
}

static void A_task()
{
	char code[6] = { 0 };

	scanf(" %s", code);

	const char* ans = "Good\n";
	char bfr = code[0];
	for (int i = 1; i < 4; i++) {
		if (bfr == code[i]) {
			ans = "Bad\n";
		}
		bfr = code[i];
	}
	printf(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a;
int main(){
	scanf("%d",&n);
	int mx=0,mxc,mn=n,mnc;
	for(int i=0,a;i<n;i++){
		scanf("%d",&a);
		if (a>mx)mx=a,mxc=1;
		else if (a==mx)mxc++;
		if (a<mn)mn=a,mnc=1;
		else if (a==mn)mnc++;
	}
	if (mx==mn&&(mx==n-1||mx<=n/2)||mx==mn+1&&mx-mnc>0&&mx-mnc<=mxc/2)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int st=1,st2=0;
  long long count=0,count2=0;
  for(int i=0;i<s.length();i++)
  {
      if((s[i]-'0')!=st)count++;
      else count2++;
    st=(st+1)%2;
    st2=(st2+1)%2;
  }
  cout<<min(count,count2)<<endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  rep(i,7){
    if(s==week[i]){
      cout << 7 - i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	//n5=i%10;
	//i/=10;
	//n4=i%10;
	//i/=10;
	//n3=i%10;
	//i/=10;
	//n2=i%10;
	//i/=10;
	//n1=i;
	//cout<<n1<<n2<<n3<<n4<<n5<<endl;
	for(int i=a;i<=b;i++){
		int n1,n2,n4,n5,ok=1;
		n1=i/10000;
        n2=(i/1000)%10;
        n4=(i/10)%10;
        n5=i%10;
		//cout<<n1<<n2<<n3<<n4<<n5<<endl;
		if(n5!=n1||n4!=n2) ok=0;
		if(ok) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,d,a;cin>>n>>d>>a;d*=2;
    vector<pair<ll,ll>> p(n);
    rep(i,n) cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    ll dam=0;
    queue<pair<ll,ll>> que;
    ll res=0;
    rep(i,n){
        ll x=p[i].first,h=p[i].second;
        while(que.size()){
            ll x1=que.front().first,h1=que.front().second;
            if(x1<x-d){
                dam-=h1;
                que.pop();
            }else break;
        }
        h-=dam;
        if(h<=0)continue;
        ll tmp=(h+a-1)/a;
        res+=tmp;
        que.push({x,tmp*a});
        dam+=tmp*a;
    }
    cout<<res<<endl;
}

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

int n; bitset <4000001> dp;

int main(){
	int i, sum = 0, v;
	scanf("%d", &n);
	dp[0] = true;
	for(i = 1; i <= n; ++ i){
		scanf("%d", &v);
		dp |= dp << v;
		sum += v;
	}
	for(i = (sum + 1) >> 1; !dp[i]; ++ i) ;
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	ll a[n];
	ll ans = 0;
	fo(i, n)
	{
		cin >> a[i];
		ans ^= a[i];
	}
	fo(i, n)
	{
		cout << (ans ^ a[i]) << " ";
	}

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 5208
# coding: utf-8
# Your code here!

import heapq

N, M = map(int, input().rstrip().split())
A = list(map(lambda x: -int(x), input().rstrip().split()))
heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)
    a = a / 2
    heapq.heappush(A, a)
    
print(sum([-int(x) for x in A]))
    

Measured memory_bytes: 98840
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >=  M:
    print(0)
else:
    X.sort()
    X_sub = []
    for i in range(len(X)-1):
        X_sub.append(X[i+1]-X[i])
    X_sub.sort()
    for i in range(N-1):
        del X_sub[-1]
    print(sum(X_sub))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  bool ok = 0;
  for (int i = 1; i < 10; ++i) {
    if (n % i) continue;
    if (n / i < 10) 
    {
		ok = 1;
      	break;
    }
  }
  if (ok) puts ("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;
int N, M;
double x[21], y[21], z[21];

int main(){

   cin>> N>> M;
   for(int i=0; i<N; i++){
      cin>> x[i]>> y[i]>> z[i];
   }

   double D=0;
   for(int i=0; i<(1<<N); i++){
      vector<int> v;
      for(int j=0; j<N; j++){
         if((i>>j)&1) v.push_back(j);
      }
      if(v.size()!=M) continue;
      double d=0;
      for(int j=0; j<v.size(); j++){
         for(int k=j+1; k<v.size(); k++){
            d+=(x[v[j]]-x[v[k]])*(x[v[j]]-x[v[k]]);
            d+=(y[v[j]]-y[v[k]])*(y[v[j]]-y[v[k]]);
            d+=(z[v[j]]-z[v[k]])*(z[v[j]]-z[v[k]]);
         }
      }
      D=max(d, D);
   }

   printf("%.15f\n", D);

   return 0;
}

Measured memory_bytes: 3296
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        for(int i=0;i<s.length();i++){
            int flag=0;
            for(char c='a';c<='z';c++){
                if(s.charAt(i)==(c)){
                    c-=32;
                    System.out.print(c);
                    flag=1;
                    break;
                }
            }
            if(flag==0){
                for(char c='A';c<='Z';c++){
                    if(s.charAt(i)==(c)){
                        c+=32;
                        System.out.print(c);
                        flag=1;
                        break;
                    }
                }
            }
            if(flag==0) System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}


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

using namespace std;

#define REP(i, x, y) for (int i = x;i < y; i++)

const int8_t  INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF  = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ios::sync_with_stdio(0);
    int a,b;
    cin >> a >> b;
    cout << max(0,a-b+1) << endl;
    return 0;
}

Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int main(){
    int gg[3];
    int n; cin >> n >> gg[0] >> gg[1] >> gg[2];
    vector<string> da(n);
    rip(i,n,0) cin >> da[i];
    vector<int> ans(n);
    da.push_back("AB");
    rip(i,n,0){
        int x = da[i][0]-'A';
        int y = da[i][1]-'A';
        if(gg[x] == gg[y]){
            if(da[i+1][0] == da[i][0] || da[i+1][1] == da[i][0]){
                ans[i] = x;
                gg[x]++;
                gg[y]--;
            }
            else{
                ans[i] = y;
                gg[y]++;
                gg[x]--;
            }
            if(gg[x] < 0 || gg[y] < 0){
                cout << "No" << endl;
                return 0;
            }
        }
        else if(gg[x] > gg[y]){
            ans[i] = y;
            gg[y]++;
            gg[x]--;
        }
        else{
            ans[i] = x;
            gg[x]++;
            gg[y]--;
        }
    }
    cout << "Yes" << endl;
    rip(i,n,0) printf("%c\n", ans[i]+'A');
    return 0;
}

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

using namespace std;

int main()
{
    vector<int> N(3,0);
    for(auto&& x : N)
        cin >> x;
    
    sort(N.begin(),N.end());
    
    cout << N[0] << ' ' << N[1] << ' ' << N[2] <<'\n';
    
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=2e5+200;
struct node{
	int x,y;
}a[maxn];
bool mp1(node m,node w){
	return m.x+m.y<w.x+w.y;
}
bool mp2(node m,node w){
	return m.x-m.y<w.x-w.y;
}
bool mp3(node m,node w){
	return m.y-m.x<w.y-w.x;
}
int main(){
	int n,xi,yi;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d %d",&a[i].x,&a[i].y);
	}
	sort(a+0,a+n,mp1);
	int max1=abs(a[n-1].x-a[0].x)+abs(a[n-1].y-a[0].y);
	sort(a+0,a+n,mp2);
	int max2=abs(a[n-1].x-a[0].x)+abs(a[n-1].y-a[0].y);
	sort(a+0,a+n,mp3);
	int max3=abs(a[n-1].y-a[0].y)+abs(a[n-1].x-a[0].x);
	cout<<max(max1,max(max2,max3))<<endl;
	return 0;
}

Measured memory_bytes: 5328
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]

    d, m = int(N / K), N % K
    r = d ** 3
    if K % 2 == 0:
        if K / 2 <= m:
            r += (d + 1) ** 3
        else:
            r *= 2

    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  ull a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int happiness1 = 1000 * (X / 500);
        X %= 500;
        int happiness2 = 5 * (X / 5);

        System.out.println(happiness1 + happiness2);
    }
}


Measured memory_bytes: 21460
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Println((nextInt() - 1) * (nextInt() - 1))
}


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

int main() {


int a,b,c,count=0;
cin>>a>>b>>c;
if(a==b){
    count++;
}
if(c==b){
    count++;
}
if(a==c){
    count++;
}

if(count==1){
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}



}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define FIRST 1
#define SECOND 0
int N, K;
int a[110];
int dp[100010][2];
int game(int x = K, int turn = FIRST) {
    if(dp[x][turn] != -1) return dp[x][turn];
    rep(i, N) {
        int n = x - a[i];
        if(n >= 0 && game(n, !turn) == turn) {
            return dp[x][turn] = turn;
        }
    }
    return  dp[x][turn] = !turn;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K;
    rep(i, N) cin >> a[i];
    rep(i, 100010) rep(j, 2) dp[i][j] = -1;
    if(game() == FIRST) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }


    return 0;
}


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

using namespace std;

int main()
{   
    int x;
    vector<int> p;
    
    cin >> x;
    
    for(int i = 2;i <= 10;++i){
        int j = 1;
        while(pow(j, i) <= 1000){
            p.push_back(pow(j, i));
            j++;
        }
    }
    sort(p.begin(), p.end());
    cout << p[upper_bound(p.begin(), p.end(), x) - p.begin() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
def g(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x + 1
    elif x % 4 == 3:
        return 0


def f(a, b):
    res = g(b)
    if a > 0:
        res ^= g(a - 1)
    return res


a, b = map(int, input().split())
print(f(a, b))


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

// x の下から key 番目 (0-indexed) の bit を消す
int erase_bit(int x, int key) {
    int mask = pow(2, key);
    int low = x & (mask-1);
    x = (x / (mask*2)) * mask;
    return x + low;
}

// x の下から key 番目 (0-indexed) に bit を挿入
int insert_bit(int x, int key, int bit) {
    int mask = pow(2, key);
    int low = x & (mask-1);
    x = (x - low) * 2 + bit * mask;
    return x + low;
}

vector<int> solve(int a, int b, int n) {
    if(n == 1)
        return {a, b};
    int d = a ^ b;
    int key = __builtin_ctz(d); // このbitを消す
    int a_key = 0;
    int b_key = 0;
    if(a & (1 << key)) a_key = 1;
    if(b & (1 << key)) b_key = 1;
    // a_key != b_key
    a = erase_bit(a, key);
    b = erase_bit(b, key);
    int c = a ^ 1;
    auto ac = solve(a, c, n-1);
    for (int &x: ac ) {
        x = insert_bit(x, key, a_key);
    }
    auto cb = solve(c, b, n-1);
    for (int &x: cb ) {
        x = insert_bit(x, key, b_key);
        ac.push_back(x);
    }
    return ac;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    if (! __builtin_parity(A^B)) {
        cout << "NO";
        return 0;
    }
    cout << "YES" << "\n";
    auto ans = solve(A, B, N);
    for (int x: ans ) {
        cout << x << " ";
    }
    return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int q;
  cin>>q;
  int t[q];
  for(int i=0;i<q;i++) cin>>t[i];
  int ans=0;
  int used[q];
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++){
    for(int j=0;j<q;j++){
      if(used[j]) continue;
      if(s[i]==t[j]){
	ans++;
	used[j]=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
#define bis(i, j)        i & (1<<(j))

int main(void) {
  int n;
  cin >> n;
  arr(a,n);

  int x=0;
  rep(i,n){
    x = x^a[i];
  }
  vec ans;
  rep(i,n){
    ans.pb(x^a[i]);
  }
  prtall(ans);
}


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


int main()
{
    int N;
    string s;
    cin >> N;
    cin >> s;


    // 0, 1 番目の組み合わせは 4 通りしかないので全探索
    string ans;
    string allComb[4] = { "SS", "SW", "WS", "WW" };
    bool isConsistent = false;
    for( auto ini: allComb ){
        ans = ini;
        bool isSheep;
        if( ini[1] == 'S' ) isSheep = true;
        if( ini[1] == 'W' ) isSheep = false;
        // i-1, i 番目の動物から i+1 番目の動物を決める
        for( int i = 1; i < N; ++i ){
            if( s[i] == 'o' ){
                if( isSheep ){
                    if( ans[i-1] == 'S') ans += 'S';
                    else                 ans += 'W';
                }else{
                    if( ans[i-1] == 'S' ) ans += 'W';
                    else                  ans += 'S';
                }
            }else if( s[i] == 'x' ){
                if( isSheep ){
                    if( ans[i-1] == 'S') ans += 'W';
                    else                 ans += 'S';
                }else{
                    if( ans[i-1] == 'S') ans += 'S';
                    else                 ans += 'W';
                }
            }
            if( ans.back() == 'S' ) isSheep = true;
            else                    isSheep = false;
        }
        // ans に対して s[0] の条件式を判定
        if( ans.front() == ans.back() ){
            ans.pop_back();
            bool isOK = false;
            if( s[0] == 'o' ){
                if( ans[0] == 'S' ){
                    if( ans[1] == ans.back() ) isOK = true;
                }else{
                    if( ans[1] != ans.back() ) isOK = true;
                }
            }else if( s[0] == 'x' ){
                if( ans[0] == 'S' ){
                    if( ans[1] != ans.back() ) isOK = true;
                }else{
                    if( ans[1] == ans.back() ) isOK = true;
                }
            }
            if( isOK ){
                isConsistent = true;
                break;
            }
        }
    }

    if( isConsistent ) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 776
from fractions import gcd


def main():
    A, B, C, D = [int(x) for x in input().split()]
    l = (C * D) // gcd(C, D)
    b = B - anti(B, C, D, l)
    a = (A - 1) - anti((A - 1), C, D, l)
    print(int(b - a))


def anti(x, y, z, l):
    return (x // y) + (x // z) - (x // l)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5052
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def date2num(y,m,d):
    t = (y-1)//3
    days = t*10*20 + (y-1-t)*5*20+(y-1-t)*5*19
    if y%3 == 0:
        days += (m-1)*20+d
    else:
        days += (m-1)//2*19+(m-1-(m-1)//2)*20+d
    return days
    
for i in range(int(input())):
    y,m,d = map(int,input().split(" "))
    print(date2num(1000,1,1) - date2num(y,m,d))

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ll long long
#define f(i) return cout<<i<<"\n",0;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define lp(i,a,b) for (int i=(a);i<=(int)(b);++i)
#define lp2(i,a,b) for (int i=(a);i>=(b);--i)
#define clr(c,x) memset(c,x,sizeof(c))
#define allr(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
const int N=2e5+5,mod=(int)1e9+7;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int k;
    long double n;
    cin>>n>>k;
    long double tot=0;
    lp(i,1,n)
    {
        long double prob=1.0/n;
        int score=i;
        while(score<k)
        {
            score*=2;
            prob*=0.5;
        }
        tot+=prob;
    }
    cout<<fixed<<setprecision(12)<<tot<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a1, a2, b1 ,b2;
    cin >> a1 >> a2 >> b1 >> b2;
    while(a1 > 0 && b1 > 0){
        if(b1 - a2 <= 0) {cout << "Yes"; break;}
        b1 -= a2;
        if(a1 - b2 <= 0) {cout << "No"; break;}
        a1 -= b2;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
constexpr ll mod = 1e9 + 7;
const int MOD = 1000000007;

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


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[2][N];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  int dp[2][N];
  dp[0][0] = A[0][0];
  dp[1][0] = A[0][0] + A[1][0];
  for (int i = 1; i < N; i++) {
    dp[0][i] = dp[0][i - 1] + A[0][i];
    dp[1][i] = max(dp[0][i], dp[1][i - 1]) + A[1][i];
  }
  cout << dp[1][N - 1];
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)
	for i := range s {
		if i == k-1 {
			fmt.Print(strings.ToLower(string(s[i])))
			continue
		}
		fmt.Print(string(s[i]))
	}
	fmt.Println()
}

Measured memory_bytes: 640