akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

using PQ = priority_queue<ll, vector<ll>, greater<ll>>;

signed main() {
  ios::sync_with_stdio(false);
  ll n, k, q;
  cin >> n >> k >> q;
  vector<ll> a(n);
  vector<ll> b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) b[i] = a[i];
  PQ p;
  vector<ll> s;
  sort(all(b));
  ll ans = 1e9;
  REP(i, n - k + 1) {
    if(i > 0 && b[i-1] == b[i]) continue;
    p = PQ();
    s.clear();
    REP(j, n) {
      if(a[j] < b[i]) {
        while(p.size() >= k) {
          s.push_back(p.top());
          p.pop();
        }
        p = PQ();
      }
      else {
        p.push(a[j]);
      }
    }
    while(p.size() >= k) {
      s.push_back(p.top());
      p.pop();
    }
    if(s.size() < q) continue;
    sort(all(s));
    ans = min(ans, s[q-1] - s[0]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> mp;
    int cnt=0;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    set<pair<ll,pair<ll,ll>>> s;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]==a[j]||a[i]==a[k]||a[k]==a[j]) continue;
                if(a[i]+a[j]>a[k]&&a[k]+a[i]>a[j]&&a[k]+a[j]>a[i]){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int ans;
int a, b;

void solve(int i, int _b, int sum){
	if (sum == a && _b == 0){
		ans++;
		return;
	}
	if (_b == 0 || i == 10)return;
	if (i != -1)
		solve(i + 1, _b - 1, sum + i);
	solve(i + 1, _b, sum);
}

int main(){
	while (cin >> b >> a, a||b){
		ans = 0;
		solve(-1, b, 0);
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    const MOD: usize = 1000_000_007;

    let all = mod_pow(10 as i64, n as i64, MOD as i64);
    let complement = mod_pow(8 as i64, n as i64, MOD as i64);
    let nonzero = mod_pow(9 as i64, n as i64, MOD as i64);
    let x = if nonzero - complement < 0 {
        nonzero - complement + MOD as i64
    } else {
        nonzero - complement
    };
    let x = x * 2 % MOD as i64;
    let rest = if all - complement < 0 {
         all - complement + MOD as i64
    } else {
         all - complement
    };

    let ans = if rest - x < 0 {
        rest - x+ MOD as i64
    } else {
        rest - x
    };
    println!("{}", ans);
}

fn mod_pow(x: i64, n: i64, modulo: i64) -> i64 {
    let mut n = n;
    let mut x = x;
    let mut ret = 1;
    while n > 0 {
        if n & 1 == 1 {
            ret = ret * x % modulo;
        }
        x = x * x % modulo;
        n >>= 1;
    }
    ret
}

struct Combination {
    fac: Vec<usize>,
    finv: Vec<usize>,
    modulo: usize,
}

impl Combination {
    fn new(max_n: usize, modulo: usize) -> Combination {
        let mut fac = vec![0; max_n];
        let mut finv = vec![0; max_n];
        let mut inv = vec![0; max_n];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..max_n {
            fac[i] = fac[i - 1] * i % modulo;
            inv[i] = modulo - inv[modulo % i] * (modulo / i) % modulo;
            finv[i] = finv[i - 1] * inv[i] % modulo;
        }
        Combination {
            fac: fac,
            finv: finv,
            modulo: modulo,
        }
    }

    fn get(&self, n: usize, k: usize) -> usize {
        assert!(n >= k);
        self.fac[n] * (self.finv[k] * self.finv[n - k] % self.modulo) % self.modulo
    }

    #[allow(dead_code)]
    fn h(&self, n: usize, k: usize) -> usize {
        self.get(n + k - 1, k)
    }

    #[allow(dead_code)]
    fn p(&self, n: usize, k: usize) -> usize {
        assert!(n >= k);
        self.fac[n] * self.finv[n - k]
    }
}


Measured memory_bytes: 2164
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    V = li_input()
    C = li_input()

    ans = 0

    for i in range(N):
        ans += max(0, V[i] - C[i])

    print(ans)


main()


Measured memory_bytes: 5108
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int n, W;
ll dp[105][100020];

int main(int argc, char const *argv[]) {
    cin >> n >> W;
    vector<ll> w(n);
    vector<ll> v(n);
    for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];
    REP(i,n) REP(j,100010) dp[i][j] = LINF;
    REP(i,n) dp[i][0] = 0;
    REP(i,n) REP(j,100010) {
        dp[i+1][j] = dp[i][j];
        if (j-v[i] < 0) continue;
        else dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i][j]);
    }
    ll ans = 0;
    for (ll i = 0; i < 100010; ++i) {
        if (dp[n][i] > W) continue;
        else ans = max(ans, i);
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 80128
n=gets.to_i
ab=$<.map{|s|s.split.map &:to_i}
a=ab.map{|a,b|a}.sort
b=ab.map{|a,b|b}.sort
if n%2==1
p b[n/2]-a[n/2]+1
else
p (b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2])+1
end

