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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    LL k, a, b;
    cin >> k >> a >> b;
    if (b - a <= 2) {
        cout << k + 1<< endl;
    } else {
        cout << a + (b - a) * ((k - a + 1) / 2) + (k - a + 1) % 2 << endl;
    }
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
// checks if a number is a perfect square in almost O(1) time
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
int dig_sum(ll n){
    int ret=0;
    while(n>0){
        ret+=(n%10);
        n/=10;
    }
    return ret;
}


int main()
{
    io;
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> v;
    for(int i=0;i<n-1;i++){
        v.push_back(a[i+1]-a[i]);
    }
    v.push_back(k-a[n-1]+a[0]);
    long long sum  = 0;
    for(auto u:v)
        sum+=u;
    ll ans = 1000000000000LL;
    for(auto u:v){
        ans = min(ans, sum-u);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 100005;
using namespace std;
int n, p[N]; char s[N];
bool solve(int x1, int x2) {
	p[1] = x1, p[2] = x2;
	rep(i, 3, n) p[i] = ((p[i - 1] ^ (s[i - 1] == 'o')) ? p[i - 2] : 1 - p[i - 2]);
//	rep(i, 1, n) printf("%d", p[i]); printf("\n");
	if ((p[2] ^ p[n]) ^ ((s[1] == 'x') ^ (p[1]))) return false;
	if ((p[1] ^ p[n - 1]) ^ ((s[n] == 'x') ^ (p[n]))) return false;
	return true;
}
void pr() {
	rep(i, 1, n) printf("%c", p[i] ? 'W' : 'S');
}
int main() {
	scanf("%d%s", &n, s + 1);
	if (solve(0, 0)) pr(); else
	if (solve(0, 1)) pr(); else
	if (solve(1, 0)) pr(); else
	if (solve(1, 1)) pr(); else printf("-1");
	return 0;
}

Measured memory_bytes: 768
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int A, P;
	cin >> A >> P;
	P += A * 3;
	cout << P / 2 << endl;
	return 0;
}


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

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

    bool t=true;
    int s;
    sort(A,A+N);
    while(t){
        for(int i=0;i<N;i++){
            if(A[i]!=0){
                s=A[i];
                for(int j=i+1;j<N;j++){
                    A[j]%=s;
                }
            }
        }
        sort(A,A+N);
        if(s==A[N-1])t=false;
    }
    cout<<s<<endl;
}

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

long long gcd(long long a, long long b){
  if(b==0)return a;
  return gcd(b, a%b);
}
int main(){
  int k, ans=0;
  cin >> k;

  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        int tmp = gcd(i, j);
        ans+=gcd(tmp, l);
  }}}

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


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  string s;
	cin>>s;
	reps(i,1,s.size())if(s[i-1]=='A'&&s[i]=='C'){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}


