akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

const NINF: i64 = -1 * (1 << 60);

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      p: i64,
      abcs: [(usize1,usize1,i64); m],
    }

    // ベルマンフォード
    let mut dist = vec![NINF; n];
    dist[0] = 0;
    let mut ans = dist[n-1];
    for i in 0..(n*2) {
        for e in 0..m {
            let (a, b, c) = abcs[e];
            let c = c-p;
            if dist[a] != NINF && dist[b] < dist[a] + c {
                dist[b] = dist[a] + c;
            }
        }
        if i >= n {
            if ans != dist[n-1] {
                return puts!("{}\n", -1);
            }
        } else {
            ans = dist[n-1];
        }
    }
    puts!("{}\n", max(ans, 0));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
 map<int,bool> mp;
 int a,b;
 cin >> a >> b;

 mp[a] = true;
 mp[b] = true;

 for(int i = 1;i <= 3;i++)if(mp[i] == false)cout << i << endl;

} 

Measured memory_bytes: 256
import sys

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n = int(input())
if n == 1:
  print(0)
  sys.exit()

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
pow8 = [0]*(n+1)
pow8[0] = 1
pow8[1] =8

pow10=10

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    pow8[i] = (pow8[i-1]*8) % mod  
    pow10 =(pow10*10) % mod
ans = pow10 - pow8[n]
for i in range(1,n+1):
  ans = (ans - pow8[n-i]*2*cmb(n,i,mod)) % mod
               
print(ans)

Measured memory_bytes: 166760
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int n, k, c; string s; cin >> n >> k >> c >> s;
  
  int a[200000]; int b[200000];
  for (int i = 0, idx = 0; i < n; ++i) if (s[i] == 'o') {a[idx++] = i; i += c;}
  for (int i = n-1, idx = k-1; i >= 0; --i) if (s[i] == 'o') {b[idx--] = i; i -= c;}
  
  for (int i = 0; i < k; ++i) if (a[i] == b[i]) cout << a[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h> //AtCoder
#include <atcoder/all> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
using namespace atcoder;

/*int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数*/

/****************************** START ******************************/

signed main(){
  int N,Q;
  cin >> N >> Q;
  fenwick_tree<int> fw(N);
  int a;
  rep(i,0,N){
    cin >> a;
    fw.add(i,a);
  }
  int t,u,v;
  rep(j,0,Q){
    cin >> t >> u >> v;
    if (t){
      cout << fw.sum(u,v) << endl;
    } else {
      fw.add(u,v);
    }
  }
}      

Measured memory_bytes: 8204
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	vector<int> b(n);
	b = a;
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	
	int first = b.at(0);
	int second = b.at(1);

	rep(i, n) {
		if (a.at(i) == first) {
			cout << second << endl;
			continue;
		}
		else {
			cout << first << endl;
			continue;
		}
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int minimum = 1001001001;
    int ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if(a <= minimum) {
            ans++;
            minimum = min(minimum, a);
        }
    }
    cout << ans << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) if (s[i] == t[i]) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    int A, B;
    string a, b;
    cin >> a >> b;
    A = a.size(); B = b.size();
    
    vector<vector<ll>> dp(B + 1, vector<ll>(A + 1));
    constexpr ll MOD = ((1e9) + 7);
    
    for (int i = 0; i < B; i++) {
        for (int j = 0; j < A; j++) {
            if (i > 0) dp[i][j + 1] += dp[i][j];
            if (b[i] == a[j]) {
                dp[i + 1][j + 1] += (dp[i][j] + (i == 0));
                dp[i + 1][j + 1] %= MOD;
            }
        }
    }
    ll res = 0;
    for (int i = 0; i <= A; i++) {
        res += dp[B][i];
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10768
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n;
  string s;
  cin >> n >> s;
  string a, b;
  a = s.substr(0, n / 2);
  b = s.substr(n / 2, n / 2);

  if (a == b && n % 2 == 0)
    yOUT;
  else
    nOUT;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int W[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&W[i]);
    }

    int min = 10000;

    int s1, s2, abs;

    for (int T = 1; T < N; T++){

        s1 = 0;
        s2 = 0;

        for (int i = 0; i < T; i++){
            s1 += W[i];
        }

        for (int i = T; i < N; i++){
            s2 += W[i];
        }

        if(s1 < s2){
            abs = s2 - s1;
        }else{
            abs = s1 - s2;
        }

        if(min > abs){
            min = abs;
        }
    }

    printf("%d", min);

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    for i in range(-200, 200):
        for j in range(-200, 200):
            if i ** 5 - j ** 5 == N:
                print(i, j)
                return


