akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;



/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

#define index_of(as, x) distance(as.begin(), lower_bound(as.begin(), as.end(), x))
vector<int> lis_fast(const vector<int>& a) {
	const int n = a.size();
	vector<int> A(n, INF);
	vector<int> id(n);
	for (int i = 0; i < n; ++i) {
		id[i] = index_of(A, a[i]);
		A[id[i]] = a[i];
	}
	int m = *max_element(id.begin(), id.end());
	vector<int> b(m + 1);
	for (int i = n - 1; i >= 0; --i)
		if (id[i] == m) b[m--] = a[i];
	//cout << lower_bound(b.begin(),b.end(), INF) - b.begin() << endl;
	return b;
}


int main() {
	int n; cin >> n;
	vector<int> x(n);
	vector<int> ans;

	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	ans = lis_fast(x);

	cout << lower_bound(ans.begin(), ans.end(), INF) - ans.begin() << endl;


	return 0;
}


Measured memory_bytes: 4432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  ll i;
  vector<ll> H(N);
  ll max=0;
  ll now=0;
  for(i=0;i<N;i++){
    cin >> H[i];
    if(i==0) continue;
    if(H[i-1] >= H[i]){
      now++;
    }else{
      if(now>max) max = now;
      now = 0;
    }
  }
  if(now>max) max = now;
  cout << max;
}


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

class City:
    def __init__(self, id, pref, year):
        self.id = id
        self.pref = pref
        self.year = year
        self.num = 0

N,M = map(int, input().split())
cities = []
for i in range(M):
    p, y = map(int, input().split())
    cities.append(City(i+1, p, y))

cities.sort(key=lambda city: city.year)

p_cnt = [0] * N
for i in range(M):
    # 0埋め
    pref_num = str(cities[i].pref).zfill(6)
    p_cnt[cities[i].pref-1] += 1
    city_num = str(p_cnt[cities[i].pref-1]).zfill(6)
    cities[i].num = pref_num + city_num

cities.sort(key=lambda city: city.id)

for i in range(M):
    print(cities[i].num)

Measured memory_bytes: 47968
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    q = deque()
    N = I()
    s = S()
    cnt_l = 0 # (
    cnt_r = 0 # )

    for c in s:
        if c == '(':
            cnt_l += 1
        else:
            cnt_r += 1
            if cnt_l > 0:
                cnt_l -= 1
                cnt_r -= 1
        q.append(c)
    while cnt_l:
        q.append(')')
        cnt_l -= 1
    while cnt_r:
        q.appendleft('(')
        cnt_r -= 1
    ans = []
    for c in q:
        ans.append(c)
    print(''.join(ans))

main()



Measured memory_bytes: 5460
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        --tmp_a;
        a[i] = tmp_a;
    }
    vector<bool> flg(n);
    flg[0] = true;
    int next = a[0];
    bool ok = false;
    int ans = 1;
    while(1) {
        if ( flg[next] ) {
            ans = -1;
            break;
        }
        if ( next == 1 ) {
            ok = true;
            break;
        }
        flg[next] = true;
        next = a[next];
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#!usr/bin/perl

use warnings;
use strict;
use utf8;


my $answer = 0;
my $plus_count = 0;
my $all_combination;
my $math_formula;
my $num_length;
my @plus_list;
my $numbers = <STDIN>;
chomp($numbers);

$num_length = length($numbers);
$all_combination = 2 ** ($num_length - 1);

for(my $i = 0; $i < $all_combination; $i++) {
    $plus_count = 0;
    $math_formula = $numbers;
    my $b = sprintf "%099b", $i; # ここの"%099b"を"%09b"にすれば10桁まで対応
    my $ba = substr($b, -($num_length - 1));
    # print "$ba = $math_formula : ";
    &number_plus($ba);
    my @numbers = split(/\+/, $math_formula);
    foreach my $j (@numbers) {
        $answer += $j;
    }
}

print "$answer\n";

######################################################
# end main
######################################################

sub number_plus {
    my($ref_list) = @_;
    my $index = index($ref_list, "1");
    if($index >= 0) {
        substr($math_formula, $index + $plus_count + 1, 0, "+");
        # print "$ref_list = $math_formula : ";
        substr($ref_list, $index, 1, "0");
        $plus_count++;
        &number_plus($ref_list);
    }
}



Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        x: usize,
        n: usize,
        forbidden_list: [usize; n],
    }
    let mut vec = vec![(false, false); 100];

    for f in &forbidden_list {
        if x == *f {
            let diff = f - x;
            vec[diff] = (true, true);
        } else if x < *f {
            let diff = f - x;
            vec[diff].1 = true;
        } else {
            let diff = x - f;
            vec[diff].0 = true;
        }
    }

    for (i, v) in vec.iter().enumerate() {
        if !v.0 {
            println!("{}", x as isize - i as isize);
            break;
        } else if !v.1 {
            println!("{}", x+i);
            break;
        }
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#include <math.h>
const int INF = 1001001001;
main(){
  int N;
  cin>>N;
  vector<int>S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=S.at(i);
  }
  if(ans%10==0){
    for(int i=0;i<N;i++){
      if(S.at(i)%10!=0){ans-=S.at(i);cout<<ans<<endl;return 0;}
    }
     cout<<0<<endl;return 0;
    }
  
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
#include <map>
#include <queue>
 
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD=ll(1e9+7);

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

ll P_POW(ll i, ll n) {
  if(n==0) return 1;

  n--;
  ll rep = i;

  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}

void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
}

