akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1000000007;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a - b;

    vl h1(n);
    rep(i, n) {
        cin >> h1[i];
    }

    // 判定問題「x回の爆発で全部倒せるか？」を二分探索で解く
    ll left = 0;
    ll right = INF;
    while(right - left > 1) {
        ll x = (left + right)/2;
        vl h2(n);
        rep(i, n) {
            h2[i] = h1[i];
        }
        rep(i, n) {
            h2[i] -= b*x;
        }
        ll cnt = 0;  // cダメージ与える回数
        rep(i, n) {
            if(h2[i] > 0) {
                cnt += ceil(h2[i], c);
            }
        }
        if(cnt <= x) {
            right = x;
        }
        else {
            left = x;
        }
    }

    out(right);
    re0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int a,n,ok=1;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a;
        if(a%2==0){
            if(!(a%3==0 || a%5==0)){
                ok=0;
            }
        }
    }
    if(ok==1){
        cout<<"APPROVED";
    }
    else{
        cout<<"DENIED";
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

char s[9];

main(){
    scanf("%s", s);
    puts(strchr(s, 'A') && strchr(s, 'B')?"Yes": "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    int N;
    cin >> N;
    // Actual program code starts here.
    const int MOD = 1000000007;
    VEC(int) V{0, 0, 0};

    lint ret = 1;
    FOR(i, 0, N) {
        int a, t;
        cin >> a;

        t = count(ALL(V), a);
        if (t == 0) {
            ret = 0;
            break;
        }

        ret = ret * t % MOD;
        FOR(j, 0, 3)
            if (V[j] == a) {
                V[j]++;
                break;
            }
    }

    cout << ret << endl;

    return 0;
};

Measured memory_bytes: 384
# Problem https://atcoder.jp/contests/abc072/tasks/abc072_b
# Python 3rd Try
import copy


class Problem:
    def __init__(self, inputstring):
        self.inputstring = inputstring

    def __str__(self):
        return self.inputstring

    def solver(self):
        result = ''
        string = copy.copy(self.inputstring)
        result = string[0:len(string):2]
        return result


if __name__ == "__main__":
    s = input()
    x = Problem(s)
    print(x.solver())


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

int main(){
    string s;
    cin >> s;
    string year = s.substr(0,4);
    string month = s.substr(5,2);
    string day = s.substr(8,2);

    int yearI = stoi(year);
    int monthI = stoi(month);
    int dayI = stoi(day);

    if(yearI > 2019){
        cout << "TBD";
    }else{
        if(monthI > 4){
            cout << "TBD";
        }else{
            if(dayI > 30){
                cout << "TBD";
            }else{
                cout << "Heisei";
            }
        }
    }
}

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

const int MOD = 998244353;
const int MAXN = 200005;
int n;
int f[1000005];
int sm[1000005];

int pw(int a, int p) {
	if (p == 0) return 1;
	int r = pw(a, p/2);
	r = (r * 1ll * r) % MOD;
	if (p%2==1) {
		return (a*1ll * r) % MOD;
	}
	return r;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		f[x]++;
	}
	int ans = 0;
	for (int i = 1000000; i >= 1; i--) {
		int cur = 0;
		int curSm = 0;
		for (int j = i; j <= 1000000; j += i) {
			for (int k = 0; k < f[j]; k++) {
				curSm = (curSm + j * 1ll * cur) % MOD;
				cur += j;
				cur %= MOD;
			}
		}
		for (int j = i; j <= 1000000; j += i) {
			curSm -= sm[j];
			if (curSm < 0) curSm += MOD;
			curSm %= MOD;
		}
		sm[i] = curSm;
		ans = (ans + curSm * 1ll * pw(i, MOD - 2)) % MOD;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 8064
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = []
i = 0
until n == i
    if i % 2 == 0
        b << a[i]
    else
        b.unshift(a[i])
    end
    i += 1
end
if n % 2 == 0
    puts b.join(" ")
else
    puts b.reverse.join(" ")
end


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

void Main()
{
  ll K;
  cin >> K;
  ll cnt = 0;
  ll i = 0;
  while (cnt < K) {
    i++;
    string s = to_string(i);
    //cout << s << endl;
    //if (i >= 10000) cout << "i: " << i << endl;
    bool lunlun = true;
    for (int j = 1; j < s.size(); j++) {
      if (!(s[j] == s[j-1] || abs(s[j]-s[j-1]) == 1)) {
        lunlun = false;
        if (s.size()-j-1 > 0) {
          i += pow((ll)10, (ll)(s.size()-j-1));
          i = i - i % (ll)pow((ll)10, (ll)(s.size()-j-2));
          i--;
        }
        break;
      }
    }
    if(lunlun) {
      //cout << i << endl; 
      cnt++;
    }
  }
  cout << i << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string yes = "Yes";
    string no = "No";
    int n;
    cin >> n;
    vl h(n);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n-1){
        if(h[i] < (h[i+1])){
            h[i+1]--;
        }
        else if(h[i] > h[i+1]){
            cout << no << endl;
            return 0;
        }
    }
    
    cout << yes << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

void fastInOut();
const int N = 1e5 + 2;

int a[3][N], n;

int dp[N][4];
int solve(int i = 0, int prv = 3)
{
    if(i == n) return 0;
    int &res = dp[i][prv];
    if(~res) return res;
    res = 0;
    if(prv != 0) res = max(res, solve(i+1, 0) + a[0][i]);
    if(prv != 1) res = max(res, solve(i+1, 1) + a[1][i]);
    if(prv != 2) res = max(res, solve(i+1, 2) + a[2][i]);
    return res;
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    fastInOut();
    cin >> n;
    for(int i=0; i<n; ++i)
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    memset(dp, -1, sizeof dp);
    cout << solve() << '\n';
    return 0;
}

void fastInOut() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
}


Measured memory_bytes: 7680
s = input()
t = input()
n1 = len(s)
n2 = len(t)
ans = 999999999
for i in range(n1 - n2 + 1):
    cnt, x = 0, 0
    for j in range(i, i + n2):
        if s[j] != t[x]: cnt -= -1
        x -= -1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 67516
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int MAX = 300010;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

segtree<int, op, e> seg(MAX);

int main(void){
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) a[i] = in();
    REP(i,n){
        int l = max(0, a[i] - k);
        int r = min(MAX, a[i] + k + 1);
        int x = seg.prod(l, r);
        seg.set(a[i], x + 1);
    }
    int ans = seg.all_prod();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8568
#include <iostream>
#include <algorithm>
using namespace std;
const int INF=0x3f3f3f3f,maxn=2e5+5;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
struct node
{
	int t1,t2;
	bool operator < (node a) const
	{
		return t2<a.t2;
	}
}a[maxn];
int n,m;
long long t;
int main()
{
	int i,j,k,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i].t1>>a[i].t2;
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		if(a[i].t1+t>a[i].t2)
		{
			cout<<"No"<<endl;
			return 0;
		}
		t+=a[i].t1;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int s = scanner.nextInt();
        final int w = scanner.nextInt();

        if (w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 32632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  for (ll i = n - 1; i > 0; i--) {
    if (a[i - 1] > a[i]) a[i - 1]--;
  }
  for (ll i = 1; i < n; i++) {
    if (a[i - 1] > a[i]) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
int read();

int n, s, t;
int p[200005], q[200005];
int id[2][200005], idcnt;

void work(int u, int* nx, int* id) {
    if (id[u]) return;
    id[u] = idcnt, work(nx[u], nx, id);
}

int hd[200005], nx[1000006], to[1000006], c[1000006], cnt;
void add(int f, int t, int cap) {
    nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t, c[cnt] = cap;
}
void fadd(int f, int t, int c) { add(f, t, c), add(t, f, 0); }
struct Flow {
    int dep[200005];
    queue<int> q;
    bool bfs() {
        for (int i = 1; i <= t; ++i) dep[i] = 0;
        dep[s] = 1, q.push(s);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int i = hd[u], v; i; i = nx[i]) {
                if (!c[i] || dep[v = to[i]]) continue;
                dep[v] = dep[u] + 1, q.push(v);
            }
        }
        return dep[t];
    }

    int iter[200005];
    int dfs(int u, int dist) {
        if (u == t) return dist;
        for (int &i = iter[u], v, d; i; i = nx[i]) {
            if (!c[i] || dep[v = to[i]] != dep[u] + 1) continue;
            if (d = dfs(v, min(dist, c[i]))) return c[i] -= d, c[i ^ 1] += d, d;
        }
        return 0;
    }
    int Dinic() {
        int rt = 0, d;
        while (bfs()) {
            for (int i = 1; i <= t; ++i) iter[i] = hd[i];
            while (d = dfs(s, 10000000)) rt += d;
        }
        return rt;
    }
} flow;

int main() {
    n = read(), cnt = 1;
    for (int i = 1; i <= n; ++i) p[i] = read() + 1;
    for (int i = 1; i <= n; ++i) q[i] = read() + 1;
    int res = n;
    for (int i = 1; i <= n; ++i)
        if (!id[0][i]) ++idcnt, work(i, p, id[0]);
    for (int i = 1; i <= n; ++i)
        if (!id[1][i]) ++idcnt, work(i, q, id[1]);

    s = ++idcnt, t = ++idcnt;
    for (int i = 1; i <= n; ++i)
        if (p[i] == i && q[i] == i)
            --res;
        else if (p[i] == i)
            fadd(id[1][i], t, 1);
        else if (q[i] == i)
            fadd(s, id[0][i], 1);
        else if (p[i] != q[i])
            fadd(id[1][i], id[0][i], 1);
        else
            fadd(id[1][i], id[0][i], 1), fadd(id[0][i], id[1][i], 1);
    printf("%d\n", res - flow.Dinic());
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 19200
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let h: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut i = 0;
    let mut ans = 0;
    while i < n {
        let mut prev = 1001001001;
        let mut cnt = 0;
        while i < n && h[i] <= prev {
            prev = h[i];
            i += 1;
            cnt += 1;
        }
        ans = std::cmp::max(ans, cnt - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#include <string>
int ans[4][4];
int sans[4][4];
int main(){
  int A[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      ans[i][j]  = 0;
      sans[i][j] = 0;
      cin >> A[j][i];
    }
  }
  int n; 
  cin >> n;
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
	if(A[j][k]==b){
	  ans[0][j] += 1;
	  ans[k+1][1] += 1;
	  if(j==k)ans[2][2]+=1;
	  
	  if((j+k)%2==0)sans[(j+k)/2][(j+k)/2]+=1;
	}
      }
    }
  }
  string out = "No";
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      if(ans[i][j]>2) out = "Yes";
      if(sans[1][1]>2)out = "Yes";
    }
  }
  cout << out << endl;
}


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