main()


Measured memory_bytes: 67440
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──████AJ████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int N, M;
vector<vector<int>> adj;
vector<int> dp;

// Returns the longest directed path from the given node
int getLongestPath(int node) {
	if (adj[node].size() == 0) {
		return 0;
	}
	if (dp[node] != -1) return dp[node];
	int result = 0;
	for (auto x : adj[node]) {
		result = max(result, getLongestPath(x));
	}
	return dp[node] = 1 + result;
}

int main() {
	cin >> N >> M;
	adj = vector<vector<int>> (N + 1);
	dp = vector<int>(N + 1, -1);
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}

	int result = 0;
	for (int i = 1; i <= N; i++) {
		result = max(result, getLongestPath(i));
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 11116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    char s;
    cin >> s;
    s++;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    ll a[3],k;
    rep(i,3)cin>>a[i];
    cin>>k;
    sort(a,a+3);
    rep(i,k)a[2]*=2;
    cout<<a[0]+a[1]+a[2]<<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 all(x) x.begin(),x.end()
typedef long long ll;

int n,k,h,w;
string s,t;

int main() {
  cin >> n >> k;
  cout << (k==1 ? 0 : n-k) << endl;
}

Measured memory_bytes: 256
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

map <string, int> a;

int main() {
	a["SUN"] = 0;
	a["MON"] = 1;
	a["TUE"] = 2;
	a["WED"] = 3;
	a["THU"] = 4;
	a["FRI"] = 5;
	a["SAT"] = 6;
	string s;
	cin >> s;
	cout << 7 - a[s] << '\n';
}


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

const int N = 2005;

vector<int>V[N], p[N];
priority_queue<int>Q;
int a[N], n, Gr[N], u, v;
bool vi[N];
int gcd (int a, int b) { return b ? gcd(b, a % b) : a; }

void Dfs (int u) {
	vi[u] = 1;
	sort(V[u].begin(), V[u].end());
	for (auto v : V[u]) if (!vi[v]) p[u].emplace_back(v), ++Gr[v], Dfs(v);
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) if (gcd(a[i], a[j]) > 1) V[i].emplace_back(j), V[j].emplace_back(i);
	for (int i = 1; i <= n; ++i) if (!vi[i]) Dfs(i), Q.push(i);
	while (!Q.empty()) {
		u = Q.top(); Q.pop();
		printf("%d ", a[u]);
		for (auto v : p[u]) if (!--Gr[v]) Q.push(v);
	}
	return 0;
}

Measured memory_bytes: 18816
#include <stdio.h>

long long cache[89];

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

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


using namespace std;


const int MAXN = 2000 + 3;