int main() {
  ll n, k;
  cin >> n >> k;
  // 2次元vector
  //vector<vector<ll>> a(n ,vector<ll>{2,0});
  // vector
  // vector<ll> s(n,0);
  //vector<vector<ll>> v;
  //map<ll,ll> m;
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;

  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    pq.push(make_pair(a, b));
  }

  ll total = 0;
  while(!pq.empty()) {
    total = total + pq.top().second;
    pq.pop();
    if(total < k && k <= total + pq.top().second) cout << pq.top().first << endl;
  }

}


Measured memory_bytes: 2420
maxd2 = 40**2*10
intd2 = set()
maxi = int(maxd2**(1/2))+10
for i in range(maxi):
    intd2.add(i**2)


n, d = list(map(int, input().split()))
x = []
for _ in range(n):
    xi = list(map(int, input().split()))
    x.append(xi)
    
cnt = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        distance = sum([(x[i][k]-x[j][k])**2 for k in range(d)])
        if distance in intd2:
            cnt += 1
            
print(cnt//2)
    


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

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

    vector<int> a(n);
    rep (i, n)
        cin >> a[i];

    vector<int> cnt(n, 0);
    cnt[0] = 1;
    int pos = a[0] - 1;
    int repLen;
    int beginRepPos;
    bool beginRep = false;
    while (1)
    {
        cnt[pos]++;

        if (cnt[pos] == 2 && beginRep == false)
        {
            beginRep = true;
            beginRepPos = pos;
        }
        if (cnt[pos] == 3)
            break;

        if (beginRep)
            repLen++;
        pos = a[pos] - 1;
    }

    pos = 0;
    while (k)
    {
        k--;
        pos = a[pos] - 1;
        if (pos == beginRepPos)
            k %= repLen;
    }

    cout << pos + 1 << endl;
    return 0;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
using VD = vector<double>; using VVD = vector<VD>; using VVVD = vector<VVD>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VI a(3);
  REP (i, n) {
    int x; cin >> x;
    x--;
    a[x]++;
  }
  double N = n;
  VVVD dp(n + 1, VVD(n + 1, VD(n + 1)));
  REPI (s, 1, n + 1) {
    REP (k, s + 1) {
      REP (j, s + 1) {
        int i = s - k - j;
        if (i < 0) break;
        double tmp = N / s;
        if (i > 0) {
          tmp += dp[i - 1][j][k] * i / s;
        }
        if (j > 0) {
          tmp += dp[i + 1][j - 1][k] * j / s;
        }
        if (k > 0) {
          tmp += dp[i][j + 1][k - 1] * k / s;
        }
        dp[i][j][k] = tmp;
      }
    }
  }
  cout << setprecision(10);
  cout << dp[a[0]][a[1]][a[2]] << endl;
}


Measured memory_bytes: 216832
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        BigInteger a=new BigInteger(str);
        str=sc.next();
        BigInteger b=new BigInteger(str);
        System.out.println(a.add(b));
    }
}



Measured memory_bytes: 73064
#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 k,a,b;
    cin >>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
A,B,K = map(int,input().split())


