akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int128_t cal_mod(const int128_t n, const int128_t mod) {
    // n % modを計算する。ただしmod <= 0 ならば何もしない。nが負の場合、正にして補正する。
    if (mod <= 0) {
        return n;
    } else if (0 <= n) {
        return n % mod;
    } else {
        int128_t tmp = (-n) / mod + 1;
        return (n + tmp * mod) % mod;
    }
}

int128_t pow_mod(int128_t x, int128_t n, const int128_t mod) {
    // 累乗の計算。mod <= 0ならば余りの計算は行わない。
    int128_t ret = 1;
    while (n > 0) {
        if (n & 1) { ret = cal_mod(ret * x, mod); }
        x = cal_mod(x * x, mod);
        n = (n >> 1);
    }
    return ret;
}

std::vector<std::pair<long long, int>> prime_factor(long long n) {
    // nの素因数分解。計算量はO(sqrt(n))なので、long longも入り得る。
    // intにおさまらない素数を入れた場合を考えて、keyはlong longにしておく。戻り値はintで十分と思われる。
    std::vector<std::pair<long long, int>> res;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int num = 0;
            while(n % i == 0) {
                num++;
                n = n / i;
            }
            res.push_back(std::pair<long long, int>({i, num}));
        }
    }
    if (n != 1) {
        res.push_back(std::pair<long long, int>({n, 1}));
    }
    return res;
}

const int MOD = 1e9 + 7;
int N;

int main(int argc, char **argv) {
    std::cin >> N;

    std::map<long long, int> mp;
    
    for (int i = 2; i <= N; i++) {
        std::vector<std::pair<long long, int>> fac = prime_factor(i);
        for (auto p : fac) {
            if (mp.find(p.first) == mp.end()) {
                mp[p.first] = p.second;
            } else {
                mp[p.first] += p.second;
            }
        }
    }

    int128_t ret = 1;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ret = (ret * (itr->second + 1)) % MOD;
    }

    std::cout << ret << std::endl;

    return 0;
}

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

using namespace std;

int a[501*501];
int x[501];
int n;

pair<int, int> v[501];

void no() {
  cout << "No\n";
  exit(0);
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    v[i] = {x[i], i};
  }
  sort(v + 1, v + n + 1);
  int last = 1;
  for (int i = 1; i <= n; i++) {
    a[v[i].first] = v[i].second;
    for (int j = 0; j < v[i].second - 1; j++) {
      while (a[last] != 0) last++;
      if (last >= v[i].first) no();
      a[last] = v[i].second;
    }
  }
  
  last = n*n;
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j < n - v[i].second; j++) {
      while (a[last] != 0) last--;
      if (last <= v[i].first) { no(); }
      a[last] = v[i].second;
    }
  }
  
  cout << "Yes\n";
  for (int i = 1; i <= n * n; i++) {
    cout << a[i] << ' ';
  }

  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int INF = 1000000;

int n;
ll h;
ll a[100005], b[100005];

int main(void){
    cin >> n >> h;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a, a + n);
    sort(b, b + n);

    int num = -1;
    for (int i = n - 1; i >= 0; i--){
        if (a[n - 1] >= b[i]){
            num = i;
            break;
        }
    }

    ll ans = 0;
    for (int i = n - 1; i >= -1; i--){
        if (i != num){
            h -= b[i];
            ans++;
        }
        else{
            ans += h / a[n - 1] + min(1, (int)(h % a[n - 1]));
            h = 0;
        }

        if (h <= 0) break;
    }

    cout << ans << endl;
    
    

}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
  int n, m; cin >> n >> m;
  if (n==0 && m==0) return;
  vector<int> h(n); rep(i, n) cin >> h[i];
  vector<int> w(m); rep(i, m) cin >> w[i];
  vector<int> hsum(n+1), wsum(m+1);
  rep(i, n) {
    hsum[i+1] = hsum[i] + h[i];
  }
  rep(i, m) {
    wsum[i+1] = wsum[i] + w[i];
  }
  vector<int> hd(1500005);
  vector<int> wd(1500005);
  for(int i=0; i<n+1; i++) {
    for(int j=i+1; j<n+1; j++) {
      int k = hsum[j] - hsum[i];
      hd[k]++;
    }
  }
  for(int i=0; i<m+1; i++) {
    for(int j=i+1; j<m+1; j++) {
      int k = wsum[j] - wsum[i];
      wd[k]++;
    }
  }
  ll ans = 0;
  rep(i, 1500005) {
    ans += hd[i]*wd[i];
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  while(!cin.eof()) {
    solve();
  }
}