int n, m, q, ps[MAXN][MAXN], e[2][MAXN][MAXN], x[2], y[2];
string s[MAXN];

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (auto &j : s[i])
            j -= '0';
    }
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + s[i - 1][j - 1];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) e[0][i][j] = e[0][i][j - 1] + e[0][i - 1][j] - e[0][i - 1][j - 1] + (s[i - 1][j - 1] && (i < n && s[i][j - 1]));
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) e[1][i][j] = e[1][i][j - 1] + e[1][i - 1][j] - e[1][i - 1][j - 1] + (s[i - 1][j - 1] && (j < m && s[i - 1][j]));
    while (q--) {
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        cout << ps[x[1]][y[1]] - ps[x[0] - 1][y[1]] - ps[x[1]][y[0] - 1] + ps[x[0] - 1][y[0] - 1]
        - (e[0][x[1] - 1][y[1]] - e[0][x[0] - 1][y[1]] - e[0][x[1] - 1][y[0] - 1] + e[0][x[0] - 1][y[0] - 1])
        - (e[1][x[1]][y[1] - 1] - e[1][x[0] - 1][y[1] - 1] - e[1][x[1]][y[0] - 1] + e[1][x[0] - 1][y[0] - 1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 52864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const int MOD = 993244853;
const ll INF = 1000000000000000010LL;

const int MAXN = 200010;
const int MAXK = 62;

int n;
ll a[MAXN];

int m;

void solve()
{
	cin >> n;
	ll sum = 0;
	
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		sum ^= a[i];
	}
	for (int i = 1; i <= n; ++ i)
		a[i] &= ~sum;
	
	for (int k = MAXK-1; k >= 0; -- k)
	{
		int id = 0;
		for (int i = m+1; i <= n; ++ i)
			if (a[i]>>k&1)
			{
				id = i;
				break;
			}
		if (!id) continue;
		++ m;
		swap(a[m], a[id]);
		for (int i = 1; i <= n; ++ i) if (i != m)
			if (a[i]>>k&1) a[i] ^= a[m];
	}
	
	ll ans = sum;
	
	ll tmp = 0;
	
	for (int i = 1; i <= m; ++ i)
		if ((tmp^a[i]) > tmp) tmp ^= a[i];
	
	ans += tmp*2;
	
	cout << ans << endl;
}

int main() {
	
	solve();
	
	return 0;
}

Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * a.cc: Addition
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int en = 0, on = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if (ai & 1) on++;
    else en++;
  }

  if ((on & 1) == 0 || en == 0) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11884
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define ft first
#define sd second
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    long long n;
    cin >> n;
    long long  a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    long long sum[n+1];
    sum[0]=0;
    for(int i=0;i<n;i++){
        sum[i+1] = sum[i] + a[i];
    }
    sort(sum, sum+n+1);
    long long cnt=1;
    long long ans=0;
    for(int i=0;i<n;i++){
        if(sum[i] == sum[i+1]) cnt++;
        else{
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define len(x)           x.length()
#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

//coded by Avijit Mandal

int main(){
   IOS;
   ll n,x,y,i,j,a,b,c;
   cin>>n;
   long double dp[n+1][n+1],res=0.0;
   long double p[n+1];
   for(i=0;i<n;i++)cin>>p[i+1];
   for(i=0;i<=n;i++){
      for(j=0;j<=n;j++)dp[i][j]=0.0;
   }
   dp[1][0]=1.0-p[1];
   for(i=2;i<=n;i++)dp[i][0]=dp[i-1][0]*(1.0-p[i]);

   dp[0][0]=1;
   for(i=1;i<=n;i++){
      for(j=1;j<=i;j++){
         dp[i][j]=(1.0-p[i])*(dp[i-1][j])+p[i]*(dp[i-1][j-1]);
      }
   }
   for(i=n;i>=n/2+1;i--)res+=dp[n][i];
   cout << fixed << setprecision(10) << res<<endl;;
}


Measured memory_bytes: 140928
#include<stdio.h>
#define MAX_N 100000
int par[MAX_N];
int rank[MAX_N];

//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return find(par[x]);
    return par[x] = find(par[x]);
  }
}

//x,y????±?????????????????????¨??????
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else {
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}


//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}


int main(){
  int N,Q;
  char s[16];
  int i,d;
  long long int res;
  while(1){
    if(!gets(s))break;
    sscanf(s,"%d %d",&N,&Q);
    if(N==0)break;
    res=0;
    init(N);
    for(i=1;i<N;i++){
      gets(s);
      sscanf(s,"%d",&par[i]);
      par[i]--;
    }
    for(i=0;i<Q;i++){
      gets(s);
      sscanf(s+2,"%d",&d);
      switch(s[0]){
      case 'Q':
        res+=find(d-1)+1;
        break;
      case 'M':
        par[d-1]=d-1;
        break;
      }
    }
    printf("%lld\n",res);
  }
  return 0;
}

Measured memory_bytes: 1388
import math
a,b,x = map(int,input().split())
S = x/a
if S >= a*b/2:
    h = 2*(a*b-S)/a
    print(math.degrees(math.atan2(h,a)))
else:
    h = 2*S/b
    print(math.degrees(math.atan2(b,h)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n&1) r=(r*base)%mod;
        base=(base*base)%mod;
        n/=2;
    }
    return r%mod;
}
ll C(ll a,ll b)
{
    ll cheng=1;
    ll cishu=a;
    ll cishu1=cishu;
    ll chu=1;
    while(cishu--)
    {
        cheng=(cheng*b)%mod;
        b--;
    }
        while(cishu1--)
    {
        chu=(chu*a)%mod;
        a--;
    }
    ll chushu=power(chu,mod-2);
    ll ans=(cheng*chushu)%mod;
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
     ans=(ans+mod+power(2,n)-1);
     ans%=mod;
    ans=(ans-C(a,n)+mod);
    ans%=mod;
    ans=(ans-C(b,n)+mod);
    ans%=mod;
    cout<<ans<<'\n';








}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"



