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

int f(int x) {
  int ans = 0;
  while(x % 2 == 0) {
    ans++;
    x /= 2;
  }
  return ans;
}

int g(int64_t x, int64_t y) {
  if(x > y) {
    return g(y, x);
  }
  else if(y % x == 0) {
    return x;
  }
  else {
    return g(y % x, x);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> b(N);
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    b.at(i) = a / 2;
  }
  vector<int> count(N);
  for(int i = 0; i < N; i++) {
    count.at(i) = f(b.at(i));
  }
  sort(count.begin(), count.end());
  if(count.at(0) != count.at(N - 1)) {
    cout << 0 << endl;
  }
  else {
    for(int i = 0; i < N; i++) {
      b.at(i) /= pow(2, count.at(i));
    }
    bool check = true;
    int64_t a = b.at(0);
    for(int i = 1; i < N; i++) {
      int m = g(a, b.at(i));
      a = a * b.at(i) / m;
      if(a > 1000000000) {
        check = false;
        break;
      }
    }
    if(!check) {
      cout << 0 << endl;
    }
    else {
      int x = a * pow(2, count.at(0));
      if((M / x) % 2 == 0) {
        cout << M / x / 2<< endl;
      }
      else {
        cout << M / x / 2 + 1 << endl;
      }
    }
  }
}

Measured memory_bytes: 1024
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
l = lmiinps()

ans = 0

if n < 3:
    print(0)
    exit()

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
                continue
            if l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
                ans += 1

print(ans)

Measured memory_bytes: 9112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long a = Long.parseLong(str[0]);
		long b = Long.parseLong(str[1]);
		long c = Long.parseLong(str[2]);

		int ans = 0;
		for (long i = a; i <= b; i++) {
			if (i % c == 0) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 32580
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, int d, int i, vector<Pii> &ans){
        if(d <= ans[v].second) return;
        if(ans[v].first == -1) ans[v] = Pii(i, d);
        if(d > ans[v].second) ans[v].second = d;
        if(d > 0){
            REP(k, G[v].size()) dfs(G[v][k].to, d - 1, i, ans);
        }
    }

};

