akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

vector<int> Z_algorithm(string S) {
    vector<int> Z(S.size());
    Z[0] = S.size();
    int i = 1, j = 0;
    while(i < S.size()){
        while(i + j < S.size() && S[j] == S[i + j]) j++;
        Z[i] = j;

        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(k < j && k + Z[k] < j){
            Z[i + k] = Z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return Z;
}

int N;
int A[200000], B[200000];

bool ok[200000];
int ans[200000] ={};

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    rep(i, N) ok[i] = true;
    rep(i, 30){
        bool flg[200000] ={};
        {
            // xor 0
            string a;
            string b;
            rep(j, N) a += (char)(((A[j]>>i)&1)+'0');
            rep(j, N) b += (char)(((B[j]>>i)&1)+'0');
            //cout << b << " " << a << " " << a << endl;
            vector<int> z = Z_algorithm(b+a+a);
            rep(j, N){
                //cout << z[N+j] << " ";
                if(z[N+j] >= N){
                    flg[j] = true;
                    ans[j] += 0<<i;
                }
            }
            //cout << endl;
        }
        {
            // xor 1
            string a;
            string b;
            rep(j, N) a += (char)(((A[j]>>i)&1)+'0');
            rep(j, N) b += (char)(((B[j]>>i)&1^1)+'0');
            //cout << b << " " << a << " " << a << endl;
            vector<int> z = Z_algorithm(b+a+a);
            rep(j, N){
                //cout << z[N+j] << " ";
                if(z[N+j] >= N){
                    flg[j] = true;
                    ans[j] += 1<<i;
                }
            }
            //cout << endl;
        }
        rep(j, N) ok[j] &= flg[j];
    }

    rep(i, N){
        if(ok[i]) cout << i << " " << ans[i] << endl;
    }
}

Measured memory_bytes: 7012
n, k = map(int, input().split())
P = list(map(int, input().split()))
maxv = tempsum = sum(P[:k])
for i in range(1, n-k+1):
	tempsum = tempsum - P[i-1] + P[i+k-1]
	maxv = max(maxv, tempsum)
print((maxv + k) * 0.5)

Measured memory_bytes: 71792
// D

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N;
  cin>>N;
  int A[10][10]={0};
  for (int i(1);i<=N;i++){
    string s = to_string(i);
    A[s[0]-'0'][s[s.size()-1]-'0']++;
  }
  ll ans(0);
  for (int i(1);i<=N;i++){
    string t = to_string(i);
    char f = t[0],l = t[t.size()-1];
    //cout << f << l << endl;
    ans += A[l-'0'][f-'0'];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a[3];
	int n;
	cin >> n;
	for(int i = 0 ; i < n; i++){
		for(int j = 0; j < 3;j++){
		cin >> a[j] ;
	}

	sort(a, a+3);
	if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1]) cout << "YES" << endl;
	else cout << "NO" << endl;


	}
	
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  vector<ll> v(n+1); int j;
  j=n;
  rep(i,n){
    while(j>0 && c[j-1]>b[n-1-i]) --j;
    v[n-1-i] = v[n-i] + n-j;
  }
  ll ans = 0;
  j=0;
  rep(i,n){
    while(j<n && b[j]<=a[i]) ++j;
    ans += v[j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

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

	cin >> n;

	if (n == 1) {
		cout << "Hello World";
	}
	else {
		cin >> a >> b;

		cout << a + b;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	string s;
	cin >> s;
	int p = 2019;
	map <int, int> mp;
	++mp[0];
	int curr = 0, pw = 1;
	ll ans = 0;
	for(int i = s.size() - 1; i >= 0; i--) {
		curr = (((s[i] - '0') * pw + curr)) % p;
		ans += mp[curr];
		++mp[curr];
		pw = (pw * 10) % p;
	}
	cout << ans;
}


Measured memory_bytes: 3728
def main():
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    N = int(input())
    print(A[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int t = 0;
    rep(i, s.length()) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt >= t) {
            t = cnt;
        }
    }
    cout << t << "\n";
}


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

#define NMAX 100000
#define QMAX 200000
#define WMAX 10000

using namespace std;

class RQS{
private:
    int size;
    vector<int> Tree;
    vector<vector<int> > Node;
    vector<int> numbers;
    vector<int> numbers_child;
    
    void dfs(int index) {
        static int id = 0;
        numbers[index] = id++;
        for (int i = 0; i < Node[index].size(); ++i)
            dfs(Node[index][i]);
        numbers_child[index] = id;
    }
    
    void update(int index, int weight, int a, int b, int left, int right) {
        if (right <= a || b <= left)
            return;
        else if (a <= left && right <= b)
            Tree[index] += weight;
        else {
            int mid = (left + right) / 2;
            update(index * 2 + 1, weight, a, b, left, mid);
            update(index * 2 + 2, weight, a, b, mid, right);
        }
    }
    
public:
    RQS(){
        int RSize;
        cin >> RSize;
        
        if(!(2 <= RSize && RSize <= NMAX))
            exit(1);
        
        Node.resize(RSize);
        for (int i = 0; i < RSize; i++) {
            int k, v;
            cin >> k;
            
            for (int j = 0; j < k; j++) {
                cin >> v;
                Node[i].push_back(v);
            }
        }
        
        size = 1;
        while (size < RSize)
            size *= 2;
        
        numbers.resize(RSize, -1);
        numbers_child.resize(RSize, -1);
        Tree.resize(2 * size - 1, 0);
        
        dfs(0);
    }
    
    int sum(int target) {
        if(!(0 <= target && target < size))
            exit(1);
        
        int index = numbers[target];
        index += size - 1;
        int sum = Tree[index];
        while (index > 0) {
            index = (index - 1) / 2;
            sum += Tree[index];
        }
        
        return sum;
    }
    
    void update(int target, int weight){
        if(!(1 <= target && target < size) || !(1 <= weight && weight <= WMAX))
            exit(1);
        update(0, weight, numbers[target], numbers_child[target], 0, size);
    }
};

int main() {
    RQS rqs;
    int q, o, v, w;
    
    cin >> q;
    if(!(2 <= q && q <= QMAX))
        exit(1);
        
    for (int i = 0; i < q; i++) {
        cin >> o;
        if (o == 0) {
            cin >> v >> w;
            rqs.update(v, w);
        }
        else if(o == 1){
            cin >> v;
            cout << rqs.sum(v) << endl;
        }
        else
            exit(1);
    }
    
    return 0;
}




Measured memory_bytes: 12616
n,m = map(int,input().split())
graph = [[] for i in range(n)]
for i in range(m):
  a,b = map(lambda z:int(z)-1,input().split())
  graph[a].append(b)
  graph[b].append(a)

size = [0 for i in range(n)]
check = [True for i in range(n)]
for i in range(n):
  if check[i]:
    tmp = 1
    stack = [i]
    check[i] = False
    while stack:
      now = stack.pop()
      size[now] = tmp
      tmp+=1
      for to in graph[now]:
        if check[to]:
          check[to] = False
          stack.append(to)

print(max(size))


Measured memory_bytes: 52184
fn check_existence(v: &Vec<f32>) -> bool {
    v[0] + v[1] > v[2]
}

fn triangle_type(v: &Vec<f32>) -> usize {
    let v_sq: Vec<f32> = v.iter().map(|&x| x * x).collect();
    match v_sq[0] + v_sq[1] - v_sq[2] {
        x if x < 0.0 => 0,
        x if x == 0.0 => 1,
        x if x > 0.0 => 2,
        _ => panic!("invalid sub"),
    }
}

fn main() {
    let mut n_triangles = 0;
    let mut total_triangle_types = vec![0 as i32; 3];
    loop {
        let mut line = String::new();
        match std::io::stdin().read_line(&mut line) {
            Ok(len) if len > 0 => {
                let mut inputs: Vec<f32> = line.split_whitespace()
                    .map(|e| e.parse::<f32>().ok().unwrap())
                    .collect();
                inputs.sort_by(|a, b| a.partial_cmp(b).unwrap());
                if check_existence(&inputs) {
                    n_triangles += 1;
                    let ttype = triangle_type(&inputs);
                    total_triangle_types[ttype] += 1;
                } else {
                    break;
                }
            }
            _ => break,
        };
    }

    println!(
        "{} {} {} {}",
        n_triangles, total_triangle_types[1], total_triangle_types[2], total_triangle_types[0]
    );
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

signed main(){
	string t;
	cin >> t;
	for(int i = 0;i < t.length();i++){
		if(t[i] == '?') t[i] = 'D';
	}
	cout << t << endl;
}

Measured memory_bytes: 3756
great_list = []
x,y,z,k = map(int,input().split(' '))
a = list(map(int,input().split(' ')))
b = list(map(int,input().split(' ')))
c = list(map(int,input().split(' ')))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

for i in range(min(k,len(a)))[:k]:
	for j in range(min(k // (i+1),len(b)))[:k]:
		for l in range(min(k // ((i+1) * (j+1)),len(c)))[:k]:
			great_list.append(a[i] + b[j] + c[l])

great_list.sort(reverse=True)
for i in great_list[:k]:
    print(i)

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

int main() {
    int N; cin >> N;
    vector<int> diff(N); for (int i = 0; i < N; i++) cin >> diff[i];
    sort(diff.begin(), diff.end());
    int l = diff[N/2-1];
    int r = diff[N/2];
    cout << r - l << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int a[3];
    REP (i,3) cin >> a[i];
    sort(a,a+3);
    if (a[0] == a[1] && a[1] == 5 && a[2] == 7) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long x, k, d;
    scanf("%ld %ld %ld", &x, &k, &d);

    x = labs(x);
    if(x / d <= k){
        k -= x/d;
        x %= d;
    }
    else{
        x -= k * d;
        k = 0;
    }

    if(k == 0){
        printf("%ld\n", x);
    }
    else if(k % 2 == 0){
        printf("%ld\n", x);
    }
    else{
        printf("%ld\n", labs(x - d));
    }

    return 0;
}


Measured memory_bytes: 1732
def solve():
    N = int(input())
    works = []
    for i in range(N):
        period, deadline = map(int, input().split())
        works.append((period,deadline))
    
    works.sort(key=lambda x:x[1])

    time = 0
    for period, deadline in works:
        time += period
        if time > deadline:
            print('No')
            return
    
    print('Yes')

    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 31884
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#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 = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    vl x(3);
    x[0] = a;
    x[1] = b;
    x[2] = c;
    sort(all(x));
    
    if(x[0] + x[1] == x[2]) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdint.h>
#include <math.h>
#include <algorithm>

using namespace std;

class Task {
	public:
		void solve(istream &in, ostream &out) {
            int r, g, b;
            in >> r >> g >> b;
            string n_str = to_string(r) + to_string(g) + to_string(b);
            int n = stoi(n_str);
            
            if (n % 4 == 0) cout << "YES";
            else cout << "NO";            
		}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	istream &in(cin);
	ostream &out(cout);
	Task t;
	t.solve(in, out);
	return 0;
}


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

using namespace std;

using ll = long long;

const vector<pair<char, char>> add = {{1, '3'}, {2, '5'}, {4, '7'}};

int Solve(string &x, char flag, const int n) {
    int res = (flag == 7);
    for (const auto &it : add) {
        x.push_back(it.second);
        if (stoll(x) <= n) res += Solve(x, flag | it.first, n);
        x.pop_back();
    }
    return res;
}

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

    int n;
    cin >> n;
    string x;
    cout << Solve(x, 0, n) << endl;;

    return 0;
}


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

d=[]
for i in range(1,N):
  d.append(A[i]-A[i-1])

d0=K-A[N-1]+A[0]
if max(d)>d0:
  print(K-max(d))
else:
  print(K-d0)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vc res;
vs s;
int n;
bool dfs(int t,int A,int B,int C){
    if(t == n)return true;
    if(s[t] == "AB"){
        if(A == 0 && B == 0)return false;
        if(A > 0 && dfs(t+1,A-1,B+1,C)){
            res.emplace_back('B');
            return true;
        }
        if(B > 0 && dfs(t+1,A+1,B-1,C)){
            res.emplace_back('A');
            return true;
        }
        return false;
    }
    else if (s[t] == "BC"){
        if(C == 0 && B == 0)return false;
        if(C > 0 && dfs(t+1,A,B+1,C-1)){
            res.emplace_back('B');
            return true;
        }
        if(B > 0 && dfs(t+1,A,B-1,C+1)){
            res.emplace_back('C');
            return true;
        }
        return false;
    }
    else if (s[t] == "AC"){
        if(A == 0 && C == 0)return false;
        if(A > 0 && dfs(t+1,A-1,B,C+1)){
            res.emplace_back('C');
            return true;
        }
        if(C > 0 && dfs(t+1,A+1,B,C-1)){
            res.emplace_back('A');
            return true;
        }
        return false;
    }
    return false;
}
signed main()
{   
    gearup;
    int a,b,c; cin >> n >> a >> b >> c;
    s.resize(n);
    rep(i,n)cin >> s[i];
    dfs(0,a,b,c);
    if(res.size() == n){
        out("Yes");
        reverse(all(res));
        rep(i,n)out(res[i]);
    }
    else out("No");
}

Measured memory_bytes: 12960
import java.util.Scanner;

 
public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
     
      String b = sc.next();
      char[]c = b.toCharArray();
     
        
        if(c[0] == 'A'){
          System.out.println('T');
        } else if (c[0] == 'T'){
          System.out.println('A');
        } else if (c[0] == 'C'){
          System.out.println('G');
        } else if(c[0] == 'G') {
          System.out.println('C');
        } 
     
      
      
      
    }
}
          
    
        
       

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a=0;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  for(int i=0;i<30;i++){
    for(int j=0;j<n;j++){
      if(v[j]%2==0){
        
      }else{
        cout<<i<<endl;
        return 0;
      }
      v[j]/=2;
      
    }
  }
}


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

//C++14 (GCC 5.4.1)
int main() {
    string S;
    cin >> S;
    
    //-----------------------------------
    bool is= S[0]==S[1]||S[1]==S[2] ||S[2]==S[3];


    cout << ((is) ? "Bad" : "Good") <<endl;
    return (0);
}

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

int main(int argc, char *argv[])
{
  string s1, s2;
  cin >> s1 >> s2;
  reverse(s2.begin(), s2.end());
  if(s1 == s2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    int xpymax = INT_MIN, xpymin = INT_MAX;
    int xmymax = INT_MIN, xmymin = INT_MAX;
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        xpymax = max(xpymax, x + y);
        xpymin = min(xpymin, x + y);
        xmymax = max(xmymax, x - y);
        xmymin = min(xmymin, x - y);
    }

    int ans = max(xpymax - xpymin, xmymax - xmymin);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c; 	
	scanf("%d %d %d", &a, &b, &c); 	
	if((a*100+b*10+c)%4==0){ 		
		printf("YES"); 	} 	
	else{ 		printf("NO"); 	
		} 	 
} 

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

int main(){
	vector<pair<int, int> > job;
	int n;
	cin >> n;
	for (int i=0;i<n;i++){
		int a, b;
		cin >> a >> b;
		job.push_back({b,a});
	}
	
	sort(job.begin(),job.end());
	reverse(job.begin(),job.end()); 
	
	int endt = job[0].first;
	for (int i=0;i<n;i++){
		if (endt>job[i].first) endt = job[i].first;
		endt = endt - job[i].second;
	}
	if (endt<0) cout << "No";
	else cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 2420
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int a,b;
	cin>>a>>b;
	if(a+b<10) cout<<a+b<<endl;
	else cout<<"error"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[i])continue;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s] += 1;
    }
    int max = 0;
    for (auto p : m)
    {
        if (max < p.second)
        {
            max = p.second;
        }
    }
    for (auto p : m)
    {
        if (p.second == max)
        {
            cout << p.first << endl;
        }
    }
}