int main() {
	
	ll N;
	cin >> N;
	ll A[MAX];
	repn(i, N) cin >> A[i];

	ll ans=A[1];

	repn(i, N - 1) ans = gcd(ans, A[i + 1]);

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(int argc, char* argv[])
{
  ll n, m;
  std::cin >> n >> m;
  std::vector< ll > vx;
  std::vector< ll > vy;

  vx.resize(n);
  vy.resize(m);
  //fill(vx.begin(), vx.end(), 0);
  //fill(vy.begin(), vy.end(), 0);

  std::vector< ll >::iterator it;
  for (it = vx.begin(); it != vx.end(); it++) {
    ll idx = std::distance(vx.begin(), it);
    std::cin >> vx[idx];
  }

  for (it = vy.begin(); it != vy.end(); it++) {
    ll idx = std::distance(vy.begin(), it);
    std::cin >> vy[idx];
  }

  std::vector< ll > x_sum(n, 0);
  x_sum[0] = vx[0];
  for (ll i = 1; i < n; i++) {
    x_sum[i] = vx[i] + x_sum[i-1];
  }

  ll XX = 0;
  for (ll i = 0; i < n; i++) {
    XX += x_sum[n-1] - x_sum[i] - vx[i] * (n-i-1);
    XX %= MOD;
  }

  std::vector< ll > y_sum(m, 0);
  y_sum[0] = vy[0];
  for (ll i = 1; i < m; i++) {
    y_sum[i] = vy[i] + y_sum[i-1];
  }

  ll YY = 0;
  for (ll i = 0; i < m; i++) {
    YY += y_sum[m-1] - y_sum[i] - vy[i] * (m-i-1);
    YY %= MOD;
  }
  //std::cout << XX << std::endl;
  //std::cout << YY << std::endl;
  std::cout << (XX * YY) % MOD << std::endl;

  
  return 0;
}



Measured memory_bytes: 3328
N,X=map(int,input().split())
L=list(map(int,input().split()))

D=[0]*(N+1)

D[0]=0
count=1
for i in range(1,N+1):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    count+=1
  else:
    break
print(count)


Measured memory_bytes: 3060
<?php
  while (true) {
    $str = trim(fgets(STDIN));
    if ($str == "-") {
      return;
    }
    $num = trim(fgets(STDIN));
    for($i = 0; $i < $num; $i++) {
      $z = trim(fgets(STDIN));
      $a = substr($str, 0, $z);
      $str = substr_replace($str, '', 0, $z);
      $str = $str . $a;
    }
    print($str . "\n");
  }
?>

Measured memory_bytes: 6544
from operator import itemgetter
n, m = map(int, input().split())
l  = [list(map(int, input().split())) for i in range(m)]
l_sort = sorted(l, key=itemgetter(1))
ans = 0
last = 0
for i in range(m):
    if last <= l_sort[i][0]:
        last = l_sort[i][1]
        ans += 1
print(ans)


Measured memory_bytes: 29352
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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


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

int n;
vector<int> a;
vector<int> s;
int main(){
  int i,j,min=10000000;
  while(1){
    cin >> n;
    if(n==0)break;
    min =10000000;
    for(i=0;i<n;i++){
      cin >> j;
      a.push_back(j);
    }
    sort(a.begin(),a.end());
    for(i=0;i<n-1;i++)if(min>a[i+1]-a[i])min = a[i+1]-a[i];
    cout << min << endl;
    while(a.size())a.pop_back();
  }
  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;
const ll inf = 1e9;

int main(){
  ll N , K; cin >> N >> K;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  vector<ll> s(N); vector<ll> t(N);
  rep(loop , K){
    if(a[0] == N and a[N - 1] == N) break;
    // update s and t
    rep(i,N){
      s[i] = max( (ll)0 , i - a[i]);
      t[i] = min(N , i + a[i] + 1);
    }
    SORT(s); SORT(t);
    ll cnt = 0;
    // update a
    rep(i,N){
      cnt += POSU(s, i) - POSL(s , i);
      cnt -= POSU(t, i) - POSL(t , i);
      a[i] = cnt;
    }
  }
  rep(i,N) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 7940
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll p[n];
    rep(i,0,n){
        scanf("%lld",&p[i]);
    }
    rep(i,0,n-2){
        if(p[i]<p[i+1] && p[i+1]<p[i+2]) ans++;
        else if(p[i]>p[i+1] && p[i+1]>p[i+2]) ans++;
    }
    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

int main(){
    int a,b;
    scanf("%d",&a);
    char s[a],c;
    scanf("%s",s);
    scanf("%d",&b);
    c = s[b - 1];
    for(int i = 0;i < a;i++){
        if(s[i] != c) s[i] = '*';
    }
    printf("%s\n",s);
}

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

int main()
{
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int a[n+1],b[m+1];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	if(a[n-1]<b[0]&&x<b[0]&&b[0]<=y)cout<<"No War\n";
	else cout<<"War\n";
	return 0;
}


Measured memory_bytes: 256
//
// Created by sanyinchen on 17/4/25.
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B
//
#include <iostream>
#include <cstdio>

using namespace std;

void SelectionSort(int *a, int n) {
    int step = 0, min, j;
    for (int i = 0; i < n; i++) {
        min = i;
        for (j = i; j < n; j++) {
            if (a[j] < a[min]) {
                min = j;
            }
        }

        if (a[min] != a[i]) {
            step++;
            swap(a[min], a[i]);
        }
    }
    for (int i = 0; i < n; i++) {
        if (i != 0)cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << step << endl;
}


int main() {
    //freopen("../files/in.txt", "r", stdin);
    int a[101], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SelectionSort(a, n);
    return 0;
}

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

int main(int argc, char **argv)
{
	cin.tie(NULL);

	int type;
	cin >> type;

	if (type == 1)
	{
		cout << "Hello World" << endl;
	}
	else if (type == 2)
	{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// abc171_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll all = 0;
    REP(i, N){
        all ^= A[i];
    }

    vector<ll> ans(N);
    REP(i, N){
        ans[i] = all ^ A[i];
    }

    print_line(ans, N);

    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
/*int graph[50][50];

int n, m;
int bfs();*/

int main() {


	//B
	char p[52][52];
	int i, j;
	int h, w;
	cin >> h >> w;
	for (i = 0; i <= h+1; i++) {
		for (j = 0; j <= w+1; j++) {
			if ((i == 0) || (j == 0) || (i == h + 1) || (j == w + 1)) {
				p[i][j] = '.';

			}
			else {
				cin >> p[i][j];
			}
		}
	}
	int counter;
	int ii, jj;
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if (p[i][j] == '.') {
				counter = 0;
				for (ii = -1; ii <= 1; ii++) {
					for (jj = -1; jj <= 1; jj++) {
						if (p[i + ii][j + jj] == '#') {
							counter++;
						}
					}
				}
				p[i][j] = counter + '0';
				
			}
			cout << p[i][j];
		}
		cout << endl;
	}
	return 0;

	//C
	/*cin >> n >> m;

	//queue<int> graph[50];
	//int graph[50][50];
	int i,j,a,b;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			graph[i][j] = 0;
		}
	}
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		graph[a - 1][b - 1] = 1;
		graph[b - 1][a - 1] = 1;
	}
	//cout << graph[1][6];
	int counter = 0;

	for (i = 0; i < n; i++) {
		for (j = i; j < n; j++) {
	//i = 1; j = 6;
			if (graph[i][j] == 1) {
				graph[i][j] = 0;
				graph[j][i] = 0;

				if (bfs() == 0) {
					counter++;
					//cout << i << ' ' << j << endl;
				}

				graph[i][j] = 1;
				graph[j][i] = 1;
			}
		}
	}
	cout << counter << endl;
	return 0;
	*/


	//D
	/*
	long long int x[50], xs[50], y[50], ys[50];
	int n, k;
	cin >> n >> k;
	int i1,i2,j1,j2,i,l;
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		xs[i] = x[i]; ys[i] = y[i];
	}
	sort(xs, xs + n);
	sort(ys, ys + n);
	int counter;
	long long int rectangle = 4000000000000000000;
	for (i1 = 0; i1 < n-1; i1++) {
		for (j1 = i1 + 1; j1 < n; j1++) {
			for (i2 = 0; i2 < n - 1; i2++) {
				for (j2 = i2 + 1; j2 < n; j2++) {
					if ((xs[j1] - xs[i1]) * (ys[j2] - ys[i2]) < rectangle) {


						counter = 0;
						for (i = 0; i < n; i++) {
							if ((x[i] >= xs[i1]) && (x[i] <= xs[j1]) && (y[i] >= ys[i2]) && (y[i] <= ys[j2])) {
								counter++;
							}
						}
						if (counter >= k) {
							rectangle = (xs[j1] - xs[i1]) * (ys[j2] - ys[i2]);
						}
					}
				}
			}
		}
	}
	cout << rectangle << endl;
	return 0;
	*/
}
/*int bfs() {
	int i, j;
	int edge[50];
	for (i = 0; i < n; i++) {
		edge[i] = 0;
	}
	queue<int> q;
	q.push(0);
	edge[0] = 1;
	int x;
	while (q.size()>0) {
		//cout << 'a';
		x = q.front(); q.pop();
		for (i = 0; i < n; i++) {
			//cout << 'a';
			//cout << x << ' ' << i << endl;
			if (i != x) {
				if (graph[x][i] == 1) {
					if (edge[i] == 0) {
						//cout << x << ' ' << i << endl;
						edge[i] = 1;
						q.push(i);
						//cout << i << endl;
					}
				}
			}
		}

	}
	for (i = 0; i < n; i++) {
		if (edge[i] == 0) {
			//cout << i << endl;
			return 0;
		}
	}
	return 1;
	
}*/

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

int main()
{
  int n;
  scanf("%d", &n);
  vector<double> dp(n + 1);
  // base case 
  dp[0] = 1;
  for(int coins = 0; coins < n; coins++)
  {
    double p;
    scanf("%lf", &p);
    for(int i = coins + 1; i >= 0; i--)
    {
      dp[i] = (i == 0 ? 0 : dp[i - 1] * p) + dp[i] * (1 - p);
    }
  }
  double sol = 0;
  for(int i = n / 2 + 1; i <= n; i++)
  {
    sol += dp[i];
  }
  printf("%.10lf", sol);
  
  return 0;
}


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

int main() {
    int H, W, N; cin >> H >> W >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<vector<int>> ans(H, vector<int>(W));
    int pos = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int jt;
            if(i%2==1) jt = W-1-j;
            else jt = j;
            if(a[pos]!=0){
                a[pos]--;
            } else {
                pos++;
                a[pos]--;
            }
            ans[i][jt] = pos+1;
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << ans[i][j];
            if(j!=W-1) cout << " ";
            else cout << endl;
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N=1e9+7;
int32_t main()
{
    IOS;
    int n,x,t;
    cin>>n>>x>>t;
    int ans = n%x==0?n/x:n/x+1;
    cout<<ans*t;
}

Measured memory_bytes: 3596
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    //"strings"
    //"reflect"
)

var sc = bufio.NewScanner(os.Stdin)

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

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

func storeIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

func main() {
    sc.Split(bufio.ScanWords)

    n := nextInt()
    a := storeIntArr(n)

    count := 0
    for {
        i := 0
        for ; i < n; i++ {
           if a[i] % 2 != 0 {
                break
           } else {
               a[i] /= 2
           }
        }
        if i != n {
            break
        }
        count++
    }

    fmt.Println(count)

}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    int len = s.size();
    int cnt = 0;
    rep (i, len) {
        int j = i;
        while (s[j] == s[j + 1]) j++;
        if (j > i) cnt += (j - i + 1) / 2;
        i = j;
    }
    ll ans;
    ans = k * cnt;

    if (s[0] != s[len - 1]) {
        cout << ans << endl;
        return 0;
    }

    bool all = true;
    rep (i, s.size()) {
        if (s[0] != s[i]) all = false;
    }

    int start, end;
    int j = 0;
    while (s[0] == s[j]) j++;
    start = j;
    j = len - 1;
    while (s[len - 1] == s[j]) j--;
    end = len - 1 - j;
    if (all) {
        ans = 0;
        if (len % 2) {
            ll x = len * k;
            ans = x / 2;
        } else {
            ans = k * cnt;
        }        
        cout << ans << endl;
        return 0; 
    } else {
        if ((start + end) % 2) {
            cout << ans << endl;
            return 0;
        }
        if (start % 2 == 0) {
            cout << ans << endl;
            return 0;
        }
        ans += k - 1;
        cout << ans << endl;
        return 0;
    }

    return 0;
}



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

int main(){
  int N;
  int a, b;

  cin >> N;
  a = N / 2;
  b = N % 2;
  if(b == 0){
    cout << a << endl;
  }
  else{
    cout << a + 1 << endl;
  }
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

struct edge {
	int to; ll cap;
};
vector<edge> G[1 << 17];

bool inpath[1 << 17];
int s, g;
vector<int> path;
bool find_path(int id,int fr) {
	if (id == g) {
		inpath[id] = true;
		path.push_back(id); return true;
	}
	rep(j, G[id].size()) {
		int to = G[id][j].to;
		if (to == fr)continue;
		if (find_path(to,id)) {
			inpath[id] = true;
			path.push_back(id); return true;
		}
	}
	return false;
}

bool valid = true;

//int cnt[1 << 17];
ll t;
void dfs(int id, int fr) {
	vector<ll> v;
	rep(j, G[id].size()) {
		int to = G[id][j].to;
		if (to == fr)continue;
		dfs(to, id);
		ll rest = G[id][j].cap - t * ((ll)G[to].size()+1);
		if (rest <= 0) {
			valid = false; return;
		}
		v.push_back((rest - 1) / t);
	}
	sort(v.begin(), v.end());
	rep(i, v.size()) {
		if (v[i] < i) {
			valid = false; return;
		}
	}
}

void solve() {
	int n; cin >> n >> t >> s >> g;
	s--; g--;
	rep(i, n - 1) {
		int a, b, w; cin >> a >> b >> w; a--; b--;
		G[a].push_back({ b,w });
		G[b].push_back({ a,w });
	}
	if (t == 0) {
		cout << "Yes" << endl; return;
	}
	find_path(s, -1);
	per(i, (int)path.size()) {
		int v = path[i];
		vector<ll> u;
		rep(j, G[v].size()) {
			int to = G[v][j].to;
			if (!inpath[to]) {
				dfs(to, v);
				ll rest = G[v][j].cap - t * ((ll)G[to].size()+1);
				if (v == s)rest += t;
				if (rest <= 0) {
					cout << "No" << endl; return;
				}
				u.push_back((rest - 1) / t);
			}
		}
		sort(u.begin(), u.end());
		rep(j, u.size()) {
			if (u[j] < j) {
				cout << "No" << endl; return;
			}
		}
		if (i > 0) {
			ll c = 0;
			rep(j, G[v].size()) {
				if (G[v][j].to == path[i - 1]) {
					c = G[v][j].cap; break;
				}
			}
			ll sum = t * ((ll)G[v].size() - 1);
			if (sum >= c) {
				cout << "No" << endl; return;
			}
		}

	}
	if (!valid) {
		cout << "No" << endl; return;
	}
	cout << "Yes" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 16500
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long[] list=new long[N];
		for(int i=0;i<N;i++){
			list[i]=sc.nextInt();
		}
		//１回で取れる個数
		long pick=(long)N*(long)(N+1)/2;

		long sum=0;
		for(int i=0;i<N;i++){
			sum=sum+list[i];
		}
		if(sum-(long)(sum/pick)*pick!=0){
			System.out.println("NO");
			return;
		}
		//総ピック回数
		long count=sum/pick;
		if(((int)(list[0]-list[N-1])-count)%N!=0||((int)(list[0]-list[N-1])-count)>0){				
			System.out.println("NO");
			return;
		}

		for(int i=1;i<N;i++){
			if(((int)(list[i]-list[i-1])-count)%N!=0||((int)(list[i]-list[i-1])-count)>0){				
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");

	}
}

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

int main(){
	int n;
	while (std::cin >> n){

		if (n == -1)break;

		std::vector<int>res;

		do{

			res.push_back(n % 4);

			n /= 4;

		} while (n != 0);

		for (int i = res.size() - 1; i >= 0; i--)std::cout << res[i];
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1212
n = int(input())
list = []

for i in range(n):
    s, p = map(str, input().split())
    list.append([s, int(p), i+1])

list.sort(key=lambda x:x[1], reverse=True)
list.sort(key=lambda x:x[0])
for val in list:
    print(val[2])


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int a,b;
void input()
{
    cin>>a>>b;
    return;
}

void solve()
{
    int ans=0;
    rep(i,max(a,b)){
        ans+=pow(10,i)*min(a,b);
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-27 17:52:45
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

template<class T> std::vector<T> divisor(T n) {
  std::vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0){
      res.push_back(i);
      if (i * i != n){
        res.push_back(n / i);
      }
    }
  }
  std::sort(res.begin(), res.end());

  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  vector<int> v = divisor(m);
  int p = m / n;
  cout << *(upper_bound(all(v), p) - 1) << endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0;i<N;i++){
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int res=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      res+=card.at(i);
    }else{
      res-=card.at(i);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n, m = map(int, input().split())

    # See:
    # https://img.atcoder.jp/arc085/editorial.pdf
    x = 1900 * m + 100 * (n - m)
    q = 2 ** m
    result = x * q
    print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i ++)
#define for1(i, n) for (int i = 1; i <= n; i ++)
#define repn(i, n) for (int i = n-1; i >= 0; i --)
#define rep1(i, n) for (int i = n; i >= 1; i --)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<pii> qpii;

void test_case() {
	int n; cin >> n;
	vll a(n);
	ll XOR = 0;
	forn(i,n) {
		cin >> a[i];
		XOR ^= a[i];
	}
	for (int i = 0; i < n; i ++) {
		cout << (XOR ^ a[i]) << ' ';
	}
	//for (int i = 0; i < n; i ++) {
		//int wyn = 0;
		//for (int j = 0; j < n; j ++) {
			//if (j == i) continue;
			//wyn ^= a[j];
		//}
		//cout << wyn << ' ';
	//}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1; 
	//cin >> q;
	while (q--) {
		test_case();
	}
	return 0;
}


Measured memory_bytes: 4728
/*
[caddi2018] C - Product and GCD
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

ll N, P;

ll solve() {
    map<ll, int> fac;
    ll p = P;
    for (ll d = 2; d * d <= P; d++) {
        while (p % d == 0) {
            fac[d]++;
            p /= d;
        }
    }
    if (p > 0) {
        fac[p]++;
    }

    ll ans = 1;
    for (auto &kv : fac) {
        ll d = kv.first;
        int cnt = kv.second;
        while (cnt >= N) {
            ans *= d;
            cnt -= N;
        }
    }

    return ans;
}

int main() {
    cin >> N >> P;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<pair<ll, ll>, ll> P;		//from, to, cost

int main(){
	vector<P> v;
	ll n; cin >> n;
	vector< pair<ll, ll> > vx, vy;
	for(ll i = 0; i < n; ++i){
		ll x, y; cin >> x >> y; --x; --y;
		vx.push_back(pair<ll, ll>(x, i));
		vy.push_back(pair<ll, ll>(y, i));
	}
	bool used[n] = {0};
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	for(ll i = 0; i < vx.size() - 1; ++i){
		P p;
		p.first = pair<ll, ll>(vx[i].second, vx[i + 1].second);
		p.second = vx[i + 1].first - vx[i].first;
		v.push_back(p);
		p.first = pair<ll, ll>(vy[i].second, vy[i + 1].second);
		p.second = vy[i + 1].first - vy[i].first;
		v.push_back(p);
	}
	vector< pair<ll, ll> > lis[n];
	for(int i = 0; i < v.size(); ++i){
		lis[v[i].first.first].push_back(pair<ll, ll>(v[i].second, v[i].first.second));
		lis[v[i].first.second].push_back(pair<ll, ll>(v[i].second, v[i].first.first));
	}

	ll ans = 0;
	priority_queue<pair<ll, ll> , vector< pair<ll, ll> >, greater< pair<ll, ll> > > q;
	q.push(pair<ll, ll>(0, 0));

	while(!q.empty()){
		pair<ll, ll> p = q.top(); q.pop();
		if(used[p.second]) continue;
		used[p.second] = 1;
		ans += p.first;
		for(pair<ll, ll> u : lis[p.second]){
			if(!used[u.second]) q.push(u);
		}
	}

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

Measured memory_bytes: 24028
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(x) cerr<<#x": "<<(x)<<endl
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int V = 1000010;
const int MOD = 998244353;

int pw(int base, int exp, int mod = MOD) {
	int res;
	for(res = 1; exp; exp >>= 1) {
		if(exp & 1) res = (1LL * res * base) % mod;
		base = (1LL * base * base) % mod;
	}
	
	return res;
}

int modInv(int base, int mod = MOD) {
	return pw(base, mod - 2, mod);
}

void add(int &x, int y) { if((x += y) >= MOD) x -= MOD; }
void sub(int &x, int y) { if((x -= y) < 0) x += MOD; }

int dp[V];

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n, a, s;

	cin >> n;

	s = 0;
	for(int i = 1; i <= n; ++i) {
		cin >> a;
		add(dp[a], a);
		add(s, a);
	}

	for(int i = 1; i < V; ++i) {
		for(int j = i + i; j < V; j += i) add(dp[i], dp[j]);
		dp[i] = (1LL * dp[i] * dp[i]) % MOD;
	}

	int ans = 0;
	for(int i = V - 1; i; --i) {
		for(int j = i + i; j < V; j += i) sub(dp[i], dp[j]);

		add(ans, 1LL * dp[i] * modInv(i) % MOD);
	}

	sub(ans, s);

	cout << (1LL * ans * modInv(2) % MOD) << '\n';

	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#define INF (1e9)
using namespace std;

int main(){
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    int sum[1001]={},in[1001],out[1001],maxsum=0,maxid=0;
    for(int i=0;i<1000;i++) out[i]=in[i]=INF;
    
    for(int i=0;i<n;i++){
      int month,day,h,m,id;
      char ch;
      scanf("%d/%d %d:%d",&month,&day,&h,&m);
      cin>>ch>>id;
      
      maxid=max(maxid,id);
      int time=(month*100000)+(day*10000)+(h*60)+m;
      
      if(ch=='I')in[id]=time;
      if(ch=='O'){
	out[id]=time;
	
	if(id&& out[0]>in[id]&&out[id]>in[0]){
	  sum[id]+=min(out[0],out[id])-max(in[0],in[id]);
	  maxsum=max(maxsum,sum[id]);
	}
	
	for(int j=1;!id&&j<=maxid;j++)
	  if(out[0]>in[j]&&out[j]>in[0]) {
	    sum[j]+=min(out[0],out[j])-max(in[0],in[j]);
	    maxsum=max(maxsum,sum[j]);
	  }
	in[id]=out[id]=INF;
      }

    }
    cout <<maxsum<<endl;
  }

  return 0;
}

Measured memory_bytes: 1252
import java.awt.Point;
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt(), w = scanner.nextInt();
        long ans = 0;
        char[][] c = IntStream.range(0, h).mapToObj(i -> scanner.next().toCharArray()).toArray(char[][]::new);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (c[i][j] != '\0') {
                    long bl = 0, wh = 0;
                    Deque<Point> deque = new ArrayDeque<>(Collections.singleton(new Point(i, j)));
                    while (!deque.isEmpty()) {
                        Point p = deque.pollLast();
                        char ch = c[p.x][p.y];
                        if (ch == '\0') continue;
                        else if (ch == '#') bl++;
                        else if (ch == '.') wh++;
                        c[p.x][p.y] = '\0';
                        if (p.x > 0 && ch != c[p.x - 1][p.y])
                            deque.push(new Point(p.x - 1, p.y));
                        if (p.x + 1 < h && ch != c[p.x + 1][p.y])
                            deque.push(new Point(p.x + 1, p.y));
                        if (p.y > 0 && ch != c[p.x][p.y - 1])
                            deque.push(new Point(p.x, p.y - 1));
                        if (p.y + 1 < w && ch != c[p.x][p.y + 1])
                            deque.push(new Point(p.x, p.y + 1));
                    }
                    ans += bl * wh;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41908
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

	ll r = 0;

	for (ll b = k + 1; b <= n; ++b)
	{
		r += (b - k) * (n / b);
		if (n % b >= k)
			r += n % b - k + (k ? 1 : 0);
	}

	cout << (r) << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n=inp()
    ok=0
    ng=n
    print(0)
    s=input()
    if s=='Vacant':
        return
    for _ in range(19):
        mid = (ok+ng)//2
        print(mid)
        ss=input()
        if ss=='Vacant':
            return
        elif (ss==s and (mid-ok)%2==1) or (ss!=s and (mid-ok)%2==0):
            ng = mid
        else:
            ok = mid
            s = ss


if __name__ == "__main__":
    main()

Measured memory_bytes: 38920
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

// TODO: write
int main() {
  ll a,b,k;cin>>a>>b>>k;
  ll tmp = min(a,k);
  a -= tmp;
  k -= tmp;
  b -= min(b,k);
  cout<<a<<" "<<b<<endl;
  return 0; 
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> c(m);
  for(int i = 0; i < m; i++){
    int p, y;
    cin >> p >> y;
    c.at(i) = {p, y, i};
  }
  
  vector<string> ans(m);
  sort(c.begin(), c.end());
  int lp = -1, cnt = 0;
  for(int i = 0; i < m; i++){
    int np = get<0>(c.at(i)), x = get<1>(c.at(i)), id = get<2>(c.at(i));
    if(np != lp) lp = np, cnt = 0;
    cnt++;
    string npushp = "";
    for(int j = 0; j < 6; j++){
      npushp.push_back('0' + np % 10);
      np /= 10;
    }
    reverse(npushp.begin(), npushp.end());
    string npushc = "";
    int ncnt = cnt;
    for(int j = 0; j < 6; j++){
      npushc.push_back('0' + ncnt % 10);
      ncnt /= 10;
    }
    reverse(npushc.begin(), npushc.end());
    npushp += npushc;
    ans.at(id) = npushp;
  }
  
  for(int i = 0; i < m; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 7476