akhauriyash/Code-Regression huggingface dataset:
fn solve() {
    let stdin = std::io::stdin();
    let mut scn = Scanner {
        stdin: stdin.lock(),
    };
    let n: i64 = scn.read();
    let mut m = 1;
    let mut divs = vec![];
    while m * m <= n {
        if n % m == 0 {
            divs.push(m);
            divs.push(n / m);
        }
        m += 1;
    }
    if n > 0 {
        divs.push(n);
    }
    divs.sort();
    divs.dedup();
    let mut result = 0;
    for &q in divs.iter() {
        //m = n / q - 1
        let m = n / q - 1;
        if m == 0 {
            continue;
        }
        if n / m == n % m {
            result += m;
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

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

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
import numpy as np
import sys
input = sys.stdin.readline

_n, _k = map(int, input().split())
alist = [int(item) for item in input().split()]
flist = [int(item) for item in input().split()]


def chker(costs, diffs, max_k):
	costs = np.sort(costs)[::-1]
	diffs = np.sort(diffs)
	
	_min, _max = 0, 10 ** 12
	while _min < _max:
		_mid = (_min + _max) // 2
		cnt = costs - _mid // diffs
		if cnt[cnt > 0].sum() <= max_k:
			_max = _mid
		else:
			_min = _mid + 1


	print(_min)


chker(alist, flist, _k)


Measured memory_bytes: 43540
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using Edge = tuple<int, int>;
vector<vector<Edge>> G;
vi memo;

bool dfs(int v, int d){
    if(memo[v] != -1) return memo[v] == d;
    memo[v] = d;

    bool ret = true;
    for(auto& e : G[v]){
        int nv, dd; tie(nv, dd) = e;
        int nd = d + dd;
        ret &= dfs(nv, nd);
        if(not ret) break;
    }

    return ret;
}

int main(void){
    int n, m; cin >> n >> m;
    G = vector<vector<Edge>>(n);

    vi root(n, true);
    rep(loop, m){
        int l, r, d; cin >> l >> r >> d;
        l--, r--;
        G[l].emplace_back(Edge(r, d));
        root[r] = false;
    }

    memo = vi(n, -1);
    bool res = true;
    rep(v, n){
        if(not root[v]) continue;
        res &= dfs(v, 0);
        if(not res) break;
    }
    rep(v, n) if(memo[v] == -1) res = false;

    cout << (res ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int[] b = new int[4];

		b[0] = a/1000;
		b[1] = (a/100)%10;
		b[2] = (a/10)%10;
		b[3] = a%10;

		int TH = b[0]*10 + b[1];
		int TO = b[2]*10 + b[3];

		if(TH > 12) {
			if(TO > 12) System.out.print("NA");
			else if(TO <=12) {
				if(TO==0) {System.out.print("NA");
				System.exit(0);}
				System.out.print("YYMM");}

		}

		else if(TH <=12) {

			if(TH==0) {

			if(TO > 12) System.out.print("NA");
			else if(TO<=12 && TO>0)  System.out.print("YYMM");
			else if(TO==0) System.out.print("NA");
			}

			else {
				if(TO > 12) System.out.print("MMYY");
				else if(TO<=12 && TO>0) System.out.print("AMBIGUOUS");
				else if(TO==0) System.out.print("MMYY");
			}
		}
	}

}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll x;
    cin>>x;
    ll ans=1;
    rep2(i,1,35){
        ll a=i;
        rep(j,13){
            a*=i;
            // cout<<a<<endl;
            if(a<=x) chmax(ans,a);
            else break;
        }
    }
    cout<<ans<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

const int MAX = 300;
const int INF = 1073741823;
int main() {
	int N;
	static int A[MAX][MAX], load[MAX][MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) {
		for (int j = 0;j < N;j ++) {
			cin >> A[i][j];
			load[i][j] = A[i][j];
		}
	}
	for (int i = 0;i < N;i ++) {
		for (int j = 0;j < N;j ++) {
			for (int k = 0;k < N;k ++) {
				load[i][j] = min(load[i][j], load[i][k] + load[k][j]); // ワーシャルフロイド法
			}
		}
	}
	int64_t dist = 0;
	bool add;
	for (int i = 0;i < N;i ++) {
		for (int j = 0;j < N;j ++) {
			if (i == j) continue;
			if (A[i][j] > load[i][j]) { // この時点でこんな経路が無いことが分かるよ
				cout << -1;
				return 0;
			}
			add = true;
			for (int k = 0;k < N;k ++) {
				if (i == k || j == k) continue;
				if (load[i][j] == load[i][k] + load[k][j]) add = false; // 要らない辺
			}
			if (add) dist += load[i][j];
		}
	}
	cout << dist / 2; // 同じ辺を行き帰りで2回数えているので
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、先に道を置いておこう
そして、最短経路問題として、つまりWarshall-Floyd法を用いて最短経路を確定させよう
後は元のと比較して、うっかり元経路より短くしてたら終了、-1
そうでなければ、必要な辺だけ数えていこう

次に、必要な辺とは何か考えよう
もしその辺が無くなるとコストが増えるなら、それは必要な辺だよね
逆にその辺が無くなってもコスト増えないなら、まぁそれはうん、いらねぇ
*/

Measured memory_bytes: 896
def max_heapify(a, i):
    heap_size = len(a)
    left = (i + 1) * 2 - 1
    right = left + 1
    if left < heap_size and a[left] > a[i]:
        largest = left
    else:
        largest = i
    if right < heap_size and a[right] > a[largest]:
        largest = right
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)


def build_max_heap(a):
    heap_size = len(a)
    for i in reversed(range(0, heap_size // 2)):
        max_heapify(a, i)


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    build_max_heap(a)
    for it in a:
        print(' {}'.format(it), end='')
    print()


if __name__ == '__main__':
    main()



Measured memory_bytes: 63700
from bisect import bisect_right

n = int(input())

l = [1]
i = 1
while 6 ** i <= 100000:
    l.append(6 ** i)
    i += 1
i = 1
while 9 ** i <= 100000:
    l.append(9 ** i)
    i += 1
l.sort()

dp = [float('inf')] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    for v in l:
        if v > i:
            break
        dp[i] = min(dp[i], dp[i-v] + 1)

print(dp[n])

Measured memory_bytes: 74740
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    set<int> st;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        st.emplace(a);
    }

    cout << (st.size() == n ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 9600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N;
    cin >> N;
    ll ans = N * (N - 1) / 2;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e2 + 5, mod = 1e9 + 7;

vector<pair<int, ll>> adj[N];
ll n, m, l;
pair<ll, ll> dis[N][N];

void dij(int src){
    dis[src][src] = {0, l};
    /// cost, m3aya, node
    priority_queue< pair< pair<ll, ll>, int>  > pq;

    pq.push({{0, l}, src});
    while(pq.size()){
        int node = pq.top().second;
        ll m3aya = pq.top().first.second;
        ll cost = -pq.top().first.first;
        pq.pop();
        if(dis[src][node] != make_pair(cost, m3aya)) continue;
        for(auto i: adj[node]){
            ll new_dis = dis[src][node].first + (m3aya < i.second);
            ll new_m3aya = m3aya >= i.second ? m3aya - i.second : l - i.second;
            pair<ll, ll> p = {new_dis, new_m3aya};
            if(new_dis < dis[src][i.first].first){
                dis[src][i.first] = p;
                pq.push({{-new_dis, new_m3aya}, i.first});
            }
            else if(new_dis == dis[src][i.first].first && new_m3aya > dis[src][i.first].second){
                dis[src][i.first] = p;
                pq.push({{-new_dis, new_m3aya}, i.first});
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m >> l;
    for(int i = 0; i < m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        if(c > l) continue;
        adj[u].push_back({v, c});
        adj[v].push_back({u, c});
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            dis[i][j] = {1e18, 1e18};
        }
    }
    for(int i = 1; i <= n; i++){
        dij(i);
    }
    int q;
    cin >> q;
    while(q--){
        int u, v;
        cin >> u >> v;
        if(dis[u][v].first == 1e18) cout << -1;
        else cout << dis[u][v].first;
        cout << '\n';
    }

    return 0;
}


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

int main(){
  ll H, W;
  cin >> H >> W;
  vvc ss(H, vc(W));
  string s;
  rep(i, H){
    cin >> s;
    
    rep(j, W) ss[i][j] = s[j];
  }

  rep(i, H){
    rep(j, W){
      if(ss[i][j] == '.') continue;
      
      if((i > 0) && (ss[i - 1][j] == '#')) continue;
      if((i < H - 1) && (ss[i + 1][j] == '#')) continue;
      if((j > 0) && (ss[i][j - 1] == '#')) continue;
      if((j < W - 1) && (ss[i][j + 1] == '#')) continue;

      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX = 100;
typedef pair<int,int> ii;
int h,w,n,q,sx,sy,gx,gy;
char c[MAX][MAX];
int r[MAX],field[MAX][MAX];
bool visited[MAX][MAX];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

bool dfs(int x,int y){
  if( x == gx && y == gy ) return true;
  rep(i,4){
    int nx = x + dx[i], ny = y + dy[i];
    if( !( 0 <= nx && nx < w && 0 <= ny && ny < h ) ) continue;
    if( c[ny][nx] == '#' ) continue;
    if( !visited[ny][nx] ) {
      visited[ny][nx] = true;
      if( dfs(nx,ny) ) return true;
    }
  }
  return false;
}

void draw(int x,int y,int index){
  rep(i,h) rep(j,w) if( c[i][j] == '.' ) {
    if( index == n ) {
      if( abs(j-x) <= r[index-1] && abs(i-y) <= r[index-1] ) continue;
      ++field[i][j];
    } else {
      if( !( abs(j-x) <= r[index] && abs(i-y) <= r[index] ) ) continue;
      ++field[i][j];
    }
  }
  if( !index || index == n ) return;
    rep(i,h) rep(j,w) if( c[i][j] == '.' ) {
      if( !( abs(j-x) <= r[index-1] && abs(i-y) <= r[index-1] ) ) continue;
      --field[i][j];
  }
}

int main(){
  cin >> h >> w >> n >> q;
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) {
      c[i][j] = s[j];
      if( s[j] == 'D' ) { sx = j, sy = i; c[i][j] = '.'; }
    }
  }
  rep(i,n) cin >> r[i];
  rep(_,q){
    int x,y,s;
    cin >> x >> y >> s;
    draw(x,y,s);
  }
  /*
  rep(i,h) {
    rep(j,w){
      cout << field[i][j] << " ";
    } puts("");
  }
  */
  int cnt = 0;
  vector<ii> vec;
  rep(i,h) rep(j,w) if( field[i][j] == q ) { ++cnt; vec.push_back(ii(j,i)); }
  if( cnt == 0 ) puts("Broken");
  else {
    cnt = 0;
    rep(i,vec.size()){
      memset(visited,false,sizeof(visited));
      visited[sy][sx] = true;
      gx = vec[i].first, gy = vec[i].second;
      if( dfs(sx,sy) ) ++cnt;
    }
    if( cnt == vec.size() ) puts("Yes");
    else if( cnt == 0 ) puts("No");
    else puts("Unknown");
  }
  return 0;
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<ll>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    ll nc=x[n-1],r=-1;
    ll mid=nc/2;
    
    for(int i=0;i<n;i++){
        ll tmp1=x[i],tmp2=r;
        if(tmp1>mid)tmp1=nc-tmp1;
        if(tmp2>mid)tmp2=nc-tmp2;
        if(tmp1>tmp2)r=x[i];
    }
    cout<<nc<<" "<<r<<endl;
    return 0;
}

Measured memory_bytes: 3928
// Author: Harshdeep Sharma , IIT  Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();




ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	ll n  ;
	cin >> n  ;
	ll d ;
	cin >> d ;

	ll ans = 0 ;
	for (ll i = 0 ; i < n ; i++) {
		ll x  , y ;
		cin >> x >> y ;
		if (x * x + y * y <= d * d) {
			ans++ ;
		}
	}
	cout << ans << "\n";





	// }









	return 0 ;

}



Measured memory_bytes: 3660
n, m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(reverse=True, key=lambda x:x[1])
tmp = []
for B, C in bc:
    tmp += [C]*B
    if len(tmp) >= n:
        break

a.extend(tmp)
a.sort(reverse=True)

print(sum(a[:n]))

Measured memory_bytes: 36040
// OURL: https://atcoder.jp/contests/abc138/tasks/abc138_d
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

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

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

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

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  int n,q;
  cin >> n >> q;

  auto edge = make_v<int>(n, 0);
  REP(i,n-1) {
    int a, b;
    cin >> a >> b;
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
  }

  auto counter = make_v<int>(n);

  REP(i, q) {
    int p, x;
    cin >> p >> x;
    counter[p-1] += x;
  }

  queue<int> que;
  auto parent = make_v<int>(n);
  que.push(0);
  while(!que.empty()) {
    int x = que.front();
    que.pop();
    for (int p : edge[x]) {
      if (p != parent[x]) {
        que.push(p);
        parent[p] = x;
        counter[p] += counter[x];
      }
    }
  }
  REP(i, n) {
    cout << counter[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 16372
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0189 : Convenient Location **/
int d[10][10];
int E;


int main()
{
	int a, b, c, sum[10], minSum, minN;
	while (cin >> E, E!=0) {
		rep(i, 10) rep(j, 10) d[i][j]=INF;
		memset(sum, 0, sizeof(sum));
		minSum=INF;
		
		rep(i, E) {
			cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
		}
		
		rep(k, 10)
			rep(i, 10)
				rep(j, 10)
					d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
		
		rep(i, 10) {
			rep(j, 10) {
				if (d[i][j]<INF && i!=j)
					sum[i] += d[i][j];
			}
			if (minSum > sum[i]) {
				if (sum[i]<=0) continue;
				minSum = sum[i];
				minN = i;
			}
		}
		cout << minN << " " << minSum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(ceil(((double)a / d)) >= ceil(((double)c / b))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 3652
def li():
    return [int(x) for x in input().split()]

N = int(input())
A = li()

import math
from functools import reduce
from collections import defaultdict

# 最大公約数（リスト引数）
# 空のリストを渡さないよう注意
def GCD_list(numbers):
    return reduce(math.gcd, numbers)



# 数列全ての高速素因数分解
MAX = 10 ** 6
is_prime = [True] * (MAX + 1)
divs = [1] * (MAX + 1)
is_prime[0], is_prime[1] = False, False
i = 1
while i * i <= MAX:
    if not is_prime[i]:
        i += 1
        continue
    for j in range(2 * i, MAX + 1, i):
        is_prime[j] = False
        divs[j] = i
    i += 1

pairwise_coprime = True
all_primes = defaultdict(int)
for k in range(N):
    n = A[k]
    p = divs[n]
    primes = defaultdict(int)
    while p > 1:
        primes[p] += 1
        n = n // p
        p = divs[n]
    # 最後に残った数は1か素数にしかならない
    if n != 1:
        primes[n] += 1
    for key in primes:
        if all_primes[key] > 0 and primes[key] > 0:
            pairwise_coprime = False
            break
        all_primes[key] += primes[key]

gcd = GCD_list(A)
setwise_comprime = (gcd == 1)
if pairwise_coprime:
    print('pairwise coprime')
elif setwise_comprime:
    print('setwise coprime')
else:
    print('not coprime')

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

int main() {
  string  w;
  cin >> w;
 
  int s[30] ;
   for (int i = 0; i < 30; i++)
    s[i] = 0;
  
   
  
      for (int i = 0; i < w.size() ; i++) {
      
        s[w[i]-'a']++;
      }
        
      
  for (int i = 0; i < 30; i++){
    
       if (s[i] /2 != 0){
         cout << "no" <<endl;
   return 0;    }
  }
      cout << "yes" << endl;
         
    }

            
          
          
        

          
        
        


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	string str; cin >> str;
	bool ok = 1;
	for (int i = 0; i < sz(str); i++) {
		for (int j = 0; j < sz(str); j++) {
			if (i == j) continue;
			if (str[i] == str[j]) {
				ok = 0; break;
			}
		}
	}
	if (ok) cout << "yes";
	else cout << "no";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

#define INF 1e+9
#define MAX_V 100000

struct edge {
  int to;
  int cost;
  
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V+1];
int d[MAX_V+1],pre[MAX_V+1];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+MAX_V, INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for (int i=0; i<G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
	pre[e.to] = v;
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
	       
      }
              
    }
        
  }
  
}

int main(void){
  int n,m;
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    edge e1 = {b-1,1};
    edge e2 = {a-1,1};
    G[a-1].push_back(e1);
    G[b-1].push_back(e2);
  }
  rep(i,n){
    pre[i] = -1;
  }


  dijkstra(0);
  for(int i=0;i<n;i++){
    //    cout << d[i] << " ";
  }
  bool flag = true;
  for(int i=1;i<n;i++){
    if(pre[i] == -1){
      flag = false;
    }
  }

  if(flag){
    cout << "Yes" << endl;
    for(int i=1;i<n;i++){
      cout << pre[i]+1 << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 13492
STDIN.each_line do |line|
	a,b,c,d,e,f = line.split.map(&:to_f)
	x = (b*f-c*e)/(b*d-a*e)
	y = (c-a*x)/b
	puts sprintf("%.3f %.3f",x+0.0,y+0.0)
	# puts "#{sprintf("%.3f",x)} #{sprintf("%.3f",y)}"
end

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

int n;

void solve(char arr[], int cur, int done)
{
	if(cur == n)
	{
		for(int i=0; i<n; i++)
			cout << arr[i];
		cout << "\n";
		return;
	}

	for(int i=0; i<done+1; i++)
	{
		arr[cur] = i+'a';
		// cout << arr[cur] << i << endl;
		if(i == done)
		{
			solve(arr, cur+1, done+1);
		}
		else
		{
			solve(arr, cur+1, done);
		}
	}
}

int main()
{
	cin >> n;
	char arr[n];
	char alpha[26];
	for(int i=0; i<26; i++)
		alpha[i] = i+'a';
	set<char> done;
	solve(arr, 0, 0);
}

Measured memory_bytes: 1536
// comment
// #simulation

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

bool check_side(int x, int mx){
  if(x < 0)return true;
  if(x >= mx)return true;
  return false;
}

int main(void) {
  int n,m;
  cin>>n>>m;
  vector<vector<char> > v(n, vector<char>(m));
  vector<vector<int> > vi(n, vector<int>(m, 0));
  for(int i = 0 ; i < n ; i ++)
    for(int j = 0 ; j < m ; j ++){
      cin>>v[i][j];

      if(v[i][j] == '#'){
        for(int k = -1 ; k <= 1 ; k ++)
          for(int l = -1 ; l <= 1 ; l ++) {
            if (check_side(i + k, n) || check_side(j + l, m)) continue;
            vi[i + k][j + l] ++;
          }
      }
    }

  for(int i = 0 ; i < n ; i ++){
    for(int j = 0 ; j < m ; j ++){
      if(v[i][j] == '#') {
        cout<<'#';
      } else {
        cout<<vi[i][j];
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
ll n,a,d[3];
int main(int argc,char** argv) {

	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a;
		if(a % 4 == 0) {
			d[2]++;
		} else if(a % 2 == 0) {
			d[1]++;
		} else {
			d[0]++;
		}
	}
	if(d[1] != 0) d[0]++;
	if(d[0] > d[2] + 1) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char ch[100001];
    int flag1=0,tmp1=0;
    cin>>ch;
    for(int i=0;i<strlen(ch);i++){
        if(ch[i]=='C'){
            flag1=1,tmp1=i+1;
        }    
        if(ch[i]=='F'&&(i+1)>tmp1&&flag1==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;    
}

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

int main() {

	int a, b, ans = -1, ha, hb;

	cin >> a >> b;

	for (int i = 10; i < 1100; i++) {
		ha = i * 0.08;
		hb = i * 0.1;
		if (ha == a && hb == b) {
			ans = i;
			break;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
//Space: O(1) Time: O(n)
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
using namespace std;
int main(){
int n,a,b,c,A=0,B=0,C=0,tA=0,tB=0,tC=0;
cin>>n;
while (n--){
    cin>>a>>b>>c;
    A=a+max(tB,tC); B=b+max(tA,tC); C=c+max(tA,tB);
    tA=A; tB=B; tC=C;
}
cout<<max(max(A,B),C);
return 0;
}


Measured memory_bytes: 384
object Main extends App {
  val Array(h, w) = io.StdIn.readLine.split(" ").map(_.toInt)
  val ans = Array.fill(h+2)(Array.empty[Char].toBuffer)
  val line = Array.fill(w+2)('#')
  ans.head ++= line
  ans.tail.init.foreach(e => {
    e += '#'
    e ++= io.StdIn.readLine
    e += '#'
  })
  ans.last ++= line
  ans.foreach(a => println(a.mkString))
}

Measured memory_bytes: 28764
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500][500];
ll x[800005],y[800005],z[900005];

int main(){	
	cin>>n>>m;		
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=0;i<n-1;i++){
		if(x[i]+x[i+1]>m){
			ans += min(x[i]+x[i+1]-m,x[i+1]);
			x[i+1] -= min(x[i]+x[i+1]-m,x[i+1]);
		}
		if(x[i]+x[i+1]>m){
			ans += min(x[i]+x[i+1]-m,x[i]);
			x[i] -= min(x[i]+x[i+1]-m,x[i]);
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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;}
int main()
{
int n;
cin >> n;
vector<int> d(n);
rep(i,n) cin >> d[i];

int sum=0;
rep(i,n-1){
    for(int j = i+1; j < n; j++){
        sum += d[i]*d[j];
    }
}

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,M,L = map(int,input().split())
ABC = [tuple(map(int,input().split())) for i in range(M)]
Q = int(input())
ST = [tuple(map(int,input().split())) for i in range(Q)]

INF = 10**20
g = [[INF]*N for _ in range(N)]
for a,b,c in ABC:
    a,b = a-1,b-1
    g[a][b] = g[b][a] = c
for i in range(N):
    g[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if g[i][j] > g[i][k] + g[k][j]:
                g[i][j] = g[i][k] + g[k][j]

h = [[N]*N for _ in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        if g[i][j] <= L:
            h[i][j] = h[j][i] = 1
for i in range(N):
    h[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if h[i][j] > h[i][k] + h[k][j]:
                h[i][j] = h[i][k] + h[k][j]

ans = []
for s,t in ST:
    s,t = s-1,t-1
    if h[s][t] == N:
        ans.append(-1)
    else:
        ans.append(h[s][t] - 1)
print(*ans, sep='\n')

Measured memory_bytes: 96348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int N, res = 0;
    cin >> N;

    vector<int> A(N);
    vector<int> B(N);

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

    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += A[j];
        }
        for (int j = i; j < N; j++) {
            sum += B[j];
        }
        res = max(res, sum);
    }

    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N;
	cin>>N;
	int K;
	cin>>K;
	vector<int> h(N);
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	vector<int> min_h(N,0);
	for(int i=1;i<N;i++){
		long long mini = 1000000000000;
		for(int j=1;j<=K;j++){
			if(i-j<0)break;
			mini = min(mini,(long long)min_h[i-j]+abs(h[i]-h[i-j]));
		}
		min_h[i]=mini;
	}
	cout<<min_h[N-1]<<endl;
	return 0;
}


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

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& x : a)
		cin >> x;

	auto f = [&](ll t){
		for(auto& x : a)
			t -= t % x;
		return t;
	};
	auto g = [&](function<bool(ll)> h){
		ll st = 0, en = INF;
		while(en - st > 1){
			ll num = (st + en) / 2;
			(h(f(num)) ? en : st) = num;
		}
		return st;
	};
	ll mi = g([](ll x){return x >= 2;});
	ll ma = g([](ll x){return x > 2;});
	if(mi >= ma)
		cout << -1 << endl;
	else
		cout << mi + 1 << " " << ma << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;
#define MAX_N 200010
class UnionFind {
public:
	//UnionFind
	int par[MAX_N];
	int ufrank[MAX_N];
	int ufsize[MAX_N];
	UnionFind(int ufsize_of_tree) {
		for (int i = 0; i < ufsize_of_tree; i++)
		{
			par[i] = i;
			ufrank[i] = 0;
			ufsize[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (ufrank[x] < ufrank[y]) {
			par[x] = y;
			int sx = ufsize[x], sy = ufsize[y];
			ufsize[x] = ufsize[y] = sx + sy;
		}
		else {
			par[y] = x;
			if (ufrank[x] == ufrank[y]) ufrank[x]++;
			int sx = ufsize[x], sy = ufsize[y];
			ufsize[x] = ufsize[y] = sx + sy;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
//////////////////////////////////////////////////////////////////////
int main() {
	int n, k, l; cin >> n >> k >> l;
	vi cn(n,1);
	UnionFind Uni1(n);
	UnionFind Uni2(n);

	rep(k) {
		int p, q; cin >> p >> q; p--, q--;
		Uni1.unite(p, q);
	}
	rep(l) {
		int r, s; cin >> r >> s; r--, s--;
		Uni2.unite(r, s);
	}
	vp rt(n);
	map<pi,int> m;
	rep(n) {
		pi a = mp(Uni1.find(i), Uni2.find(i));
		m[mp(Uni1.find(i), Uni2.find(i))]++;
	}
	rep(n) {
		pi a = mp(Uni1.find(i), Uni2.find(i));
		cout << m[a] << " ";
	}

	return 0;
}

Measured memory_bytes: 21248
#include<stdio.h>
int main(){
  int a, b;
  scanf("%d %d",&a,&b);

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

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

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

  return 0;
}

Measured memory_bytes: 580
import math
import sys
sys.setrecursionlimit(10000)

X, Y = map(int, input().split())

if (X + Y) % 3 != 0:
    print(0)
else:
    N_r = int((2*X-Y) / 3)
    N_u = int((2*Y-X) / 3)

    if N_u < 0 or N_r < 0:
        print(0)
    elif N_u == 0 or N_r == 0:
        print(1)
    else:

        mod = 1000000007
        ans = 0

        def power(x, y):
            if   y == 0     :
                return 1
            elif y == 1     :
                return x % mod
            elif y % 2 == 0 :
                return power(x, y//2)**2 % mod
            else            :
                return power(x, y//2)**2 * x % mod

        def mul(a, b):
            return ((a % mod) * (b % mod)) % mod

        def div(a, b):
            return mul(a, power(b, mod-2))


        factorial = [1]
        for n in range(N_r + N_u-1):
            factorial.append(factorial[n]*(n+2)%mod)

        inverse_factorial = [0] * (N_u + N_r)
        inverse_factorial[-1] = power(factorial[-1], mod-2)

        for n in range(N_u+N_r-2, -1, -1):
            inverse_factorial[n] = (inverse_factorial[n+1] * (n+2)) % mod

        def combi(n, m):
            return factorial[n-1] * inverse_factorial[m-1] * inverse_factorial[n-m-1] % mod

        print(int(combi(N_u+N_r, N_u)))


Measured memory_bytes: 55856
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

class UF(size:Int) {
	private val a = IntArray(size) {-1}

	fun root(t:Int):Int = if(a[t]<0) t else root(a[t]).also {a[t] = it}

	fun isConnected(a:Int,b:Int) = root(a)==root(b)
	fun groupSize(t:Int) = -a[root(t)]

	fun connect(p:Int,q:Int):Boolean {
		val r = root(p)
		val s = root(q)
		if(r==s) return false
		if(a[r]>a[s]) {
			a[s] += a[r]
			a[r] = s
		} else {
			a[r] += a[s]
			a[s] = r
		}
		return true
	}
}

fun main() {
	abc000X()
}

fun abc000X() {
	val (n,m) = list()
	val uf = UF(n)
	for(i in 1..m) {
		val (a,b) = list().map {it-1}
		uf.connect(a,b)
	}
	println((0 until n).map {uf.groupSize(it)}.max()!!)
}


Measured memory_bytes: 61272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    ll n;
    cin >> n;
    ll x[200000];
    ll orig[200000];
    rep(i, n) {
        cin >> x[i];
        orig[i] = x[i];
    }
    sort(x, x + n, greater<ll>());
    ll midf = x[n/2 - 1];
    ll midb = x[n/2];
    rep(i, n) {
        if (orig[i] >= midf)
            cout << midb << endl;
        else
            cout << midf << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int remainder = in.nextInt()%1000;
		if (remainder == 0)
			System.out.println("0");
		else
			System.out.println(1000 - remainder);
	}
}



Measured memory_bytes: 35460
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

LL a, b, x;

LL yen(LL n) {
	LL keta = 0, n2 = n;
	while (n2 > 0) {
		n2 /= 10;
		keta++;
	}
	LL res = a * n + b * keta;
	return res;
}

template<typename T> inline T absdiff(T a, T b) { return (a - b) * (static_cast<T>(a > b) * 2 - 1); }

signed main() {	
	int x;
	cin >> x;

	int ans = 8 - (x - 400) / 200;
	col(ans);
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int answer,N,K;
  answer = 1;
  cin >> N >> K;
  
 for(int i=0;i<N;i++){
   if((answer+K) < (answer*2)){
     answer += K;
   }else{
     answer*=2;
   }
 }
  cout << answer << endl;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = list(map(lambda x:x-1, P))

ans = -float('inf')
for si in range(N):
    s = []
    tot = 0
    x = si
    while True:
        x = P[x]
        s.append(C[x])
        tot += C[x]
        if x==si:
            break
    l = len(s)
    now = 0
    t = 0
    for i in range(l):
        if i+1 > K: break
        t += s[i]
        now = t
        if tot >0:
            e = (K-(i+1))//l
            now += tot * e
        ans = max(ans, now)


print(ans)

Measured memory_bytes: 81016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, sum = 1, ans = 0;
  cin >> n;
  if(n == 1){ cout << 1 << endl; return 0; }
  long long a[n];
  for(int i=0; i<n; ++i) cin >> a[i];
  sort(a, a+n);
  for(int i=0; i<n; ++i){
    if(i < n && a[i] == a[i+1]){
      ++sum;
    }else{
      if(sum%2 != 0 || (i == n-1 && a[i-1] != a[i])) ++ans;
      sum = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4352