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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    ll n = SZ(s);
    REP(i,n){
        if(s[i]=='g'){
            if(cnt>0){
                cnt--;
                ans++;
            }
            else{
                cnt++;
            }
        }
        else{
            if(cnt>0){
                cnt--;
            }
            else{
                cnt++;
                ans--;
            }
        }
    }
    cout << ans <<endl;




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D,G;
  cin >> D >> G;
  vector<int> p(D),c(D);
  for (int i = 0; i < D; i++) cin >> p.at(i) >> c.at(i);
  int ans = 1000;
  
  for (int tmp = 0; tmp < (1 << D); tmp++) {
    bitset<10> s(tmp);
    int sum = 0;
    int a = 0;
    int rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (s.test(i)) {
        sum += p.at(i) * (i+1) * 100 + c.at(i);
        a += p.at(i);
      } else rest_max = i;
    }
    
    if (sum < G) {
      int b = (G - sum + (rest_max+1) * 100 - 1) / ((rest_max+1) * 100);
      if (b >= p.at(rest_max)) continue;
      a += b;
    }
    
    ans = min(ans,a);
  }

  
  cout << ans << endl;
}

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

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

    int n;
    string s, t;
    cin >> n >> s >> t;

    for(int i = 0; i < n; i++) {
    	if(i != n - 1) {
    		cout << s[i] << t[i];
    	}else {
    		cout << s[i] << t[i] << endl;
    	}
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

 int p(int i){return i/2;}
 int l(int i){return i*2;}
 int r(int i){return i*2+1;}

 int main(){
        int n,i,key[251];
        scanf("%d",&n);
        for(i=1;i<=n;i++){scanf("%d",&key[i]);}

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


Measured memory_bytes: 2104
#include <stdio.h>
int main(){
  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      printf(" %d",x);
    }
    else{
      while(x){
      if(x%10 == 3){ 
    printf(" %d",i);
        break;
      }
      x = x/10;
      }
    }
  }
    printf("\n");
  return 0;
}



Measured memory_bytes: 2104
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var max=0;
var arr=[];
Arr.forEach(function(v){
var a=(v.split(" "))[0]-0;
var b=(v.split(" "))[1]-0;
   if(max==b)arr.push(a);
   if(max<b){
      max=b;
      arr=[a];
   }
});
arr.sort(function(a,b){return a-b;});
console.log(arr[0]+" "+max);

Measured memory_bytes: 7648
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int H, W, h, w;

int main()
{
  scanf( "%d%d%d%d", &H, &W, &h, &w );

  printf( "%d\n", H*W-h*W-w*H+h*w );
  
  return 0;
}

Measured memory_bytes: 128
package main
import (
    "fmt"
    )
func main(){
    var n,x int
    
    fmt.Scan(&n,&x)
    
    l := make([]int,n)
    
    for i := 0; i < n; i++ {
        var a int
        fmt.Scan(&a)
        
        l[i] = a
    }
    
    dp := make([]int, n+2)
    
    dp[1] = l[0]
    
    cnt := 0
    
    for i := 2; i <= n; i++ {
        dp[i] = dp[i - 1] + l[i - 1]
    }
    
    for i := 0; i <= n; i++ {
        if dp[i] <= x {
            cnt++
        }
    }
    
    fmt.Println(cnt)
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[1001];
int height[1001]={0};
int visit[1001]={0};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int m,d;
    cin>>m>>d;
    int count = 0;
    vector<int>arr(m+1, 0);
    for (int i = 1; i <= d; i++)
    {
        if(i%10>=2 && ((i/10)%10)>=2){
            int p = (i%10)*(((i/10))%10);
            if(p<=m){
                arr[p]++;
            }
        }
    }
    for(int i =1 ; i <=m ; i++){
        count = count+arr[i];
    }
    cout<<count;
}


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

vector<vector<long>> dp;