Measured memory_bytes: 34660
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	for i := 0; i <= 25; i++ {
		for j := 0; j <= 14; j++ {
			if N-((4*i)+(7*j)) == 0 {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}


Measured memory_bytes: 640
n,m=map(int,input().split())

l=[0]*n
w=0
c=0
ac=set()

for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=='WA':
    l[p-1]+=1
  else:
    if p not in ac:
      c+=1
      w+=l[p-1]
      ac.add(p)

print(c,w)


Measured memory_bytes: 18012
#include<stdio.h>
int main()
{
  int n,d,x,nb=0,eaten=0;
  scanf("%d %d %d",&n,&d,&x);
  int a[n];
  while(nb<n)
  {
    scanf("%d",&a[nb]);
    nb++;
  }
  nb=0;
  while(nb<n)
  {
    eaten+=((((d-1)-((d-1)%a[nb]))/a[nb])+1);
    nb++;
  }
  printf("%d",x+eaten);
  return 0;
}

Measured memory_bytes: 128
// Code for D - Friends
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> size; // size[i]: i の属するグループのサイズ

  UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
    for(int i = 0; i < N; i++) size[i] = 1;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    size[ry] += size[rx];
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(M), B(M);
  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }

  UnionFind u(N);

  REP(i, M) {
    u.unite(A[i], B[i]);
  }

  int m = 0;
  REP(i, N) {
    if (m < u.size[i]) {
      m = u.size[i];
    }
  }

  cout << m << endl;
  return 0;
}


Measured memory_bytes: 6420
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let d: usize = read();
    let mut y: Vec<Vec<i64>> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut x = Vec::with_capacity(d);
        for _ in 0..d {
            x.push(read());
        }
        y.push(x)
    }
    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let dist = (0..d).into_iter().fold(0, |a, k| a + (y[i][k] - y[j][k]).pow(2));
            for k in 0..((dist as f64).sqrt() as u64 + 1) {
                if k * k == dist as u64 {
                    //println!("{}, {}", i, j);
                    ans += 1;
                    break;
                }
            }
        }
    }
    println!("{}", ans / 2);
}