int main() {
	int n,i,sum=0;
	int k;
	cin>>n;
	int d[n];
	for(i=0;i<n;i++)
	{
		cin>>d[i];
		sum+=d[i];
	}
sort(d,d+n);
k=d[n/2]-d[n/2-1];




	cout<<k;
	return 0;
}

Measured memory_bytes: 640
#200322D
from collections import Counter

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

c = Counter(A)
#print(c)
#print(c[1])
#print(c[A[0]])
L = len(c)
#print(L)

def nCm(x):
    return x * (x - 1) / 2

c_list = list(c.keys())

All = 0
for i in range(L):
    All += nCm(c[c_list[i]])

for i in range(N):
    Ans = All - (c[A[i]]) + 1
    print(int(Ans))


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

int main() {
    int64_t D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i, D){
        cin >> p.at(i);
        cin >> c.at(i);
    }
    int ans = 1001;
    for (int bit = 0; bit < (1 << D); bit++){
        int count = 0;
        int64_t sum = 0;
        rep(i, D){
            if (bit & (1 << i)){
                sum += p.at(i) * 100 * (i + 1) + c.at(i);
                count += p.at(i);
            }
        }
        if (sum >= G) ans = min(ans, count);
        else{
            for (int j = D - 1; j >= 0; j--){
                if (!(bit & (1 << j))){
                    rep(k, p.at(j) - 1){
                        count++;
                        sum += 100 * (j + 1);
                        if (sum >= G) break;
                    }
                }
                if (sum >= G) break;
            }
            if (sum >= G) ans = min(ans, count);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    int main()
    {
        fastread;
        char ch;
        cin>>ch;
        ch++;
        cout<<ch;
    	return 0;
    }

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [[c==".#"[(i+j)%2] for j,c in enumerate(input())] for i in range(H)]#(0,0)が黒のときFalse
V = [[-1]*W for _ in [0]*H]
ans = 0
for si in range(H):
    for sj in range(W):
        if V[si][sj] != -1:continue
        V[si][sj] = 0
        cnt = [0,0]
        cnt[(S[si][sj]+si+sj)%2]+=1
        q = [[si,sj]]
        while q:
            i,j = q.pop()
            for di,dj in ((1,0),(-1,0),(0,1),(0,-1)):
                if (not (0<=i+di<H)) or (not (0<=j+dj<W)):continue
                if V[i+di][j+dj] != -1:continue
                if S[i][j] != S[i+di][j+dj]:continue
                V[i+di][j+dj] = V[i][j]
                q.append([i+di,j+dj])
                cnt[(S[i][j]+i+di+j+dj)%2] += 1
        ans += cnt[0]*cnt[1]
print(ans)

Measured memory_bytes: 15556
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

class P
{
public:
  double x,y;
  P(){};P(double x,double y):x(x),y(y){};
  P operator+(const P&q){P t;t.x=x+q.x;t.y=y+q.y;return t;}
  P operator+=(const P&q){x+=q.x;y+=q.y;return *this;}
  P operator-(const P&q){P t;t.x=x-q.x;t.y=y-q.y;return t;}
  P operator-=(const P&q){x-=q.x;y-=q.y;return *this;}
  template<typename T> P operator*(T d){return P(x*d,y*d);}
  template<typename T> P operator*=(T d){x*=d;y*=d;return *this;}
  template<typename T> P operator/(T d){return P(x/d,y/d);}
  template<typename T> P operator/=(T d){x/=d;y/=d;return *this;}
  bool operator<(const P&q){return (x!=q.x)?(x<q.x):(y<q.y);}
  bool operator>(const P&q){return (x!=q.x)?(x>q.x):(y>q.y);}
  double norm(void){return sqrt(x*x+y*y);}
  double arg(void){return acos(x/this->norm())*P(1,0).sign(*this);}
  P nvec(){return P(y,-x);}
  P rotate(double t){double c=cos(t),s=sin(t);return P(c*x-s*y,s*x+c*y);}
  P reverseX(void){return P(-x,y);}
  P reverseY(void){return P(x,-y);}
  P unit(void){return (*this).norm()==0?P(0,0):(*this)/(*this).norm();}
  P floor(void){return P((int)x,(int)y);}
  double dot(const P&q){return x*q.x+y*q.y;}
  double det(const P&q){return x*q.y-y*q.x;}
  int sign(const P&q){double d = (*this).det(q); return (d>0)-(d<0);}
  static bool on_seg(P p1,P p2,P q){return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;}
  static P intersection(P p1,P p2,P q1,P q2){return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));}
};


