akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};


    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	if ((n+1)/2>=k)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N;
    cin >> N;
    int H[N];
    rep(i, N) cin >> H[i];
    int ans = 0;
    int tmp = 1;
    rep(i, N - 1) {
        if (H[i] >= H[i + 1]) tmp++;
        else {
            ans = max(ans, tmp);
            tmp = 1;
        }
    }
    ans = max(ans, tmp);

    cout << max(0, ans - 1) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    rep(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--;
        Y[i]--;
    }
    UnionFind uf(N);
    rep(i, M) { uf.unite(X[i], Y[i]); }
    set<int> se;
    rep(i, N) { se.insert(uf.root(i)); }
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 7680
# -*- coding: utf-8 -*-
from itertools import product, permutations
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

X = [0]*5
for i in range(5):
    X[i] = int(input())

ans = 10**9
for Y in permutations(X, r=5):
    tmp = 0
    for y in Y[:4]:
        tmp += y
        tmp = -(-tmp//10) * 10
    ans = min(ans, tmp + Y[-1])
print(ans)

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
string s;
vector<char> ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,f[3];
	cin >> n >> f[0] >> f[1] >> f[2];
	int d = f[0] + f[1] + f[2];
	if(d == 0){
		cout << "No";
		return 0;
	}
	else{
		if(d == 1){
			rep(i,0,n){
				cin >> s;
				int x = s[0] - 'A';
				int y = s[1] - 'A';
				if(!f[x] && !f[y]){
					cout << "No";
					return 0;
				}
				else{
					if(f[x]){
						f[x]--;
						f[y]++;
						ans.pb(char(y+'A'));
					}
					else{
						f[x]++;
						f[y]--;
						ans.pb(char(x+'A'));
					}
				}
			}
		}
		else{
			if(d == 2){
				string last ="";
				rep(i,0,n){
					cin >> s;
					int x = s[0] - 'A';
					int y = s[1] - 'A';
					if(!f[x] && !f[y]){
						if(last == ""){
							cout << "No";
							return 0;
						}
						else{
							swap(f[last[0] - 'A'],f[last[1] - 'A']);
							ans[sz(ans)-1] = (ans[sz(ans)-1] == last[0] ? last[1] : last[0]);
						}
					}
					if(f[x]){
						f[x] --;
						f[y] ++;
						ans.pb(char(y+'A'));
					}
					else{
						f[x] ++;
						f[y] --;
						ans.pb(char(x+'A'));
					}
					last = s;
				}
			}
			else{
				rep(i,0,n){
					cin >> s;
					int x = s[0] - 'A';
					int y = s[1] - 'A';
					if(!f[x] && !f[y]){
						cout << "No";
						return 0;
					}
					
					if(f[x] > f[y]){
						f[x] --;
						f[y] ++;
						ans.pb(char(y+'A'));
					}
					else{
						f[x] ++;
						f[y] --;
						ans.pb(char(x+'A'));
					}
				}
			}
		}
	}
	cout << "Yes\n";
	rep(i,0,n)cout  << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 3796
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
//元首万岁 
using namespace std;
long long n,m;
long long a[90];
long long f(int x)
{
	if(a[x])
	return a[x];
	else
	a[x]=f(x-1)+f(x-2);
	return a[x];
}
int main()
{
	cin>>n;
	a[1]=1;
	a[0]=2;
	cout<<f(n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdint.h>

#include <algorithm>
#include <iostream>

using namespace std;

int main(void) {
  int64_t N;
  cin >> N;

  int64_t ans = N - 1;
  for (int64_t i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      ans = min(N / i - 1 + i - 1, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define L (x << 1)
#define R (x << 1 | 1)
#define N 100110
using namespace std;
vector<int> edge[N];
vector<int> mark[N], query[N];
int n, m;
struct Tree{
	struct node{
		int v;
	}tr[N * 3];
	void init(){
		memset(tr, 0, sizeof(tr));
	}
	void update(int x){
		tr[x].v = max(tr[L].v, tr[R].v);
	}
	void modify(int x, int a, int b, int pos, int ad){
		if(a == b){
			tr[x].v = ad;
			return;
		}
		int mid = a + b >> 1;
		if(pos <= mid) modify(L, a, mid, pos, ad);
		else modify(R, mid + 1, b, pos, ad);
		update(x);
	}
	int query(int x, int a, int b, int l, int r){
		if(l <= a && b <= r) return tr[x].v;
		int mid = a + b >> 1;
		if(r <= mid) return query(L, a, mid, l, r);
		else if(l > mid) return query(R, mid + 1, b, l, r);
		else return max(query(L, a, mid, l, r), query(R, mid + 1, b, l, r));
	}
}sg;

LL ans = 0;
int list[N];
int pos[N], f[N];
void dfs(){
	int u = 1, d = 1;
	for(int i = 1; i <= n; i ++) pos[i] = 0;
	while(1){
		list[d] = u;
		for(int i = 0; i < mark[u].size(); i ++){
			int _index = mark[u][i];
			sg.modify(1, 1, m, _index, d);
		}
		for(int i = 0; i < query[u].size(); i ++){
			int _index = query[u][i];
			int id = sg.query(1, 1, m, 1, _index);
			ans = ans + list[id];
			//cout << u << ' ' << id << ' ' << list[id] << endl;
		}
		if(pos[u] < edge[u].size()){
			u = edge[u][pos[u] ++];
			d ++;
		}
		else{ 
			while(1){
				if(pos[u] < edge[u].size() || u == 1) break;
				for(int i = 0; i < mark[u].size(); i ++){
					int _index = mark[u][i];
					sg.modify(1, 1, m, _index, 0);
				}
				u = f[u];
				d --;
			}
			if(pos[u] < edge[u].size()){
				u = edge[u][pos[u] ++];
				d ++;
			}
			else break;
		}
	}
}
void solve(){
	ans = 0;
	for(int i = 1; i <= n; i ++){
		edge[i].clear();
		query[i].clear();
		mark[i].clear();
	}
	for(int i = 2; i <= n; i ++){
		scanf("%d", &f[i]);
		edge[f[i]].push_back(i);
	}
	
	mark[1].push_back(1);
	m ++;
	for(int i = 2; i <= m; i ++){
		char str[2];
		int v;
		scanf("%s%d", str, &v);
		if(str[0] == 'Q') query[v].push_back(i);
		else mark[v].push_back(i);
	}
	
	sg.init();
	dfs();
	
	printf("%lld\n", ans);
}
int main(){
	while(scanf("%d%d", &n, &m) == 2 && n + m){
		solve();
	}
	return 0;
}

Measured memory_bytes: 19532
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    string a,b;
    cin >> a>> b;
    string ans="EQUAL";

    if(a.size()>b.size()) ans = "GREATER";
    else if(a.size()<b.size()) ans = "LESS";
    else{
        REP(i,a.size()){
            if(a[i]>b[i]){
                ans = "GREATER";
                break;
            }else if(a[i]<b[i]){
                ans = "LESS";
                break;
            }
        }
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

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

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  if(a[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  

  ll ans = 0;
  for(int i = n-1; i >= 0; i--) {
    if(i == n-1) ans += a[i];
    else{
      if(a[i+1]-a[i] > 1){
        cout << -1 << endl;
        return 0;
      }
      else if(a[i] + 1 == a[i+1]) continue;
      else{
        ans += a[i];
      }
    }
  }

  cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N){
        ll a; cin >> a;
        A[i] = a-(i+1);
    }
    sort(ALL(A));
    ll b = A[N/2];
    ll ans = 0;

    REP(i,N){
        ans += abs(A[i] - b);
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[2][n];
    for(int i=0; i<n; i++){
        cin >> a[0][i];
    }
    for(int i=0; i<n; i++){
        cin >> a[1][i];
    }
    int sum[2][n+1];
    sum[0][0] = 0;
    sum[1][0] = 0;
    for(int i=1; i<n+1; i++){
        sum[0][i] = sum[0][i-1] + a[0][i-1];
        sum[1][i] = sum[1][i-1] + a[1][i-1];
    }
    int ans = 0;
    for(int i=1; i<n+1; i++){
        ans = max(ans,sum[0][i]+sum[1][n]-sum[1][i-1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define ll long long
    #define int long long
    #define lb long double
    #define f(i,a,b) for(int i=a;i<=b;i++)
    #define fd(i,a,b) for(int i=a;i>=b;i--)
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define si set<int>
    #define pb push_back
    #define mk make_pair
    #define fi first
    #define se second
    #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
    #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
    #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
    #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
    #define all(v) v.begin(),v.end()
    #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
    #define pi 3.141592653589793238
    const int mod=998244353;
    const int inf=1e18;
    //bool vis[1000+1]={};
    const int MAXN=1e6+1;
    int spf[MAXN];
    ll power(ll x, unsigned ll y)
    {
        ll res = 1;
        while (y > 0)
        {
            if (y & 1)
                res = res*x;
            y = y>>1;
            x = x*x;
        }
        return res;
    }

    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
        void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    int lcm(int a, int b)
    {
        return (a*b)/__gcd(a,b);
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        {
           int n;
           cin>>n;
           r(a,n);
           int q;
           cin>>q;
           int sum=0;
           f(i,1,n)
           sum+=a[i];
           mii m;
           f(i,1,n)
           m[a[i]]++;
           int b,c;
           f(i,1,q)
           {cin>>b>>c;
           sum-=(b*m[b]);
           sum+=(c*m[b]);
           m[c]+=m[b];
           m[b]=0;
           cout<<sum<<endl;}
        }
    }


Measured memory_bytes: 10344
from heapq import heappush, heappop
INF = 10**10
a = int(input())
d = [[] for i in range(a)]
for i in range(a):
    tl = list(map(int,input().split()))
    ta , tb = tl[0],tl[1]
    t = 2
    for j in range(tb):
        tta,ttb = tl[t],tl[t+1]
        d[i].append((tta,ttb))
        t+=2

def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(que, (dist[t], t))
    for i in range(a):
        print(str(i)+" "+str(dist[i]))
dijkstra(a,d,0)


Measured memory_bytes: 68764
def primes(max)
  nums = Array.new(max + 1, 1)
  nums[0] = nums[1] = 0

  (2..Math.sqrt(max)).each do |sieve|
    if nums[sieve] == 1
      (2 * sieve).step(max, sieve).each do |num|
        nums[num] = 0
      end
    end
  end

  nums
end

max = 10_000

primes = primes(max)

while line = gets
  n = line.chomp.to_i
  break if n == 0

  n.downto(5) do |i|
    if primes[i] == 1 && primes[i - 2] == 1
      puts "#{i - 2} #{i}"
      break
    end
  end
end

Measured memory_bytes: 8820
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	var ans int
	dig := map[int]int{
		1: -9,
		2: -9,
		3: -9,
	}

	//s桁目の値が未指定または指定済みの値と一致する場合はOK それ以外は除外する
	for i := 0; i < m; i++ {
		s := nextInt()
		c := nextInt()
		if dig[s] == -9 {
			dig[s] = c
		} else if dig[s] == c {
			continue
		} else {
			ans = -1
			break
		}
	}

	//先頭に0が指定されたら除外する
	if n != 1 && dig[1] == 0 {
		ans = -1
	}

	//未指定の桁が最上位の場合は1、それ以外の場合は0を代入
	if ans != -1 {
		for i := 1; i <= n; i++ {
			if dig[i] == -9 {
				if i == 1 && (n == 3 || n == 2) {
					dig[i] = 1
				} else {
					dig[i] = 0
				}
			}
		}
		switch n {
		case 3:
			ans = dig[1]*100 + dig[2]*10 + dig[3]
		case 2:
			ans = dig[1]*10 + dig[2]
		case 1:
			ans = dig[1]
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
import math
A, B, H, M = map(int,input().split())

pi = math.pi
rad = pi * 2 * (H / 12 + (M / 60) / 12 - M / 60 )

length = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(length)

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

signed main() {
	int n, m;
	cin >> n >> m;

	vector<vector<int>> mat(n, vector<int>(m));
	vector<int> vec(m);

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> mat[i][j];
		}
	}

	for (int i = 0; i < m; ++i) {
		int num;
		cin >> num;
		vec[i] = num;
	}

	for (int i = 0; i < n; ++i) {
		int sum = 0;
		for (int j = 0; j < m; ++j) {
			sum += vec[j] * mat[i][j];
		}
		cout << sum << endl;
	}
}



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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

vector<int> vec;

void init(){
    vec.push_back(0);
    for(int i=1;i<20;i++){
        int m1=i*(i+1);
        m1/=2;
        int m2=(i+1)*(i+2);
        m2/=2;
        for(int j=m1;j<m2;j++){
            vec.push_back(i);
            if(vec.size()>100)break;
        }
        if(vec.size()>100)break;
    }
}

signed main(){
    int n;cin>>n;
    init();
    int ans=0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            int cnt=0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            ans+=vec[cnt];
//            cout<<i<<" "<<cnt<<" "<<vec[cnt]<<" "<<ans<<endl;
        }
    }
    if(n!=1)ans++;
    cout<<ans;
}


Measured memory_bytes: 3680
function Main(input) {
	var W = parseInt(input.split(" ")[0]);
  var aPosi = parseInt(input.split(" ")[1]);
  var bPosi = parseInt(input.split(" ")[2]);
  if((aPosi + W) < bPosi){
     console.log(bPosi - (aPosi + W));
     }else if(aPosi > (bPosi + W)){
     console.log(aPosi - (bPosi + W));
     }else{
     console.log("0");         
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 500011

int n, m, i, l, r, fr, la, p, ans;
vector< pair<int, int> > data;
multiset<int> S;

int main()
{
    //freopen("test.in","r",stdin);

    fr = 1 << 30;
    la = - 1 << 30;

    scanf("%d%d", &n, &m);
    for (i = 1; i <= n; i++) {
        scanf("%d%d", &l, &r);
        r = m + 1 - r;

        if (l == 0 && r == 0) continue;

        data.pb(mp(-l, r - 1));
        fr = min(fr, -l);
        la = max(la, r - 1);
    }

    sort(data.begin(), data.end());
    p = 0;
    for (i = fr; i <= la; i++) {
        while (p < data.size()) {
            if (data[p].first > i) break;
            S.insert(data[p].second);
            p++;
        }

        while (!S.empty()) {
            if (*S.begin() >= i) break;
            S.erase(S.begin());
        }

        if (S.empty()) continue;
        S.erase(S.begin()); ans++;
    }

    ans = min(ans, m);
    cout << n - ans;



    return 0;
}


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

vector<int> to[200000];
vector<ll> ans;

void dfs(int v, int p=-1){
  for(int u : to[v]){
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

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

  rep(i, n - 1) { int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i, n) cout << ans[i] << ' ';
  return 0;
}



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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    ll n,x=0; cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        x^=a[i];
    }
    rep(i,n){
        cout<<(x^a[i]);
        if(i!=n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	vector<string> s(3);
	rep(i,3) cin >> s[i];
	rep(i,3) cout << (char)(s[i][0] + ('A' - 'a'));
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val roadList = mutableMapOf<Int, MutableMap<Int, Long>>()
    (1 until n).forEach { a ->
        val (u,v,w) = readLine()!!.split(" ") .map { it.toLong() }
        val (s,e) = listOf(u,v).map { it.toInt() - 1 }
        if(!roadList.containsKey(s)) {
            roadList[s] = mutableMapOf()
        }
        if(!roadList.containsKey(e)) {
            roadList[e] = mutableMapOf()
        }
        roadList[s]!![e] = w
        roadList[e]!![s] = w
    }
    val queue = LinkedList<Int>()
    val color = (0 until  n).map { -1 }.toMutableList()
    color[0] = 0
    queue.push(0)
    while (queue.isNotEmpty()) {
        val current = queue.pop()
        for(next in roadList[current]!!.keys) {
            if(color[next] >= 0) {
                continue
            }
            if(roadList[current]!![next]!! % 2 == 0L) {
                color[next] = color[current]
            } else if(color[current] == 0) {
                color[next] = 1
            } else {
                color[next] = 0
            }
            queue.push(next)
        }
    }
    color.forEach { println(it) }
}


Measured memory_bytes: 126536
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int maximum = 0;
	int x = 0;
	vector<int> a;
	set<pair<pair<int,int>,int>> se;
	map<pair<pair<int,int>,int>,int> mp;
	cin>>N;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		x ^= a[i];
	}
	
	if(x){
		cout<<"No"<<endl;
		return 0;
	}
	
	if(N == 4){
		if(a[0] != a[2] || a[1] != a[3]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	/*
	int NUM = 8;
	for(int i = 0; i < NUM; i++){
		for(int j = 0; j < NUM; j++){
			for(int k = 0; k < NUM; k++){
				int a = i^j;
				int b = j^k;
				int c = k^i;
				// se.insert(make_pair(make_pair(a,b),make_pair(c,0)));
				mp[make_pair(make_pair(a,b),c)]++;
				cout<<a<<" "<<b<<" "<<c<<endl; 
			}
		}
	}
	// cout<<se.size()<<endl;
	
	for(pair<pair<pair<int,int>,int>,int> p : mp){
		cout<<p.first.first.first<<" "<<p.first.first.second<<" "<<p.first.second<<" con = "<<p.second<<endl;
		cout<<(p.first.first.first^p.first.first.second^p.first.second)<<endl;
	}
	
	*/
	cout<<"Yes"<<endl;
	
	return 0;
}

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

vector<vector<int> > graph;
vector<int> dist, used;

int go(int u) {
	used[u] = 1;
	dist[u] = 0;
	
	for(int v: graph[u]) {
		if(not used[v]) go(v);
		dist[u] = max(dist[u], dist[v] + 1);
	}

	return dist[u];
}

int main() {
	int v, e;
	cin >> v >> e;
	graph.assign(v, vector<int>());

	for(int i = 0; i < e; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].push_back(v);
	}
	dist.assign(v, 0);
	used.assign(v, 0);
	
	int ans = 0;
	for(int i = 0; i < v; i++) {
		if(not used[i]) {
			ans = max(ans, go(i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	while (a >=7) {
		a = a % 7;
	}
	if (a ==0 ) {
		cout << "thu" << endl;
	}
	if (a ==1 ) {
		cout << "fri" << endl;
	}
	if (a ==2 ) {
		cout << "sat" << endl;
	}
	if (a == 3) {
		cout << "sun" << endl;
	}
	if (a == 4) {
		cout << "mon" << endl;
	}
	if (a == 5) {
		cout << "tue" << endl;
	}
	if (a ==6 ) {
		cout << "wed" << endl;
	}
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;cin>>N>>A>>B;
  int ans=0;
  int P;
  int x;
  for(int i=1;i<N+1;i++){
    P=0;
    x=i;
    while(x){
      P+=x%10;
      x=(x-x%10)/10;
    }
    if(A<=P && P<=B)ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;

void solve()
{ long long int a=-1,b=-1,c=-1,n,w,i,j,ans=0,ans1,ans2;
  cin>>n>>w;
  vector<pair<ll,ll>>v;
  ll dp[n+1][w+1];
for(i=0;i<n;i++)
{
  cin>>a>>b;
   v.push_back(make_pair(a,b));
}

for(i=0;i<=n;i++)
{
  for(j=0;j<=w;j++)
  {   if(j==0 || i==0)
    {
       dp[i][j]=0;
       continue;
    }
     a=v[i-1].first;
     b=v[i-1].second;
     if(a<=j)
     dp[i][j]=max(dp[i-1][j-a]+b,dp[i-1][j]);
    else
      dp[i][j]=dp[i-1][j];
   //cout<<dp[i][j]<<" "<<i<<"  //";
  }
}
cout<<dp[n][w];

  
}
             
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
       


Measured memory_bytes: 82416
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	vl dp(m+1);
	dp[0]++;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		vl DP(m+1);
		for(int j=0;j<=m;j++) DP[j]=(dp[j]*2+(j>=x?dp[j-x]:0))%mod;
		dp=DP;
	}
	cout<<dp[m]<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	int now=1;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(now==a[i])now++;
	}
	if(now==1){
		cout << -1 << endl;
	}
	else{
		cout << n-now+1 << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) {
        cin >> L[i];
    }

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            for(int k=j+1; k<N; k++) {
                if(L[i] == L[j]) continue;
                if(L[j] == L[k]) continue;
                if(L[k] == L[i]) continue;
                int mn = min({L[i], L[j], L[k]});
                int mx = max({L[i], L[j], L[k]});
                int mi = L[i] + L[j] + L[k] - mn - mx;
                if(mn + mi > mx) ++ans;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
list = input().split()
for i in range(0,n):
   if int(list[i]) == n:
      p = i
      break

list1 = []
list2 = []
for k in range(0,n):
   list1.append(n* int ( list[k] ) - n + 1)
for k in range(0,n):
   list2.append( max ( int(list1[p] ) + 1 - p + k - int( list1[k] ), n - int ( list[k] ) +1))

a = ""
b = ""

list2.sort(reverse = True)
list1.sort()
for l in range (0,n):
   a += str(list1[l])
   a += " "
   b += str(list2[l])
   b += " "

print(a)
print(b)

Measured memory_bytes: 7172
N, Q = map(int, input().split())
S = input()
l = list()
cnt = [0] * N
for i in range(1, N):
  if(S[i-1] == 'A' and S[i] == 'C'):
    cnt[i] = cnt[i-1] + 1
  else:
    cnt[i] = cnt[i-1]
for i in range(Q):
  l, r = map(int, input().split())
  print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 6060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    double p[n] = {};
    for(int i=0;i<n;++i)
    {
      cin >> p[i];
    }

    double dp[n+1][n+1] = {};
    FILL(dp, 0);
    dp[0][0] = 1;
    for(int i=0;i<n;++i)
    {
      for(int j=0;j<=n;++j)
      {
        if(j > 0)
        {
          dp[i+1][j] = dp[i][j-1] * p[i] + dp[i][j] * (1 - p[i]);          
        }
        else
        {
          dp[i+1][j] = dp[i][j] * (1 - p[i]);
        }
      }
    }

    double ret = 0;
    for(int i=n;i>n-i;--i)
    {
      ret += dp[n][i];
    }

    printf("%.12lf\n", ret);
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std; // ;?????????
int main(){
	int a,b,c,i,j=0;
	cin >> a >> b >> c;
	
	for (i=0; i<=b-a; i++){
		if (c % (a+i)==0)
			j++;
	}
	cout << j << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n = 0;
    int k = 0;
    std::cin >> n >> k;
    
    std::vector<int> h;
    h.reserve(n);
    
    for(int i = 0; i < n; ++i)
    {
        int hn = 0;
        std::cin >> hn;
        h.emplace_back(hn);
    }
    
    std::sort(h.begin(), h.end());
    
    long long sum = 0;
    
    for(int i = 0; i < n - k; ++i)
    {
        sum += h.at(i);
    }
    
    std::cout << sum << std::endl;
}

Measured memory_bytes: 1656
#include <stdio.h>

int main(void)
{
	float judge[4] = {1.1, 0.6, 0.2, 0.0};
	float f;
	int i, eye[4][2] = {0};
	
	while (scanf("%f", &f) != EOF){
		i = 0;
		while (1){
			if (f >= judge[i]){
				eye[i][0]++;
				break;
			}
			i++;
		}	
		
		scanf("%f", &f);
		i = 0;
		while (1){
			if (f >= judge[i]){
				eye[i][1]++;
				break;
			}
			i++;
		}
	}
	
	for (i = 0; i < 4; i++){
		printf("%d %d\n", eye[i][0], eye[i][1]);
	}
	
	return (0);
}

Measured memory_bytes: 624
# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]

lmax = [0 for _ in range(n)]
rmax = [0 for _ in range(n)]

tmp_lmax = 0
for i, e in enumerate(a):
    tmp_lmax = max(tmp_lmax, e)
    lmax[i] = tmp_lmax

tmp_rmax = 0
for i, e in enumerate(a[::-1]):
    tmp_rmax = max(tmp_rmax, e)
    rmax[n - 1 - i] = tmp_rmax

# 1st
print(rmax[1])
# mid
for i in range(1, n-1):
    print(max(lmax[i-1], rmax[i+1]))
# last
print(lmax[n-2])


Measured memory_bytes: 15704
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/11/20 21:59:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  string s; cin>>s;
  auto solve = [&]() {
    if (n%2==1) {
      return false;
    }
    return s.substr(0, n/2) == s.substr(n/2, n/2);
  };
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#三井住友信託銀行2019-B
import math
n = int(input())

a = math.floor(n / 1.08)
b = math.ceil(n / 1.08)

if math.floor(a * 1.08) == n:
    print(a)
elif math.floor(b * 1.08) == n:
    print(b)
else:
    print(':(')

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(int(1e6))

n, m = map(int, input().split())

edges = {}

for i in range(m):
    s, t = map(int, input().split())
    if s not in edges:
        edges[s] = set()
    edges[s].add(t)

stack = []
visited = set()


def visit(v):
    if v in visited:
        return
    visited.add(v)
    if v in edges:
        for t in edges[v]:
            visit(t)
    stack.append(v)


for i in range(n):
    visit(i)

while len(stack) > 0:
    print(stack.pop())



Measured memory_bytes: 13444
#include <iostream>

int main()
{
  using namespace std;

  int a, b, c;
  int inputNum;
  cin >> inputNum;
  a = inputNum / 100;
  b = inputNum % 100 / 10;
  c = inputNum % 100 % 10;
  // cout << inputNum << endl;
  // cout << a << endl;
  // cout << b << endl;
  // cout << c << endl;
  if (a == 7 || b == 7 || c == 7)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int s,w ;
 cin >> s>> w;
 if(s<=w)
 cout <<"unsafe" << endl ;
 else

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

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){

    set<int> ans;
    REP(i,3){
        int t; cin>>t;
        ans.insert(t);
    }
    cout<<ans.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int m1, m2, d1, d2;
    scanf("%d %d\n %d %d\n", &m1, &d1, &m2, &d2);
    if(m1 == m2){
        printf("0\n");
    }else {
        printf("1\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, W = mapint()
VW = [list(mapint()) for _ in range(N)]
dp = [0]*(W+1)

for i in range(1, W+1):
    for v, w in VW:
        if i>=w:
            dp[i] = max(dp[i], dp[i-w]+v)

print(dp[-1])


Measured memory_bytes: 5928
#include<stdio.h>
int main(){
  int a,b;
  char s;

  while(1){
    scanf("%d %c %d", &a, &s, &b);
    if(s == '?')break;
    switch(s){
      case('+') : printf("%d\n", a+b);break;
      case('-') : printf("%d\n", a-b);break;
      case('*') : printf("%d\n", a*b);break;
      case('/') : printf("%d\n", a/b);break;
    }
  }
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

struct UnionFindTree{
    vector<int>par,sz,uku;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
		uku.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
			uku[i]=0;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
		uku[x]|=uku[y];
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,H,W;

signed main(){
	cin>>N>>H>>W;
	vector<tuple<int,int,int>>es;
	rep(i,N){
		int y,x,a;
		cin>>y>>x>>a;
		y--;x--;
		es.pb(make_tuple(a,y,x+H));
	}
	sort(all(es));reverse(all(es));

	int ans=0;
	UnionFindTree uf(H+W);
	for(auto &t:es){
		int a,y,x;
		tie(a,y,x)=t;
		if(uf.areSame(y,x)){
			if(uf.uku[uf.find(y)])continue;
			uf.uku[uf.find(y)]=1;
			ans+=a;	
		}
		else{
			if(uf.uku[uf.find(y)]&&uf.uku[uf.find(x)])continue;
			uf.unite(y,x);
			ans+=a;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    ll ans = 0;
    ll p = 0;
    for (int i = n; i--;) {
        ll cnt = (a[i] + ans) / b[i];
        ll rem = (a[i] + ans) % b[i];
        if (rem) cnt++;
        p = b[i] * cnt - (a[i] + ans);
        // cout << a[i] << ' ' << b[i] << ' ' << cnt << ' ' << p << '\n';
        ans += p;
    }

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


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

int main()
{
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = double(a) / double(b);
    cout << d << " " << r << " " << flush;
    cout<<fixed<<setprecision(5)<<f << endl;
    return 0;
}


Measured memory_bytes: 3296
program main
	implicit none
    integer(8)::n,m,i,t
    integer(8),allocatable::x(:),y(:)
    read(*,*)n,m
    allocate(x(m), y(m-1))
    read(*,*) x
    if(n>=m)then
    	write(*,*) 0
    else
    	t=0
    	call msort(x)
        do i=1,m-1
        	y(i)=abs(x(i+1)-x(i))
        end do
        call msort(y)
        do i=1,n-1
        	t=t+y(m-i)
        end do
        write(*,*) x(m)-x(1)-t
    end if
    deallocate(x,y)
        
        
        
        
        
    stop
contains
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b
 
    integer(8) :: c
 
    c = a
    a = b
    b = c
 
  end subroutine swap
 
  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program main

Measured memory_bytes: 5340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,b=0,w=0,t=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='.')w++;
   }
   t=w;
  for(int i=0;i<n;i++){
    if(s[i]=='#')b++;
    t=min(t,b+w-(i+1-b));
  }
  cout<<t;
}

Measured memory_bytes: 640
def resolve():
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)):
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 39152
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		
		String[] buf=sc.nextLine().split(" ");
		
		int a=Integer.parseInt(buf[0]);;
		int b=Integer.parseInt(buf[1]);;
		
		if(a+b!=15 && a*b!=15){
			System.out.println("x");
		}else if(a+b==15){
			System.out.println("+");
		}else if(a*b==15){
			System.out.println("*");
		}
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll s(n+1);
  rep(i,n) s[i+1]=s[i]+a[i];
  
  ll ans=0;
  
  rep(i,n){
    (ans+=(s[n]-s[i+1]+MOD)%MOD*a[i]%MOD)%=MOD;
  }
  
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 6368
#include<stdio.h>
int main(){
int a,b,c;
char op;
while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?') break;
if(op=='+') printf("%d\n",a+b);
if(op=='-') printf("%d\n",a-b);
if(op=='*') printf("%d\n",a*b);
if(op=='/') printf("%d\n",a/b);
}
return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a, b, c, k, ans;
  cin >> a >> b >> c >> k;

  if(a>=k){
    cout << k << endl;
    return 0;
  }
  if(a+b>=k){
    cout << a << endl;
    return 0;
  }
  cout << 2*a-k+b << endl;
  return 0;
}

Measured memory_bytes: 3580