Measured memory_bytes: 19240
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,inp;
	cin >> N;
	vector<int> A(N,0);

	for(int i = 0; i<N-1; i++){
		cin >> inp;
		A[inp-1]++;
	}

	for(int i = 0; i<N; i++)
		cout << "\n" << A[i];
  

	return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
typedef pair<int,int> iP;
int power(int x,int y){
    int res=1;
    x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
int mulmod(int a,int b){ 
    int res=0;
    a=a%mod; 
    while(b>0){
        if(b%2==1) 
        res=(res+a)%mod; 
        a=(a*2)%mod; 
        b/=2;
    } 
    return res%mod; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;
    string s,t;
    cin>>s>>t;
    cout<<t+s;
}

Measured memory_bytes: 384
#line 1 "ALDS1_1_C.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_1_C"
#line 1 "/Users/knaga/programming/procon_library/math/sieve_of_eratosthenes.cpp"


#line 1 "/Users/knaga/programming/procon_library/macro/macros.hpp"



/*
@title Macro
@category template
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;

const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";


#line 4 "/Users/knaga/programming/procon_library/math/sieve_of_eratosthenes.cpp"

/*
@title エラトステネスの篩(Sieve of Eratosthenes)
@category math
@brief 計算量$O($NloglogN$)$

*/
template<typename T>
vector<bool> sieve(T x){
    vector<bool> is_prime(x + 1, true);
    if(x >= 0)is_prime[0] = false;
    if(x >= 1)is_prime[1] = false;
    for(T i = 2; i * i <= x;i++){
        if(!is_prime[i])continue;
        for(T j = i + i; j <= x;j+=i){
            is_prime[j] = false;
        }
    }
    return is_prime;
}

#line 3 "ALDS1_1_C.test.cpp"

int main(){
    vector<bool> is_prime = sieve(100100100);
    int n;
    cin >> n;
    int ans = 0;
    while(n--){
        int x;
        cin >> x;
        ans += is_prime[x];
    }
    cout << ans << endl;
}



Measured memory_bytes: 14876
N = int(input())
if N <= 9:
	print(N)
elif N <= 99:
  	print(9)
elif N <= 999:
  	print(9 + N - 99)
elif N <= 9999:
  	print(909)
elif N <= 99999:
  	print(909 + N - 9999)
else:
  	print(90909)

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

def num2alpha(num):
  if num<=26:
    return chr(64+num)
  elif num%26==0:
    return num2alpha(num//26-1)+chr(90)
  else:
    return num2alpha(num//26)+chr(64+num%26)

n = num2alpha(N).lower()
print(n)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
/*l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums*/
/*vector<vector<l> > c(100000);
void dfs(vector<l> v[],l root,bool vis[])
{
	vis[root]=true;
	//cout<<root<<"\n";
	for(l i=0;i<v[root].size();i++)
	{
		if(vis[v[root][i]]==false)
		{
			c[root].pb(v[root][i]);
			dfs(v,v[root][i],vis);
		}
	}
}*/
void frooty()
{
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes"<<"\n";
	else
		cout<<"No"<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	//q++;
	for(int i=0;i<q;i++)
	{
		frooty();
	}
}

Measured memory_bytes: 3648
# coding:utf-8

import sys
import math

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, a, b = LI()

    return max(0, (n - 2) * (b - a) + 1)


print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
#define PI 3.14159265
#include <math.h>
int main(){
    double a,b,x;
    cin>>a>>b>>x;
    if(x/a > a * b /2){
        double c = x/a - a*b/2;
        // cout<<c/a<<endl;
        double ans = atan(a/(b-2*c/a)) * 180 / PI;
        printf("%.8f\n", 90-ans);
        // cout<<90-ans<<endl;
    } else if(x/a == a * b /2) {
        cout<<45<<endl;
    } else {
        double c = 2*x/(b*a);
        // cout<<c<<endl;
        float ans = atan((c/b)) * 180 / PI;
        // cout<<90 - ans<<endl;
        printf("%.8f\n", 90-ans);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int L,R;
bool mark[2020];
int main() {
	scanf("%d %d",&L,&R);
	for(int i=L;i<=R;i++){
		if(mark[i%2019])break;
		mark[i%2019]=1;
	}
	int mn=2020;
	for(int i=0;i<=2018;i++)	
		for(int j=i+1;j<=2018;j++)
			if(mark[i]&&mark[j])
				mn=min(mn,i*j%2019);
	printf("%d\n",mn);
	return 0;
}

Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/18 15:30:25
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 3005;

int n, t;
int a[N], b[N];
int dp1[N][N], dp2[N][N];

void run(){
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= t - 1; j++) {
            dp1[i][j] = dp1[i - 1][j];
            if(j >= a[i]) 
                dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - a[i]] + b[i]);
        }   
    }
    for(int i = n; i >= 1; i--) {
        for(int j = 1; j <= t - 1; j++) {
            dp2[i][j] = dp2[i + 1][j];
            if(j >= a[i])
                dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - a[i]] + b[i]);   
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= t - 1; j++) {
            ans = max(ans, dp1[i - 1][j] + dp2[i + 1][t - 1 - j] + b[i]);
        }   
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    while(cin >> n >> t) run();
	return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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 data[101];
	int n;
	cin >> n;
	REP(i,n) cin >> data[i];
	REP(i,n){
		if(i!=n-1) cout << data[i] << " ";
		else cout << data[i] << endl;
	}
	REP(i,n-1){
		int pv = data[i+1];//????????????
		bool isin = false;
		int j = 0;
		while(1){
			if(j==i+1||isin==true) break;
			if(data[j]>pv){
				//?????????
				for(int k=i+1;k>=j; k--) data[k] = data[k-1];
				data[j] = pv;
				isin = true;
			}
			j++;
		}
		REP(j,n){
			if(j!=n-1) cout << data[j] << " ";
			else cout << data[j] << endl;
		}
	}
}

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

