akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
long long dp[100005];
vector <pair<int,int> > v[100005];
const long long INF=2e18+3;
int main()
{
	int n,m;
	cin>>n>>m;
	int a,b,d;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b>>d;
		a--,b--;
		v[a].push_back(make_pair(b,d));
		v[b].push_back(make_pair(a,-d));
	}
	for(int i=0;i<n;i++)
	    dp[i]=INF;
	for(int i=0;i<n;i++)
	{
		if(dp[i]==INF)
		{
			queue <int> que;
			que.push(i);
			dp[i]=0;
			while(que.size())
			{
				int u=que.front();
				que.pop();
				for(int j=0;j<v[u].size();j++)
				{
					pair<int,int> p=v[u][j];
					int to=p.first,c=p.second;
					if(dp[to]==INF)
					{
						dp[to]=dp[u]+(long long)c;
						que.push(to);
					}
					else
					if(dp[to]!=dp[u]+(long long)c)
					{
						cout<<"No";
						return 0;
					}
				}
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 9728
m,g[9999],D,d;S(i){g[i]?g[i]=0,++d>D?D=d:0,S(i-1),S(i+1),S(i+m),S(i-m),g[i]=d--:0;}main(n){for(;scanf("%d%d",&m,&n)*m;printf("%d\n",D)){bzero(g,4e4);for(D=n*=++m;D--;)D%m&&scanf("%d",g+m+D);for(;n--;)S(m+n);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	for( auto &s : l ){
		cin >> s;
	}
	sort( l.begin(), l.end(), greater<int>() );
	int sum = accumulate( l.begin(), l.end(), 0 );
	if( l[0] < sum-l[0] ){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    vector<int> v(1e5 * 2 + 1);
    lint ans=0;
    for (int i = 2; i < SZ(v);i++)
    {
        if(v[i]==0&&i>=n){
            cout << i << "\n";
            return 0;
        }
        for (int j = 1; i * j < SZ(v);j++){
            v[i * j] = 1;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ss;
    cin>>ss;
    int tot=0;
    int n=ss;
    while(ss>0){
        tot+=ss%10;
        ss/=10;
    }
    if(n%tot==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(){
	int N , T , B , L;
	while(cin >> N >> T >> L >> B && N){
		int flag[101] = {0};
		for(int i = 0 ; i < L ; i++){int a; cin >> a; flag[a] = 1;}
		for(int i = 0 ; i < B ; i++){int a; cin >> a; flag[a] = 2;}
		double dp[111][101]={0};
		dp[0][0] = 1.0;
		for(int i = 0 ; i < T ; i++){
			for(int j = 0 ; j < N ; j++){
				for(int k = 1 ; k <= 6 ; k++){
					int next;
					int nextindex = i+1;
					if(j+k > N){
						next = 2*N-(j+k);
					}else{
						next = j+k;
					}
					if(flag[next] == 2) next = 0;
					else if(flag[next]==1) nextindex++;
					dp[nextindex][next] += dp[i][j] / 6;
				}
			}
		}
		double ans = 0;
		for(int i = 0 ; i <= T ; i++){
			ans += dp[i][N];
		}
		printf("%.8f\n",ans);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
long long d,p[maxn],dx1[maxn],dx2[maxn];
vector<long long> v;
void dfs(long long s,long long e,vector<pair<long long,long long> >&w,long long val,long long cnt)
{
	if(s==e)
	{
		w.push_back(pair<long long,long long>(val,cnt));
		return ;
	}
	for(long long i=-9;i<=9;i++)
		dfs(s+1,e,w,val+i*v[s],cnt*(s==0?dx2[i+10]:dx1[i+10]));
}
long long solve(long long l)
{
	v.clear();
	for(long long i=0;l-1-i>i;i++)
		v.push_back(p[l-1-i]-p[i]);
	vector<pair<long long,long long> >v1,v2;
	dfs(0,(v.size()+1)/2,v1,0,1);
	dfs((v.size()+1)/2,v.size(),v2,0,1);
	long long cnt=0;
	map<long long,long long> mp;
	for(auto &i: v2)
		mp[i.first]+=i.second;
	for(auto &i: v1)
		cnt+=mp[i.first+d]*i.second;
	if(l%2==1)
		cnt*=10;
	return cnt;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    p[0]=1;
    for(long long i=1;i<20;i++)
    	p[i]=p[i-1]*10;
    for(long long i=0;i<10;i++)
    	for(long long j=0;j<10;j++)
    		dx1[i-j+10]++;
    for(long long i=1;i<10;i++)
    	for(long long j=0;j<10;j++)
    		dx2[i-j+10]++;
    cin>>d;
    long long ans=0;
    for(long long i=2;i<=18;i++)
    	ans+=solve(i);
    cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define rg register
#define In inline
#define ll long long 

const int N = 524288;
const ll mod = 924844033;
const ll g = 5;
const ll vg = (mod * 8 + 1) / g;

namespace IO{
	In ll read(){
		ll s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(ll x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
}
using namespace IO;

namespace ModCalc{
	In void Inc(ll &x,ll y){
		x += y;if(x >= mod)x -= mod;
	}
	In void Dec(ll &x,ll y){
		x -= y;if(x < 0)x += mod;
	}
	In ll Add(ll x,ll y){
		Inc(x,y);return x;
	}
	In ll Sub(ll x,ll y){
		Dec(x,y);return x;
	}
}
using namespace ModCalc;

//polycalc
ll power(ll a,ll n){
	ll s = 1,x = a;
	while(n){
		if(n & 1)s = s * x % mod;
		x = x * x % mod;
		n >>= 1;		
	}
	return s;
}

int bit_rev[N+5];
ll p[N+5],jc[N+5],iv[N+5];

void NTT(ll a[],int deg,int L,int opt){
	for(rg int i = 1;i < deg;i++){
		bit_rev[i] = (bit_rev[i>>1]>>1) ^ ((i&1)<<(L-1));
		if(i < bit_rev[i])swap(a[i],a[bit_rev[i]]);
	}
	int x = opt == 1 ? g : vg;
	for(rg int n = 2;n <= deg;n <<= 1){
		int m = n >> 1;
		ll wm = power(x,(mod-1) / n);
		for(rg int i = 0;i < deg;i += n){
			ll w = 1;
			for(rg int j = 0;j < m;j++,w = w * wm % mod){
				ll u = a[i+j],v = a[i+j+m] * w % mod;
				a[i+j] = Add(u,v);
				a[i+j+m] = Sub(u,v);
			}
		}
	}
	if(opt == -1){
		ll inv = power(deg,mod - 2);
		for(rg int i = 0;i < deg;i++)a[i] = a[i] * inv % mod;
	}
}

ll f[N+5],c[N+5];

void prepro(){
	jc[0] = 1;
	for(rg int i = 1;i <= N;i++)jc[i] = jc[i-1] * i % mod;
	iv[N] = power(jc[N],mod - 2);
	for(rg int i = N - 1;i >= 0;i--)iv[i] = iv[i+1] * (i + 1) % mod;
}

//tree
vector<int>E[N+5];
int sz[N+5];
int n;

void dfs(int u,int fa){
	sz[u] = 1;
	for(rg int i = 0;i < E[u].size();i++){
		int v = E[u][i];
		if(v == fa)continue;		
		dfs(v,u);
		sz[u] += sz[v];
	}
	if(u != 1){
		Dec(p[sz[u]],1);
		Dec(p[n-sz[u]],1);
		p[n]++;
	}
}

ll a1[8],a2[8],a3[8];

int main(){
//	freopen("AGC005F.in","r",stdin);
//	freopen("AGC005F.out","w",stdout);
	n = read();
	for(rg int i = 1;i < n;i++){
		int u = read(),v = read();
		E[u].push_back(v);
		E[v].push_back(u);
	}
	dfs(1,0);
	prepro();

	for(rg int i = 0;i <= n;i++)p[i] = p[i] * jc[i] % mod;
	for(rg int i = 0;i <= n;i++)c[i] = iv[n-i];
	int deg = 1,L = 0;
//cout<<"p[]:"<<endl;
//for(rg int i = 0;i <= n;i++)cout<<p[i]<<" ";cout<<endl;
//cout<<"c[]:"<<endl;
//for(rg int i = 0;i <= n;i++)cout<<c[i]<<" ";cout<<endl;
	while(deg <= 2 * n)deg <<= 1,L++;
	NTT(p,deg,L,1);
	NTT(c,deg,L,1);
	for(rg int i = 0;i < deg;i++)f[i] = p[i] * c[i] % mod;
	NTT(f,deg,L,-1);
//for(rg int i = 0;i < deg;i++)cout<<f[i]<<" ";cout<<endl;
	
	for(rg int i = 0;i <= n;i++)f[i] = Add(f[i+n] * iv[i] % mod,jc[n] * iv[i] % mod * iv[n-i] % mod);
	for(rg int i = 1;i <= n;i++)write(f[i]),putchar('\n');
	return 0;
}

Measured memory_bytes: 57344
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
c = Counter(S)
l = c.most_common()
max = l[0][1]
answer = []
for k, v in l:
    if v == max:
        answer.append(k)

answer.sort()
for a in answer:
    print(a)


Measured memory_bytes: 47796
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
        int a,b,c;
        cin>>a>>b>>c;
        cout<<min(a*b,c);
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	string s, t;
	cin >> s >> t; t.erase(--t.end());
	if (t == s)puts("Yes"); else puts("No");
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
 
using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,k;
  cin>>a>>b>>k;
  if (k <= a) {
    a -= k;
  } else {
    k -= a;
    a = 0;
    b -= k;
    b = max(b, 0l);
  }
  cout<<a<<' '<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var s = input[0];
            var w = input[1];
            
            if(s <= w) {Console.WriteLine("unsafe");}
            else {Console.WriteLine("safe");}
        }
    }
}


Measured memory_bytes: 28180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int> t(n);
    rep(i,n) cin>>t[i];

    sort(all(t));
    int ans=0;
    int i=0;
    while(i<n){
        ans++;
        int start=i;
        while(i<n && t[i]-t[start]<=k && i-start<c) i++;
    }

    cout<<ans<<endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  bool res = true;
  if (n % 2 != 0) {
    res = false;
  }
  else {
    string l = s.substr(0, n / 2);
    string r = s.substr(n / 2, n / 2);
    if (l != r) {
      res = false;
    }
  }
  if (res) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,r;cin >> n >> r;
    if(n>=10)
    {
        cout << r << endl;
        return 0;
    }else
    {
        cout << r+100*(10-n) << endl;
    }
    
}

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

struct path{
	int cost;
	int time;
};

using namespace std;

int main(){


	int N, T;

	cin >> N >> T;

	struct path x[N];

	for(int i = 0; i < N; i++){
		cin >> x[i].cost >> x[i].time;
	}

	sort(&x[0], &x[N], [](const path& a, const path& b) {return a.cost < b.cost;} );

	int ans = 0;
	for( int i = 0; i < N ; i++){
		if(x[i].time <= T){
			cout << x[i].cost << endl;
			return 0;
		}
	}

	cout << "TLE"  << endl;

	return 0;
}


Measured memory_bytes: 256
N=io.read"*n"
K=io.read"*n"

a={}
for i=1,K do
	d=io.read"*n"
	for i=1,d do
		a[io.read"*n"]=0
	end
end
s=0
for i=1,N do
	if not(a[i])then s=s+1 end
end
print(s)

Measured memory_bytes: 2728
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
using namespace std;

long long int wa(string s, int l, int r){
    long long int ans = 0;
    for(int i = l; i <= r; i++){
        ans = ans *10 + (s[i] - '0');
    }
    return ans;
}

int main(void){
    string s;
    long long int ans = 0;
    cin >> s;
    int pls = s.length() - 1;

    for (int bit = 0; bit < (1<<(pls)); ++bit) {
        int left = 0, right = 0;
        for(int i=0; i < pls; i++){
            if(bit & (1<<i)){
                ans += wa(s, left, i);
                left = i + 1;
            }
        }
        ans += wa(s, left, pls);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vec a(n);
    rep(i,n)a[in()]++;
    bool bl=true;
    if(n%2==0)rep(i,n){
        if((i%2==0&a[i]!=0)||(i%2==1&a[i]!=2))bl=false;
    }else{
        if(a[0]!=1)bl=false;
        rep2(i,1,n-1)if((i%2==0&a[i]!=2)||(i%2==1&a[i]!=0))bl=false;
    }
    if(!bl){
        cout<<0<<endl;
    }else{
        ll ans=1;
        rep(i,n/2){
            ans*=2;
            ans%=1000000007;
        }
        cout<<ans<<endl;
    }
}

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

#define int long long

typedef pair<int,int> pii;

int N,K;
vector<int> V;
vector<int> A;
vector<pii> B;

int sum(int i)
{
    int res = 0;
    while(i > 0)
    {
        res += B[i - 1].second;
        i -= i & -i;
    }
    return res;
}

void add(int i,int x)
{
    while(i <= B.size())
    {
        B[i - 1].second += x;
        i += i & -i;
    }
    return;
}

signed main()
{
    scanf("%lld%lld",&N,&K);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%lld",&a);
        V.push_back(a - K);
    }
    A.push_back(0);
    A.push_back(V[0]);
    for(int i = 1; i < V.size(); i++)
    {
        V[i] += V[i - 1];
        A.push_back(V[i]);
    }
    V.push_back(0);
    sort(V.begin(),V.end());
    /*
    for(int i = V.size() - 1; i >= 0; i--)
    {
        if(i == V.size() - 1)
        {
            B.push_back(make_pair(V[i],1));
        }
        else if(B[B.size() - 1].first != V[i])
        {
            B.push_back(make_pair(V[i],1));
        }
        else
        {
            B[B.size() - 1].second++;
        }
    }
    */
    for(int i = V.size() - 1; i >= 0; i--)
    {
        if(i == V.size() - 1 || B[B.size() - 1].first != V[i])
        {
            B.push_back(make_pair(V[i],0));
        }
    }
    bool flag = false;
    for(int i = 0; i < V.size(); i++)
    {
        if(V[i] == 0 && !flag)
        {
            flag = true;
            continue;
        }
        int l = 0,r = B.size();
        while(r - l > 1)
        {
            int mid = (l + r) / 2;
            if(B[mid].first == V[i])
            {
                l = mid;
                break;
            }
            else if(B[mid].first > V[i])
            {
                l = mid + 1;
            }
            else
            {
                r = mid;
            }
        }
        add(l + 1,1);
    }
    int ans = 0;
    for(int i = 0; i < A.size() - 1; i++)
    {
        int l = 0,r = B.size();
        while(r - l > 1)
        {
            int mid = (l + r) / 2;
            if(B[mid].first == A[i])
            {
                l = mid;
                break;
            }
            else if(B[mid].first > A[i])
            {
                l = mid + 1;
            }
            else
            {
                r = mid;
            }
        }
        ans += sum(l + 1);
        l = 0;r = B.size();
        while(r - l > 1)
        {
            int mid = (l + r) / 2;
            if(B[mid].first == A[i + 1])
            {
                l = mid;
                break;
            }
            else if(B[mid].first > A[i + 1])
            {
                l = mid + 1;
            }
            else
            {
                r = mid;
            }
        }
        add(l + 1,-1);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int h, w, d[55][55];
char c[55][55];

int bfs() {
	std::queue<p> que;
	for (int i = 1;i <=h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	que.push(p(1, 1));
	d[1][1] = 0;
	while (que.size()) {
		p P = que.front();que.pop();
		if (P.first == h&&P.second == w) {
			break;
		}
		for (int i = 0;i < 4;i++) {
			ll nx = P.first + dx[i], ny = P.second + dy[i];
			if (0 < nx&&nx <= h && 0 < ny&&ny <= w&&c[nx][ny] == '.'&&d[nx][ny] == INF) {
				que.push(p(nx, ny));
				d[nx][ny] = d[P.first][P.second] + 1;
			}
		}
	}
	return d[h][w];
}

int main() {
	int sum = 0;
	std::cin >> h >> w;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			std::cin >> c[i][j];
			if (c[i][j] == '.')sum++;
		}
	}
	if (bfs() == INF)std::cout << -1 << std::endl;
	else std::cout << sum - bfs() - 1 << std::endl;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), np.int64)

A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]

def f(x):
    cnt_tpl = 0
    if x >= 0: cnt_tpl += len(zero) * N
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    cnt_tpl -= np.count_nonzero(A * A <= x)
    # assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x

print(right)

Measured memory_bytes: 32300
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int t[6];
int p,q,all;
int b[6];
int d[6];
bool flag,flag2;
char res[30001];
char now[30001];
char str[4]={'E','N','S','W'};

bool check(){
	if(d[0]<0 || d[1]<0 || d[2]<0 || d[3]<0 || d[4]<0 || d[5]<0)return false;
	if(d[0]+d[3]>d[1]+d[2]+d[4]+d[5])return false;
	if(d[1]+d[4]>d[0]+d[2]+d[3]+d[5]+1)return false;
	if(d[2]+d[5]>d[0]+d[1]+d[3]+d[4]+1)return false;
	return true;
}


void roll(int v){
	if(v==0){
		int sw=d[0];
		d[0]=d[2];
		d[2]=d[3];
		d[3]=d[5];
		d[5]=sw;
	}
	if(v==2){
		int sw=d[0];
		d[0]=d[1];
		d[1]=d[3];
		d[3]=d[4];
		d[4]=sw;
	}
	if(v==1){
		int sw=d[0];
		d[0]=d[4];
		d[4]=d[3];
		d[3]=d[1];
		d[1]=sw;
	}
	if(v==3){
		int sw=d[0];
		d[0]=d[5];
		d[5]=d[3];
		d[3]=d[2];
		d[2]=sw;
	}
}

void dfs(int rest,int power){
	if(flag2)return;
	if(rest==0){
		flag2=true;
		flag=true;
		for(int i=0;i<all;i++)res[i]=now[i];
	}
	for(int i=0;i<4;i++){
		roll(i);
		d[3]--;
		if(check()){
			now[all-rest]=str[i];
			if(power==0){
				if(str[i]==res[all-rest])dfs(rest-1,0);
				if(str[i]<res[all-rest])dfs(rest-1,1);
			}
			else dfs(rest-1,1);
		}
		d[3]++;
		if(i==0)roll(3);
		if(i==3)roll(0);
		if(i==1)roll(2);
		if(i==2)roll(1);
	}
}

int main(void){
	for(int i=0;i<6;i++)b[i]=i;
	while(1){
		all=0;
		for(int i=0;i<6;i++){
			scanf("%d",&t[i]);
			all+=t[i];
		}
		if(all==0)break;
		flag=false;
		scanf("%d %d",&p,&q);
		do{
			for(int i=0;i<6;i++){
				d[i]=t[b[i]];
			}
			if(check()){
				flag2=false;
				if(!flag)dfs(all,1);
				else dfs(all,0);
			}
		}while(next_permutation(b,b+6));
		if(!flag)printf("impossible\n");
		else{
			for(int i=p-1;i<q;i++){
				printf("%c",res[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[1000][5][5][5];
//main
signed main(){
  char a;cin>>a;
  if(a=='A')cout<<"T"<<endl;
  if(a=='T')cout<<"A"<<endl;
  if(a=='C')cout<<"G"<<endl;
  if(a=='G')cout<<"C"<<endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double x[4],y[4];
	while(cin>>x[0]){
		cin>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
		if(x[1]<x[2] || x[3]<x[0] || y[1]<y[2] || y[3]<y[0]){
			out("NO");
		}
		else out("YES");
	}
	
	return 0;
}


Measured memory_bytes: 3216
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque

class Dinic:
    def __init__(self,n,edges):
        self.n=n
        self.edges=[[] for _ in range(n)]
        self.iter=[0]*n
        self.level=None
        self.graph(edges)
    def graph(self,E):
        edges=self.edges
        for fr,to,cap in E:
            edges[fr].append([to,cap,len(edges[to])])
            edges[to].append([fr,0,len(edges[fr])-1])
    def maxflow(self,source,sink):
        max_flow=0
        while True:
            self.bfs(source)
            if self.level[sink]<0:
                return max_flow
            self.iter=[0]*self.n
            flow=self.dfs(source,sink,float('inf'))
            while flow:
                max_flow+=flow
                flow=self.dfs(source,sink,float('inf'))
    def bfs(self,source):
        edges=self.edges
        level=[-1]*self.n
        level[source]=0
        q=deque([source])
        while q:
            fr=q.popleft()
            for to,cap,_ in edges[fr]:
                if cap>0>level[to]:
                    level[to]=level[fr]+1
                    q.append(to)
        self.level=level
    def dfs(self,source,sink,flow):
        if source==sink:
            return flow
        while self.iter[source]<len(self.edges[source]):
            to,cap,rev=self.edges[source][self.iter[source]]
            if cap>0 and self.level[source]<self.level[to]:
                f=self.dfs(to,sink,min(flow,cap))
                if f:
                    self.edges[source][self.iter[source]][1]-=f
                    self.edges[to][rev][1]+=f
                    return f
            self.iter[source]+=1
        return 0

n=int(input())
A=list(map(int,input().split()))
Edges=[]
s=0
for i in range(n):
    if A[i]<=0:
        Edges.append((0,i+1,-A[i]))
    else:
        s+=A[i]
        Edges.append((i+1,n+1,A[i]))
    for j in range(2*(i+1),n+1,i+1):
        Edges.append((i+1,j,float('inf')))
dinic=Dinic(n+2,Edges)
print(s-dinic.maxflow(0,n+1))

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

int main() {
    char x, y;
    cin >> x >> y;
    map<char, int> s;
    s['A'] = 0;
    s['B'] = 1;
    s['C'] = 2;
    s['D'] = 3;
    s['E'] = 4;
    s['F'] = 5;
    if(x==y){
        cout << '=' << endl;
        return 0;
    }
    if(s[x] < s[y]){
        cout << '<' << endl;
    }else{
        cout << '>' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = input()
	N = N[:-1]

	ind = [chr(i) for i in range(97,97+26)]

	for i, val in enumerate(ind):
		#print(val)
		if val == N:
			print(ind[i+1])

if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
n = int(input())
A = list(map(int, input().split()))
 
def adj(n, a ,flag):
    na = 0
    cnt = 0
    for i in range(n):
        na += a[i]
        if flag == 1:
            if na <= 0:
                cnt += 1 - na
                na = 1
            flag = -1
        
        elif flag == -1:
            if na >= 0:
                cnt += na + 1
                na = -1
            flag = 1
    return cnt            

print(min(adj(n, A, 1),adj(n, A, -1)))

Measured memory_bytes: 14332
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int m = 10;
    vector<int> F(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x;
            cin >> x;
            if (x == 1) {
                F[i] |= 1 << j;
            }
        }
    }

    vector<vector<int>> P(n, vector<int>(m + 1, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= m; ++j) {
            cin >> P[i][j];
        }
    }

    long long res = -(1LL << 60);
    for (int i = 1; i < (1 << m); ++i) {
        long long pro = 0;
        for (int j = 0; j < n; ++j) {
            int f = F[j] & i;
            int cnt = 0;
            for (int k = 0; k < m; ++k) {
                if ((f >> k) & 1) {
                    ++cnt;
                }
            }
            pro += P[j][cnt];
        }
        res = max(res, pro);
    }
    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    deque< char > dq;
    for(auto &ele:s)dq.push_back(ele);
    ll q,f=0;cin>>q;
    while(q--){
        ll t;cin>>t;
        if(t==1)f=!f;
        else{
            ll pos;cin>>pos;
            char ch;cin>>ch;
            if(pos==1){
                if(!f)dq.push_front(ch);
                else dq.push_back(ch);
            }
            else{
                if(!f)dq.push_back(ch);
                else dq.push_front(ch);
            }
        }
    }

    if(!f)while(!dq.empty())cout<<dq.front(),dq.pop_front();
    else while(!dq.empty())cout<<dq.back(),dq.pop_back();
}






Measured memory_bytes: 976
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n[101]={},a,i,max=0;
    
    while(scanf("%d",&a)!=EOF){
        ++n[a];
    }
    for(i=1;i<=100;i++){
        if(max<n[i])
            max=n[i];
    }
    for(i=1;i<=100;i++){
        if(n[i]==max)
            printf("%d\n",i);
    }
    
    return 0;
}

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

int main(){
	int N, C, K;
	cin >> N >> C >> K;
	int T[N];
	rep(i,N) cin >> T[i];
	sort(T,T+N);

	int ans = 0;
	int n = 1;
	int t = T[0];
	for (int i = 1; i < N; i++) {
		if (T[i]>t+K || n==C) {
			ans++;
			n = 0;
			t = T[i];	
		}
		n++;
	}
	if (n != 0) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-a+b) << endl;
}


Measured memory_bytes: 256
N = int(input())
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
ans = 0
for i in range(N):
    S = sum(A_1[0:i+1]) + sum(A_2[i:N])
    if S > ans:
        ans = S
 
print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int K;
int gcd(int,int);
int gcd3(int,int,int);
int sum =0;
int main(){
    cin >> K;
    FOR(i,1,K+1){
        FOR(j,i,K+1){
            FOR(l,j,K+1){
                sum += gcd3(i,j,l);
            }
        }
    }

    cout << sum << endl;
}

int gcd3(int a,int b,int c){
    int ma = max(a,gcd(b,c));
    int mi = min(a,gcd(b,c));
    int ans = gcd(mi,ma);

    if(a == b && b == c){return ans;}
    else if(a != b && b != c && c != a){return 6*ans;}
    else{return 3 * ans;}
}

int gcd(int x, int y){
    if(y % x == 0){return x;}
    else{
        return(gcd(y % x, x));
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main()
{
  long long n;
  cin >> n;
 
  long long a, b;
  cin >> a >> b;
 
  long long x[n + 1];
 
  for (int i = 1; i <= n; i++)
    cin >> x[i];
  
  long long sum = 0;
 
  for (int i = 1; i < n; i++) {
    int dis = x[i + 1] - x[i];
    if (dis * a < b)
      sum += dis * a;
    else
      sum += b;
  }
 
  cout << sum << endl;
 
  return 0;
}

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

int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int N;
	
	scanf("%d",&N);
	int A[N];
	int i,def;
	
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	qsort(A,N,sizeof(int),compare_int);
	printf("%d",A[N-1]-A[0]);
	
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
int main(){
  int n,R[MAX],j,v;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> R[i];
  }
  for(int i = 0; i < n; i++){
    if(i != n-1){
      cout << R[i] << " ";
    }else{
      cout << R[i];
    }
  }
  cout << endl;
  for(int i = 1; i < n; i++){
    v = R[i];
    j = i-1;
    while((j >= 0) && R[j] > v){
      R[j+1] = R[j];
      j--;
    }
    R[j+1] = v;
    for(int i = 0; i < n; i++){
      if(i != n-1){
        cout << R[i] << " ";
      }else{
        cout << R[i];
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;
const ll SGM = 2;

ll C[N][SGM], n, L, ts, deg[N], h[N];

void Add(string s){
	int Now = 0, H = 0;	
	for (auto u:s){
		if (!C[Now][u - '0']) C[Now][u - '0'] = ++ts, deg[Now] ++;;
		h[Now] = H;
		Now = C[Now][u - '0'];
		H++;
	}
	h[Now] = H;
	return;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> L;
	//cout << POW(2, 3) << '\n';
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		Add(s);
	}
	ll G = 0;
	for (int i = 0; i <= ts; i++){
		if (deg[i] == 1){
			ll cnt = 1;
			ll ajab = L - h[i];
			while (ajab % 2 == 0){
				cnt ++;
				ajab /= 2;
			}
			G ^= cnt;
		}
	}
	cout << (G ? "Alice" : "Bob");


 








	return 0;
}


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

vector<bool> seen;

void dfs(const Graph &G, int v){
    seen[v] = true;
    for (auto next_v : G[v]){
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}

int main(){
    int n, m, cnt = 0;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m){
        int c, d;
        cin >> c >> d;
        a[i] = c - 1;
        b[i] = d - 1;
    }

    rep(i, m){
        Graph g(n);
        rep(j, m){
            if (j != i){
                g[a[j]].push_back(b[j]);
                g[b[j]].push_back(a[j]);
            }
        }
        seen.assign(n, false);
        dfs(g, 0);
        bool flag = true;
        rep(i, seen.size()) flag = flag & seen[i];
        if (!flag) cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;

#define MAXN 21
#define ll long long
#define db(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9 + 7;
int N;
int vals[MAXN + 5][MAXN + 5];
int vis[MAXN][(1<<MAXN)-1];
ll dp[MAXN][(1<<MAXN)-1];

void add(ll &a, ll b)
{
	a += b;
	if (a >= MOD)
	{
		a -= MOD;
	}
}

ll solve(int m, int mask)
{
	if (m == N)
	{
		return 1;
	}
	
	if (vis[m][mask])
	{
		return dp[m][mask];
	}
	vis[m][mask] = 1;
	
	ll res = 0;

	for (int i = 0; i < N; i++)
	{
		if (vals[m][i] && ((mask & (1 << i)) == 0))
		{
			add(res, solve(m + 1, mask | (1 << i)));
		}
	}

	dp[m][mask] = res;
	return res;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			scanf("%d", &vals[i][j]);
		}
	}

	printf("%lld\n", solve(0, 0));
}


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

#define int long long
#define endl '\n'

int dp[1005][1 << 13];
vector<int> vals[1005], costs(1005);
int n, m; 

int rec(int id, int mask) {
    if (id == -1) {
        if (mask == ((1 << n) - 1))
            return 0;
        return 1e10;
    }
    int &ans = dp[id][mask];
    if (ans != -1)
        return ans;
    ans = rec(id - 1, mask);
    for (auto i: vals[id])
        mask |= 1 << (i - 1);
    ans = min(ans, costs[id] + rec(id - 1, mask));
    return ans;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> costs[i];
        int sz; cin >> sz;
        vals[i] = vector<int> (sz);
        for (auto &j: vals[i])  cin >> j;
    }
    memset(dp, -1, sizeof dp);
    int ans = rec(m - 1, 0);
    if (ans == 1e10)    ans = -1;
    cout << ans;
}

Measured memory_bytes: 64768
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];

int n, m;
int diff[N];
int pref[N];

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a * b/ __gcd(a, b);
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

// gcd
LL gcd(LL a, LL b) {
	while(b){
		auto t=a%b;
		a=b;
		b=t;
	}
	return a;
}


LL solve(long long N, long long X, long long D){
	if(X==0&&D==0){
		return 1;
	}
	if(X==0){
		return N*(N-1)/2+1;
	}
	if(D==0){
		return N+1;
	}

	LL g=gcd(X,D);
	X/=g;
	D/=g;
	if(D<0){
		D*=-1;
		X*=-1;
	}
	//cerr << X << ", " << D << endl;
	LL ret=0;
	vector<P> rs;
	vector<P> qs;
	for(LL i=0;i<min(N+1,D);i++){
		rs.clear();
		for(LL j=i;j<=N;j+=D){
			LL c=j*(j-1)/2+(j-i)/D*X;
			LL d=(N-1)*j-j*(j-1)/2+(j-i)/D*X+1;
			rs.push_back(P(c,d));
			//cerr << j << ": " << c << ", " << d << endl;
		}
		sort(rs.begin(),rs.end());
		qs.clear();
		for(auto p:rs){
			if(qs.size()&&qs.back().second>=p.first){
				qs.back().second=max(qs.back().second,p.second);
			}
			else{
				qs.push_back(p);
			}
		}
		for(auto q:qs){
			ret+=q.second-q.first;
		}
		//cerr << endl;
	}
	return ret;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long D;
    scanf("%lld",&D);
    cout << solve(N, X, D) << endl;
    return 0;
}


Measured memory_bytes: 6256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	vector<int>b(n,-1);
	int k,sum;
	for(int i=n-1;i>=0;i--){
		k=n/(i+1);
		if(k==1) b[i]=a[i];
		else{
			sum=0;
		for(int j=1;j<k;j++){
			sum+=b[i+(i+1)*j];
		}
		sum+=a[i];
		b[i]=sum%2;
		}
	}
	//rep(i,n)cout<<b[i]<<",";cout<<endl;
	int cnt=0;
	rep(i,n){
		if(b[i]==1)cnt++;
	}
	cout<<cnt<<endl;
	rep(i,n){
		if(b[i]==1){
			cout<<i+1<<" ";
		}
	}
	if(cnt!=0) cout<<endl;

	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main(){
  int x, y;
  int ans = 0;

  scanf ("%d %d", &x, &y);

  if (x == 1) ans += 300000;
  if (x == 2) ans += 200000;
  if (x == 3) ans += 100000;
  if (y == 1) ans += 300000;
  if (y == 2) ans += 200000;
  if (y == 3) ans += 100000;
  if (x == 1 && y == 1) ans += 400000;

  printf ("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int l,r,d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l;i <=r;i++){
		if(i % d == 0){
			ans++;
		}
	}
	cout << ans << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3644
x = int(input())

if x >= 400 and x <= 599:
    print(8)
elif x >= 600 and x <= 799:
    print(7)
elif x >= 800 and x <= 999:
    print(6)
elif x >= 1000 and x <= 1199:
    print(5)
elif x >= 1200 and x <= 1399:
    print(4)
elif x >= 1400 and x <= 1599:
    print(3)
elif x >= 1600 and x <= 1799:
    print(2)
else: #x >= 1800 and x <= 1999:
    print(1)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	ll b_sum = 0;
	REP(i,n){ 
		cin >> a[i] >> b[i];
		c[i] = a[i] + b[i];
		b_sum += b[i];
	}
	sort(ALL(c), greater<ll>());
	ll c_sum = 0;
	for(int i=0; i<n; i+=2) c_sum += c[i];
	cout << c_sum - b_sum << '\n';
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(void)
{
  int x,n,p[101] = {0},k[101] = {0},low,up,i,j;
  
  scanf("%d%d",&x,&n);
  
  if(n==0){
    printf("%d", x);
    return 0;
  }
  
  for(i=0;i<n;i++)
    scanf("%d", &p[i]);
  
  for(i=0;i<=101;i++)
      k[i] = i;
  
  for(i=0;i<n;i++){
    for(j=1;j<=100;j++){
      if(p[i]==k[j]){
        k[j] = 0;
      }
    }
  }
  
  for(i=x;i>=0;i--){
    if(k[i]!=0){
      low = k[i];
      break;
    }
  }
  
  for(i=x;i<=101;i++){
    if(k[i]!=0){
      up = k[i];
      break;
    }
   }
    
    if(x - low <= up -x)
       printf("%d", low);
    else
       printf("%d", up);
    
    return 0;
}



Measured memory_bytes: 1728
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<set>

using namespace std;

int search(set<int> btr,int low,int high)
{
    if(btr.count(low)==0)
    {
        return low;
    }
    else if(btr.count(high)==0)
    {
        return high;
    }
    else if((btr.count(high)==1) && (btr.count(low)==1))
    {
        return search(btr,low-1,high+1);
    }
}

int main()
{
    int x,n;
    set<int> vexas;
    int input;

    cin>>x>>n;

    for(int i=0;i<n;i++)
    {
        cin>>input;
        vexas.insert(input);
    }

    int ans; 

    if(n==0)
    {
        cout<<x<<endl;
    }
    else
    {
        ans = search(vexas,x,x);
        cout<<ans<<endl;
    }
    
    vexas.clear();
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int main(){
    int h,w,n;cin>>h>>w>>n;
    int a=max(h,w);
    cout<<(n-1)/a+1;
}

Measured memory_bytes: 256