void solve() {
	int n;
	cin >> n;
	int temp, count = 0;
	for (int i=1; i<=n; ++i) {
		cin >> temp;
		if ((i & 1) && (temp & 1)) ++count; 
	}
	cout << count;
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tc = 1; //cin >> tc;
	while (tc--) {
		solve();
		cout << '\n';
	}
}


Measured memory_bytes: 3648
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

r, D, x = map(int, raw_input().split())

for i in range(10):
    x = x * r - D
    print x

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;


int64_t modpow(int64_t x, int64_t n){
    int64_t res = 1;
    for(int64_t i = n; i > 0; i >>= 1){
        if(i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int64_t comb(int64_t n, int64_t k){
    if(n - k < k) k = n - k;
    int64_t ch = 1, pa = 1;
    for(int64_t i = n; i > n - k; i--){
        ch = ch * i % MOD;
    }
    for(int64_t i = k; i > 0; i--){
        pa = pa * i % MOD;
    }

    return ch * modpow(pa, MOD - 2) % MOD;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int64_t ans = modpow(2, n) - 1;
    ans = ((ans - comb(n, a) + MOD) % MOD - comb(n, b) + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)


int main(){
	
	string S;
	cin>>S;
	if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
		cout<<"Yes"<<endl;
	}
	else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]){
		cout<<"Yes"<<endl;
	}
	else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 256
import Data.List

input k = loop [] k
  where
    loop :: [Int] -> Int -> IO [Int]
    loop list k = do
      if k == 0
        then return list
        else do
        _ <- getLine
        sunuke <- map read . words <$> getLine
        loop (nub (sunuke ++ list)) (k-1)


main = do
  [n,k] <- map read . words <$> getLine
  ns <- length <$> input k
  print $ n - ns


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  vector<ll>a(1000002);
  for(ll i=0;i<n;i++){
    ll val;
    cin>>val;
    a[val]++;
  }
  
  ll ans=0;
  for(ll i=1;i<=1e6;i++){
    if(a[i]>0){
    	if(a[i]==1){
    		ans+=a[i];
		}
      for(ll j=2*i;j<=1e6;j+=i){
        a[j]=0;
      }
    }
  }
  cout<<ans;
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int h,w;
string s[101];
void solve(){
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		cin >> s[i];
		s[i] = '.'+s[i]+'.';
	}
	s[0] = s[h+1] = s[1];
	for(int i = 0; i <= w+1; i++) s[0] = s[h+1] = '.';
	
	int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(s[i][j] == '#'){
				bool ok = 0;
				for(int k = 0; k < 4; k++){
					int nx = dx[k]+i, ny = dy[k]+j;
					if(s[nx][ny] == '#') ok = 1;
				}
				if(!ok){
					cout << "No" << endl;
					return;
				}
			}
		}
	}
	cout << "Yes" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),
            B = sc.nextInt();
        if(B%A > 0){
            System.out.println(B-A);
        } else{
            System.out.println(A+B);
        }
    }
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int p[200000],q[200000],r[200000];