int main() {
    int n; cin >>n;
    int t = 0, x = 0 , y = 0;
    string ret = "Yes";
    for (int i = 0; i < n; i++) {
        int tt, tx, ty; cin >>tt >> tx >> ty;
        // (tt - t)秒間に、(x,y) -> (tx,ty)に移動した場合かかる時間を引いたもの
        int tmp = (tt - t) - abs(tx - x) - abs(ty - y);
        if (tmp<0 || tmp%2!=0) {ret = "No"; break;} // tmp<0は時間的に到達不能、 tmp%2は時間つぶしで入れるか確認
        t = tt; x = tx; y = ty;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], res[12345678];
signed main() {
	vector<char> v; map<int, int> cost;
	int n, m, a, b, c, x, ans = 0; string s, t; double cnt;
	cin >> n;
	if (n % 10 == 3) { cout << "bon" << endl; }
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    int s = 0;
    rep(i, n) s += w[i];
    int t = 0, ans = 1e9;
    rep(i, n)
    {
        t += w[i];
        s -= w[i];
        int tmp = abs(t - s);
        if (tmp < ans)
            ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int h = sc.nextInt();
		
		int []a = new int [n];
		int []b = new int [n];
		
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		sc.close();
		
		Arrays.sort(a);
		Arrays.sort(b);

		
		int max = a[n-1];
		
		int hp = h;
		int cnt = 0;
		int temp = 0;
		
		for(int i = n-1 ; i >= 0 ;i--) {
			if(max < b[i]) {
				hp = hp - b[i];
				cnt++;
			}
			if(hp <= 0){
				temp = -1;
				break;
			}
		}
		
		if(temp == 0) {
		double p = (double) hp/max;
		
		cnt += (int)Math.ceil(p);
		
		System.out.println(cnt);
		
		}
		
		if(temp == -1) {
			System.out.println(cnt);
		}
		
		
		
	}

}


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

struct BIT {
    int N;
    int bit[300010];

    void init(int n) {
        N = n;
        for (int i=0;i<=n;++i) bit[i]=0;
    }
    void add(int a, int x) {
        for (int i=a;i<=N;i+=i&-i) bit[i] += x;
    }
    int sum(int a) {
        int s = 0;
        for (int i=a;i>0;i-=i&-i) s += bit[i];
        return s;
    }
};

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

    int N, M; cin >> N >> M;
    vector<int> w[M + 2];
    vector<pair<int, int>> lr(N);
    BIT bit;
    bit.init(M + 2);

    rep(i,N) {
        cin >> lr[i].first >> lr[i].second;
        w[lr[i].second - lr[i].first + 1].push_back(i);
    }

    int cnt = 0;
    for (int d = 1; d <= M; ++d) {
        for (int i : w[d]) {
            cnt++;
            bit.add(lr[i].first, 1);
            bit.add(lr[i].second + 1, -1);
        }

        int ans = N - cnt;
        for (int m = d; m <= M; m += d) {
            ans += bit.sum(m);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>

using namespace std;



int main()
{
    long long n,k;
    cin>>n>>k;
    long long x,v[n];
    for(long long i=0; i<n; i++){
        cin>>v[i];
    }
    sort(v,v+n);long long minn=1000000005;
    for(long long i=0; i<=n-k; i++){
        if(abs(v[i+k-1]-v[i])<minn)
            minn=abs(v[i+k-1]-v[i]);
    }
    cout<<minn;
    return 0;
}


Measured memory_bytes: 1024
#define ONLINE_JUDGE //in case i forget to uncomment this, sometimes the grader defines the macro ^.^
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include "stdc++.h"
#endif


#define int long long
using namespace std;

signed main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/kdkdk/Desktop/input.txt", "r", stdin);
    //freopen("/Users/kdkdk/Desktop/output.txt", "w", stdout);
#endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
    else {
        cout << min(a*b,min(a*c,b*c)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int X;
   std::cin >> X;
   while(true){
      bool flag = true;
      for(int i=2; i*i<X; ++i){
	 if(X%i==0) {
	    flag = false;
	    break;
	 }
      }
      if(flag) {
	 std::cout << X << std::endl;
	 return 0;
      }
      ++X;   
   }
   return -1; 
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import operator

N,H,W = map(int,readline().split())
m = map(int,read().split())
RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True)

root = list(range(H+W))
size = [1] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)


Measured memory_bytes: 35448
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if((Math.abs(B - A - 1) % 2) == 0){
			System.out.println("Borys");
		}else{
			System.out.println("Alice");

		}
		}
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
 
    return 0;
}

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

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::map<int, int> count;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    count[a]++;
  }
  int total = count.size(),
      multiple = 0,
      multiple_sum = 0;
  for (auto i = std::begin(count); i != std::end(count); i++) {
    if (i->second == 1) continue;
    multiple++;
    multiple_sum += i->second;
  }
  std::cout << ((multiple % 2 == multiple_sum % 2) ? total : total - 1) << std::endl;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    long long int n;
    double s;
    scanf("%lld",&n);
    s=sqrt(n);
    n=s;n*=n;
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128
import collections
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    ans = 0
    c = collections.Counter()

    for i in range(n):
        ans += c[i + 1 - A[i]]
        c[i + 1 + A[i]] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40604
