akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		for (int i = 1; i <= n; i++) {

			if (n >= 10) {
				if ((i % 10 == 3) || (i % 3 == 0)) {
					System.out.print(" " + i);
					continue;
				}
				
				int x = i;

				while (x > 9) {
					/*if ((i % 10 == 3) || (i % 3 == 0)) {
						System.out.print(" " + i);
						break;
					}*/

					x = x / 10;
					if ((x % 10 == 3) ) {
						System.out.print(" " + i);
						break;
					}
					
				}

			} else {
				if ((i % 10 == 3) || (i % 3 == 0)) {
					System.out.print(" " + i);

				}
			}

		}
		System.out.println();
	}

}

Measured memory_bytes: 28552
#include <iostream>
#include <algorithm>

int main() {
	long long int n, k;
	std::cin >> n >> k;

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

	std::sort(a, a + n);

	int cnt = std::max(0LL, n - k);
	long long int ans = 0;

	for (int i = 0; i < cnt; ++i)
		ans += a[i];

	std::cout << ans;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
signed main()
{
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 2; i < N; i++)
    {
        if (S[i - 2] == 'A' && S[i - 1] == 'B' && S[i] == 'C')
        {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
    }
    for(int i=0;i<n;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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>;
using vv = vector<vector<ll>>;
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;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    string s; cin >> s;
    for(int i=0;i<s.size();i++){
	if(s[i]=='?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3752
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
nums = get_nums_l()

check = [False] * n
ans = 0

def need():
    for n in nums:
        if n > 0:
            return True
    return False

while need():
    left = -1
    right = -1
    for i,x in enumerate(nums):
        if x != 0:
            left = i
            break
    
    min_ = nums[left]
    prev = left
    for i in range(left+1, n):
        if nums[i] > 0:
            min_ = min(min_, nums[i])
            prev = i
        else:
            break
    right = prev

    for i in range(left, right+1):
        nums[i] -= min_
    ans += min_

    
print(ans)

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

int gcd(int x, int y) {
    int temp;
    if (x < y) {
        temp = x;
        x = y;
        y = temp;
    }
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;

    return 0;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 100000;
    for(int i = 0; i < n; i++) {
        int counter = 0;
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            counter++;
        }
        ans = min(ans,counter);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
// // // // // // // // // // // // // // // // // // //


int q, n;
int main(){
    int64 n,k;
    cin >> n >> k;
    n = n % k;
    int64 n2 = abs(n - k);
    cout << min(n,n2);
    return 0;
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/
#[allow(unused_macros)]
macro_rules! input {
	(source = $s:expr, $($r:tt)*) => {
		let mut iter = $s.split_whitespace();
		let mut next = || { iter.next().unwrap() }; 
		input_inner!{next, $($r)*}
	};
	($($r:tt)*) => {

		let stdin = std::io::stdin();
		let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); 
		let mut next = move || -> String{
			bytes
				.by_ref()
				.map(|r|r.unwrap() as char) 
				.skip_while(|c|c.is_whitespace()) 
				.take_while(|c|!c.is_whitespace()) 
				.collect()
			};
	input_inner!{next, $($r)*} 
	};
}

#[allow(unused_macros)]
macro_rules! input_inner { 
	($next:expr) => {}; 
	($next:expr, ) => {};

	($next:expr, $var:ident : $t:tt $($r:tt)*) => { 
		let $var = read_value!($next, $t); 
		input_inner!{$next $($r)*}
	}; 
}
#[allow(unused_macros)]
macro_rules! read_value { 
	($next:expr, ( $($t:tt),* )) => {
		( $(read_value!($next, $t)),* ) 
	};
	
	($next:expr, [ $t:tt ; $len:expr ]) => {
		(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
	};

	($next:expr, chars) => {
		read_value!($next, String).chars().collect::<Vec<char>>()
	};
	
	($next:expr, bytes) => {
		read_value!($next, String).into_bytes()
	};
	
	($next:expr, usize1) => { 
		read_value!($next, usize) - 1
	};

	($next:expr, $t:ty) => {
		$next().parse::<$t>().expect("Parse error")
	};
}

fn main(){
    input!{
        n : i64,
        m : usize,
        x : i64,
        a : [i64; m],
    }
    let mut count1 : i64 = 0;
    let mut count2 : i64 = 0;
    for i in 0..m {
        if a[i] < x {
            count1 = count1 + 1;
        } else {
            count2 = count2 + 1;
        }
    }
    if count1 < count2 {
        println!("{}",count1);
    } else {
        println!("{}",count2);
    }
}

Measured memory_bytes: 4352
# ABC103 D-Islands War

N, M = map(int, input().split())
ab = []
for i in range(M):
    ab.append(list(map(int, input().split())))
    
ab = sorted(ab, key=lambda x:x[1])
ans = 0
lastremoved = 0

for i, j in enumerate(ab):
    if i == 0:
        ans += 1
        temp = j[1] - 1
    else:
        if j[0] <= temp:
            continue
        else:
            ans += 1
            temp = j[1] - 1
            
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct enemy { ll x; ll h; };

int main() {
  int N, D, A; cin >> N >> D >> A;
  enemy e[N]; rep(i,N) { ll tx, th; cin >> tx >> th; th = (th+A-1)/A; e[i] = {tx,th}; }
  sort(e,e+N,[](const enemy &x, const enemy &y){return x.x<y.x;});

  map<ll, ll> b; b[-1*LLINF] = 0;
  ll result = 0;
  rep(i,N) {
    auto lp = b.lower_bound(e[i].x-D*2); lp--;
    ll damage = result-lp->second;
    if (damage>=e[i].h) continue;
    else {
      b[e[i].x] = result + e[i].h - damage;
      result += e[i].h - damage;
    }
  }
  cout << result << endl;
  // for (auto x: b) cout << x.first << " " << x.second << endl;
  return 0;
}

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

using namespace std;

int main()
{  
  int N, K;
  cin >> N >> K;
  int sum = 0;

  for(int i = 0; i < N; i++)
  {
      int h;
      cin >> h;
      if(K <= h)
      {
          sum++;
      }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 384
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=1e6+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,k,a[N];

bool F(ll cur)
{
    ll cnt=0;
    vector<ll> v;
    for(ll i=0;i<n;i++)
    {
        ll div=a[i]%cur;
        v.pb(div);
    }
    sort(all(v));
    ll low=0,high=v.size()-1;
    while(low<high)
    {
        ll moves=min(v[low],cur-v[high]);
        v[low]-=moves;
        v[high]+=moves;
        cnt+=moves;
        if(v[low]==0){low++;}
        if(v[high]==cur){high--;}
    }
    return cnt<=k;
}

int main()
{
    cin>>n>>k;
    ll maxi=0,sum=0;
    for(ll i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    for(ll i=1;i<=sqrt(sum)+1;i++)
    {
        if(sum%i){continue;}
        ll pos=F(i);
        ll qpos=F(sum/i);
        if(pos){maxi=max(maxi,i);}
        if(qpos){maxi=max(maxi,sum/i);}

    }
    cout<<maxi<<endl;
}

Measured memory_bytes: 256
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define int long long
const int N=300010,Mod=1e9+7;
LL n,m,x,tot;
LL nums[N],n2[N];
int vis[N];
signed main(){
    IOS;
    /* START CODE */
    cin>>n>>x>>m;
    int l,r;
    for(int i=1;;++i){
        if(vis[x]) {
            l=vis[x],r=i-1;
            break;
        }
        nums[++tot]=x;
        vis[x]=i;
        x=x*x%m;
       // cout<<x<<endl;
    }
    for(int i=1,j=l;j<=r;++j,++i){
        n2[i]=nums[j];
    }
    for(int i=1;i<=tot;++i) nums[i]+=nums[i-1];
    LL sum=nums[l-1];

    int len=r-l+1;
    n-=l-1;
    for(int i=1;i<=len;++i) n2[i]+=n2[i-1];
    //cout<<sum<<endl;
    sum=sum+n/len*n2[len]+n2[n%len];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4704
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

# 何回で1ループするか
i = 0
done_dict = {i: -1 for i in range(N)}

route_list = []
route_len = 0
step = 1
while True:
    route_len += 1
    done_dict[i] = step
    route_list.append(i)
    next_i = a_list[i] - 1

    if done_dict[next_i] != -1:
        loop_end_i = i
        loop_start_i = next_i
        # print("loop_end_i: " + str(loop_end_i))
        # print("loop_start_i: " + str(loop_start_i))

        first_route_step = step
        # ループのステップ数
        # print("{} -> {}".format(done_dict[loop_start_i], done_dict[loop_end_i]))
        loop_len = done_dict[loop_end_i] - done_dict[loop_start_i] + 1
        # print("loop_len:" + str(loop_len))
        # print(route_list)
        break
    step += 1
    i = next_i

if K < first_route_step:
    ans = route_list[K] + 1
else:
    k = K - first_route_step
    k = k % loop_len
    ans = route_list[done_dict[loop_start_i] - 1 + k] + 1


print(ans)


Measured memory_bytes: 124980
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)


Measured memory_bytes: 7076
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[10];
  for(int i=0;i<10;i++){
    cin>>a[i];
  }
  sort(a,a+10);
  for(int i=9;i>6;i--){
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,j,a,b,c,d,x,y,z;
int main(){
  cin>>a>>b>>c>>d;a--;
  x=b/c;
  y=b/d;
  z=b/(c/__gcd(c,d)*d);
  n=x+y-z;
  x=a/c;
  y=a/d;
  z=a/(c/__gcd(c,d)*d);
  m=x+y-z;
  cout<<b-a-n+m;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    b = list(map(int, input().split()))
    ans = []
    for i in range(N):
        pos = 0
        for j in range(N-i):
            tmp = j+1 - b[j]
            if tmp < 0:
                print(-1)
                exit()
            elif tmp == 0:
                pos = j
        ans.append(b.pop(pos))
    for a in ans[::-1]:
        print(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int PI = acos(-1);

int main()
{
    int n;
    while(cin >> n && n + 1)
    {
        double z = sqrt(n), a = 0;
        
        REP(i, 1, n)
            a += atan2(1, sqrt(i));
        
        cout << z * cos(a) << endl << z * sin(a) << endl;
    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

const int sz = 5005;
ll dp[sz][sz];
bool used[sz];

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

	ll n, a, b;cin >> n >> a >> b;
	vector<ll> v(n);
	REP(i, n)cin >> v[i],v[i]--;

	REP(i, sz)REP(j, sz)dp[i][j] = LLINF;
	dp[0][0] = 0;

	REP(i, n+1){
		if(i > 0)used[v[i-1]] = true;
		REP(j, n+1){
			if(used[j])dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
			else dp[i][j+1] = min(dp[i][j+1], dp[i][j] + b);
			if(v[i] == j)dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]);
			if(v[i] < j)dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			else dp[i+1][j] = min(dp[i+1][j], dp[i][j] + a);
		}
	}

	cout << dp[n][n] << endl;

	return 0;
}


Measured memory_bytes: 195968
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
snk = a[0]
ans = abs(total - 2*snk)
for i in range(1,n-1):
    snk += a[i]
    if ans > abs(total - 2*snk):
        ans = abs(total - 2*snk)
print(ans)

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < N;i++)
#define INF 0x3f3f3f3f

int v[105],w[105];
int dp[2][10005];


int main(){
    int N,W;
    scanf("%d %d",&N,&W);
    memset(dp,0,sizeof(dp));

    _for(i,1,N+1){
        scanf("%d %d",&v[i],&w[i]);
    }

    _for(i,1,N+1){
        _for(j,0,W+1){
            int num1 = dp[(i-1)%2][j];
            int num2 = -1;
            if(j - w[i] >= 0){
                num2 = dp[i%2][j-w[i]] + v[i];
            }
            dp[i%2][j] = max(num1,num2);
        }
    }

    printf("%d\n",dp[N%2][W]);
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int T,t,x,y,sum=0,flag=0,st=0;
	 cin>>T;
	 while(T--)
	 {
	 	 cin>>t>>x>>y;
	 	   if(flag)continue;
	 	  int pt=t-st;
	 	 if(pt-abs(x+y-sum)<0||(pt-abs(x+y-sum))%2==1)
	 	  flag=1;
	 	st=t;
	 	  sum=x+y; 
	  } 
	  if(flag)printf("No\n");
	  else printf("Yes\n");
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<long long> kumi, sum(N + 1, 0);
    for(int i = 1; i < N + 1; i++){
        sum[i] = sum[i - 1] + a[i - 1]; 
    }
    for(int i = 1; i < N + 1; i++){
        for(int j = 0; j < i; j++) kumi.push_back(sum[i] - sum[j]);
    }
    long long ans = 0;
    long long u = 39, b = 2;
    long long temp = 1;
    while(u > 0){
        if(u & 1) temp *= b;
        b *= b;
        u >>= 1;
    }
    for(int k = 0; k < 40; k++){
        long long res = ans + temp;
        int cnt = 0;
        for(int i = 0; i < kumi.size(); i++){
            if((res & kumi[i]) == res) cnt++;
        }
        if(cnt >= K) ans += temp;
        temp /= 2;
    }
    cout << ans << endl;
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  if(n%2 == 0){
    cout << fixed << setprecision(10);
  	cout << 0.50000000000 << endl;
  }
  else{
  	cout << fixed << setprecision(10);
  	cout << (double)(n+1)/n/2 << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

class Dice
    def initialize(top, s, e, w, n, bottom)
        @top    = top
        @s      = s
        @e      = e
        @w      = w
        @n      = n
        @bottom = bottom
	end

	def top
		@top
	end

	def rotate!(dist)
		@top, @s, @e, @w, @n, @bottom = 
		case dist
		when 'N' then [@s, @bottom, @e, @w, @top, @n]
		when 'S' then [@n, @top, @e, @w, @bottom, @s]
		when 'E' then [@w, @s, @top, @bottom, @n, @e]
		when 'W' then [@e, @s, @bottom, @top, @n, @w]
		end
	end
end

if __FILE__ == $0 then
	dice = Dice.new(*gets.split.map(&:to_i))
	gets.chomp.each_char do |c|
		dice.rotate!(c)
	end
	p dice.top
end



Measured memory_bytes: 8904
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Either
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  s <- getI
  putStrLn . show $ buf s (M.singleton s True) 2

buf s mp cnt
    | even s = do
        let a = s `div` 2
            f = M.lookup a mp
        if isNothing f then buf a (M.insert a True mp) (cnt+1)
        else cnt
    | True = do
        let a = 3 * s + 1
            f = M.lookup a mp
        if isNothing f then buf a (M.insert a True mp) (cnt+1)
        else cnt
      


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

int main() {
    int S;
    cin >> S;
    int L = S/100;
    int R = S%100;
    if (1<=L && L<=12) {
        if (1<=R && R<=12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1<=R && R<=12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(){
  int n,q,i,j,k;
  int left,right,mid,cnt;
  int s[100000],t[50000];

  cnt = 0;
  //this is binary search function here
   scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&q);
  for(j=0;j < q;j++){
    scanf("%d",&t[j]);
  }
    
  for(k=0;k < q;k++){
    left = 0; right = n;
    while( left < right){
      mid = (left + right) / 2;
      if (s[mid] == t[k]){
	cnt++;
	break;
      } else if (s[mid] > t[k]){
	right = mid;
      } else {
	left = mid + 1;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}




Measured memory_bytes: 2292
from collections import Counter
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.par=[i for i in range(n)]
        self.size=[1]*n
    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.size[x]>=self.size[y]:
            self.par[y]=x
            self.size[x]+=self.size[y]
        else:
            self.par[x]=y
            self.size[y]+=self.size[x]
n,k,l=map(int,input().split())
uf1=UnionFind(n)
uf2=UnionFind(n)
for _ in range(k):
    u,v=map(int,input().split())
    uf1.unite(u-1,v-1)
for _ in range(l):
    u,v=map(int,input().split())
    uf2.unite(u-1,v-1)
cc=Counter()
for i in range(n):
    cc[(uf1.find(i),uf2.find(i))]+=1
ans=[cc[(uf1.find(i),uf2.find(i))] for i in range(n)]
print(*ans)
    


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

int main() {
	
	int n;
	cin >> n;
	vector<int> vc;
	for (int i=1; i<=n; i++) vc.push_back(i);
	
	map<vector<int>, int> pe;
	
	int nu = 1;
	do {
		pe[vc] = nu;
		nu++;
	} while (next_permutation(vc.begin(), vc.end()));
	
	vector<int> a(n);
	for (int i=0; i<n; i++) cin >> a[i];
	vector<int> b(n);
	for (int i=0; i<n; i++) cin >> b[i];
	
	cout << abs(pe[b] - pe[a]) << endl;
	
}


Measured memory_bytes: 5248
#include <iostream>

using namespace std;

int main(){
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	if(((a - a % k + k) <= b) || ((b - b % k) >= a)){
		cout << "OK"; 
	}
	else{
		cout << "NG";
	}
	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3))
    cout << "Bad" <<endl;
  else cout<<"Good" <<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
v=[int(i) for i in input().split()]

idou=min(n,k)
ans=0

for i in range(idou):
    for j in range(n,n-idou+i,-1):

        A=v[:i+1]
        B=v[j:]
        C=[0 for i in range(k)]
        C+=A+B
        C.sort()
        C=[C[i] for i in range(k-len(A)-len(B))if 0>C[i]]

        #print(A,B,C)

        ans=max(sum(A)+sum(B)-sum(C),ans)

ans=max(sum(v[n-k:]),ans)


print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rt return
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#include <iomanip>
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    double x,y;
    cin>>x>>y;
    cout<<fixed<<setprecision(10)<<x/y<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<vector<pll>> edge;
vector<ll> ans;

void dfs(ll w,ll p,ll c){
    ans[w]=c;
    for(auto &I:edge[w]){
        if(I.F!=p){
            dfs(I.F,w,c^(I.S&1));
        }
    }
}

int main(){
    cin>>n;
    edge.resize(n);
    ans.resize(n);
    for(int i=1;i<n;i++){
        ll u,v,w;
        cin>>u>>v>>w;
        u--; v--;
        edge[u].push_back({v,w});
        edge[v].push_back({u,w});
    }
    dfs(0,-1,0);
    for(auto &I:ans){
        cout<<I<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
using namespace std;
int main(){
    int a, b, c, x;
    int cnt = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; ++j){
            for ( int k = 0; k <= c; ++k){
                int total = 500*i + 100*j + 50*k;
                if (total == x){
                    ++cnt;
                }
                // cout << i << j << k << endl;
            }
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S, T := sc.nextRuneSlice(), sc.nextRuneSlice()
	ok := true
	sTot := make(map[rune]rune)
	tTos := make(map[rune]rune)
	for i := 0; i < len(S); i++ {
		if sTot[S[i]] == 0 {
			sTot[S[i]] = T[i]
		}
		if tTos[T[i]] == 0 {
			tTos[T[i]] = S[i]
		}
		if sTot[S[i]] != T[i] || tTos[T[i]] != S[i] {
			ok = false
			break
		}
	}

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 3200
/******tech_knight18_@11******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld x,y,d; cin>>x>>y>>d;
          lld ans=y/d-x/d;
          if(x%d==0)  ans++;
          cout<<ans<<nl;
      }
}


Measured memory_bytes: 3648
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let (n,k) = read!(usize, i32);
	let h = read!([i32]);
	println!("{}", h.into_iter().filter(|&x| x>=k).count());
}

fn run() {
    solve();
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)


const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

struct segment_tree{

    vector<ull>tree;
    int size;
    ll DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<ull>(2*size,0);
    }

    ull merge(ull a,ull b){return a|b;}
    bool search(ull x,int l,int r){
        int m=(l+r)/2;
        if(size<=l || size<=r || l>r) return false;
        if(tree[m]==x)
            return true;
        else if(tree[m]>x)
            return search(x,l,m);
        else
            return search(x,m,r);
    }
    bool search(ull x){
        return search(x,0,size);
    }
    void set(int i,int x,ull v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,ull v){
        set(i,0,v,0,size);
    }
    ull sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    ull sum(int l,int r){
        return sum(l,r,0,0,size);
    }
    void print(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};


ll gcd(ll a,ll b){ return (a%b==0? b: gcd(b,a%b)) ;}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}


void solve();
int main(){
    FAST;
    int t=1;
    //   cin >> t;
    while(t--)
        solve();
    return 0;
}
list<char>ans;
vector<bool>vis;
bool ok;
void dfs(int src,vector<vector<char>>adj){
    vis[src]=true;
    for(char nbr:adj[src-'a']){
        if(!vis[nbr])
            dfs(nbr,adj);
        else
            ok=false;
    }
    ans.push_back(src);
}
void solve(){
    int b,g,r,k;
    cin >> r >> g >> b >> k;

    while(k && g<=r) {
        g *= 2;
        k--;
    }
    while(k && b<=g) {
        b*=2;
        k--;
    }
    if(b>g && g>r) out("Yes")
    else out("No")
}

Measured memory_bytes: 3540
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = int(input())
    i = int(s**0.5)
    while i*i < s:
        i+= 1
    r = i*i-s
    ans = [0, 0, i, r, 1, i]
    print(*ans)
        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9420
#include <iostream>


using namespace std;


int main()
{
    int a ,b, temp, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if( a==0 && b==0 )
            break;
            
        if(a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << endl;
    }
}




Measured memory_bytes: 3028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

int main()
{
	LL x, y;
	cin >> x >> y;
	LL ans = 0;
	if (x == 1 && y == 1) {
		ans += 400000;
	}
	if (x <= 3) {
		ans += 400000 - x*100000;
	}
	if (y <= 3) {
		ans += 400000 - y*100000;
	}
	cout << ans << endl;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n-k){
    if(a[i]<a[i+k]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}



Measured memory_bytes: 4044
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    S = 0
    for a in A:
        S ^= a
    B = [0 for _ in range(N)]
    for i in range(N):
        B[i] = S ^ A[i]
    print(*B)


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 32952
class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def main():
  N,Q=map(int,input().split())
  uf = UnionFind(N)
  for i in range(Q):
    t,u,v=map(int,input().split())
    if t:
      print(+(uf.same(u,v)))
    else:
      uf.unite(u,v)
      
if __name__=="__main__":
  main()

Measured memory_bytes: 81908
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e5 + 5
#if !testing
	#define cerr if(0)cout
#endif
// minimum independent set kinda i guess
int n,m;
vector <int> V[MAXN];
bool visited[MAXN];

void dfs(int x) {
	visited[x] = 1;
	for (auto v : V[x]) if (!visited[v]) dfs(v);
}

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	cin >> n >> m;
	FOR(i,1,m) {
		int a,b,c; cin >> a >> b >> c;
		V[a].pb(b);
		V[b].pb(a);
	}
	int ans = 0;
	FOR(i,1,n) {
		if (!visited[i]) {++ans;dfs(i);}
	}
	cout << ans;
		
}


Measured memory_bytes: 8960