long solve(int i, int w, vector<int> &weights, vector<int> &profits)
{
    if(i >= weights.size())
        return 0;
    if(w == 0)
        return 0;
    if(dp[i][w] != -1)
        return dp[i][w];
    if(weights[i] > w)
        dp[i][w] = solve(i + 1, w, weights, profits);
    else
        dp[i][w] = max(solve(i + 1, w, weights, profits), solve(i + 1, w - weights[i], weights, profits) + profits[i]);
    return dp[i][w];
}

int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> weights(n), profits(n);
    for(int i = 0; i < n; i++)
        cin >> weights[i] >> profits[i];
    // vector<long> dp(w + 1), dp1;
    // for(int i = 0; i < n; i++)
    // {
    //     for(int j = w; j >= weights[i]; j--)
    //     {
    //         dp[j] = max(dp[j], dp[j - weights[i]] + (long)profits[i]);
    //     }
    // }
    // cout << dp[w];
    dp = vector<vector<long>> (n, vector<long>(w + 1, -1));
    cout << solve(0, w, weights, profits);
    return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  set<int> used;
  while(cin >> n >> m, n | m) {
    vector<int> sum = {0};
    for(int i = 0; i < n; ++i) {
      int K;
      cin >> K;
      sum.push_back((sum.back() + (K % m)) % m);
    }
    used = {m};
    int answer = 0;
    for(auto j: sum) {
      answer = max(answer, (j - *used.upper_bound(j) + m) % m);
      used.insert(j);
      used.insert(j + m);
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 3768
def check_size arr
  case a=arr.shift
  when /[A-Z]+/
    a.size
  when /\d+/
    a.to_i*check_size(arr)
  when ?(
    ans=0
    ans+=check_size(arr) while arr[0]!=?)
    arr.shift
    ans
  end
end

def get_ch arr,n
  while a=arr.shift
    case a
    when /[A-Z]+/
      l=a.size
      break a[n] if n<l
      n-=l
    when /\d+/
      tarr=arr.dup
      l=check_size(tarr)
      break get_ch(arr,n%l) if n<l*a.to_i
      arr=tarr
      n-=l*a.to_i
    end
  end
end

while (a,b=gets.split)!=[?0]*2
  puts get_ch(a.scan(/[A-Z]+|\(|\)|\d+/),b.to_i)||0
end

Measured memory_bytes: 6208
#include <cstdio>
#include <algorithm>

using namespace std;

int g[120000];
int i,n;

inline long long insert(int x,int y,long long z)
{
	if (x==n+1)
		return 0;
	if (y==1)
		if (g[x]+z>0)
			return insert(x+1,-y,z+g[x]);
		else
			return insert(x+1,-y,1)+1-g[x]-z;
	else
		if (g[x]+z<0)
			return insert(x+1,-y,z+g[x]);
		else
			return insert(x+1,-y,-1)+1+g[x]+z;
}

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	printf("%lld",min(insert(1,1,0),insert(1,-1,0)));
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if(a+b<10) cout<<a+b<<endl;
    else cout<<"error"<<endl;
}


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

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

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

int main() {
  long a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

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

int main() {
  int X;
  int s1, s2, s3;
  cin >> X;
  s1 = X/100;
  s2 = (X%100)/10;
  s3 = (X%100)%10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,A[100];
  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  for(int i=n-1;i>=0;i--) {
    if(i!=n-1) cout<<(" ");
    cout<<A[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3060
//made by Sert
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (ll)1e18 + 34;
const int N = (int)3e5 + 34;
const int M = (int)1e4 + 34;

ll upd(ll &ans, ll s1, ll s2, ll s3, ll s4) {
    ans = min(ans, max(max(s1, s2), max(s3, s4)) - min(min(s1, s2), min(s3, s4)));
}

ll kek(ll lft, ll sum) {
    return max(lft, sum - lft) - min(lft, sum - lft);
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<int> a(n + 1);
    ll sumr = 0, suml = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sumr += a[i];
    }
    ll sumll = 0, sumrl = 0;
    ll numll = 0, numrl = 0;
    ll ans = INF;
    for (int numl = 0; numl <= n; numl++) {
        while (kek(sumll + a[numll], suml) < kek(sumll, suml)) sumll += a[numll++];
        while (kek(sumrl + a[numrl], sumr) < kek(sumrl, sumr)) sumrl += a[numrl++];
        //cerr << numl << " " << numll << " " << numrl << " | " << sumrl << " " << sumr << "\n";
        upd(ans, sumll, suml - sumll, sumrl, sumr - sumrl);
        suml += a[numl];
        sumr -= a[numl];
        sumrl -= a[numl];
    }
    cout << ans << "\n";
}

int main() {
#ifdef MADE_BY_SERT
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    solve();
    solve();
    //solve();
#endif
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[100000];
	int last;

	scanf("%s", s);
	last = (int)strlen(s) - 1;
	while (last > -1)
	{
		// dream
		if (s[last] == 'm' && s[last - 1] == 'a' && s[last - 2] == 'e' && s[last - 3] == 'r' && s[last - 4] == 'd')
		{
			last -= 5;
		}
		// dreamer
		else if (s[last] == 'r' && s[last - 1] == 'e' && s[last - 2] == 'm' && s[last - 3] == 'a' && s[last - 4] == 'e' &&
			s[last - 5] == 'r' && s[last - 6] == 'd')
		{
			last -= 7;
		}
		// erase
		else if (s[last] == 'e' && s[last - 1] == 's' && s[last - 2] == 'a' && s[last - 3] == 'r' && s[last - 4] == 'e')
		{
			last -= 5;
		}
		// eraser
		else if (s[last] == 'r' && s[last - 1] == 'e' && s[last - 2] == 's' && s[last - 3] == 'a' && s[last - 4] == 'r' &&
			s[last - 5] == 'e')
		{
			last -= 6;
		}
		else
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			//long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			bool[] ac = new bool[n];
			int[] wa = new int[n];
			for (int i = 0; i < m; i++) {
				string[] r = Console.ReadLine().Split();
				int p = int.Parse(r[0]);
				string s = r[1];
				if (!ac[p - 1]) {
					if (s == "AC") {
						ac[p - 1] = true;
					} else {
						wa[p - 1]++;
					}
				}
			}
			int acCnt = 0, waCnt = 0;
			for (int i = 0; i < n; i++) {
				if (ac[i]) {
					acCnt++;
					waCnt += wa[i];
				}
			}
			Console.WriteLine($"{acCnt} {waCnt}");


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 17632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

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

int N, K;

int Sum[200010];
map<int, int> counter;

int f(int a)
{
	a += K * 1001001001;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}
	//rep(i,N+1)Sum[i]=(Sum[i]-i+K*1001001001)%K;
 

	rep(i, N+1) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
const double pi=3.14159265435897932384626433832795;
int main(){
	double a,b,x; cin>>a>>b>>x;
	double d=a*a*b-x;
	if(x>d){
		double e=d*2/a/a;
		printf("%.6lf",atan(e/a)/pi*180);
	}else{
		double e=x*2/a/b;
		printf("%.6lf",atan(b/e)/pi*180);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N),psum(N+1);
  vector<vector<long long>> maxwin(N,vector<long long>(N));
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    maxwin[i][i] = A[i];
    psum[i+1] = psum[i] + A[i];
  }
  for(int l = 1; l < N; ++l){
    for(int b = 0; b+l < N; ++b){
      int e = b+l;
      maxwin[b][e] = psum[e+1]-psum[b]-min(maxwin[b][e-1],maxwin[b+1][e]);
    }
  }
  cout << 2*maxwin[0][N-1]-psum[N];
  return 0;
}

Measured memory_bytes: 70784
s=list(input())
S=[]
for i in range(len(s)):
    if s[i]=="x":
        pass
    else:
        S.append(s[i])
        
#print(S)
sr=s[::-1]
SR=S[::-1]
if S!=SR:
    print(-1)
else:
    if len(S)%2==0:
        L=len(S)//2
    else:
        L=len(S)//2+1
    SF=[]
    cntx=0
    for y in range(len(s)):
        if s[y]=="x":
            cntx+=1
        else:
            SF.append(cntx)
            cntx=0
    SF.append(cntx)
    SE=SF[::-1]
    ans=0
    for x in range(len(SE)):
        ans+=abs(SE[x]-SF[x])
    print(ans//2)

Measured memory_bytes: 7848
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,S; cin >> n;
    ll A[200200];
    rep(i,n){
        cin >> A[i];
    }
    S = A[0];
    for(int i=1;i<n;i++){
        S ^= A[i];
    }
    ll ans;
    rep(i,n){
        ans = S ^ A[i];
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 5036
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
inline int cmax(int &x,int y) { if(x<y) x=y; }
char S[N],res[N];
int f[N][2],s[N][2],n;
int main() {
	scanf("%s",S+1); n=strlen(S+1);
	memset(f,-0x3f,sizeof(f));
	f[0][0]=0;
	for(int i=1;i<=n;++i)
	for(int c=0;c<2;++c) {
		int now=f[i-1][c];
		if(S[i]!='?') {
			if(f[i][S[i]=='P']<now+(S[i]=='D')+(S[i]=='D'&&c))
				f[i][S[i]=='P']=now+(S[i]=='D')+(S[i]=='D'&&c),
				s[i][S[i]=='P']=c;
		}
		else {
			if(f[i][0]<now+1+c)
				f[i][0]=now+1+c,
				s[i][0]=c;
			if(f[i][1]<now)
				f[i][1]=now,
				s[i][1]=c;
		}
	}
	int c=f[n][0]>f[n][1]?0:1;
	for(int i=n;i>=1;--i) {
		res[i]=c==0?'D':'P';
		c=s[i][c];
	}
	for(int i=1;i<=n;++i) putchar(res[i]);
	return 0;
}

Measured memory_bytes: 7272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[2000005];
map<ll,ll>mp;
int main()
{
    /*char ch;
    cin >> ch;
    if(ch>='A'&&ch<='Z')
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
    int a[10000];
    int n,k;
    cin >> n>> k;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout << ans << endl;*/
    /*ll c;
    cin >> c;
    vector<ll>v;

            while(c>0)
            {
                if(c%26==0)
                v.push_back(26);
                else
                v.push_back(c%26);
                //cout << c << endl;
                if(c%26==0)
                    c= c/26-1;
                else
                    c= c/26;

            }

            for(ll i=v.size()-1;i>=0;i--)
            {
                //cout << v[i] << endl;
                printf("%c",v[i]+96);
            }*/
    /*ll n,sum=0;
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        sum+=a[i];
    }

    ll q;
    cin >> q;
    while(q--)
    {
        ll b,c;
        cin >> b >> c;
        if(mp.find(b)==mp.end())
        {
            cout << sum << "\n";
            continue;
        }
            sum-=mp[b]*b;
            sum+=mp[b]*c;
            mp[c]+= mp[b];
            mp[b]=0;
            //sum+=mp[c]*c;
            cout << sum << "\n";

    }*/

    int n,xor1=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        xor1^=a[i];
    }

    for(int i=0;i<n;i++)
        cout << (xor1^a[i]) << " ";
    cout << endl;

}


Measured memory_bytes: 5176
<?php
fscanf(STDIN, "%d %d", $n, $m);

if ($n === 1) {
	if ($m === 1) {
		echo "1\n";
		return;
	}
	echo $m - 2, "\n";
	return;
}
if ($m === 1) {
	echo $n - 2, "\n";
	return;
}
echo ($n - 2) * ($m - 2), "\n";


Measured memory_bytes: 4856
"""
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m, ans = 10**9 + 7, 0
    for s in map(lambda x: x.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
"""
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans = (ans + s * (n - s) * (1 << i)) % m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

int main(){
  int n;
  cin >> n;
  long long int spot[n+1] = {};

  long long int prev = 0, sum = 0;
  for(int i = 0; i < n; i++){
    cin >> spot[i];
    sum += abs(prev - spot[i]);
    prev = spot[i];
  }
  sum += abs(spot[n-1] - 0);
  prev = 0;
  long long int tmp;
  for(int i = 0; i < n-1; i++){
    tmp = sum;
    tmp -= abs(prev - spot[i]);
    tmp -= abs(spot[i] - spot[i+1]);
    tmp += abs(prev - spot[i+1]);
    cout << tmp << endl;
    prev = spot[i];
  }
  tmp = sum;
  tmp -= abs(prev - spot[n-1]);
  tmp -= abs(spot[n-1] - 0);
  tmp += abs(prev - 0);
  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main() {
  int a[4], b[4], c, d;
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    c = d = 0;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i] == b[j]) (i == j) ? c++ : d++;
    cout << c << ' ' << d << endl;
  }
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int D = Integer.parseInt(in.next());
            int[] c = new int[26];
            for (int i = 0; i < 26; i++) {
                c[i] = Integer.parseInt(in.next());
            }
            int[][] s = new int[D][27];
            for (int i = 0; i < D; i++) {
                for (int j = 0; j < 26; j++) {
                    s[i][j] = Integer.parseInt(in.next());
                }
            }

          int[] last = new int[26];
            for (int i = 0; i < D; i++) {
                int t = 0;
                int satisfy = -999999999;

                for (int j = 0; j < 26; j++) {
                    int manj = 0;
                    for (int k = 0; k < 26; k++) {
                        if (j == k) {
                            manj += s[i][j];
                        } else {
                            manj -= (c[k] * ((i + 1) - last[k]));
                        }
                    }

                    if (manj > satisfy || (manj == satisfy && c[j] > c[t])) {
                        satisfy = manj;
                        t = j;
                    }
                }

                last[t] = i + 1;
                System.out.println(t + 1);
            }
        }

    }
}



Measured memory_bytes: 42796
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e6;
constexpr int INF = 1<<30;
struct Edge {
	int t, w;
	Edge(int t, int w): t(t), w(w) {}
};
vector<Edge> G[MAX];
int n;
vi d;
inline void bfs(int s) {
	d.assign(n, INF);
	deque<int> dq;
	dq.eb(s);
	d[s] = 0;
	int u;
	while(!dq.empty()) {
		u = dq.front(); dq.pop_front();
		rep(i, 0, len(G[u])) {
			Edge e = G[u][i];
			if(d[e.t] == INF) {
				d[e.t] = d[u] + e.w;
				dq.eb(e.t);
			}
		}
	}
}
inline void solve() {
	bfs(0);
	int maxv = 0, tgt = 0;
	rep(i, 0, n) {
		if(d[i] == INF) continue;
		if(maxv < d[i]) {
			maxv = d[i];
			tgt = i;
		}
	}
	bfs(tgt);
	maxv = 0;
	rep(i, 0, n) {
		if(d[i] == INF) continue;
		maxv = max(maxv, d[i]);
	}
	P(maxv);
}
int main() {
	cin >> n;
	int s, t, w;
	rep(i, 0, n - 1) {
		cin >> s >> t >> w;
		G[s].eb(Edge(t, w));
		G[t].eb(Edge(s, w));
	}
	solve();
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> L(M), R(M);
  rep(i, M) cin >> L[i] >> R[i];

  /* min_R - max_L + 1 */
  sort(all(R));
  sort(all(L), greater<int>());
  cout << max(0, R[0] - L[0] + 1) << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

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

    cout << max(0, c - (a-b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(v.begin(),v.end(),std::true_type());static std::false_type c(...);public:const static bool value=decltype(c(std::declval<T>()))::value;};
template<class T,typename enable_if<iterable<T>::value, nullptr_t>::type=nullptr>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vi b(n-1);
    cin>>b;
    int ans=b[0];
    REP(i,1,n-1){
        ans+=min(b[i-1],b[i]);
    }
    ans+=b[n-2];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    if N == 3{
        println!("2 5 63");
        return
    }
    if N == 4{
        println!("2 5 20 63");
        return
    }
    let template: Vec< Vec<usize>> = vec![vec![],
                                          vec![3],
                                          vec![0,2],
                                          vec![0,2,3],
                                          vec![0,2,4,6],
                                          vec![0,1,2,3,5],
                                          vec![1,2,3,4,5,7],
                                          vec![0,1,2,3,4,5,6]
    ];
    let mut nums:Vec<usize> = vec![];
    for i in 0..5000{
        nums.push(i*6+2);
        nums.push(i*6+3);
        nums.push(i*6+4);
        nums.push(i*6+6);
    }
    nums.sort();
    let quotient = N/8;
    let remainder = N%8;
    let mut ans:String = "".to_string();
    for i in 0..quotient{
        for j in 0..8{
            ans.push(' ');
            ans.push_str(&nums[i*8+j].to_string());
        }
    }
    for i in 0..remainder{
        ans.push(' ');
        ans.push_str(&nums[quotient*8+template[remainder][i]].to_string());
    }
    println!("{}", ans.trim());
        


}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int a,t,Max = -1;
char c[110];
int main(){
    cin>>a>>c;
    for(int i = 0 ; i < a ; ++ i){
        if(c[i] == 'I'){
            t ++;
        }
        else t --;
        Max = max(Max,t);
    }
    if(Max == -1) Max = 0;
    cout<<Max;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;
 
long long int mul(long long int ans, long long int x, long long int y){
    while (y){
        if (y%2){
            ans = (ans * x) % MOD;
        }
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}
 
long long int inv(long long int n){
    return mul(1, n, MOD-2);
}
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> prime(1000000, 0);
    for (int i=0; i<n; i++){
        int m = a[i];
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        prime[2] = max(prime[2], count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            prime[j] = max(prime[j], count);
        }
        prime[m] = max(prime[m], 1);
    }
 
    long long int lcm = 1;
    for (int i=2; i<prime.size(); i++){
        if (prime[i] != 0)  lcm = mul(lcm, i, prime[i]);
    }
 
    long long int ans = 0;
    for (int i=0; i<n; i++){
        long long m = a[i], _ans = lcm;
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        _ans = mul(_ans, inv(2), count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            if (count != 0)  _ans = mul(_ans, inv(j), count);
        }
        _ans = mul(_ans, inv(m), 1);
        ans += _ans;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
n = int(input())
train = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    t = 0
    for j in range(i, n-1):
        c, s, f = train[j]
        t = max(t, s)
        t += (f - t % f) % f
        t += c
    print(t)

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

int main(){
  string s;cin>>s;
  int g=0,p=0,ans=0;
  REP(i,s.size()){
    if(s.at(i)=='g') g++;
    else p++;
  }
  ans=(g-p)/2;

  cout<<ans;
}

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

int main(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1!=m2)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

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

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

int N, Q;

vector<int> g[MAX];
ll val[MAX];

bool m[MAX];

void dfs(int i) {
	m[i] = 1;
	for (auto j : g[i]) {
		if (!m[j]) {
			val[j] += val[i];
			dfs(j);
		}
	}

}

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

	int a, b;

	for (int i = 1; i <= N - 1; i++) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 1; i <= N; i++) {
		val[i] = 0;
		m[i] = 0;
	}


	int p;
	ll x;
	for(int i=1; i<=Q; i++){
		cin >> p >> x;
		val[p] += x;
	}

	
	dfs(1);

	for (int v = 1; v <= N; v++) {
		cout << val[v]<<" ";
	}


	system("PAUSE");

}

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

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


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

int main(){
    char s[4];
    cin >> s[0] >> s[1] >> s[2] >> s[3];
    int a=s[0]-'0';
    int b=s[1]-'0';
    int c=s[2]-'0';
    int d=s[3]-'0';
    if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int x,a,b; cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b))cout<<"A"<<endl;
    else cout<<"B"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 998244353;

const int MAX_N = 200010;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

ll pow2[MAX_N];
void pow_init() {
    pow2[0] = 1;
    for(int i=1; i<MAX_N; ++i) {
        pow2[i] = mul(2LL, pow2[i-1]);
    }
}

// sum(0), add(0,x) してはいけない
template<typename T>
class BIT{
public:
    vector<T> bit;
    int size;
    BIT(int size):
        bit(vector<T>(size+1,0)),size(size){}
    
    T sum(int i){
        if(!i) return 0;
        return bit[i]+sum(i-(i&(-i)));
    }

    void add(int i,T x){
        if(i>size)return;
        bit[i]+=x;
        add(i+(i&(-i)),x); 
    }   
};

int main(){
    int N; cin >> N;
    vector<int> xs, ys;
    vector<pair<int,int>> ps;
    REP(i,N) {
        int x, y; cin >> x >> y;
        xs.push_back(x);
        ys.push_back(y);
        ps.push_back(make_pair(x,y));
    }
    // 座標圧縮
    sort(all(xs));
    sort(all(ys));
    sort(all(ps));
    xs.erase(unique(all(xs)),xs.end());
    ys.erase(unique(all(ys)),ys.end());
    REP(i,N) {
        ps[i].first = lower_bound(all(xs), ps[i].first) - xs.begin() + 2;
        ps[i].second = lower_bound(all(ys), ps[i].second) - ys.begin() + 2;
    }
    
    pow_init();
    ll ans = 0;
    BIT<int> y_cnt(MAX_N);
    multiset<int> tmp;
    REP(i,N) {
        int x = ps[i].first;
        int y = ps[i].second;
        ans = add(ans, pow2[y_cnt.sum(MAX_N)]-1);
        ans = sub(ans, pow2[y_cnt.sum(y-1)]-1);
        ans = sub(ans, pow2[y_cnt.sum(MAX_N)-y_cnt.sum(y)]-1);
        tmp.insert(y);
        if(i!=N-1 && ps[i+1].first!=ps[i].first) {
            for(auto e:tmp) {
                y_cnt.add(e,1);
            }
            tmp.clear();
        }
    }

    tmp.clear();
    REP(i,MAX_N+1) y_cnt.bit[i] = 0;
    for(int i=N-1; i>=0; --i) {
        int x = ps[i].first;
        int y = ps[i].second;
        ans = add(ans, pow2[y_cnt.sum(MAX_N)]-1);
        ans = sub(ans, pow2[y_cnt.sum(y-1)]-1);
        ans = sub(ans, pow2[y_cnt.sum(MAX_N)-y_cnt.sum(y)]-1);
        tmp.insert(y);
        if(i!=0 && ps[i-1].first!=ps[i].first) {
            for(auto e:tmp) {
                y_cnt.add(e,1);
            }
            tmp.clear();
        }
    }

    sort(all(ps),[](pair<int,int> p1, pair<int,int> p2){return p1.second<p2.second;});
    int cnt = 0;
    int tmp1 = 0;
    REP(i,N) {
        ans = add(ans, pow2[cnt]-1);
        tmp1++;
        if(i!=N-1 && ps[i].second!=ps[i+1].second) {
            cnt += tmp1;
            tmp1 = 0;
        }
    }

    cnt = 0;
    tmp1 = 0;
    for(int i=N-1; i>=0; --i) {
        ans = add(ans, pow2[cnt]-1);
        tmp1 ++;
        if(i!=0 && ps[i].second!=ps[i-1].second) {
            cnt += tmp1;
            tmp1 = 0;
        }
    }
    ans = sub(mul((ll)N,pow2[N]-1), ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5724
void main() {
	auto N = ri;
	alias Pair = Tuple!(int, "amount", int, "end");
	Pair[] pairs;
	foreach(i; 0..N) {
		auto ip = readAs!(int[]), A = ip[0], B = ip[1];
		pairs ~= Pair(A, B);
	}
	pairs.sort!((a, b) => a.end < b.end);
	ulong current;
	foreach(p; pairs) {
		if(current + p.amount > p.end) {
			writeln("No");
			return;
		}
		current += p.amount;
	}
	writeln("Yes");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.next());
        int cake = Integer.parseInt(sc.next());
        int donut = Integer.parseInt(sc.next());
        
        System.out.println((total-cake)%donut);
    }
}


Measured memory_bytes: 22740
import fractions
A,B,C,D = map(int, input().split())

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

def lcm(x,y):
    return (x*y) // fractions.gcd(x,y)

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)




Measured memory_bytes: 5060
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int sosuu[1001];
int main(){
    REP(i,1001){
       sosuu[i]=1;
    }
    int N;
    cin>>N;
    long long ans=1;
    REP(i,N+1){
        if(i==0||i==1){
           continue;
        }
        if(sosuu[i]==0)continue;
        int temp=1;
        long long j=i;
        while(j<=N){
           temp+=(N/j);
           j*=i;
        }
        //cout<<j<<" "<<N/j<<" "<<temp<<endl;
        ans=(ans*temp)%1000000007;
        for(int k=2;k<N+1;k++){
            if(k%i==0)sosuu[k]=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll mod = 2019;
  ll L, R;
  cin >> L >> R;
  ll ans = inf;
  for (ll i = L; i < min(L + 2022, R); ++i) {
    for (ll j = L + 1; j <= min((ll)i + 2022, R); ++j) {
      ans = min(ans, (i * j) % mod);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL L, R;
	in >> L >> R;

	LL ans;
	if (R / 2019 > L / 2019) ans = 0;
	else
	{
		ans = 11234567890;
		for (LL i = L; i <= R; ++i)
		{
			for (LL j = i + 1; j <= R; ++j)
			{
				ans = std::min(ans, (i * j) % 2019);
			}
		}
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
/*
    title: E.cpp
    author: Akhil
    date: 2020-09-19
    time: 18:32:13
*/

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    long long n, x, m; cin >> n >> x >> m;
    vector<long long> v;
    v.push_back(x);
    unordered_set<long long> s;
    s.insert(x);
    while (true)
    {
        x = (x * x) % m;
        if (s.count(x)) break;
        else v.push_back(x), s.insert(x);
    }
    int idx = -1; 
    for (int i = 0; i < (int) v.size(); i++) if (v[i] == x) {idx = i; break;}
    long long ans = 0; 
    if (n <= idx)
    {
        ans = accumulate(v.begin(), v.begin() + n, 0LL); 
        cout << ans << endl;
        return 0; 
    }
    ans += accumulate(v.begin(), v.begin() + idx, 0LL); 

    long long count = (n - idx) / (v.size() - idx);
    ans += count * accumulate(v.begin() + idx, v.end(), 0LL);

    long long rem = (n - idx) % (v.size() - idx); 
    ans += accumulate(v.begin() + idx, v.begin() + idx + rem, 0LL); 
    cout << ans << endl;
    return 0;
}

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


string s;

void read() {
    int dummy;
    cin >> dummy >> s;
}


void work() {
    if (s.size() % 2 != 0) {
        cout << "No" << endl;
        return;
    }

    for (int i = 0; i < s.size() / 2; ++i) {
        if (s[i] != s[i + s.size() / 2]) {
            cout << "No" << endl;
            return;
        }
    }
    
    cout << "Yes" << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}



int main() {
	int n;
	cin >> n;
	vector<int> v(n + 2);
	vector<ll> ans(n);
	ll sum = 0;
	v[0] = 0;
	v[n + 1] = 0;
	for (int i = 1; i <= n; i++){
		cin >> v[i];
		sum += abs(v[i] - v[i - 1]);		
	}
	sum += abs(v[n]);
	REP(i, n) {
		ans[i] = abs(v[i + 2] - v[i]) - abs(v[i + 1] - v[i]) - abs(v[i + 2] - v[i + 1]);
	}
	REP(i, n)cout << sum + ans[i] << endl;
}



Measured memory_bytes: 2432
import numpy as np
import math

a,b,h,m = map(int, input().split())

m_co = m * 6

h_co = h * 30 + m * 0.5

t = np.abs(h_co - m_co)

cor = min(t, 360-t)

ans = float(((a ** 2) + (b ** 2) - 2 * a * b * math.cos(math.radians(cor))) ** 0.5)

print(ans)

Measured memory_bytes: 27212