int main(){
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	rep(i,a)scanf("%d",&p[i]);
	rep(i,b)scanf("%d",&q[i]);
	rep(i,c)scanf("%d",&r[i]);
	sort(p,p+a,greater<>());
	sort(q,q+b,greater<>());
	sort(r,r+c,greater<>());
	priority_queue<int,vector<int>,greater<int>>que;
	ll sum=0;
	rep(i,x){
		que.push(p[i]),sum+=p[i];
	}
	rep(i,y){
		que.push(q[i]),sum+=q[i];
	}
	rep(i,c){
		if(que.top()<r[i]){
			sum-=que.top();que.pop();sum+=r[i];
			que.push(r[i]);
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 2552
#include <stdio.h>
#define black 1
#define white 0
#define MAX 200000000
 
int n ,c[100][100], A[100], cl[100];
 
void Road() {
  int i, min, u, v;
     
  for (i = 0; i < n; ++i) {
    cl[i]  = white;
    A[i] = MAX;
  }
     
  A[0] = 0;
     
  while(1) {
    min = MAX;
         
    u = -1;
    for(i = 0; i < n; i++) {
      if (min > A[i] && cl[i] != black) {
        u = i;
        min = A[i];
      }
    }
    if (u == -1) break;
         
    cl[u] = black;
    for (v = 0; v < n; ++v) {
      if (cl[v] != black) {
        if (A[v] > A[u] + c[u][v]) {
          A[v] = A[u] + c[u][v];
        }
      }
    }
  }     
}
int main() {
  int i, j, k, a, b;
  scanf("%d", &n);
     
  for (i = 0; i < n; ++i){
    for (j = 0; j < n; ++j) {
      c[i][j] = MAX;
 
    }
  }
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &a, &k);
      for (j = 0; j < k; ++j) {
        scanf("%d %d", &a, &b);
          c[i][a] = b;
      }
  }
  Road();
     
  for (i = 0; i < n; ++i) {
    printf("%d %d\n", i, A[i]);
  }
 
  return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(auto i=0; i<(n); i++)
#define rep2(i,x,n) for(auto i=x; i<(n); i++)
#define MOD 1000000007
#define INF 1e+9
#define MAX_V 10

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

ll n;
ll ans = 0;

int main() {
    cin >> n;
    ll a[n+10];
    rep(i,n)cin >> a[i];
    ll p = 1;
    rep(i, 61)
    {
        ll cnt = 0;
        rep(j,n){
            if((a[j]>>i)&1)
                cnt++;
        }
        ans += ((((p%1000000007)*cnt)%1000000007)*(n-cnt))%1000000007;
        p *= 2;
    }
    cout << ans%1000000007 << endl;

    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = 0;
  if(a<b){
    ans +=a;
  }else{
    ans +=b;
  }
  if(c<d){
    ans +=c;
  }else{
    ans +=d;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=3e5+5, P=998244353;
char s[N];
int n, r, g, b, rg, rb, gb;
int main() {
	long long ans=1;
	assert(scanf("%d%s", &n, s)==2);
	for(int i=1; i<=n; ++i) ans=ans*i%P;
	for(int i=0; i<3*n; ++i, ans%=P)
		switch(s[i]) {
			case 'R':
				if(gb) ans*=gb--;
				else if(g) ans*=g--, ++rg;
				else if(b) ans*=b--, ++rb;
				else ++r;
				break;
			case 'G':
				if(rb) ans*=rb--;
				else if(r) ans*=r--, ++rg;
				else if(b) ans*=b--, ++gb;
				else ++g;
				break;
			case 'B':
				if(rg) ans*=rg--;
				else if(g) ans*=g--, ++gb;
				else if(r) ans*=r--, ++rb;
				else ++b;
				break;
		}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(void) {
  int N, M, K; cin >> N >> M >> K;
  vector<int> friends[N+1];
  vector<int> blocked[N+1];

  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  for (int i = 0; i < K; ++i) {
    int c, d; cin >> c >> d;
    blocked[c].push_back(d);
    blocked[d].push_back(c);
  }


  int belong[N+1];
  memset(belong, 0xFF, sizeof(belong));

  vector<vector<int>> frnV;
  int Vnum = 0;
  for (int i = 1; i <= N; ++i) {
    if (belong[i] == -1) {
      vector<int> V;
      vector<int> pre;
      vector<int> nex;
      nex.push_back(i);
      V.push_back(i);
      belong[i] = Vnum;

      while (!nex.empty()) {
        pre = nex;
        nex.clear();
        for (auto mn = pre.begin(); mn != pre.end(); ++mn) {
          for (auto frnd = friends[*mn].begin(); frnd != friends[*mn].end(); ++frnd) {
            if (belong[*frnd] == -1) {
              nex.push_back(*frnd);
              V.push_back(*frnd);
              belong[*frnd] = Vnum;
            }
          }
        }
      }
      frnV.push_back(V);
      Vnum++;
    }
  }

  for (int i = 1; i <= N; ++i) {
    int recN = frnV[belong[i]].size() - friends[i].size() - 1;
    for (auto blkd = blocked[i].begin(); blkd != blocked[i].end(); ++blkd) {
      if (belong[i] == belong[*blkd]) {
        recN--;
      }
    }

    cout << recN << (i != N ? " " : "\n");
  }

  return 0;
}

Measured memory_bytes: 14464
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        for(int i = 0; i < M; i++){
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }
        sc.close();
        if(min(R) - max(L) < 0)
            System.out.println(0);
        else   
            System.out.println(min(R) - max(L) + 1);
    }

    static int min(int[] l){
        int min = l[0];
        for(int i = 0; i < l.length; i++){
            if(l[i] < min)
                min = l[i];
        }
        return min;
    }
    static int max(int[] r){
        int max = r[0];
        for(int i = 0; i < r.length; i++){
            if(r[i] > max)
                max = r[i];
        }
        return max;
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
inline int in() { int x; cin >> x; return x; }

int cnt;
vector<bool> seen;
vector<bool> watch;
vector<int> member;
vector<int> F[100100];
vector<int> B[100100];
int answer[100100];
void dfs(int v) {
  if (!seen[v]) {
    cnt++;
    member.push_back(v);
  }
  seen[v] = true;
  watch[v] = true;
  for (auto next_v : F[v]) if (!seen[next_v]) dfs(next_v);
}

int main(){
  int N = in(), M = in(), K = in();
  watch.assign(N,false);
  REP(i,M+K) {
    int a = in()-1, b = in()-1;
    if (i<M) {
      F[a].push_back(b);
      F[b].push_back(a);
    }
    B[a].push_back(b);
    B[b].push_back(a);
  }
  REP(i,N) {
    if (watch[i]) continue;
    cnt = 0;
    seen.assign(N,false);
    member.assign(0,0);
    dfs(i);
    REP(j,cnt) {
      int exclude = 0;
      int mj = member[j];
      REP(l,B[mj].size()) if (seen[B[mj][l]]) exclude++;
      answer[mj] = cnt - exclude - 1;
    }
  }
  REP(i,N) cout << answer[i] << endl;
}


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

int main(void){
  long long a,b;
  int k;
  
  cin >> a >> b >> k;
  for (int i=0; i<k; i++){
    int x,y;
    x = a; y = b;
    a = x/2;
    b = x/2 + y;
    if (++i>=k) break;
    x = a; y = b;
    a = x + y/2;
    b = y/2;
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,i;
  char s[101];
  cin>>a;
  for(i=0;i<a;i++){
    cin>>s[i];
    if(s[i]=='Y'){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
}

Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define endl 			"\n"
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(10);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k - 1] += 32;
	cout << s;

	return 0;
}

Measured memory_bytes: 3672
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(a: int, b: int, h: int):
    print(h*(a+b)//2)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    h = int(next(tokens))  # type: int
    solve(a, b, h)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,a,b; cin >>n>>a>>b;

    int res = min(n*a, b);
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
"use strict";

class Dice {
    /**
     *    +--+
     *    |0 |
     * +--+--+--+--+
     * |3 |1 |2 |4 |
     * +--+--+--+--+
     *    |5 |
     *    +--+
     */
    constructor(stat) {
        this.stat = stat;
    }

    rot_ns(val) {
        if (val < 0) val += 4 * Math.floor(-val / 4) + 4;
        const old_i = [0, 1, 5, 4];
        const new_i = [val, val + 1, val + 2, val + 3].map(elt => old_i[elt % 4]);
        [this.stat[old_i[0]], this.stat[old_i[1]], this.stat[old_i[2]], this.stat[old_i[3]]] =
            [this.stat[new_i[0]], this.stat[new_i[1]], this.stat[new_i[2]], this.stat[new_i[3]]];
    }

    rot_we(val) {
        if (val < 0) val += 4 * Math.floor(-val / 4) + 4;
        const old_i = [0, 2, 5, 3];
        const new_i = [val, val + 1, val + 2, val + 3].map(elt => old_i[elt % 4]);
        [this.stat[old_i[0]], this.stat[old_i[1]], this.stat[old_i[2]], this.stat[old_i[3]]] =
            [this.stat[new_i[0]], this.stat[new_i[1]], this.stat[new_i[2]], this.stat[new_i[3]]];
    }
}


new Promise(function (resolve, reject) {
    let content = "";
    process.stdin.on("data", chunk => { content += chunk; });
    process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
    const [init, command] = cin.split("\n").slice(0, 2);
    const dice = new Dice(init.split(" ").map(elt => parseInt(elt)));
    for (const ch of command) {
        switch (ch) {
            case "N": dice.rot_ns(1); break;
            case "S": dice.rot_ns(-1); break;
            case "W": dice.rot_we(1); break;
            case "E": dice.rot_we(-1); break;
        }
    }
    cout.write(`${dice.stat[0]}\n`);
});



Measured memory_bytes: 16252
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<stack>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int A(int a, int b) {
	int get = 1;
	for (int i = 1; i <= a; i++) {
		get *= b;
		b--;
	}
	return get;
}

int C(int a, int b) {
	return (int)A(a, b) / A(a, a);
}

int main() {
	int N, a[10];
	cin >> N;
	int i, j, k;
	for (i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0)
			a[i] = 1;
		else
			a[i] = 2;
	}
	int num = 0;
	for (i = 0; i < N; i++) {
		int get = 1;
		for (j = 0; j < i; j++) {
			get *= C(1, 3 - a[j]);
		}
		get *= C(1, a[i]);
		for (j = i+1; j < N; j++) {
			get *= C(1, 3);
		}
		num += get;
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char X, Y;
	cin >> X >> Y;
	if (X < Y) {
		cout << "<";
	}
	if (X > Y) {
		cout << ">";
	}
	if (X == Y) {
		cout << "=";
	}
    return 0;
}

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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a < b) {
		cout << (a < c && c < b ? "Yes" : "No") << endl;
	}
	else {
		cout << (b < c && c < a ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  for(int i=0;i<min(s.size(),t.size());i++){
    if(s.at(i)<t.at(i)){
      cout << "Yes" << endl;
      return 0;
    }
    else if(s.at(i)>t.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.size()<t.size()) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> height(n);
  for(int i = 0; i < n; ++i) cin >> height[i];
  for(int i = n - 1; i > 0; --i){
    if(height[i] >= height[i - 1])continue;
    if(height[i] >= height[i - 1] - 1){
      height[i - 1]--;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline

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

def S(n):
    return 2**(n+2)-3
def P(n):
    return 2**(n+1)-1

def count(n,x):
    if n == 0:
        return P(0)
    else:
        if x == 1:
            return 0
        if 1 < x <= S(n-1)+1:
            return count(n-1,x-1) 
        if x == S(n-1)+2:
            return 1 + count(n-1,x-2)
        if S(n-1)+2 < x <= 2*S(n-1)+2:
            return P(n-1) + 1 + count(n-1,x-2-S(n-1))
        else:
            return P(n-1) + 1 + count(n-1,x-3-S(n-1))

print(count(N,X))

Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>
int main ()
{
	long n;
	long a;
	while(scanf("%d",&n)!=EOF)
	{
		for(; n >= 0;n--)
		{
			a = sqrt(n);
			if(n == a * a)
			{
				printf("%d\n",n);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
// https://beta.atcoder.jp/contests/abc070
// status:
// tag: [BFS]

#define SUBMIT
//#define DEBUG

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

const int MAX_N = 100000;
vector<int> adj[MAX_N + 1];
i64 d[MAX_N + 1];
bool done[MAX_N + 1];
map<pair<int, int>, i64> cost;
int N, Q, K;

void bfs(int s) {
    queue<int> q;
    q.push(s);
    done[s] = true;

    while (!q.empty()) {
        auto u = q.front(); q.pop();
        for (auto v : adj[u]) {
            if (done[v]) continue;

            d[v] = d[u] + cost[make_pair(u, v)];
            q.push(v);
            done[v] = true;
        }
    }
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(5
1 2 1
2 3 2
1 4 3
4 5 4
2 5
3 4
1 3
)");
#endif
    stream >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        i64 c;
        stream >> a >> b >> c;
        adj[a].push_back(b);
        adj[b].push_back(a);
        cost[make_pair(a, b)] = c;
        cost[make_pair(b, a)] = c;
    }

    stream >> Q >> K;
    bfs(K);

    for (int q = 0; q < Q; ++q) {
        int x, y;
        stream >> x >> y;
        auto ans = d[x] + d[y];
        cout << ans << endl;
    }
#ifdef DEBUG
    cout << "floyd" << endl;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            cout << d[y][x] << " ";
        }
        cout << endl;
    }

    cout << "input" << endl;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            cout << A[y][x] << " ";
        }
        cout << endl;
    }
#endif
    return 0;
}

Measured memory_bytes: 20700
#include<bits/stdc++.h>
using namespace std;
struct node
{
    string s;
    int n,ord;
    friend bool operator <(const node a,const node b)
    {
        if(a.s!=b.s) return a.s<b.s;
        else return a.n>b.n;

    }
}f[105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
       cin>>f[i].s;
       scanf("%d",&f[i].n);
       f[i].ord=i;
    }
    sort(f+1,f+1+n);
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",f[i].ord);
    }



    return 0;
}



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

using namespace std;

int p[1000001]={0},prime[1000001]={0};

int main()
{
    int n;
    cin>>n;
    int a[n],hcf=0,setwiseprime=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        hcf=__gcd(a[i],hcf);
        p[a[i]]++;
    }
    if(hcf!=1) cout<<"not coprime";
    else
    {
        for(int i=2,count=0;i<1000001;i++,count=0)
        {
            if(prime[i]) continue;
            for(int j=i;j<1000001;j+=i)
            {
                if(p[j]) count++;
                prime[j]++;
            }
            if(count>1){ setwiseprime=1; break; }
        }
        if(setwiseprime) cout<<"setwise coprime";
        else cout<<"pairwise coprime";
    }
}


Measured memory_bytes: 15272
// abc100_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;
    REP(i, N){
        int a = A[i];
        while (a % 2 == 0) {a >>= 1; ans++;}
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<vector>
#include<queue>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>
#include <bitset>
#include<ctime>

using namespace std;

int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<vector<int>>vii;
typedef vector<vector<char>>vvc;
typedef vector<vector<ll>>vll;
typedef vector< pair<ll, ll>>vpll;
typedef vector< pair<ld, ld>>vpld;
typedef vector< pair<int, int>>vpi;
typedef pair<ld, ld>pld;
#define mp make_pair
#define pb push_back

int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}
int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}
int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}
int ibit(int n, int i)
{
	return ((n >> i) & 1);
}
void outp(vii &ou)
{
	for (int i = 0; i < ou.size(); i++)
	{
		for (int j = 0; j < ou[i].size(); j++)
		{
			cout << ou[i][j] << ' ';
		}
		cout << '\n';
	}
}
int bp(int x, int y)
{
	if (y == 0)
	{
		return 1;
	}
	int a = 0;
	if (!(y % 2))
	{
		a = bp(x, y / 2);
	}
	return (y % 2) ? mlt(bp(x, y - 1), x) : mlt(a, a);
}
int obr(int x)
{
	return bp(x, mod - 2);
}
const int maxn = 200007;
int fact[1000007], ofact[1000007];
vii del(maxn), alldivs(maxn);
vi maxpr(maxn);
vi mu(maxn), sqf(maxn, 1);
void prec()
{
	fact[0] = 1;
	ofact[0] = 1;
	for (int i = 1; i < maxn; i++)
	{
		fact[i] = mlt(fact[i - 1], i);
	}
	//cerr << "sdsds" << endl;
	ofact[maxn - 1] = obr(fact[maxn - 1]);
	for (int i = maxn - 2; i > 0; i--)
	{
		ofact[i] = mlt(ofact[i + 1], i + 1);
	}
}
int c(int a, int b)
{
	return ((a <= b) && (a >= 0)) ? mlt(fact[b], mlt(ofact[a], ofact[b - a])) : 0;
}
ll gcd(ll x, ll y)
{
	//cerr << x << y << endl;
	if (x == 0)return y;
	return(x > y) ? gcd(y, x) : gcd(y%x, x);
}
vector<int>obrs;
int ans(int ones, int twos, int threes, int n)
{
	int cur = fact[ones+twos+threes+2];
	cur = mlt(cur, obrs[ones + 1]);
	cur = mlt(cur, obrs[twos+ones+2]);
	cur = mlt(cur, fact[twos+threes+1]);
	cur = mlt(cur, obrs[twos+1]);
	cur = mlt(cur, fact[threes]);
	cur = obr(cur);
	cur = mlt(cur, fact[n]);
	cur = mlt(cur, cur);
	return cur;
}
int main()
{
	int n;
	cin >> n >> mod;
	prec();
	//obrs.resize(2228);
	n *= 3;
	vii dp(3, vi(2 * n + 12));
	vi newdp(2 * n + 12);
	dp[0][n] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int bal = -n; bal <= n; bal++)
		{
			newdp[bal + n] = 0;
			if (i >= 1)newdp[bal + n] = sum(newdp[bal + n], dp[(i + 2) % 3][max(0, bal + n - 1)]);
			if (i >= 2)newdp[bal + n] = sum(newdp[bal + n], mlt(dp[(i + 1) % 3][min(2*n+10, bal + n +1)], i-1));
			if (i >= 3)newdp[bal + n] = sum(newdp[bal + n], mlt((i-2)*(i-1),dp[i% 3][bal+n]));
		//	cerr << "ibal " << i << ' ' << bal << ' ' << newdp[bal + n] << endl;
		}
		dp[i % 3] = newdp;
	}
	int summ = 0;
	for (int bal = 0; bal <= n; bal++)summ = sum(dp[0][bal + n], summ);
	cout << summ << endl;
	cin >> n;
}

Measured memory_bytes: 19072
def cntDiv(n):
    cnt = 0
    while n % 2 == 0:
        n /= 2
        cnt += 1
    return cnt


n = int(input())
res = 1
cnt = 0
for i in range(1, n + 1):
    tmp = cntDiv(i)
    if cnt < tmp:
        cnt = tmp
        res = i
print(res)


Measured memory_bytes: 3060
local s = io.read()
local k = io.read("*n")
local n = #s
s = s .. s
local t = {}
for i = 1, 2 * n do
  t[i] = s:sub(i, i)
end
local spos = 1
for i = 1, n - 1 do
  if t[i] ~= t[i + 1] then
    spos = i + 1
    break
  end
end
if spos == 1 then
  print(math.floor(n * k / 2))
else
  local edgelen = spos - 1
  local epos = n
  local ecnt = 0
  for i = n, 1, -1 do
    if t[1] == t[i] then
      ecnt = ecnt + 1
    else
      epos = i
      break
    end
  end
  edgelen = edgelen + ecnt
  local intcost = 0
  local len = 1
  for i = spos + 1, epos do
    if t[i] == t[i - 1] then
      len = len + 1
      if len % 2 == 0 then
        intcost = intcost + 1
      end
    else
      len = 1
    end
    -- print(i, len)
  end
  local edgecost = math.floor(edgelen / 2)
  -- print(intcost)
  -- print(intcost * k + edgecost * (k - 1))
  -- print(edgecost)
  -- print(intcost * k, edgecost * (k - 1),  math.floor((spos - 1) / 2) , math.floor(ecnt / 2))
  print(intcost * k + edgecost * (k - 1) + math.floor((spos - 1) / 2) + math.floor(ecnt / 2))
end
--  8999939997
-- 11999919996


Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int i;
	char a[100];
	scanf("%s", a,100);
	for(i = 0; i < 100; i++) {
		if (a[i] == '\0') {
			break;
		}
	}
	printf("%c%d%c", a[0], i - 2, a[i - 1]);
    return 0;
}


Measured memory_bytes: 128