Measured memory_bytes: 14600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    ll suma=0;
    for(auto i:s)
        suma+=(i-'0');
    if(suma%9==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3740
#include <cstdio>
#include <algorithm>
#define N 100001
#define inf 0x3f3f3f3f
using namespace std;
int n,m;
struct souvenir{
	int l,r,len;
	bool operator <(const souvenir &b){
		return len<b.len;
	}
}s[N*3];
int c[N];
int get(int i){
	int ans=0;
	for(;i;i-=i&(-i))ans+=c[i];
	return ans;
}
void add(int i,int v){
	for(;i<=m;i+=i&(-i))c[i]+=v;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,l,r;i<=n;++i){
		scanf("%d%d",&l,&r);
		s[i]=(souvenir){l,r,r-l+1};
	}
	sort(s+1,s+1+n);
	for(int i=1,j=1;i<=m;++i){
		while(j<=n&&s[j].len<i){
			add(s[j].l,1);
			add(s[j].r+1,-1);
			++j;
		}
		int ans=n-j+1;
		for(int k=i;k<=m;k+=i)
			ans+=get(k);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>a;	//priority_queue<Type,Container,Functional>
//Container默认vector Functional默认用operator<>
//队头元素最大
long long ans;
int main()
{
	int n,m,t;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		a.push(t);
	}
	for(int i=0;i<m;i++)
	{
		int x;
		x=a.top();
		a.pop();
		a.push(x/2);
	}
	for(int i=0;i<n;i++)
	{
		ans+=a.top();
		a.pop(); 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 892
n,x = input().split()
n,x = int(n),int(x)
L = input().split()
L = [int(l) for l in L]

D = 0
count = 1

for i in range(len(L)):
    D = D+L[i]
    if(D<=x):
        count += 1
    else:
        break
print(count)
    



Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	readb(x, y);
	
	FOR (i, 0, 100)
	    FOR (j, 0, 100)
	    {
	        if (i + j == x && 2*i + 4*j == y) {cout << "Yes"; return 0;}
	    }
	    
	    cout << "No";
}



















Measured memory_bytes: 3652
inp = list(map(int, input().split(" ")))
n = inp[0]
x = inp[1]

L = list(map(int, input().split(" ")))

c = 1
cood = 0
for l in L:
  cood += l
  if cood <= x:
    c += 1
  else:
    break
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)

using ll = long long;
using namespace std;

const int N = 2e5 + 100;

int n, a[N][2];
queue <int> q;

int s(int x) {
	return a[(x - 1 + n) % n][1] + a[(x + 1) % n][1];
}

void nie() {
	printf ("-1\n");
	exit(0);
}

int main() {
	scanf ("%d", &n);
	rep(j, 0, 1)
		rep(i, 0, n - 1)
			scanf ("%d", &a[i][j]);
			
	rep(i, 0, n - 1) {
		if (a[i][0] > a[i][1]) nie();
		if (a[i][1] > a[i][0] && s(i) < a[i][1]) q.push(i);
	}
		
	ll moves = 0;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		int cnt = (a[x][1] - a[x][0]) / s(x);
		moves += cnt;
		a[x][1] -= s(x) * cnt;
		
		int prv = (x - 1 + n) % n, nxt = (x + 1) % n;
		if (s(nxt) < a[nxt][1] && a[nxt][1] > a[nxt][0]) q.push(nxt);
		if (s(prv) < a[prv][1] && a[prv][1] > a[prv][0]) q.push(prv);
	}
	rep(i, 0, n - 1) if (a[i][0] != a[i][1]) nie();
	printf ("%lld\n", moves);
	return 0;
}