Measured memory_bytes: 4352
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  reps(t,max(1,a[0]-1),min(n,a[0]+1)+1){
    int sing=0;
    int mult=0;
    int ok=1;
    for(int x:a){
      if(x==t) ++mult;
      else if(x+1==t) ++sing;
      else ok=0;
    }
    if(sing+!!mult <= t && t <= sing+mult/2);
    else ok=0;
    if(ok){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vector<string> s1(n),s2(n);
  vector<string> v(3),ans(2);
  v[0]="kougekida";
  v[1]="tameru";
  v[2]="mamoru";
  ans[0]="Isono-kun";
  ans[1]="Nakajima-kun";
  rep(i,n)cin>>s1[i];
  rep(i,n)cin>>s2[i];
  int a=0,b=0;
  rep(i,n){
    if(s1[i]==v[0] && s2[i]==v[0]){
      if(a==b)a=b=0;
      else{
	if(a<b)cout<<ans[1]<<endl;
	else cout<<ans[0]<<endl;
	return 0;
      }
    }
    if(s1[i]==v[0] && s2[i]==v[1]){
      if(a==0)cout<<ans[1]<<endl;
      else cout<<ans[0]<<endl;
      return 0;
    }
    if(s1[i]==v[0] && s2[i]==v[2]){    
      if(a>=5 || a==0){
	if(a)cout<<ans[0]<<endl;
	else cout<<ans[1]<<endl;
	return 0;
      }else{
	a=0;
      }
    }
    if(s1[i]==v[1] && s2[i]==v[0]){
      if(b) cout<<ans[1]<<endl;
      else cout<<ans[0]<<endl;
      return 0;
    }
    if(s1[i]==v[1] && s2[i]==v[1]){
      a=min(5,a+1);
      b=min(5,b+1);
    }
    if(s1[i]==v[1] && s2[i]==v[2]){
      a=min(5,a+1);
    }
    if(s1[i]==v[2] && s2[i]==v[0]){
      if(b>=5 || b==0){
	if(b)cout<<ans[1]<<endl;
	else cout<<ans[0]<<endl;
        return 0;
      }else{
        b=0;
      } 
    }
    if(s1[i]==v[2] && s2[i]==v[1]){
      b=min(5,b+1);
    }
  }
  cout<<"Hikiwake-kun"<<endl;
}

Measured memory_bytes: 3236
/////////////////////    答案    /////////////// 
/*
注意点：
1. 
*/
//----------------------自打1------------------ 

//---------------------标准答案--------------------

//////////////////////////      一      //////////////
/*
注意点：
1. 
*/
//------------------1z-------------- 

//-----------------------------------------分界线----------------------------------------------- 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//指定了间隔g的插入排序 
void insertionSort(int A[],int n,int g){
	for(int i=g;i<n;++i){
		int V=A[i];
		int j=i-g; 
		while(j>=0&&A[j]>V){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=V;
	}
}

void shellSort(int A[],int n){
	//生成数列G={1，4，13，40，121，364，1093，...} 
	for(int h=1;;){
		if(h>n) break;
		G.push_back(h);
		h=3*h+1;
	}
	
	for(int i=G.size()-1;i>=0;i--){//按逆序指定G[i]=g 
		insertionSort(A,n,G[i]);
	}
}

int main(){
	cin>>n;
	//使用速度更快的scanf函数进行输入 
	for(int i=0;i<n;++i) scanf("%d",&A[i]);
	cnt=0;
	 
	shellSort(A,n);
	
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--){
		printf("%d",G[i]);
		if(i) printf(" ");
	} 
	printf("\n");
	printf("%d\n",cnt);
	for(int i=0;i<n;++i) printf("%d\n",A[i]);
	
	return 0;
} 


Measured memory_bytes: 7172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BUnhappyHackingABCEdit solver = new BUnhappyHackingABCEdit();
        solver.solve(1, in, out);
        out.close();
    }

    static class BUnhappyHackingABCEdit {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String s = in.string();
            StringBuilder d = new StringBuilder();
            for (char c : s.toCharArray()) {
                switch (c) {
                    case '0':
                        d.append("0");
                        break;
                    case '1':
                        d.append("1");
                        break;
                    case 'B':
                        if (d.length() > 0) {
                            d.setLength(d.length() - 1);
                            d.trimToSize();
                        }
                        break;
                }
            }
            out.println(d);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

    }
}



Measured memory_bytes: 22356
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long circle = sc.nextLong();
        ArrayList<Sushi> sushi = new ArrayList<Sushi>();
        long[] clockwise = new long[n+1];
        long[] clockwise2 = new long[n+1];
        long[] reversewise = new long[n+1];
        long[] reversewise2 = new long[n+1];
        for(int i = 0 ; i < n; i++){
            long d = sc.nextLong();
            long c = sc.nextLong();
            Sushi s = new Sushi(d,c);
            long pd = i != 0 ? sushi.get(i-1).d : 0;
            clockwise[i+1] = clockwise[i]+c+pd-d;
            clockwise2[i+1] = clockwise2[i]+c-2*(d-pd);
            sushi.add(s);
        }
        for(int i = 0; i < n; i++){
            long pd = i != 0 ? circle-sushi.get(n-i).d: 0;
            Sushi s = sushi.get(n-1-i);
            reversewise[i+1] = reversewise[i]+s.c+pd-(circle-s.d);
            reversewise2[i+1] = reversewise2[i]+s.c-2*(circle-s.d-pd);
        }
        for(int i = 1; i < n; i++){
            clockwise[i+1] = Math.max(clockwise[i],clockwise[i+1]);
            clockwise2[i+1] = Math.max(clockwise2[i],clockwise2[i+1]);
            reversewise[i+1] = Math.max(reversewise[i],reversewise[i+1]);
            reversewise2[i+1] = Math.max(reversewise2[i],reversewise2[i+1]);
        }
        long ans = 0;
        for(int i = 0; i <= n; i++){
            ans = Math.max(ans,clockwise[i]+reversewise2[n-i]);
            ans = Math.max(ans,reversewise[i]+clockwise2[n-i]);
        }
        System.out.println(ans);
    }
}