int main()
{
  int q; cin >> q;
  REP(i,q)
  {
    int ans;
    double x0,y0,x1,y1,x2,y2,x3,y3;
    cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
    P u = P(x1-x0,y1-y0);
    P v = P(x3-x2,y3-y2);
    if(u.det(v)==0) ans = 2;
    else if(u.dot(v)==0) ans = 1;
    else ans = 0;
    cout << ans << endl;
  }
  return 0;
}

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

typedef pair<int, int> P;
const int INF = 1000*1000 +10;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> masu;
    masu.resize(H);
    rep(i, H) {
        cin >> masu[i];
    }

    queue<P> loc_queue;
    int ans = 0;
    vector<vector<int>> d_temp(H, vector<int>(W, 0));

    rep(i, H) {
        rep(j, W) {
            if (masu[i][j]=='#') {
                loc_queue.push(P {i, j});
            }
        }
    }

    int dh[4] = {0, 1, 0, -1};
    int dw[4] = {1, 0, -1, 0};

    while (!loc_queue.empty()) {
        int h = loc_queue.front().first;
        int w = loc_queue.front().second;
        loc_queue.pop();

        rep(i, 4) {
            int nh = h + dh[i];
            int nw = w + dw[i];
            if (0<=nh && 0<=nw && nh<H && nw<W && masu[nh][nw]=='.') {
                masu[nh][nw] = '#';
                loc_queue.push(P {nh, nw});
                d_temp[nh][nw] = d_temp[h][w] + 1;
                ans = max(ans, d_temp[nh][nw]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13456
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<math.h>

using namespace std;

int main(void)
{
	int x, a, b;
	cin >> x >> a >> b;

	if (fabs(x - a) < fabs(x - b))
	{
		cout << "A\n";
	}
	else
	{
		cout << "B\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const* argv[])
{
	string str;
	int n;
	cin >> n;
	cin >> str;
	int max = 0;
	int current = 0;
	int left[26];
	int right[26];
	for(int i = 0; i < 26; i++){
			left[i] = 0;
			right[i] = 0;
	}
	for(int i = 0; i < str.size(); i++){
			right[str[i]-'a'] += 1;
	}
	for(int i = 0; i < str.size(); i++){
			right[str[i]-'a'] -= 1;
			left[str[i]-'a'] += 1;
			if(right[str[i]-'a'] == 0 && left[str[i]-'a'] != 1)current -= 1;
			else if(right[str[i]-'a'] != 0 && left[str[i]-'a'] == 1)current += 1;
			if(current > max)max = current;
	}
	cout << max << endl;
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

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

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    string S;
    cin >> S;

    if(S[0] != S[1]){
        if(S[2] == S[0] && S[3] == S[1]){
            cout << "Yes" << endl;
            return 0;
        }
        if(S[2] == S[1] && S[3] == S[0]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(S[0] == S[1]){
        if(S[2] != S[0] && S[2] == S[3]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n,flag,temp,count=0,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
  }
  
  flag=1;
  i=0;
  while(flag){
   
    flag = 0;
    for(j=n-1;j>=i+1;j--){

      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	count++;
	flag =1;
      }
     
    }
    
    i++;
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],count);
  return 0;
}

Measured memory_bytes: 600
n = int(input())
xy = [[i] + list(map(int,input().split())) for i in range(n)]

xy.sort(key=lambda x:x[1])
edge  = []
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((x2-x1,i1,i2))

xy.sort(key=lambda x:x[2])
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((y2-y1,i1,i2))
class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

#クラスカル法
uf = UnionFind(n)
edge.sort()
ans = 0
edge_cnt = 0
i = 0
while edge_cnt < n-1:
    cost,i1,i2 = edge[i]
    if not uf.same(i1,i2):
        ans += cost
        uf.unite(i1,i2)
        edge_cnt += 1
    i += 1
print(ans)

Measured memory_bytes: 52236
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  if((abs(b-a)<=d && abs(c-b) <=d) || abs(c-a)<=d){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int N; 
  cin >> N;
  vector<int> A(N), B(N);

  REP(i, N){
    cin >> A[i] >> B[i];
  }

  ll ans = 0;

  IFOR(i, 0, N){
    ans += ((B[i] - (A[i]+ans)%B[i])%B[i]);
  }
  cout << ans << endl;
}


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v, T) for_each((v).begin(), (v).end(), [](T& a) { cout << a << " "; }); cout << "\n";

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

using PII = pair<int, int>;
using PIL = pair<int, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;


int X, Y, Z, K;
V<LL> a;
V<LL> b;
V<LL> c;
V<LL> ab;
priority_queue<LL> abc;
priority_queue<LL> tmp;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> X; cin >> Y; cin >> Z; cin >> K;

    REP(i,X) {
        LL x; cin >> x; a.push_back(x);
    }
    REP(i,Y) {
        LL x; cin >> x; b.push_back(x);
    }
    REP(i,Z) {
        LL x; cin >> x; c.push_back(x);
    }

    REP(i, X) {
        REP(j, Y) {
            ab.push_back(a[i] + b[j]);
        }
    }

    std::sort(ALL(ab),  [](const LL& x, const LL& y) { return x > y; } );
    std::sort(ALL(c),  [](const LL& x, const LL& y) { return x > y; } );

    REP(i, std::min(X*Y, Z)) {
        LL x = ab[i];
        LL y = c[i];
        abc.push(x+y);

        while(!tmp.empty()) {
            if(ab[i] + c[i] <= tmp.top()) {
                abc.push(tmp.top());
                tmp.pop();
            } else break;
        }

        if(K <= abc.size()) break;

        for(int j = i + 1; j < X*Y; j++) {
            if (i+1 >= std::min(X*Y, Z)) break;
            if (ab[i+1] + c[i+1] <= ab[j] + y) {
                abc.push(ab[j] + y);
            } else {
                tmp.push(ab[j] + y);
            }
        }

        for(int j = i + 1; j < Z; j++) {
            if (i+1 >= std::min(X*Y, Z)) break;
            if (ab[i+1] + c[i+1] <= x+ c[j]) {
                abc.push(x + c[j]);
            } else {
                tmp.push(x + c[j]);
            }
        }
    }

    if(abc.size() < K) {
        while(!tmp.empty()) {
            abc.push(tmp.top());
            tmp.pop();
        }
        for(int i = X*Y; i < Z; i++) {
            abc.push(ab[X*Y-1] + c[i]);
        }
        for(int i = Z; i < X*Y; i++) {
            abc.push(ab[i] + c[Z-1]);
        }
    }

    REP(i, K) {
        cout << abc.top() << "\n";
        abc.pop();
    }
}


Measured memory_bytes: 272372
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  ll n;
  cin >> n;
  vector<ll> t;
  while (n--) {
    ll a;
    cin >> a;
    t.push_back(a);
  }
  ll k;
  cin >> k;
  vector<pair<ll, ll>> p;
  while (k--) {
    ll a, b;
    cin >> a >> b;
    p.push_back(make_pair(a - 1, b));
  }
  for (auto a : p) {
    ll tmp = t[a.first];
    t[a.first] = a.second;
    cout << accumulate(t.begin(), t.end(), 0) << endl;
    t[a.first] = tmp;
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
aa = []
bb = []
for k in range(n):
    a, b = list(map(int, input().split()))
    aa.append(a)
    bb.append(b)

# aa =     [384, 1725, 170, 4, 2, 578, 702, 143, 1420, 24, 849, 76, 85, 444, 719, 470, 1137, 455, 110, 15, 368, 104, 3, 366, 7, 610, 152, 4, 292, 334]
# bb = [8895, 9791, 1024, 11105, 6, 1815, 3352, 5141, 6980, 1602, 999, 7586, 5570, 4991, 11090, 10708, 4547, 9003, 9901, 8578, 3692, 1286, 4, 12143, 6649, 2374, 7324, 7042, 11386, 5720]
# n = len(aa)

aa = np.array(aa)
bb = np.array(bb)

must_start = bb - aa

s = np.argsort(bb)

must_start = must_start[s]
must_end = bb[s]
aa = aa[s]
ruikei_end = np.cumsum(aa)
must_end  >= ruikei_end

if (must_end  >= ruikei_end).all() == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 28136
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <unordered_set>

using namespace std;

unordered_set<int> d;

int GetD(int x, int d) {
    int m = x / pow(10, d);
    return (m % 10);
}

bool FindGet(int n) {
    int len = 0;
    int x = n;
    while (x > 0) { x /= 10; len++; }
    for (int i = 0; i < len; i++) {
        if (d.find(GetD(n, i)) != d.end()) { return false; }
    }
    return true;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < k; i++) {
        int d0;
        scanf("%d", &d0);
        d.emplace(d0);
    }

    while (!FindGet(n)) {
        n++;
   }
    printf("%d\n", n);
}

Measured memory_bytes: 384
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
    
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 9412
import sys

alphabet = "abcdefghijklmnopqrstuvwxyz"
count_dict = dict.fromkeys(alphabet,0)
s = []
for l in sys.stdin:
    s.append(l)

def count(str):
    for c in alphabet:
        count_dict[c] += str.count(c)
    str = str.swapcase()
    for c in alphabet:
        count_dict[c] += str.count(c)

for str in s:
    count(str)
    
for key,value in count_dict.items():
    print("{} : {}".format(key,value))



Measured memory_bytes: 5568
N = int(input())
A = list(map(int,input().split()))

cnt4,cnt2,cnt0 = 0,0,0 
for i in range(N):
    if A[i]%4==0:
        cnt4 += 1
    elif A[i]%2==0:
        cnt2 += 1
    else:
        cnt0 += 1

if cnt2>0:
    print("Yes" if cnt4 >= cnt0 else "No")
else:
    print("Yes" if cnt4 >= cnt0-1 else "No")

Measured memory_bytes: 14252
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	int n, h, w;
	cin >> n;
	cin >> h;
	cin >> w;

	n+= 1;

	int ans = (n-h)*(n-w);

	std::cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 169B.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP          PIC X(2000000).
*>
WORKING-STORAGE SECTION.
01 N          PIC 9(06) COMP.
01 P1         PIC 9(07) COMP.
01 P2         PIC 9(07) COMP.
01 I          PIC 9(06) COMP.
01 TBL.
   03 A       PIC S9(18) OCCURS 100000.
01 X          PIC X(19).
01 FLG-K19    PIC X(01).
01 FLG-UP     PIC X(01).
01 CNT        PIC S9(18) COMP.
01 CNTW       PIC S9(18) COMP.
01 AMR        PIC 9(18)  COMP.
01 OUT        PIC Z(17)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  OPEN INPUT STDIO.
  READ STDIO.         
  CLOSE STDIO.
*>
  MOVE ZERO TO TBL.
  MOVE 1 TO CNT.
  MOVE 1 TO P1
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N OR CNT = 0
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A(I) X
    IF (X(19:1) NOT = ' ') 
      MOVE -1 TO A(I)
    ELSE
      IF (A(I) = 0) 
        MOVE 0 TO CNT
      END-IF
    END-IF
*>
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 999999999999999999 TO CNTW.
  MOVE '0'                TO FLG-K19.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N OR CNT <= 0
    DIVIDE 999999999999999999 BY CNT GIVING CNTW REMAINDER AMR
    IF (CNT > 1) AND (AMR + 1 = CNT)
      ADD  1   TO CNTW
      MOVE 0   TO AMR
      MOVE '1' TO FLG-UP
    ELSE
      MOVE '0' TO FLG-UP 
    END-IF
*>    
    IF (A(I) = -1)
      IF (CNT > 1)
        MOVE -1 TO CNT
      ELSE
        MOVE 999999999999999999 TO CNT
        MOVE '1'                TO FLG-K19
      END-IF 
    ELSE
      IF (A(I) <= CNTW)
        IF (A(I) = CNTW) AND (AMR = 0) AND (FLG-UP = '1')
          MOVE 999999999999999999 TO CNT
          MOVE '1'                TO FLG-K19
        ELSE
          COMPUTE CNT = CNT * A(I)
        END-IF
      ELSE 
        MOVE -1 TO CNT
      END-IF
    END-IF
*>
  END-PERFORM.
  EVALUATE CNT
    WHEN 0
      DISPLAY '0'
    WHEN -1
      DISPLAY '-1'
    WHEN 999999999999999999
      IF (FLG-K19 = '1')
        DISPLAY '1000000000000000000'
      ELSE
        DISPLAY '999999999999999999'
      END-IF
    WHEN OTHER
      MOVE CNT TO OUT
      DISPLAY FUNCTION TRIM(OUT)
  END-EVALUATE.
*>
  STOP RUN.


Measured memory_bytes: 7652
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int dsum(int n){
  if(n == 0)
    return 0;
  else
    return dsum(n/10)+n%10;
}

int main()
{
  int N,res=0,A,B;
  cin >>N >>  A >> B;
  for(int i=1;i<=N;i++){
    int d=dsum(i);
    if(d >= A && d <= B){
      res += i;
    }
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(mut aa: Vec<usize>) -> usize {
    use std::collections::BinaryHeap;

    let n = aa.len();

    let mut cnt = 0;

    while true {
        aa.sort();
        let a = aa[n-1];
        if a < n {
            break
        }

        let c = (a-n)/n;
        if c == 0 {
            break
        }

        aa[n-1] -= c*n;

        for i in 0..n-1 {
            aa[i] += c;
        }

        cnt += c;
    }

    while true {
        aa.sort();
        if aa[n-1] <= n-1 {
            return cnt
        }

        aa[n-1] -= n;

        for i in 0..n-1 {
            aa[i] += 1
        }

        cnt += 1;
    }

    unreachable!()
}

fn main() {
    read_line!();
    let aa = parse_vec!(usize);

    println!("{}", solve(aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![3,3,3,3]), 0);
    assert_eq!(solve(vec![1,0,3]), 1);
    assert_eq!(solve(vec![2,2,]), 2);
    assert_eq!(solve(vec![27,0,0,0,0,0,0]), 3);
    assert_eq!(solve(vec![1000, 193, 256, 777, 0, 1, 1192, 1234567891011, 48, 425]), 1234567894848);
}



Measured memory_bytes: 4352
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,A,B = [int(i) for i in readline().split()]
abc = [[int(i) for i in readline().split()] for j in range(n)]

ans = 10**9

d = {0:0}
for i in range(n):
    nd = {}
    a,b,c = abc[i]
    for amari,yen in d.items():
        if amari in nd:
            nd[amari] = min(nd[amari],yen)
        else:
            nd[amari] = yen

        yen += c
        amari += a*B-b*A
        if amari == 0 and yen != 0:
            ans = min(ans,yen)
        elif amari in nd:
            nd[amari] = min(nd[amari],yen)
        else:
            nd[amari] = yen
    d = nd
#    print(d,nd)

if ans == 10**9:
    print(-1)
else:
    print(ans)





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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  int cnt = 0;
  rep(i,n){
    cin >> s;
    if(s == "A") cnt++;
    if(s == "Un"){
      cnt--;
      if(cnt < 0){
        cout << "NO" << "\n";
        return 0;
      }
    }
  }

  if(cnt != 0)cout << "NO" << "\n";
  else cout << "YES" << "\n";
  return 0;
}



Measured memory_bytes: 3224