while true
  a,ope,b = gets.split(' ')
  a = a.to_i
  b = b.to_i
  case ope
    when '+' then
      puts a + b
    when '-' then
      puts a - b
    when '*' then
      puts a * b
    when '/' then
      puts a / b
    else 
      break
  end
end


Measured memory_bytes: 8644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int i,j,n,k,d[101]={},a[101][101]={},A[101]={},count=0;
    scanf("%d%d",&n,&k);
    for (i=0; i<k; i++){
        scanf("%d",&d[i]);
        for (j=0; j<d[i]; j++) scanf("%d",&a[i][j]);
    }
    for (i=0; i<k; i++) {
        for (j=0; j<d[i]; j++) A[a[i][j]]++;
    }
    for (i=1; i<=n; i++) {
        if (A[i]==0) count++;
    }
    printf("%d",count);
    return 0;
}



Measured memory_bytes: 1772
S=input()
K=int(input())

ss = []
for i in range( 1,K+1 ):
  for j in range( len(S)-i+1 ):
    ss.append(S[j:j+i])
ss.sort()
pre = '@'
for a in ss:
  if pre == a: continue
  pre = a
  K -= 1
#  print(a)
  if K==0:
    print(a)
    break


Measured memory_bytes: 4340
//by Sshwy
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)