class Sushi{
    long d,c;
    public Sushi(long d, long c){
        this.d = d;
        this.c = c;
    }
}


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

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
long long N=1e+5;

void solve()
{
    int n;
    cin>>n;

    vector<int>v(n+1,0);
    for(int i=1; i<=sqrt(n); i++)
    {
        for(int j=1; j<=sqrt(n); j++)
        {
            for(int k=1; k<=sqrt(n); k++)
            {
                int t=(i*i+j*j+k*k+i*j+i*k+j*k);
                if(t<=n)
                {
                    v[t]++;
                }
            }
        }
    }

    for(int i=1; i<=n; i++)
    {
        cout<<v[i]<<endl;
    }
}

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


Measured memory_bytes: 3580
l, r = map(int, input().split())
MOD = 2019

if r - l > 2019:
    print(0)
    exit()
    
ans = 2020
for i in range(l, r + 1):
    for j in range(l, r + 1):
        if i == j:
            continue
        ans = min(ans, (i * j) % MOD)
print(ans)

Measured memory_bytes: 41692
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
static const double EPS = 1e-5;
int main(){
    int N,M;
    cin >> N >> M;
    int ans = 1;
    // ans <= M/N
    if( N >= 100 ){
        int upperbound = M/N;
        for(int i = 1 ; i <= upperbound ; i++){
            if( M%i == 0 ) ans=max(ans,i);
        }
        cout << ans << endl;
    }
    else{
        for(int i = N; i <= 1000000; i++){
            if( M%i == 0 ){
                cout << M/i<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    vector<ll> ones(64, 0);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        for (ll j = 0; j < 63; ++j) {
            if ((a[i] & (1ll<<j)) == 1ll<<j) {
                ones[j]++;
            }
        }
    }
    ll sum = 0;
    for (ll i = 0; i < 64; ++i) {
        ll mul = 1ll<<i;
        sum += ((((n - ones[i]) * ones[i]) %M) * (mul % M)   )%M;
        sum %= M;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut s = read::<i64>();
    let mut ans = (s / 500) * 1000;
    s %= 500;
    ans += (s / 5) * 5;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import sys
n, a, b = [int(i) - 1 for i in sys.stdin.readline().split()]
if (a - b) % 2 == 0:
    print((b - a) // 2)
else:
    if n - b > a:
        print(a + 1 + (b - a - 1) // 2)
    else:
        print(n - b + 1 + (b - a - 1) // 2)

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

int main(){
	int n,k,x,y,fee=0,i;
  
  	cin >> n >> k >> x >> y;
  	for(i=1;i<=n;i++){
    	if(i<=k)fee+=x;
      	else fee+=y;
    }
  
  cout << fee;
  
  return 0;
}

Measured memory_bytes: 384
N=int(input())

ac=0
wa=0
tle=0
re=0

for i in range(N):
  x=input()
  if x=="AC":
    ac+=1
  if x=="WA":
    wa+=1
  if x=="TLE":
    tle+=1
  if x=="RE":
    re+=1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 9204
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a;
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s1, s2;
	ll n;
	cin >> n;
	cin >> s1 >> s2;
	string s3="",ans ="i";
	f(i, 0, n)
	{
		ans[0] = s1[i];
		s3 += ans;
		ans[0] = s2[i];
		s3 += ans;
	}
	cout << s3;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import os

n,k = [int(i) for i in input().split(' ')]
h = [int(i) for i in input().split(' ')]

hs = sorted(h)

s = 0

for i in range(n):
    if hs[i] >= k:
        break
    else:
        s += 1

print(n - s)

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#pragma GCC optmize("03")
#define boost ios::sync_with_stdio(); cin.tie(); cout.tie();
using namespace std;
typedef long long ll;
void solve()
{
    string s,t;
    cin >> s >> t;
    int ans =0;
    for(int i =0;i < s.size(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans;
}

int main()
{
    boost
    //int t; cin >> t; while(t--)
    solve();
}

Measured memory_bytes: 3924
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e5+10;
const int MAXM = (int) 1e5+10;

///--------------------START-------------------------
int n;
char s[MAXN],t[MAXN];
LL dp[MAXN][2];

void work(){
    scanf("%d",&n);
    scanf("%s%s",s+1,t+1);
    memset(dp,0,sizeof(dp));
    if(n==1) printf("3\n");
    else if(n==2) printf("6\n");
    else{
        int st;
        if(s[1]==t[1]){
            dp[1][0]=3;
            st=2;
        }
        else{
            dp[2][1]=6;
            st=3;
        }
        s[n+1]='$';
        t[n+1]='@';
        for(int i=st;i<=n;i++){
            if(s[i]==t[i]){
                dp[i][0]=(dp[i-1][0]*2+dp[i-1][1])%MOD;
                dp[i][1]=0;
            }
            else{
                dp[i][0]=0;
                dp[i][1]=(dp[i-1][0]*2+dp[i-1][1]*3)%MOD;
                i++;
                dp[i][0]=dp[i-1][0];
                dp[i][1]=dp[i-1][1];
            }
//            printf("%d : %lld %lld\n",i,dp[i][0],dp[i][1]);
        }
        printf("%lld\n",(dp[n][0]+dp[n][1])%MOD);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}







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

using namespace std;

struct Edge {
    int a, b;
    long long c;
    long long d;
    Edge() {}
    friend istream& operator>>(istream& in, Edge& e) {
        in >> e.a >> e.b >> e.c;
        --e.a;
        --e.b;
        e.d = numeric_limits<long long>::max();
        return in;
    }
    bool operator<(const Edge& e) const {
        return d > e.d;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    int m;
    cin >> N >> m;
    vector<vector<Edge>> edges(N);
    for (int i = 0; i < m; ++i) {
        Edge e;
        cin >> e;
        edges[e.a].push_back(e);
    }
    vector<long long> dists(N, numeric_limits<long long>::max());
    priority_queue<Edge> pq;
    int until = 0;
    auto set_dist = [&](long long d) {
        dists[until] = d;
        for (auto edge : edges[until]) {
            edge.d = d + edge.c;
            pq.push(edge);
        }
        ++until;
    };
    set_dist(0);
    while (!pq.empty()) {
        auto edge = pq.top();
        pq.pop();
        while (until <= edge.b) {
            set_dist(edge.d);
        }
    }
    if (until < N) {
        cout << -1 << endl;
    } else {
        cout << dists[N-1] << endl;
    }
    return 0;
}


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

int main(){
	ll q, ans = 0;cin >> q;
	priority_queue<ll> s;
	priority_queue<ll, vector<ll>, greater<ll>> l;
	for(ll _ = 0;_ < q;++_){
		ll t;cin >> t;
		if(t == 1){
			ll a, b;cin >> a >> b;
			ans += b;
			s.push(a);
			l.push(a);
			ll x = s.top();s.pop();
			ll y = l.top();l.pop();
			if(x > y){
				ans += x - y;
				swap(x, y);
			}
			s.push(x);
			l.push(y);
		}
		else {
			cout << s.top() << " " << ans << endl;
		}
	}
}


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

int main(){
    int n;
    cin >> n;
    map<string, int>total_res;
    string res[] = {"AC", "WA", "TLE", "RE"};
    /*
    total_res["AC"] = 0;
    total_res["WA"] = 0;
    total_res["TLE"] = 0;
    total_res["RE"] = 0;
    */
    for(int i = 0; i < n; i++){
        string temp;
        cin >> temp;
        ++total_res[temp];
    }
    cout<<"AC x "<<total_res["AC"]<<endl;
    cout<<"WA x "<<total_res["WA"]<<endl;
    cout<<"TLE x "<<total_res["TLE"]<<endl;
    cout<<"RE x "<<total_res["RE"]<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
const int N=100005;
int n, mod, topo[N], cnt, par[N], dp[N], dp1[N], a[N], b[N], id[N];
vector <int > g[N];

void DFS(int u) {
    topo[++cnt]=u;
    for(int v:g[u]) {
        if(v==par[u]) continue;
        par[v]=u;
        DFS(v);
    }
}

void xuli() {
    for(int i=n ; i ; --i) {
        int u=topo[i];
        dp[u]=1;
        for(int v:g[u]) {
            if(par[v]!=u) continue;
            dp[u]=(1ll*dp[u]*(dp[v]+1))%mod;
        }
    }

    dp1[1]=1;
    rep(i, 1, n) {
        int u=topo[i], dem=0;
        for(int v:g[u]) {
            if(par[v]!=u) continue;
            a[++dem]=dp[v]+1;
            b[dem]=dp[v]+1;
            id[dem]=v;
        }
        a[0]=1, b[dem+1]=1;
        rep(i, 1, dem) {
            a[i]=(1ll*a[i]*a[i-1])%mod;
        }
        for(int i=dem ; i ; --i) {
            b[i]=(1ll*b[i]*b[i+1])%mod;
        }
        rep(i, 1, dem) {
            int v=id[i];
            dp1[v]=dp1[u];
            dp1[v]=(1ll*dp1[v]*a[i-1])%mod;
            dp1[v]=(1ll*dp1[v]*b[i+1])%mod;
            dp1[v]=(dp1[v]+1)%mod;
        }
    }

    rep(i, 1, n) {
        int ans=(1ll*dp1[i]*dp[i])%mod;
        cout << ans << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> mod;
    rep(i, 2, n) {
        int u, v; cin >> u >> v;
        g[u].PB(v); g[v].PB(u);
    }
    DFS(1);
    xuli();
    return 0;
}


Measured memory_bytes: 12800
import math
from collections import defaultdict

N = int(input())
D = defaultdict(int)

NN = math.floor(math.sqrt(N))
for x in range(1,NN+1):
    for y in range(1,NN+1):
        for z in range(1,NN+1):
            a = x * x + y * y + z * z + x * y + y * z + z * x
            if a <= N:
                D[a] += 1

for i in range(1,N+1):
    print(D[i])

Measured memory_bytes: 76080
x = input()
a = b = c = 1
for i in range(3):
    if x[i] == 'a':
        a -= 1
    elif x[i] == 'b':
        b -= 1
    else:
        c -= 1
if a == 0 and b == 0 and c == 0: 
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 1e5 + 10;

int dp[MAXN][10][2][2];
vector<int> x;
int k;

int rec(int idx,int prev,int tight,int begin){
    if(idx < 0) return begin;

    int &ans = dp[idx][prev][tight][begin];

    if(ans != -1) return ans;

    ans = 0;
    if(begin == 0) ans = ans + rec(idx-1,prev,0,begin);

    int high = x[idx];
    if(tight == 0) high = 9;
    int s = 0; 
    if(begin == 0) s = 1;
    
    FOR(d,s,high){
        if(abs(prev-d) <= 1 || begin == 0){
            int n_t = tight;
            if(d < x[idx]) n_t = 0;
            ans = ans + rec(idx-1,d,n_t,1);
        }
    }

    return ans;
}

void solve(){
    cin>>k;

    int s = 1,e = 1e12;
    int ans = e;

    while(s <= e){
        int mid = (s+e)>>1;
        int val = mid;
        x.clear();
        while(val != 0){
            x.push_back(val%10);
            val /= 10;
        }
        MINUS(dp);

        int cnt = rec(sz(x)-1,0,1,0);
        if(cnt >= k) ans = mid,e = mid-1;
        else s = mid+1;
    }

    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 31616
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b,c,k; cin >> a >> b >> c >> k;
    cout << (k%2?b-a:a-b) << endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x, a, b, c;
	cin >> x;
	c = x % 60;
	a = (x - (x % 3600)) / 3600;
	b = (x - c - (3600 * a)) / 60;
	cout << a << ":" << b << ":" << c << "\n";
	cin >> a;
}

Measured memory_bytes: 3044
import sys
n=int(input())
ab=[]
for i in range(n):
  AB=[int(x) for x in input().rstrip().split()]
  ab.append(AB)
ab=sorted(ab,key=lambda x :x[0])
ab=sorted(ab,key=lambda x :x[1])

time=0
for a,b in ab:
  if time+a<=b:
    time+=a
  else:
    print("No")
    sys.exit()

print("Yes")

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

int main() {
	string s;
  	cin >> s;
  
  	int sum = 0;
  
  	if(s[0] == '1') sum++;
  	if(s[1] == '1') sum++;
  	if(s[2] == '1') sum++;
  
  	cout << sum << endl;
}

Measured memory_bytes: 256
Q,H,S,D=map(int,input().split())
N=int(input())*4
# 量は全部4倍して計算
# 1:Q円,2:H円,4:S円,8:D円
# N*4リットル買いたい (入力の時点でN*4にしておくのでNで大丈夫)

# すべて約数なので、量が大きいほうが安くなるのであればすべてそれで置き換えたほうが良い。
# どの単位を使うかの2**4通り
P=[D,S,H,Q]
ans=10**18
for i in range(2**4):
  price=0
  amount=N
  for j in range(4):
    if (i>>j)&1:
      unit=2**(3-j)
      price+=(amount//unit)*P[j]
      amount%=unit
  if amount!=0:
    continue
  if price<ans:
    ans=price
print(ans)

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

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

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


Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readChar()

ans = -1

for i in range(len(s)):
	for j in range(i+1,len(s)+1):
		flg = 1
		for k in s[i:j]:
			if k not in ["A","C","G","T"]:
				flg = 0
				break
		if flg:
			#print("flg:",s[i:j])
			ans = max(ans,len(s[i:j]))

print(max(ans,0))

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

int ma[200010],f[18][200010],g[18][200010],x,y,hd[200010],cnt,ans[200010],fa[200010],n;
struct node{int to,next;}e[400010];

void addedge(int x,int y)
{
	e[++cnt]=(node){y,hd[x]},hd[x]=cnt;
	e[++cnt]=(node){x,hd[y]},hd[y]=cnt;
}

void dfs(int x)
{
	ma[x]=max(ma[fa[x]],x);
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) fa[e[i].to]=x,dfs(e[i].to);
}

void Dfs(int x)
{
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) ans[e[i].to]+=ans[x],Dfs(e[i].to);
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<n; i++) scanf("%d%d",&x,&y),addedge(x,y);
	ma[0]=fa[1]=0,dfs(1);
	for (int i=1; i<=n; i++) f[0][i]=fa[i],g[0][i]=i;
	for (int j=1; j<=17; j++)
		for (int i=1; i<=n; i++)
			f[j][i]=f[j-1][f[j-1][i]],g[j][i]=max(g[j-1][i],g[j-1][f[j-1][i]]);
	for (int i=2; i<=n; i++)
	{
		int x=i,nw=0;
		for (int j=17; j>=0; j--)
			if (f[j][x]>1&&max(nw,g[j][x])<ma[fa[f[j][x]]]) nw=max(nw,g[j][x]),x=f[j][x];
		ans[x]++;
	}
	Dfs(1);
	for (int i=2; i<=n; i++) printf("%d ",ans[i]);
	return puts(""),0;
}

Measured memory_bytes: 42240
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int A,B,C;
	cin >> A >> B >> C;
	println(A*B/2);
}


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

int main() {
	int n;
	ll ans=1;
	cin>>n;
	vector<int> x(n+1,0);
	for (int i=2; i<=n; i++) {
        int num=i;
        for (int j=2; j<=i; j++) {
            while (num%j==0) {
                x.at(j)++;
                num/=j;
            }
        }
	}

	for (int i=2; i<=n; i++) {
        ans*=x.at(i)+1;
        ans%=MOD;
    }
	cout<<ans<<endl;
}


Measured memory_bytes: 256