signed main(){

    int N, M; cin >> N >> M;
    Graph G(N);
    int a, b;
    REP(i, M){
        cin >> a >> b;
        G.add_edge2(a - 1, b - 1, 1);
    }
    int Q; cin >> Q;
    vec v(Q), d(Q), c(Q);
    REP(i, Q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    vector<Pii> ans(N, Pii(-1, -1));
    IREP(i, Q) G.dfs(v[i], d[i], i, ans);
    REP(i, N){
        if(ans[i].first == -1) cout << 0 << endl;
        else cout << c[ans[i].first] << endl;
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int z=b-a;
   int zz=c-b ;
   if(z==zz)
   {
   	cout<<"YES"<<endl; 
   }
   else cout<<"NO"<<endl; 
   return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<queue>
using namespace std;

int a,b,cnt;
int* p;

struct P {
  int x,y;
};

int main () {
  while(cin>>a>>b,a|b){
    cnt=0;
    int d[a*b]={};p=d;int k;cin>>k;
    for(int i=0;i<k;++i){
      int x,y;cin>>x>>y;x--;y--;
      d[x+y*a]=1;
    }
    queue<P> q;q.push((P){0,0});
    while(!q.empty()){
      P e=q.front();q.pop();int x=e.x,y=e.y;
      if(x==a-1&&y==b-1){cnt++;continue;}
      if(x<a-1&&p[(x+1)+y*a]==0)q.push((P){x+1,y});
      if(y<b-1&&p[x+(y+1)*a]==0)q.push((P){x,y+1});
    }
    cout<<cnt<<endl;
  }
}

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

int main() {
  
  string S;
  cin >> S;
  
  int n = S.size();
  
  if(n==1) cout << S;
  else {
    
  int64_t A = 0;
  for (int tmp = 0; tmp < (1 << 10 ); tmp++) {
    bitset<10> p(tmp);
    if( p.test(n-1) ) {
      break;
    } else {
      string s;
      for ( int i=0; i<n; i++) {
        s += S.at(i);
        if(p.test(i) || i == n-1 ) {
          A += stoll(s);
          s = "";
        }
      }
    }
  }
  cout << A << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int a[10000000];
int n;

int solve(int i, int m)
{
	if(m == 0) return 1;
	if(i == n) return 0;
	
	return (solve(i+1, m) || solve(i+1, m - a[i]));
}

int main(void)
{
	int q, i;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	scanf("%d", &q);
	
	int b[q];
	
	for(i = 0; i < q; i++)
	{
		scanf("%d", &b[i]);
		if(solve(0, b[i]) == 1) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}


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

int N,ans;
char S[300][600];

int main(){
    cin>>N;
    rep(i,N)rep(j,N)cin>>S[i][j];
    rep(k,N){
        bool ok=1;
        rep(i,N)rep(j,N)if(S[i][(j+k)%N]!=S[j][(i+k)%N])ok=0;
        if(ok)ans+=N;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main() {
    string s, t;
    cin >> s >> t;
    
    int sc[26], tc[26];
    for (int i = 0; i < 26; i++) {
        sc[i] = tc[i] = 0;
    }
    for (char c : s) {
        sc[c-'a']++;
    }
    for (char c : t) {
        tc[c-'a']++;
    }
    sort(sc, sc+26);
    sort(tc, tc+26);
    
    bool f = true;
    for (int i = 0; i < 26; i++) {
        if (sc[i] != tc[i]) {
            f = false;
            break;
        }
    }
    
    cout << (f ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 776
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	var max, max2 int
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		arr[i] = x
		
		if x > max{
			max2 = max
			max = x
		}else if x > max2{
			max2 = x
		}
	}

	for _, x := range arr {
		if x == max{
			fmt.Println(max2)
		}else{
			fmt.Println(max)
		}
	}
	return
}


func maxInt(x, y int)int{
	if x > y{
		return x
	}
	return y
}

Measured memory_bytes: 6400
//2017-10-11
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (100000+5)

int a[N], ans[N];

int main(){
	int n, L, pos = -1;
	
	scanf("%d%d", &n, &L);
	For(i, 1, n){
		scanf("%d", &a[i]);		
		if(i > 1 && a[i] + a[i-1] >= L) pos = i-1;
	}

	if(pos == -1){
		puts("Impossible"); return 0;
	}

	puts("Possible");

	int an = 0;
	ans[++an] = pos;

	Forr(i, pos-1, 1) ans[++an] = i;
	For(i, pos+1, n-1) ans[++an] = i;
	
	Forr(i, an, 1) printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 1536
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let mut nn = vec![Vec::new(); 3];

    for _ in 0..n {
        let (a_i, b_i, c_i) = {
            let i = read::<usize>();
            (i[0], i[1], i[2])
        };
        nn[0].push(a_i);
        nn[1].push(b_i);
        nn[2].push(c_i);
    }

    // 0: A
    // 1: B
    // 2: C
    let mut dp = vec![vec![0; n]; 3];
    for i in 0..3 {
        dp[i][0] = nn[i][0];
    }

    for i in 1..n { for j in 0..3 {
        let mut prev = 0;
        for k in 0..3 {
            if k == j { continue; }
            prev = cmp::max(prev, dp[k][i - 1]);
        }
        dp[j][i] = prev + nn[j][i];
    }}

    println!("{}", cmp::max(
        dp[0][n - 1],
        cmp::max(dp[1][n - 1], dp[2][n - 1])
        )
    );
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 12540
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[100001], q, key, cnt = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key)) cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B;
  int temp, ans;
  cin >> A >> B;
  
  temp = B*2;
  ans = A-temp;
  if(ans <= 0){
    cout << 0;
  }
  else{
    cout << ans;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
int n;
int l;
array<string,1024> s;

bool ok(const string& st){
    auto ss = st;
    reverse(all(ss));
    return st == ss;
}

bool ok(string a, string b){
    reverse(all(b));
    return a == b;
}

vector<pair<string,string>> v;
array<bool,1024> used;

int main(){
    cin >> n;
    cin >> l;
    rep(i,n) cin >> s[i];
    rep(i,n) used[i] = false;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(ok(s[i],s[j]) and !used[i] and !used[j]){
                v.pb(mp(min(s[i],s[j]),max(s[i],s[j])));
                used[i] = used[j] = true;
            }
        }
    }

    sort(all(v));

    string ss = "";
    rep(i,n){
        if(!used[i] and ok(s[i])){
            if(ss=="") ss = s[i];
            else ss = min(ss,s[i]);
        }
    }

    string ans = ss;

    for(int i=v.size()-1;i>=0;i--){
        ans = v[i].fi + ans + v[i].se;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3244
# Selection Sort

n = int(input())
A = list(map(int, input().split()))

def selectionSort(A):
	n = len(A)
	cnt = 0
	for i in range(n - 1):
		minj = i
		for j in range(i, n):
			if A[j] < A[minj]: minj = j
		A[i], A[minj] = A[minj], A[i]
		if i != minj: cnt += 1
	return cnt

cnt = selectionSort(A)

print(*A)
print(cnt)



Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> H;
	int i;
	for (i = 0; i < N; i++) {
		long long h;
		cin >> h;
		H.push_back(h);
	}
	sort(H.begin(), H.end());
	long long ans = 10000000000;
	for (i = 0; i < N - K + 1; i++) {
		ans = min(H.at(i + K - 1) - H.at(i), ans);
	}
	cout << ans;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;


int n ;
int a[410];
int sum[410];
int dp[410][410];

int solve(int i , int j) {

    if (i == j)return 0;

    if (dp[i][j] != -1)return dp[i][j];

    int cost = INF;

    for (int k  = i ; k <= j - 1 ; k++) {
        cost = min(cost , sum[j] - sum[i - 1] + solve(i , k) + solve(k + 1 , j));
    }

    return dp[i][j] = cost;
}

int32_t main() {

    fastio
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    memset(dp , -1, sizeof(dp));
    cin >> n;
    for (int i = 1; i <= n ; i++)cin >> a[i];

    for (int i = 1; i <= n ; i++)sum[i] = sum[i - 1] + a[i];

    cout << solve(1, n) << '\n';

    return 0;
}


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

int main(){
  int n, t, a, ans;
  cin>>n>>t>>a;
  double h, dif = 100000;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (dif > abs(a-t+h*0.006)) {
      dif = abs(a-t+h*0.006);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>

using namespace std;
int main()
{
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long>> range(m);
  for (auto i = 0; i < m; i++) {
    long long b, e;
    cin >> b >> e;
    range[i] = make_pair(b, e);
  }

  sort(range.begin(), range.end());

  long long mine = n + 1;
  long long ret = 0;
  for (auto i = 0; i < m; i++) {
    if (mine <= range[i].first) {
      ret++;
      mine = range[i].second;
    } else mine = min(mine, range[i].second);
    while ((i+1) < m && range[i].first == range[i+1].first) {
      i++;
    }
  }

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


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

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        m[s]++;
    }
    int mx = 0;
    for(const auto& x : m){
        mx = max(mx, x.second);
    }
    for(auto itr = m.begin(); itr != m.end(); itr++){
        if(itr->second == mx){
            cout << itr->first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n; cin >> n;
  string s[n];
  int sumt[n];

  FOR(i,0,n-1){
    int t;
    cin >> s[i]; cin >> t;
    if(i==0) sumt[i] = t;
    else sumt[i] = sumt[i-1] + t;
  }

  string slept; cin >> slept;

  FOR(i,0,n-1){
    if(s[i]==slept){
      cout << sumt[n-1] - sumt[i] << endl;
      return 0;
    }
  }


}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

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

int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int factor2(int x){
    int ret = 0;
    while(x%2==0){
        x /= 2;
        ret++;
    }
    return ret;
}

signed main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    
    int l = 1;
    rep(i,N){
        cin >> a[i];
        a[i] /= 2;
        l = lcm(l,a[i]);
    }
    int f2 = factor2(l);
    rep(i,N){
        if(factor2(a[i])!=f2){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (int)ceil((M/l)/2.0) << endl;
}

Measured memory_bytes: 1024
n, d = map(int, input().split())
L = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        
        int_ = 0
        for k in range(d):
            int_ += (L[i][k]-L[j][k])**2
        if int(int_**0.5)==int_**0.5:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct pp
{
    int x,y,flag;
};
bool cmp(const pp&a,const pp&b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}
pp a[110],b[110];
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i].x>>a[i].y;
            a[i].flag=0;
        }
        for(int i=0;i<n;i++)
            cin>>b[i].x>>b[i].y;
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        int s=0;
        for(int i=0;i<n;i++)
        {
            int flag=0,p=-1;;
            for(int j=0;a[j].x<=b[i].x&&j<n;j++)
              if(a[j].x<b[i].x&&a[j].y<b[i].y&&!a[j].flag)
              {
                 if(!flag)
                    p=j;
                 else if(a[j].y>a[p].y)
                    p=j;
                 flag=1;
              }
            if(flag)
            {
                s++;
                a[p].flag=1;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void)
{
    ll n;
    ll s=0;
    cin>>n;
    vector <int> a(n),ans(n);
    rep(i,n)
    {
        cin>>a[i];
        s=s^a[i];
    }
    rep(i,n)
    {
        ans[i]=s^a[i];
        cout<<ans[i]<<" "<<endl;
    }
    return 0;
}


Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
  fastIO;
  int n;
  cin >> n;

  vector<int>H(n);
  rep(i, n) cin >> H.at(i);

  int cnt = 1;
  int maxH = H.at(0);

  for(size_t i=1; i<H.size(); ++i) {
    if(H.at(i) >= maxH) {
      cnt++;
    }
    maxH = max(maxH, H.at(i));
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3596
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

class DisjointSetUnion:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n

    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a

    def union(self, a, b):
        a, b = self.find(a), self.find(b)
        if a != b:
            if self.size[a] < self.size[b]:
                a, b = b, a

            self.num_sets -= 1
            self.parent[b] = a
            self.size[a] += self.size[b]

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets

def main():
    n,m=map(int,input().split())
    a=DisjointSetUnion(n)
    for _ in range(m):
        u,v=map(int,input().split())
        a.union(u-1,v-1)
    ans=0
    for i in range(n):
        ans=max(ans,a.set_size(i))

    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 87368
#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; cin >> k;

    queue<ll> q;
    for(ll i = 1; i <= 9; i++) q.push(i);
    rep(i, k-1){
        ll x = q.front(); q.pop();
        ll mod = x%10;
        if(mod != 0) q.push(10*x + mod - 1);
        q.push(10*x + mod);
        if(mod != 9) q.push(10*x + mod + 1);
    }
    cout << q.front() << endl;

    return 0;
}

Measured memory_bytes: 1792
n = int(input())+1
a = list(map(int, input().split()))
cnt = []
for i in range(100005):
    cnt.append(0)
sum = 0

# a.count(i)を使うとTLE
# count()がO(N)のためfor内で使用するとO(N2)になる？
for i in a:
    cnt[i] += 1
for i in range(100005):
    sum += i * cnt[i]

q = int(input())
ans = []
for i in range(q):
    b, c = map(int, input().split())
    sum += (c-b)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    ans.append(sum)

for i in ans:
    print(i)

Measured memory_bytes: 20608
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
const int N=110;
struct node{
	int x,y;
}r[N],b[N];
int match[N];
bool vis[N],flag[N][N];
int n;
bool find(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(!vis[i]&&flag[x][i]){
			vis[i]=1;
			if(match[i]==0||find(match[i]))
			{
				match[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>r[i].x>>r[i].y;
	for(int i=1;i<=n;i++) cin>>b[i].x>>b[i].y;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(r[i].x<b[j].x&&r[i].y<b[j].y)
			{
				flag[i][j]=1;
			}
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		if(find(i))
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 888
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    if (n >= 64) {
        println(64)
        return
    }
    for (i in 1..10) {
        val x = Math.pow(2.0, i.toDouble())
        val y = Math.pow(2.0, (i-1).toDouble())
        if (n < x) {
            println(y.toInt())
            return
        }
    }
}


Measured memory_bytes: 31704
N = gets.to_i
Ws = gets.split.map(&:to_i)

as = Ws.inject([0]){|ary, w| ary << ary.last + w }.drop(1)
s = as.last
i = as.bsearch_index{|a| a > s/2}
puts [(s - 2*as[i]).abs, (s - 2*as[i - 1]).abs].min

Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{
	int i,a,b,c,d,p,x,y;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	y=b;
	if(p>c){
		for(i=0;i<p-c;i++){
			y+=d;
		}
	}
//	printf("%d %d\n",x,y);
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}

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

using namespace std;


int d[10][10];

void warshall_floyd(){
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    int h, w;
    scanf("%d %d", &h, &w);
    int c[10][10];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &c[i][j]);
            d[i][j] = c[i][j];
        }
    }
    int a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("%d", &a[i][j]);
        }
    }
    warshall_floyd();
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if (a[i][j] != -1){
                ans += d[a[i][j]][1];
            }
        }
    }
    // for(int i = 0; i < 10; i++){
    //     for(int j = 0; j < 10; j++){
    //         printf("%d ", d[i][j]);
    //     }
    //     puts("");
    // }

    printf("%d\n", ans);
    
}

Measured memory_bytes: 632
// AA.cpp : Defines the entry point for the console application.
//


#include<iostream>
#include<string>
using namespace std;

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



Measured memory_bytes: 256
fun main() {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val numbers = mutableSetOf<Int>()
    (0 until k).map {
        val d = readLine()!!.toInt()
        val num = readLine()!!.split(" ").map(String::toInt)
        numbers.addAll(num)
    }

    println(n - numbers.size)
}

Measured memory_bytes: 39184
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,mod=1e9+7,inf=1e9+10;
int a[M];
int cnt[M];
main()
{
	int n,k;
	cin>>n>>k;
	int tmp1=10000;
	int tmp2=5000;
	for(int i=0;i<=n;i++)
	{
		for(int j=n-i;j>=0;j--)
		{
			if(i*tmp1+j*tmp2>k)continue;
			int res=k-(i*tmp1+j*tmp2);
			if(res%1000!=0)continue;
			if(((res)/1000)==(n-i-j))return cout<<i<<" "<<j<<" "<<n-i-j,0;
		}
	}	
	cout<<-1<<" "<<-1<<" "<<-1;
}

Measured memory_bytes: 256
#include <stack>
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstdio>
#include <map>
using namespace std;
map <string, int> table;
int Molecule(string s) {
	if (s.length() <= 0)return 0;
	if (s[0]=='('){
		int count = 1;
		int cnt = 0;
		while (++cnt) { if (s[cnt] == '(')count++; if (s[cnt] == ')')count--; 
		if (count == 0)break; }
		int now = cnt;
		int n = 0;
		while (++cnt<s.length()&&isdigit(s[cnt])) { n *= 10; n += s[cnt] - '0'; }
		if(cnt<s.length())
		return (Molecule(s.substr(1, now - 1))*n + Molecule(s.substr(cnt)));
		else return Molecule(s.substr(1, now - 1))*n;
	}
	else {
		string t = "";
		t += s[0]; int cnt = 1;
		if (islower(s[cnt])) { t += s[cnt]; cnt++; }
		if (table.find(t) == table.end())return -99999999;
		int n = 0;
		while (isdigit(s[cnt])) { n *= 10; n += s[cnt++] - '0'; }
		if(cnt<s.length())
		return table[t] * max(n,1) + Molecule(s.substr(cnt));
		else return table[t] * max(n,1);
	}
}
int main()
{

	string s; int n;
	while (cin >> s, s != "END_OF_FIRST_PART") {
		cin >> n; table[s] = n;
	}
	while (cin >> s, s != "0") {
		int tmp=Molecule(s);
		if (tmp <= 0)cout << "UNKNOWN" << endl;
		else cout << tmp << endl;
	}
 }

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;
	
	string s;
	cin >> s;

	int l = 0, r = n - 1;
	int ans = 0;
	while(l < r){
		while(s[l] == 'R') l++;
		while(s[r] == 'W') r--;
		if(l >= r) break;
		ans++;
		l++;
		r--;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2005;

int n, m;
string s[N];
int v[N][N], h[N][N];

int main()
{
  cin >> n >> m;
  for(int i = 0 ; i < n  ; i++)
    cin >> s[i];
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < m ; j++){
      if(s[i][j] == '#')
        continue;
      int k = j;
      while(k < m && s[i][k] == '.')
        k++;
      int cnt = k - j;
      for(int l = j ; l < k ; l++)
        v[i][l] = cnt;
      j = k - 1;
    }
  }
  for(int j = 0 ; j < m ; j++){
    for(int i = 0 ; i < n ; i++){
      if(s[i][j] == '#')
        continue;
      int k = i;
      while(k < n && s[k][j] == '.')
        k++;
      int cnt = k - i;
      for(int l = i ; l < k ; l++)
        h[l][j] = cnt;
      i = k - 1;
    }
  }
  int ans = 0;
  for(int i = 0 ; i < n ; i++)
    for(int j = 0 ; j < m ; j++)
      ans = max(ans, h[i][j] + v[i][j] - 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35712
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (x, y, z) = nextIntList()
    println("$z $x $y")


}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!

Measured memory_bytes: 37608
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();    /*文字列から文字を取り出す*/

            String answer = "";
            int length = line.length();
            for(int i=0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    answer += Character.toUpperCase(ch);
                }else{
                    answer += Character.toLowerCase(ch);
                }
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31404
#include<bits/stdc++.h>
using namespace std;
string s[200010];
int main()
{
	int n;
	cin>>n;
	int ans=n;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	sort(s,s+n+1);
	for(int i=1;i<=n;i++)
		if(s[i]==s[i-1])
			ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint p(n);
    rep(i, n) cin >> p[i];

    int mn = INF;
    int ans = 0;
    rep(i, n) {
        if (p[i] < mn) {
            ans++;
        }
        mn = min(mn, p[i]);
    }

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

Measured memory_bytes: 1024
#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>;

bool isPrime(ll n) {
  if (n <= 1) {
    return false;
  }
  for (ll p = 2; p * p <= n; ++p) {
    if (n % p == 0) {
      return false;
    }
  }
  return true;
}

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

  ll result = pow(10, 13);
  for (ll a = 1; a * a <= n; ++a) {
    if (n % a == 0) {
      result = min(result, (a + (n / a) - 2));
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
t = input()

ans = -1
for i in range(n + 1):
    b = s
    if i > 0:
        b += t[(-1) * i:]
    #print(b)
    if b[(-1) * n:] == t:
        ans = len(b)
        break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
int INF=pow(10,9);

mat d(110,vec(110,INF));
//頂点数
int N;

void warshall_floyd(){
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
    }
}

int main(){
    int M;cin>>N>>M;
    mat e(110,vec(110,INF));
    for(int i=1;i<=N;i++){
        d[i][i]=e[i][i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b,c;cin>>a>>b>>c;
        d[a][b]=d[b][a]=c;
        e[a][b]=e[b][a]=c;
    }
    warshall_floyd();
    int ans=0;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(e[i][j]!=INF && d[i][j]<e[i][j])
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long

using namespace std;
 main()
{
        int a,b,ans=0,i;
        cin>>a>>b;
        if(b==1)return cout<<0<<endl,0;
        for( i=0; ; i++){
           int cur=(i+1)*a-i;
            if(cur >= b){
                ans=i;
                break;
            }
        }
        cout<<ans+1<<endl;





    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
const int mx=10000001;
int dp[mx];
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
dp[1]=1;
for(int i=2;i<mx;i++)
{if(!dp[i])
    {
    for(int j=i;j<mx;j+=i)
    dp[j]=i;
    }
}
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{  map<int,int> mp;
  int x=i;
  while(x!=dp[x])
  {
      mp[dp[x]]+=1;
      x/=dp[x];
  }
  if(x!=1)
  mp[dp[x]]+=1;
    int res=1;
    map<int,int>::iterator it=mp.begin();
    for(;it!=mp.end();it++)
    {
         x=(it->second);
         x+=1;
        res*=x;
    }
    ////cout<<i<<" "<<res<<endl;
    ans+=i*res;
}

cout<<ans<<endl;











    return 0;
}


Measured memory_bytes: 81780
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0; i < n; i++){
        int b,c;
        cin >> b >> c;
        a[i] = make_pair(b + c,b - c);
    }
    sort(a.begin(),a.end());
    int ans = 0;
    int t = -1e9 - 1;
    for(int i = 0; i < n; i++){
        if(t <= a[i].second){
            ans++;
            t = a[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    cout << (x >= r && x <= w - r && y >= r && y <= h - r ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}


int main(){
	ll N,X; cin>>N>>X;
	ll res=N;
	ll a=max(N-X,X),b=min(N-X,X);

	while(b){
		ll q=a/b;
		ll r=a%b;

		res+=(b*2)*q;
		if(r==0) res-=b;
		a=b,b=r;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() {
    string s;
    cin >> s;
    int n = 0;
    n = s.size();
    int p2, p3, p4 = 0;
    p2 = (n - 1) / 2;
    p3 = (n + 3) / 2;
    p4 = n;
    // n番目以降の文字列をm文字だけ取り出す場合はsubstr(n, m) nは0スタート、mは1スタート。
    // if (s.substr(0, p2 / 2) == s.substr((p2 / 2) + 1, p2 / 2) && s.substr(p3 + 1, p2 / 2) == s.substr(((p4 - p3) / 2) + p3, p2 / 2)) {
    //     cout << "Yes" << endl;
    // }
    if (s.substr(0, p2) == s.substr(p2 + 1, p2)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

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

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int cnt = i * (m - j) + j * (n - i);
            if (cnt == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,a[100011];
bool cmp(int x,int y){return x%2>y%2;}
int main()
{
	get2(n,m);
	for(int i=1;i<=m;i++)get1(a[i]);
	if(m==1)
	{
		if(n==1)puts("1\n1\n1");
		else printf("%d\n2\n%d %d\n",n,1,n-1);
	}
	else
	{
		int cnt=0;for(int i=1;i<=m;i++)if(a[i]%2)cnt++;
		if(cnt>2){puts("Impossible");return false;}
		sort(a+1,a+m+1,cmp);swap(a[2],a[m]);
		for(int i=1;i<=m;i++)printf("%d ",a[i]);
		printf("\n%d\n",m-(a[1]==1));a[1]--;a[m]++;
		for(int i=1;i<=m;i++)if(a[i])printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk, mem;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    now = ans = nn;
    rep(i, m) {
        while('0' <= *pos) {
            mem <<= 1;
            mem += mem << 2;
            mem += *pos++ - '0';
        }
        pos++;
        k -= mem;
        mem = 0;
        if(k < 0) break;
        while(a[now] > k) --now;
        ans = max(ans, i + 1 + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7716
import java.util.*;
import java.io.*;
public class Main {

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while(st==null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        
        String nextLine()
        {
            String s = "";
            
            try
            {
                s = br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
            return s;
        }
    }
    
    public static void main(String[] args) throws java.lang.Exception
    {
        try
        {
            FastReader fr=new FastReader();
            
           String s=fr.nextLine();
            long sum=0;
           for(int i=0;i<s.length();i++) {
        	   sum+=Long.parseLong(String.valueOf(s.charAt(i)));
           }
            if(sum%9==0) {
            	System.out.println("Yes");
            }
            else {
            	System.out.println("No");
            }
            
            
        }
        catch(Exception e){}
        finally{}

	}

}


Measured memory_bytes: 45732
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val map = mutableMapOf<Int, Long>()
    println(a.mapIndexed { idx, v ->
        map[-v - idx] = map.getOrDefault(-v - idx, 0L) + 1
        map.getOrDefault(v - idx, 0L)
    }.sum())
}

Measured memory_bytes: 75324
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;
int calc(unordered_set<int >mp){
    
    int Mex=0;
    while(mp.find(Mex)!=mp.end()){
        Mex+=1;
    }
    return(Mex);
}
int main(){
    int n,k;
    cin >>n>>k;
    int arr[101];
    for(int i=0;i<n;i++) cin >> arr[i];
    int ans[100000+1];
    sort(arr,arr+n);
    for(int i=0;i<arr[0];i++) ans[i]=0;
    for(int i=arr[0];i<=k;i++){
        unordered_set<int >mp;
        for(int j=0;j<n;j++){
            if(i-arr[j]>=0){
                mp.insert(ans[i-arr[j]]);
            }
        }
        ans[i]=calc(mp);
    }
    if(ans[k]){
        cout <<"First"<<endl;
    }
    else{
        cout <<"Second"<<endl;
    }
}



Measured memory_bytes: 640