w = [0] * K

i = 0
for j in reversed(range(1,max(A,B)+1)):
    if i > K-1 : break
    if A%j == 0 and B%j == 0:
        w[i] = j
        i += 1
        
        

print(w[K-1])

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

int f(int x) {
    for(int i = 0; i < 100; i++) {
        if (x % int(pow(2, i))) {
            return i - 1;
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int res = 99;
    for (int i = 0; i < n; i++) {
        if (f(a.at(i)) < res) res = f(a.at(i));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, D;
	scanf("%d %d", &N, &D);
	int i = 1;
	int cnt = 0;
	while (i <= N)
	{
		i = i + 2 * D;
		cnt++;
		i++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble(), b = sc.nextDouble(), angle = sc.nextDouble();
        double c = Math.toRadians(angle);
        
        double s = a * b * Math.sin(c) / 2;
        double l = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(c));
        double h = b * Math.sin(c);
        
        System.out.println(s);
        System.out.println(l);
        System.out.println(h);
    }
}


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

int rec(string field[], int x, int y, int w, int h){
    int count=1;
    int f=0;
    field[y][x] = ',';
    if(x+1<w && field[y][x+1] == '.'){
        count += rec(field, x+1, y, w, h);
    }
    if(y+1<h && field[y+1][x] == '.'){
        count += rec(field, x, y+1, w, h);
    }
    if(x-1>=0 && field[y][x-1] == '.'){
        count += rec(field, x-1, y, w, h);
    }
    if(y-1>=0 && field[y-1][x] == '.'){
        count += rec(field, x, y-1, w, h);
    }
    return count;
}

int main(){
    int w, h;
    string field[20];
    int x, y;
    cin >> w >> h;
    while(w || h){
        x = string::npos;
        for(int i=0;i<h;++i){
            cin >> field[i];
            if(x==string::npos){
                x = field[i].find('@');
                y = i;
            }
        }
        cout << rec(field, x, y, w, h) << endl;
        cin >> w >> h;
    }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define se second
const int N = 2e5+5;
const int mod = 1e9+7;
ll po(int a, int b){
    if(b==0)return 1;
    ll x = po(a,b/2);
    x = (x*x)%mod;
    if(b&1)x = (x*a)%mod;
    return x;
}
ll z[N],n;
bool vis[N];
int par[N];
vector<int>v[N];
ll ans = 0;
void dfs(int x){
    vis[x] = true;
    z[x] = 1;
    for(int y:v[x]){
        if(vis[y])continue;
        par[y] = x;
        dfs(y);
        z[x]+=z[y];
    }
    if(z[x]==1)return;
    ll trt1 = po(2,z[x]-1)-1;
    ll trt2 = po(2,n-z[x])-1;
    trt1=(trt1*trt2)%mod;
    trt2 = po(2,n);
    trt2 = po(trt2,mod-2);
    trt1 = (trt1*trt2)%mod;
    ans = (ans+trt1)%mod;
    trt1 = 1;
    for(int y:v[x]){
        if(par[y]!=x)continue;
        trt1+=po(2,z[y])-1;
        trt1%=mod;
    }
    trt1 = ((po(2,z[x]-1)-trt1)%mod+mod)%mod;
    trt2 = po(2,n);
    trt2 = po(trt2,mod-2);
    trt1 = (trt1*trt2)%mod;
    ans = (ans+trt1)%mod;
}
void solve(){
    cin>>n;
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(1);
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 32520
import math

#[H]（Attack_num: 2**0）
#[floor(H/2), floor(H/2)]（Attack_num: 2**1）
#[floor(H/4), floor(H/4), floor(H/4), floor(H/4)]（Attack_num: 2**2）
#↓
#[floor(H/2**N), floor(H/2**N), ..., floor(H/2**N), floor(H/2**N)]（Attack_num: 2**N）
#
#floor(H/2**N) = 1
#
#flooer(H/2**N) = 1となるNを求める。
#このとき、攻撃の最小回数は2**0+2**1+....+2**N+2**N
#
#ex. H = 10
#[10](攻撃回数2**0)
#↓
#[5, 5](攻撃回数2**1)
#↓
#[2, 2, 2, 2](攻撃回数2**2)
#↓
#[1, 1, 1, 1, 1, 1, 1, 1]（攻撃回数2**3）
#↓
#[0, 0, 0, 0, 0, 0, 0, 0]（攻撃回数2**3）
#↓
#全滅
#
#攻撃回数: 2**0+2**1+2**2+2**3+2**3=23

def calc_rep_num(H):
    H_temp = H
    rep = 0
    while not(H_temp == 1):
        H_temp = math.floor(H_temp/2)
        rep += 1
    return rep

def calc_Attack_num(rep):
    Attack_num = (1-2**(rep))/(1-2)+2**rep
    return int(Attack_num)


    
#H: モンスターの体力
H = int(input())
#rep: 階層
rep = calc_rep_num(H)
#Attack_num: 攻撃回数
Attack_num = calc_Attack_num(rep)

print(Attack_num)


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

int main(){
    int H, W;
    int aH, aW;
    char m[100][100];
    char temp[100][100];
    char ans[100][100];
    cin >> H >> W;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> m[i][j];
        }
    }

    aH = 0;
    aW = 0;
    for(int i=0;i<H;i++){
        bool flag = false;
        for(int j=0;j<W;j++){
            if(m[i][j] == '#'){
                flag = true;
                break;
            }
        }
        
        if(flag){
            for(int j=0;j<W;j++){
              temp[aH][j] = m[i][j];
            }
            aH++;
        }
    }

    for(int j=0;j<W;j++){
        bool flag = false;
        for(int i=0;i<aH;i++){
            if(temp[i][j] == '#'){
                flag = true;
                break;
            }
        }

        if(flag){
            for(int i=0;i<aH;i++){
                ans[i][aW] = temp[i][j];
            }
            aW++;
        }
    }

    for(int i=0;i<aH;i++){
        for(int j=0;j<aW;j++){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>> N;
    int A[N];
    rep(i,0,N) cin>>A[i];
    ll ans=0, xtemp=A[0], temp=A[0];
    int l=0, r=0;
    while(l<N){
        while(xtemp==temp&&r<N){
            ans++;
            r++;
            xtemp^=A[r];
            temp+=A[r];
        }
        xtemp^=A[l];
        temp-=A[l];
        l++;
        ans+=r-l;
    }
    cout << ans<<"\n";
}

Measured memory_bytes: 1024
main :: IO ()                                                                                                              
main = map read . words <$> getLine >>= \(w:a:b:_) -> print $ f w a b                                                      
                                                                                                                           
f w a b                                                                                                                    
  | a <= b && b < a + w =  0                                                                                               
  | b <= a && a < b + w =  0                                                                                               
  | a + w <= b = b - a - w                                                                                                 
  | b + w <= a = a - b - w

Measured memory_bytes: 508
#include <stdio.h>

int main(){

int a;
int b;

scanf("%d %d",&a,&b);

if(a<b){
 printf("a < b\n");
 }
 else if(a>b){
 printf("a > b\n");
}
else if(a==b){
 printf("a == b\n");
}

return 0;
}

Measured memory_bytes: 1796
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {
    Set<Integer> set;
    AtCoder(FastScanner sc) {
        set = new HashSet<>();
        for (int i = 0; i < 3; i++) {
            set.add(sc.nextInt());
        }
    }

    void solve(PrintWriter out) {
        out.println(set.size());
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

#define endl '\n'

using namespace std;

int n, k, c;
string s;
void read()
{
    cin >> n >> k >> c >> s;
}

void solve()
{
    vector <int> v;
    for (int i = 1; i <= n; i++)
        if (s[i-1] != 'x')
            v.push_back(i);


    vector <int> p;
    p.push_back(0);
    for (int i = 1; i < v.size(); i++)
        if (v[i] - v[p.back()] >= c+1)
        p.push_back(i);

    if (p.size() > k)
        return;

    vector <int> ans;
    int sz = p.size();
    if (p[sz-1] == v.size()-1)
        ans.push_back(v[p[sz-1]]);

    p[sz-1] = v.size()-1;

    for (int i = sz-2; i >= 0; i--)
    {
        int curr = p[i];
        while (v[p[i+1]] - v[curr] >= c+1)
            curr++;

        curr--;
        if (curr == p[i])
            ans.push_back(v[p[i]]);

        p[i] = curr;
    }

    reverse(ans.begin(), ans.end());
    for (auto i: ans)
        cout << i << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 4236
n = int(input())
b = list(map(int, input().split(' ')))
a = [b[0]] + b
for i in range(n - 1):
    if b[i] != max(a[i], a[i + 1]):
        if a[i] < a[i + 1]:
            a[i + 1] = a[i]
        else:
            a[i] = a[i + 1]
print(sum(a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vector<ll>vec(n);
    for(int i=0;i<n;i++)
        cin >> vec[i];
    for(int i=k;i<n;i++)
    {
        if(vec[i]>vec[i-k])
            cout<<"Yes";
        else
            cout << "No";
        cout << endl;
    }
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

  return 0;
}


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

int main() {
	string x;
	while(cin>>x && x!="0")
	{
		int sum = 0;
		for(int i=0; i<x.length(); i++)
		{
			sum += x[i] - '0' ;
		}
		cout<<sum<<'\n' ; 
	}
	
	return 0;
}


Measured memory_bytes: 3208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<Restauran> restaurans = new List<Restauran>();
            foreach(var i in Enumerable.Range(0, n))
            {
                var tmpread = Console.ReadLine().Split(' ');
                var tmprest = new Restauran(i + 1, tmpread[0], int.Parse(tmpread[1]));
                restaurans.Add(tmprest);

            }
            var result = restaurans.OrderBy(x => x.S).ThenByDescending(x => x.P);
            foreach(var tmprest in result)
            {
                Console.WriteLine(tmprest.Num);
            }

        }
    }
    public class Restauran
    {
        public int Num, P;
        public string S;
        public Restauran(int num, string s, int p)
        {
            Num = num;
            P = p;
            S = s;
        }

    }
}


Measured memory_bytes: 11612
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll H, W;
  cin >> H >> W;

  vvc C(H + 1, vc(W));
  rep2(i, 1, H + 1){
    rep(j, W){
      cin >> C[i][j];
    }
  }

  rep2(i, 1, 2*H + 1){
    rep(j, W){
      cout << C[(i + 1)/2][j];
    }
    cout << endl;
  }
  
  return 0;
}

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


int main() {

    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n){cin >> l[i]; l[i] *= -1;}
    sort(l.begin(), l.end(), less<int>());

    int ans = 0;
    rep(i,n-2){
        for(int j = i+1; j < n-1;j++){
            int min = l[i] -l[j];
            auto itr = lower_bound(l.begin()+j+1, l.end(),min);
            int d = distance(l.begin()+j,itr) -1;
            ans += d;
            // cout << "l[j]:" << l[j] << endl;
            // cout << *itr<< endl;
            // cout << d << endl;
        }
    }

    cout << ans << endl;

    
    return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){

    ll n;
    cin >> n;
    ll a[100005] = {},b[100005] = {};

    rep(i,0,n)cin >> a[i] >> b[i];

    ll cnt = 0;
    rep(i,0,n){
        ll ri = n-i-1;
        
        ll m = ((a[ri]+cnt)%b[ri]);
        if(m != 0)cnt += b[ri] - m;
    }       
    P(cnt);
	return  0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

	bool same(int x, int y) { return (find(x) == find(y)); }
} uf;

const int MN = 200010;

using P = pair<ll, int>;

vector<pii> g[MN];
int col[MN];
ll X[MN];
vector<P> dp[MN];

void mergevec(vector<P>& a, vector<P> b) {
	for (auto p : b) {
		a.eb(p);
	}
	sort(ALL(a));

	set<int> st;
	vector<P> res;

	if (a.size()) {
		res.pb(a[0]);

		int c = a[0].se;
		for (int i = 1; i < a.size(); ++i) {
			if (a[i].se != c) {
				res.pb(a[i]);
				break;
			}
		}
	}
	
	a = res;
}

void dfs_up(int v, int p) {
	dp[v].eb(X[v], col[v]);

	for (pii e : g[v]) {
		if (e.fi != p) {
			dfs_up(e.fi, v);

			vector<P> nx;

			for (auto t : dp[e.fi]) {
				nx.eb(t.fi + e.se, t.se);
			}

			mergevec(dp[v], nx);
		}
	}
}

void dfs_down(int v, int p, int pw) {
	if (p != -1) {
		vector<P> nx;
		for (auto t : dp[p]) {
			nx.eb(t.fi + pw, t.se);
		}
		mergevec(dp[v], nx);
	}

	for (pii e : g[v]) {
		if (e.fi != p) {
			dfs_down(e.fi, v, e.se);
		}
	}
}

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

	rep(i, N) cin >> X[i];

	rep(i, N-1) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a].eb(b, c);
		g[b].eb(a, c);
	}

	uf.init(N);
	rep(i, N) {
		col[i] = i;
	}

	ll ans = 0;

	while (true) {
		bool one = true;
		for (int i = 1; i < N; ++i) {
			if (col[i] != col[0]) {
				one = false;
			}
		}
		if (one) {
			break;
		}

		rep(i, N) {
			dp[i].clear();
		}

		vector<P> mt(N, mp(LLONG_MAX, -1));

		dfs_up(0, -1);
		dfs_down(0, -1, -1);

		rep(i, N) {
			for (P p : dp[i]) {
				if (p.se != col[i]) {
					mt[col[i]] = min(mt[col[i]], mp(p.fi + X[i], p.se));
					break;
				}
			}
		}

		rep(i, N) if (mt[i] != mp(LLONG_MAX, -1)) {
			int u = i, v = mt[i].se;
			ll cost = mt[i].fi;
			if (!uf.same(u, v)) {
				uf.unite(u, v);
				ans += cost;
			}
		}

		rep(i, N) {
			col[i] = uf.find(col[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 73032
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int n;
    cin >> n;
    int f[n][10];
    rep(i, n) {
        rep(j, 5) { cin >> f[i][2 * j] >> f[i][2 * j + 1]; }
    }
    int p[n][11];
    rep(i, n) {
        rep(j, 11) { cin >> p[i][j]; }
    }

    int ans = -mod;
    repd(i, 1, 1 << 10) {
        int sum = 0;
        rep(j, n) {
            int count = 0;
            rep(k, 10) {
                if (i & (1 << k)) {
                    if (f[j][k]) {
                        count++;
                    }
                }
            }
            sum += p[j][count];
        }

        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s;
  cin >> s;
  bool flag;

  for(int i = s.size()-2; i >= 0; i-=2){
    flag = true;
    for(int j = 0; j < i/2; j++){
      if(s[j] != s[i/2+j]) {
        flag = false;
        break;
      }
    }
    if(flag) {
      print(i);
      return 0;
    }
  }
  print(1);
}


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

using namespace std;

typedef long long ll;

const int Maxn = 60;
ll dp[Maxn][Maxn][Maxn * Maxn];

int main() {
    int n, A, maxv = 0;
    cin >> n >> A;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        maxv = max(maxv, x[i]);
    }

    dp[0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i + 1; ++j) {
            for (int k = 0; k < Maxn * Maxn - maxv; ++k) {
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for (int j = 1; j <= n; ++j) {
        ans += dp[n][j][A * j];
    }

    cout << ans << endl;
}

Measured memory_bytes: 84352
#include <cstdio>
#include <algorithm>
#define LL long long
#define INF 2000000000
#define maxn 1010
using namespace std;
int n,m;
int k[][2]={{-1,0},{1,0},{0,-1},{0,1}};//L,R,U,D
int border[maxn][maxn][4];//边界
int vis[maxn][maxn],qx[maxn*maxn],qy[maxn*maxn];
LL ans;
struct node{
	int a,b,c;
}f[maxn],g[maxn];
int X[maxn],Y[maxn],XN,YN;
int findX(int v){
	return lower_bound(X,X+XN,v)-X;
}
int findY(int v){
	return lower_bound(Y,Y+YN,v)-Y;
}
void bfs(int xx,int yy){
	//printf("xx=%d yy=%d\n",xx,yy);
	int i,h,t,nx,ny,x,y;
	h=t=0;
	qx[t]=xx,qy[t]=yy,t++,vis[xx][yy]=1;
	while(h<t){
		x=qx[h],y=qy[h],h++;
		//printf("x=%d y=%d\n",x,y);
		ans+=(LL)(X[x+1]-X[x])*(Y[y+1]-Y[y]);
		//printf("ans=%lld\n",ans);
		for(i=0;i<4;i++){
			//printf("border[%d][%d][%d]=%d\n",x,y,i,border[x][y][i]);
			if(border[x][y][i])continue;
			nx=x+k[i][0],ny=y+k[i][1];
			//printf("border[%d][%d][%d]=%d nx=%d ny=%d\n",x,y,i,border[x][y][i],nx,ny);
			if(nx==0||nx==XN-1||ny==0||ny==YN-1){
				ans=-1;
				return;
			}
			if(vis[nx][ny])continue;
			//printf("x=%d y=%d i=%d nx=%d ny=%d\n",x,y,i,nx,ny),
			vis[nx][ny]=1,qx[t]=nx,qy[t]=ny,t++;
		}
	}
}
void init(){
	int i,x,y,r,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].c),X[XN++]=f[i].c;
	X[XN++]=-INF,X[XN++]=INF;
	sort(X,X+XN);//自小到大排序
	XN=unique(X,X+XN)-X;//去重
	for(i=0;i<m;i++)scanf("%d%d%d",&g[i].a,&g[i].b,&g[i].c),Y[YN++]=g[i].a;
	Y[YN++]=-INF,Y[YN++]=INF;
	sort(Y,Y+YN);//自小到大排序
	YN=unique(Y,Y+YN)-Y;
	/*printf("X: ");
	for(i=0;i<XN;i++)printf("%d ",X[i]);
	printf("\n");
	printf("Y: ");
	for(i=0;i<YN;i++)printf("%d ",Y[i]);
	printf("\n");*/
	for(i=0;i<n;i++){
		x=findX(f[i].c);
		r=findY(f[i].b);
		if(Y[r]!=f[i].b)r--;
		for(j=findY(f[i].a);j<r;j++)
			border[x-1][j][1]=border[x][j][0]=1;//,printf("border[%d][%d][%d]=%d border[%d][%d][%d]=%d\n",x-1,j,1,border[x-1][j][1],x,j,0,border[x][j][0]);//边界设定
	}
	for(i=0;i<m;i++){
		y=findY(g[i].a);
		r=findX(g[i].c);
		if(X[r]!=g[i].c)r--;
		for(j=findX(g[i].b);j<r;j++)
			border[j][y-1][3]=border[j][y][2]=1;//,printf("border[%d][%d][%d]=%d border[%d][%d][%d]=%d\n",j,y-1,3,border[j][y-1][3],j,y,2,border[j][y][2]);//边界设定
	}
}
int main(){
	init();
	bfs(findX(0)-1,findY(0)-1);
	if(ans==-1)printf("INF\n");
	else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 30748
n,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
print((pow(2,n,MOD)-comb(n,a)-comb(n,b)-1)%MOD)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n,l,t;
  cin >> n >> l >> t;
  vector<pair<int, int>> xw(n);
  REP(i,n){
    cin >> xw.at(i).first >> xw.at(i).second;
  }
  int x = xw.at(0).first;
  int w = xw.at(0).second;
  int64_t r = 0; // 0地点が最終的にxの何になるか
  for (auto i:xw){
    if (i.first != x){
      if (i.second != w){
        if (w == 1){
          r += t*2/l;
          if ((t*2%l) > (i.first - x)){
            r++;
          }
        }else{
          r -= t*2/l;
          if ((t*2%l) >= (l - (i.first - x))){
            r--;
          }
        }
      }
    }
  }
  if (r<= 0){
    r = n + r % n;
  }else{
    r = r % n;
  }
  int key; // 0地点の最終地点
  if (w == 1){
    key = (x + t % l) % l;
  }else{
    key = x - t % l;
    if (key < 0){
      key = l + key;
    }
  }
  vector<int64_t> vec(n);
  REP(j,n){
    pair<int, int> i = xw.at(j);
    int64_t z;
    if (i.second == 1){
      z = (i.first + t % l) % l;
    }else{
      z = i.first - t % l;
      if (z < 0){
        z = l + z;
      }
    }
    vec.at(j) = z;
  }
  SORT(vec);
  int index; // 0地点のvec内の位置
  REP(i, n){
    if (vec.at(i) == key){
      index = i;
      break;
    }
  }
  REP(i, n){
    int last = (i + index - r)%n;
    if (last < 0){
      last = n + last;
    }
    cout << vec.at(last) << endl;
  }
  return 0;
}



Measured memory_bytes: 2816
def popcount(n):
    return bin(n).count("1")


def f(n):
    if n == 0:
        return 0
    return 1 + f(n % popcount(n))


N = int(input())
X = input()

c = X.count('1')
t1 = [0] * N
t1[0] = 1 % (c + 1)
for i in range(1, N):
    t1[i] = (t1[i - 1] << 1) % (c + 1)
x1 = 0
for i in range(N):
    if X[i] == '0':
        continue
    x1 += t1[N - 1 - i]

if c - 1 != 0:
    t2 = [0] * N
    t2[0] = 1 % (c - 1)
    for i in range(1, N):
        t2[i] = (t2[i - 1] << 1) % (c - 1)
    x2 = 0
    for i in range(N):
        if X[i] == '0':
            continue
        x2 += t2[N - 1 - i]

result = []
for i in range(N):
    if X[i] == '0':
        n = (x1 + t1[N - 1 - i]) % (c + 1)
    elif X[i] == '1':
        if c - 1 == 0:
            result.append(0)
            continue
        n = (x2 - t2[N - 1 - i]) % (c - 1)
    result.append(1 + f(n))
print(*result, sep='\n')


Measured memory_bytes: 30036
from functools import lru_cache


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs):
    @lru_cache(maxsize=None)
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


MOD = 998244353
n, m = list(map(int, input().split()))
facts, invs = prepare(n + 3 * m, MOD)
nhr = get_nhr(n, facts, invs)
ans = 0
for odd in range(m % 2, min(m, n) + 1, 2):
    tmp = nhr((3 * m - odd) // 2)
    if odd > 0:
        tmp -= odd * nhr((m - odd) // 2)
    if odd < n and odd <= m - 2:
        tmp -= (n - odd) * nhr((m - odd - 2) // 2)
    ans = (ans + facts[n] * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
print(ans)


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

N, T = map(int, input().split())

a = [list(map(int, input().split())) for i in range(N)]

# cost = 10000000

INF = 10**4
cost = INF

# print(a)

# for i, risuto in enumerate(a):
#     if risuto[1] <= T:
#         if risuto[0] <= cost:
#             cost = risuto[0]

for i, risuto in enumerate(a):
    if risuto[1] <= T and  risuto[0] <= cost:
        cost = risuto[0]



# if cost == 10000000:

if cost == INF:
    cost = 'TLE'

print(cost)





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,b=0,c=0,d=0;
    string s;
    scanf("%d",&n);

    while(n--)

    {
        cin>>s;
        if(s[0]=='A')
            a++;
        else if(s[0]=='W')
            b++;
        else if(s[0]=='T')
            c++;
        else if(s[0]=='R')
            d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}



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

int main ()
{
	char w[101];
	if (fgets(w, 101, stdin) == NULL)
		return 1;
	for(char i = 'a'; i <= 'z'; ++i){
		int counter = 0;
		for(int j = 0; j <= strlen(w); ++j)
			if(w[j]==i)
				++counter;
		if (counter%2 == 1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL T;
LL A[100001];
int main(){
	cin>>N;
	cin>>T;
	REP(i,N){
	    cin>>A[i];
	}
	int ans=0;
	LL dis=0;
	LL m=A[N-1];
	for(int i=N-2;i>=0;i--){
	//cout<<i<<endl;
	    if(m-A[i]<0){
	       m=A[i];
	       continue;
	    }
	    if((m-A[i]==dis)&&(dis!=0)){
	       ans++;
	       continue;
	    }
	    if(m-A[i]>dis){
	       ans=1;
	       dis=m-A[i];
	    }
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  string ans = "";
  if(a == b) {
    for(int i=1;i<=b;++i) {
      ans += to_string(a);
    }
  }
  if(a != b) {
    if(a>b) {
      for(int l=1;l<=a;++l) {
        ans += to_string(b);
      }
    }
    if(a<b) {
      for(int k=1;k<=b;++k) {
        ans += to_string(a);
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  ll n=0,a;
  string s;
  cin>>s;
  if(s=="hi"){
    cout<<"Yes\n";
    return(0);
  }else if(s.size()%2==0){
    a=s.size();
  for(int i=0;i<s.size();i+=2){
      if(s[i]=='h' && s[i+1]=='i'){
       n++;
      }
    }
  if(n==a/2){
  cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  }else{
    cout<<"No\n";
    return(0);
  }

  return(0);
}


Measured memory_bytes: 256