Measured memory_bytes: 5624
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
const int num = 10000, num1 = 500000, INF = 20000000;
int n, d[num], c[num];
vector<pair<int, int> > v[num];
priority_queue<pair<int, int> > q;
inline void mini() {
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		pair<int, int> p = q.top(); q.pop();
		int a = p.second;
		c[a] = 1;
		for (int i = 0; i < v[a].size(); i++) {
			int b = v[a][i].first;
			if (c[b] == 0 && d[b] > d[a] + v[a][i].second) {
				d[b] = d[a] + v[a][i].second;
				q.push(make_pair(d[b] * -1, b));
			}
		}
	}
		
}
int main() {
	int u, k, s, t;
	cin >> n;
	for (int i = 1; i < n; i++) {
		d[i] = INF;
		c[i] = 0;
	}
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++) {
			scanf("%d%d", &s, &t);
			v[u].push_back(make_pair(s, t));
		}
	}
	mini();
	for (int i = 0; i < n; i++) {
		printf("%d %d\n", i, d[i]);
	}
	return 0;
}

Measured memory_bytes: 8184
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    int n; cin >> n;
    reg int res = n / 2;
    if (n % 2) cout << (double)(res + 1) / (double)n << endl;
    else cout << (double)res / (double)n << endl;
    return 0;
}


Measured memory_bytes: 256
INF = float("INF")

def merge(A, left, mid, right):
    count = 0
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    
    i, j = 0, 0
    for k in range(left, right):
        count = count + 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return count

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        countL = mergeSort(A, left, mid)
        countR = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + countL + countR
    return 0
        

n = int(input())
A = [int(i) for i in input().split()]
count = mergeSort(A, 0, n)
for i in range(n):
    if i:
        print(" ", end = "")
    print(A[i], end = "")
print()
print(count)




Measured memory_bytes: 61664
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char A[N],B[N];
    void main()
	{
        int n=qread(),m=qread(),L=qread();pii st;st.FR=qread(),st.SE=qread();scanf("%s%s",A+1,B+1);
        pii x={1,n},y={1,m};
        fd(i,L,1)
        {
            if(B[i]=='D') x.FR--;if(B[i]=='U') x.SE++;if(B[i]=='L') y.SE++;if(B[i]=='R') y.FR--;
            chmax(x.FR,1);chmin(x.SE,n);chmax(y.FR,1);chmin(y.SE,m);
            // printf("B (%d->%d)(%d->%d)\n",x.FR,x.SE,y.FR,y.SE);
            if(A[i]=='D') x.SE--;if(A[i]=='U') x.FR++;if(A[i]=='L') y.FR++;if(A[i]=='R') y.SE--;
            chmax(x.FR,1);chmin(x.SE,n);chmax(y.FR,1);chmin(y.SE,m);
            // printf("A (%d->%d)(%d->%d)\n",x.FR,x.SE,y.FR,y.SE);
            if(x.FR>x.SE or y.FR>y.SE) break;
        }
        puts(x.FR<=st.FR and st.FR<=x.SE and y.FR<=st.SE and st.SE<=y.SE?"YES":"NO");
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

	int k,n;cin>>k>>n;
	int a[n];
	inputarr(a,n);
	int diff=a[n-1]-a[0];
	for(int i=1;i<n;i++){
		amin(diff,a[i-1]+k-a[i]);
	}
	cout<<diff;



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l,k=0,sum=0,d=0;
  cin>>n>>l;
  int a[n+1],b[n+1];
  a[0]=0;
  for(int i=1;i<n+1;i++)
  cin>>a[i];
  for(int i=0;i<=n;i++)
 {
    sum=sum+a[i];
    b[i]=sum;
    k++;
  }
  
  for(int i=0;i<=n;i++)
  { 
  	if(b[i]<=l)
  	d++;
  }
  cout<<d;
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

string f(string a, string b, int c) {
  if (!a.size()) return c ? string(1, c + '0') : "";
  int ia = a.back() - '0', ib = b.back() - '0';
  int s = ia + ib + c;
  c     = s / 10;
  a.pop_back(),
    b.pop_back();
  return f(a, b, c) + char(s % 10 + '0');
}

void solve() {
  int n;
  cin >> n;
  rep(_, n) {
    string a, b;
    cin >> a >> b;
    while (a.size() < b.size()) a = "0" + a;
    while (a.size() > b.size()) b = "0" + b;
    string x                      = f(a, b, 0);
    cout << (x.size() > 80 ? "overflow" : x) << endl;
  }
}

Measured memory_bytes: 3100
a,b=map(int,input().split())
l=list(map(int,input().split()))
root=[i for i in range(a)]
height=[0]*a
group=[set() for i in range(a)]
def find(a):
   f=a
   if a==root[a]:
      return a
   while a!=root[a]:
      a=root[a]
   root[f]=a
   return a
def union(a,b):
   A=find(a)
   B=find(b)
   if A==B:
      return
   if height[A]>height[B]:
      root[B]=root[A]
   else:
      root[A]=root[B]
      if height[A]==height[B]:
         height[B]+=1
for i in range(b):
   x,y=map(int,input().split())
   x-=1;y-=1
   union(x,y)
for i in range(a):
   group[root[find(i)]].add(l[i])
ans=0
for i in range(a):
   if i+1 in group[find(i)]:
      ans+=1
print(ans)

Measured memory_bytes: 47912
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int Q = scan.nextInt();
        Tree tree[] = new Tree[N + 1];
        for(int i = 0; i < N + 1; i++) {
            tree[i] = new Tree();
            tree[i].value = 0;
            tree[i].tree = new Tree();
        }

        for(int i = 0; i < N-1; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            tree[b].tree = tree[a];
        }

        for(int i = 0; i < Q; i++) {
            int p = scan.nextInt();
            int x = scan.nextInt();
            tree[p].value += x;
        }

        for(int i = 0; i < N; i++) {
            if (tree[i+1].tree != null)
                tree[i+1].value += tree[i+1].tree.value;
            os.print(tree[i+1].value);
            if(i+1 < N)
                os.print(" ");
            else
                os.println();
        }
    }
}