namespace RA{
    int rnd(int p){return 1ll*rand()*rand()%p;}
    int rnd(int L,int R){return rnd(R-L+1)+L;}
}
const int N=1e5+5;
int n;
int a[N],o[N];
long long sa[N],ps;

int main(){
    scanf("%d",&n);
    scanf("%d",&a[1]);
    FOR(i,2,n){
        char op[5];
        scanf("%s%d",op,&a[i]);
        if(op[0]=='-')o[i]=-1;
        else o[i]=1;
    }
    ROF(i,n,1)sa[i]=sa[i+1]+a[i];
    o[1]=1;
    long long ans=-1e18;
    FOR(i,1,n){
        ps+=a[i]*o[i];
        if(i<n && o[i+1]==-1){
            long long s=a[i+1];
            int pos=i+2;
            while(pos<=n && o[pos]==1)s+=a[pos],++pos;
            ans=max(ans,sa[pos]-s+ps);
        }
    }
    ans=max(ans,ps);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a[3],b[3],c[3];
    cin>>a>>b>>c;
     cout<<a[0]<<b[1]<<c[2];
}   
    
    
     

     
   





Measured memory_bytes: 3652
#include <stdio.h>
int main(void) {
	int N, A, B;
	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);
	if (N*A < B) {
		printf("%d\n", N*A);
	}
	else if (N*A == B) {
		printf("%d\n", N*A);
	}
	else printf("%d\n", B);
	return 0;
}

Measured memory_bytes: 128