class Tree {
    int value = 0;
    Tree tree;

    public Tree(){}
}

Measured memory_bytes: 169516
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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() {
  double a, b, c;
  cin >> a >> b >> c;
  double s, l, h;
  c = c * M_PI / 180.;
  s = 0.5 * a * b * sin(c);
  l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c));
  h = b * sin(c);
  printf("%f\n%f\n%f\n", s, l, h);
  return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, D;
  cin >> N >> D;
  // int X[10][10];
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j < D; ++j)
    {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      int norm = 0;
      for (int k = 0; k < D; ++k)
      {
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }
      // check whether norm = k for some k
      bool flag = false;
      for (int k = 0; k <= norm; k++)
      {
        if (k * k == norm)
        {
          flag = true;
        }
      }
      if (flag)
        ans++;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int sz = 32;
using  bs = bitset<sz>;

int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;
    vint a(n), b(n);
    rep(i,n) cin>>a[i]>>b[i];
    vector<bs> ab(n);
    rep(i,n) ab[i] = bs(a[i]);


    bs kb = bs(k);
    // cout<<kb<<endl<<endl;

    ll ans = 0;

    bool f = false;
    repr(i,sz){
        ll tmp = 0;
        f = f|kb[i];
        if(!f) continue;

        if(not kb[i]) continue;
        bs mask = bs();
        rep(j,i+1) mask.set(j, 1);
        mask.flip();
        // cout<<mask<<endl;
        rep(j,n){
            if( ab[j][i]) continue;
            if(((~kb) & ab[j] & mask).any() ) continue;
            tmp += b[j];
            // cout<<"j: "<<j<<" "<<ab[j]<<endl;
        }
        chmax(ans, tmp);
    }

    ll tmp = 0;
    rep(j,n){
        if(((~kb) & ab[j]).any() ) continue;
        tmp += b[j];
        // cout<<j<<" ";
    }
    // cout<<endl;



    chmax(ans, tmp);

    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;

signed main(){
    int n, m;
    cin >> n >> m;
    if(n < m) swap(n, m);
    if(n - m > 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    rep(i, 1, n + 1){
        ans = (ans * i) % mod;
    }
    rep(i, 1, m + 1){
        ans = (ans * i) % mod;
    }
    if(n == m){
        ans = (ans * 2) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
p (gets.chars.reduce([0, 0]){|m, c|
    if m[1]<0
      m[0]+=(c=='g'?0:-1)
      m[1]+=1
    elsif c=='g'
      m[0]+=1
      m[1]-=1
    elsif c=='p'
      m[1]-=1
    end
    next m
   }).first

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;cin>>N;
  double a,b;
  vector<double>V(N);
  a=0;
  b=1;
  for(int i=0;i<N;i++){
    cin>>V.at(i);
    b*=V.at(i);
  }
  for(int i=0;i<N;i++){
    a+=b/V.at(i);
  }
  cout <<b/a<<endl;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int maxn = 1e5 + 5;
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


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 += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

int power(int x, unsigned int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;
	;
	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;

}

// Graph------------------------------------------------------------------------


int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
	// Never GIVE UP !!!!

	int n; cin >> n;
	vi dp(3);

	for (int day = 0; day < n; day++)
	{
		vi new_dp(3, 0);
		vi c(3);
		for (int i = 0; i < 3; i++)
			cin >> c[i];

		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (i != j)
				{
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}

		dp = new_dp;
	}

	cout << max(dp[0], max(dp[1], dp[2])) << endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
D = list(map(int, input().split()))

ans = 0

for left in range(K + 1):
    for right in range(K - left + 1):
        if left + right > N:
            break
        items = list(D[0:left])
        items.extend(D[::-1][0:right])
        dis = K - (left + right)
        i = 0
        items = sorted(items, reverse=True)
        while True:
            ans = max(ans, sum(items))
            if i < dis and len(items) > 0:
                i += 1
                items.pop()
                continue
            else:
                break

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    int n,a;
    vector<int> v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    int vsum = accumulate(v.begin(), v.end(), 0);
    if(vsum % 10 != 0){
        cout << vsum << endl;
        return 0;
    }
    for(unsigned i = 0;i<v.size();i++){
        if((vsum-v[i]) % 10 != 0){
            cout << vsum - v[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for(int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for(int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for(auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long N, std::vector<long long> a) {
    ascendingQueue firstArrays;
    vl firstArraysSum(N + 1);

    rep(i, 0, N) {
        firstArrays.push(a[i]);
        firstArraysSum[0] += a[i];
    }
    rep(i, N, 2 * N) {
        firstArrays.push(a[i]);
        ll minusNum = firstArrays.top();
        firstArrays.pop();
        firstArraysSum[i - (N - 1)] = firstArraysSum[i - N] + a[i] - minusNum;
    }

    decendingQueue latterArrays;
    vl latterArraysSum(N + 1);
    reverse(all(a));
    rep(i, 0, N) {
        latterArrays.push(a[i]);
        latterArraysSum[0] += a[i];
    }
    rep(i, N, 2 * N) {
        latterArrays.push(a[i]);
        ll minusNum = latterArrays.top();
        latterArrays.pop();
        latterArraysSum[i - (N - 1)] = latterArraysSum[i - N] + a[i] - minusNum;
    }

    ll ans = -INF;
    rep(i, 0, N + 1) {
        ll tmp = firstArraysSum[i] - latterArraysSum[N - i];
        ans = max(ans, tmp);
    }

    print(ans);
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(3 * N);
    for(int i = 0; i < 3 * N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 6516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int tmp,case_num = 1;

		while((tmp = sc.nextInt()) != 0){
			System.out.printf("Case %d: %d\n",case_num++, tmp);
		}
	}
}



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


int main() {
    ll n,t;
    cin >> n >> t;
    cout << max(n - t,0LL) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
bool option(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}
int32_t main(){ fast;
	int n,k; cin>>n>>k;
	set<int> set;
	int cnt = 0;
	map<int, int> map;
	rep(i, n){
		int x; cin>>x;
		if(!set.count(x)){
			cnt++;
			set.insert(x);
		}
		map[x]++;
	}
	//debug(cnt);
	if(cnt <= k){
		cout<<0<<endl;
		return 0;
	}
	vector<pair<int, int>> a;
	for(auto it: map){
		a.emplace_back(make_pair(it.first, it.second));
	}
	int need = cnt - k;
	//debug(need);
	sort(all(a), option);
	int ans = 0;
	for(int i = 0; i < need; i++){
		ans += a[i].second;
	}
	cout<<ans;
}


Measured memory_bytes: 21236
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
  cin>>n;
  long long sum[n+1];
  sum[n]=0;
  long long arr[n];
  for(int i=0;i<n;i++){
   cin>>arr[i]; 
   
  }
  for(int i=n-1;i>0;i--){
       sum[i]=arr[i]+sum[i+1];
       sum[i]%=1000000007;
   // cout<<sum[i]<<" "<<n<<endl;
      
  }
  long long ans=0;
  for(int i=0;i<n-1;i++){
    //   cout<<arr[i]<<endl;
    //   cout<<sum[i+1]<<endl;
    ans+=(arr[i]*sum[i+1])%(1000000007);
    ans%=1000000007;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6704
N, M = map(int, input().split())
P = 10**9+7
NG = [0] * (N+1)
for i in range(M):
    NG[int(input())] = 1

X = [1] + [0] * N
for i in range(1, N+1):
    if NG[i]:
        continue
    X[i] = (X[i-1] + (X[i-2] if i > 1 else 0)) % P

print(X[N])


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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    string s;
    cin>>s;

    forn(i,3){
        cout<<s[i];
    }   

    cout<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int n, t;
ll a[100010], b[100010];

int main() {
    cin >> n >> t;
    rep(i, n) {
        int l, r; cin >> l >> r;
        a[l]++;
        a[r++]--;
    }
    rep(i, t+1) {
        if (i == 0) b[i] = a[i];
        else b[i] = b[i-1] + a[i];
    }

    ll ans = 0;
    rep(i, t+1) chmax(ans, b[i]);
    cout << ans << endl;
}



Measured memory_bytes: 4660
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        List<Integer> distinctArray = new ArrayList<Integer>();
        for(int mochi :mochis){
            if(!distinctArray.contains(mochi)){
                distinctArray.add(mochi);
            }
        }

        System.out.println(distinctArray.size());
        sc.close();
    }

}


Measured memory_bytes: 22996
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int card[][]=new int[4][13];

		for(int t=0;t<n;t++) {
			String type=sc.next();
			int num=sc.nextInt();

			if(type.equals("S")) {
				card[0][num-1]=1;
			}else if(type.equals("H")) {
				card[1][num-1]=1;
			}else if(type.equals("C")) {
				card[2][num-1]=1;
			}else {
				card[3][num-1]=1;
			}
		}

		for(int a=0;a<4;a++) {
			for(int b=0;b<13;b++) {
				if(card[a][b]!=1) {
					if(a==0) {
						System.out.println("S "+(b+1));
					}else if(a==1) {
						System.out.println("H "+(b+1));
					}else if(a==2) {
						System.out.println("C "+(b+1));
					}else if(a==3) {
						System.out.println("D "+(b+1));
					}
				}
			}
		}



	}
}





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


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

  if(a-b < c){
    cout << c- (a-b) <<endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int coins_500, coins_100, coins_50;
  int target;
  FILE *fp;
  fp = stdin;
  char line[7];
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_500);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_100);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &coins_50);
  if(!fgets(line, 7, fp)) return 0;
  sscanf(line, "%d", &target);
  int i, j, k;
  int cnt = 0;
  for(i = 0; i<=coins_500; i++) {
    for(j = 0; j <=coins_100; j++) {
      for(k = 0; k <=coins_50; k++) {
        if(i*500+j*100+k*50 == target) cnt++;
      }
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, x, mn=1e18;
ll f(ll p, ll q, ll r) {
	ll x = max(p, max(q, r));
	ll y = min(p, min(q, r));
	return min(mn, x-y);
}

int main() {
	ll i, t;
	cin>>h>>w;
	if(h*w%3==0) mn = 0;
	for(i=1; i<h; i++) {
		t = h-i;
		mn = f(i*w, t/2*w, ((t-1)/2+1)*w);
		mn = f(i*w, t*(w/2), t*((w-1)/2+1));
	}
	for(i=1; i<w; i++) {
		t = w-i;
		mn = f(i*h, t/2*h, ((t-1)/2+1)*h);
		mn = f(i*h, t*(h/2), t*((h-1)/2+1));
	}
	cout<<mn;
	return 0;
}

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

#define endl '\n'
#define all(x) (x).begin(),(x).end()

namespace atcoder {
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void inline init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}

using namespace atcoder;

int main(){
	init();

	int N;
	cin >> N;
	ll ans=0;
	for(int i=1;i<=N;i++){
		if(i%3!=0&&i%5!=0) ans+=i;
	}
	cout <<ans <<endl;
}

Measured memory_bytes: 3608
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        親が同じか判別する
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        yをxの根に繋ぐ
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """
        xとyが同じ連結成分か判別する
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xの連結成分の大きさを返す
        """
        return -self.parents[self.find(x)]

    def kruskal(self, edge):
        """
        :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
        :return: 最小全域木のコストの和
        """
        edge.sort()
        cost_sum = 0
        for cost, node1, node2 in edge:
            if not self.same(node1, node2):
                cost_sum += cost
                self.union(node1, node2)
        return cost_sum


def resolve():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    res = 1
    for _ in range(m):
        a, b = map(int, input().split())
        if not uf.same(a - 1, b - 1):
            uf.union(a - 1, b - 1)
            res = max(res, uf.size(a - 1))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14432
#include<bits/stdc++.h>
using namespace std;
long long x,a,b,i,xx,nw;
int main()
{
	cin>>x;
	for(i=-(long long)sqrt(x);i*i<=x;i++)
	{
		if(i==0)
		{
			continue;
		}
		if(x%i!=0)
		{
			continue;
		}
		nw=x/i;
		for(b=-1000;b<=1000;b++)
		{
			a=b+i;
			xx=a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b;
			if(xx==nw)
			{
				cout<<a<<' '<<b<<endl;
				return 0;
			}
		}
		nw=i;
		for(b=-1000;b<=1000;b++)
		{
			a=b+x/i;
			xx=a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b;
			if(xx==nw)
			{
				cout<<a<<' '<<b<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3680
/*input
10 8
##...#.#
##...#.#
..###.#.
#.##.#.#
.#..#.#.
..##.#.#
##.#.#..
...#.#..
###.#.##
###..###
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 2005
int n, m;
int a[N][N];
pair<int, int> f[4 * N];
int top[N];
int ans = 0;

void update(int k, int l, int r, int pos, int val) {
	if (pos < l || r < pos) return;
	if (l == r && r == pos) {
		f[k].fi = val; f[k].se = pos;
		return;
	}
	int mid = (l + r) / 2;
	update(k * 2, l, mid, pos, val); update(k * 2 + 1, mid + 1, r, pos, val);
	f[k] = max(f[k * 2], f[k * 2 + 1]);
}

pair<int, int> get(int k, int l, int r, int L, int R) {
	if (r < L || R < l) return mp(0, 0);
	if (L <= l && r <= R) return f[k];
	int mid = (l + r) / 2;
	return max(get(k * 2, l, mid, L, R), get(k * 2 + 1, mid + 1, r, L, R));
}

void upgrade(int wh) {
	for (int i = 2; i <= m; i++) {
		int sum = a[wh][i] + a[wh][i - 1] + a[wh - 1][i] + a[wh - 1][i - 1];
		if (sum & 1) {
			top[i] = wh;
			update(1, 1, m, i, wh);
		}
	}
}

int solve(int l, int r, int base) {
	if (l > r) return 0;
	if (l == r) {
		int h = base - top[l] + 1;
		return h * (r - l + 2);
	}
	pair<int, int> rec = get(1, 1, m, l, r);
	int h = base - rec.fi + 1;
	int ret = h * (r - l + 2);
	ret = max(ret, solve(l, rec.se - 1, base));
	ret = max(ret, solve(rec.se + 1, r, base));
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c; cin >> c;
			if (c == '#') a[i][j] = 1;
		}
	}
	for (int i = 1; i <= m; i++) update(1, 1, m, i, 1), top[i] = 1;
	ans = max(n, m);
	for (int i = 2; i <= n; i++) {
		upgrade(i);
		ans = max(ans, solve(2, m, i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 31744
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = Integer.parseInt(sc.next());

		switch(i % 10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;

		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;

		case 3:
			System.out.println("bon");
			break;

		}
	}
}


Measured memory_bytes: 35472
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int ans[maxn],n;
int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(i==0) ans[i]+=x;
        x=n-x;
        for(int j=1;j<n;j++)
        {
            ans[n-j]=(ans[n-j]+x)%n;
            x=(x*i)%n;
        }
    }
    for(int i=0;i<n;i++)
    cout<<ans[i]<<" ";
    return 0;
}

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

inline bool operator<(const pii &lhs,const pii &rhs)
{
    return(lhs.first<rhs.first);
}

int n,k;
priority_queue<pii,vector<pii>,greater<pii>> q;

void input(){
    cin>>n;
    int a;
    rep(i,n){
        cin>>a;
        q.push({a,i+1});
    }
}

void src(){
    rep(i,n){
        cout<<q.top().second<<" ";
        q.pop();
    }
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 1780