akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rgi register int
using namespace std;
const int maxn=1e5+5,mod=998244353;
int n,a[maxn],cnt[maxn],maxa,ans=1;
inline int ksm(int p,int q)
{
	if(q==0)
		return 1;
	if(q==1)
		return p%mod;
	int ans=ksm(p,q>>1);
	if(q&1)
		return (long long)ans*ans%mod*p%mod;
	else
		return (long long)ans*ans%mod;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(rgi i=1;i<=n;++i)
	{
		cin>>a[i];
		maxa=max(maxa,a[i]);
		++cnt[a[i]];
	}
	if(a[1]!=0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	if(cnt[0]>1)
	{
		cout<<"0"<<endl;
		return 0;
	}
	for(rgi i=1;i<=n;++i)
		if(!cnt[i])
		{
			if(i!=maxa+1)
				cout<<"0"<<endl;
			else
				cout<<ans<<endl;
			break;
		}
		else
			ans=(long long)ans*ksm(cnt[i-1],cnt[i])%mod;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>

#define EPS 1e-6
using namespace std;

double cross(complex<double> a, complex<double> b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(complex<double> a, complex<double> b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  complex<double> coor[3];
  int N;
  scanf(" %d ", &N);
  for (int i = 0; i < N; i++) {
    for (int i = 0; i < 3; i++) {
      double x, y;
      scanf(" %lf %lf ", &x, &y);
      coor[i] = complex<double>(x, y);
      //printf("coor[%d](%.3lf, %.3lf)\n", i ,coor[i].real(), coor[i].imag());
    }
    complex<double> h[2], d[2];
    for (int j = 0; j < 2; j++) {
      h[j] = complex<double>((coor[j].real() + coor[j + 1].real()) / 2, (coor[j].imag() + coor[j + 1].imag()) / 2);
      d[j] = complex<double>(coor[j].real() - coor[j + 1].real(), coor[j].imag() - coor[j + 1].imag());
    }
    double D = cross(d[0], d[1]);
    complex<double>o(cross( complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ), complex<double>( d[0].imag(), d[1].imag() ) ) / D,
					cross( complex<double>( d[0].real(), d[1].real() ), complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ) ) / D);
    //printf("h1(x, y) = (%.3lf, %.3lf), h2(x, y) = (%.3lf, %.3lf), d1(x, y) = (%.3lf, %.3lf), d2(x, y) = (%.3lf, %.3lf), o(x, y) = ( %.3lf, %.3lf)\n", h[0].real(), h[0].imag(), h[1].real(), h[1].imag(), d[0].real(), d[0].imag(), d[1].real(), d[1].imag(), o.real(), o.imag());
    complex<double> t = o - coor[0];
    double r = abs(t);
    if (abs(o.real()) < EPS) {o = complex<int>(abs(o.real()), o.imag());}
    if (abs(o.imag()) < EPS) {o = complex<int>(o.real(), abs(o.imag()));}
    printf("%.3lf %.3lf %.3lf\n", o.real(), o.imag(), r);    
  }
  return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

signed main() {
  IOS;
  int p,q,r;
  cin >> p >> q >> r;
  cout << min(p+q,min(q+r,r+p)) << endl;
  return 0;
}

Measured memory_bytes: 256
PROBLEM = "A"
FILE = "%s" %(PROBLEM) 
INF = 999999999999999999L
try:
    inFile = open(FILE+".txt")
except:
    inFile = None

def read():
    if inFile:
        return inFile.readline().strip()
    else:
        return raw_input().strip()

def read_ints():
    return map(int,read().split())

n,T = read_ints()
times = read_ints()
ans = 0

for i in xrange(len(times)-1):
    ans += min(T,times[i+1]-times[i])
ans += T
print ans


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

#define xx first
#define yy second

#define MAX_N 20

using namespace std;

typedef long long lint;

lint poz(lint a)
{
    if(a < 0)
        return (-a);

    return a;
}

int n, m;

int a[MAX_N + 1][MAX_N + 1];

string s;

int rez = 0;

pair <int, int> q[MAX_N * MAX_N + 1];
int dist[MAX_N + 1][MAX_N + 1];

const int dl[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, -1, 1};

bool inMat(int l, int c)
{
    return l >= 1 && l <= n && c >= 1 && c <= m;
}

void doDfs(int l, int c)
{
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
            dist[i][j] = n * m * 2;
    }

    int st = 1, dr = 0;
    q[++ dr] = {l, c};
    dist[l][c] = 0;
    while(st <= dr)
    {
        auto cr = q[st ++];
        int cl = cr.xx;
        int cc = cr.yy;

        for(int dir = 0; dir < 4; dir ++)
        {
            int nl = cl + dl[dir];
            int nc = cc + dc[dir];
            if(inMat(nl, nc) && a[nl][nc] == 0 && dist[cl][cc] + 1 < dist[nl][nc])
            {
                dist[nl][nc] = dist[cl][cc] + 1;
                q[++ dr] = {nl, nc};
            }
        }
    }

    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            if(a[i][j] == 0 && dist[i][j] != n * m * 2)
                rez = max(rez, dist[i][j]);
        }
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
    {
        cin >> s;
        for(int j = 1; j <= m; j ++)
            a[i][j] = (s[j - 1] == '#' ? 1 : 0);
    }

    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            if(a[i][j] == 0)
                doDfs(i, j);
        }
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= a - b && a + b >= a * b) {
		cout << a + b << endl;
	}
	else if (a - b >= a + b && a - b >= a * b) {
		cout << a - b << endl;
	}
	else if (a * b >= a + b && a * b >= a - b){
		cout << a * b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll k,x,i,j,l,m;
	cin>>k>>x;
	i=x-k+1;
	for(j=0;j<2*k-1;j++)
	{
		cout<<i<<" ";
		i++;
	}
	//cout<<"\n";
	return 0;
}
	

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	while (cin >> s){
		if (s == "#")break;
		int sum = 0;
		const string left_hand = "qwertasdfgzxcvb";
		//true false
		bool a,b;
		if ((int)left_hand.find(s[0]) != -1)
			a = true;
		else a = false;
		for (int i = 1; i < s.size(); i++){
			if ((int)left_hand.find(s[i]) != -1)
				b = true;
			else b = false;
			if (a != b)sum++;
			a = b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,char> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main () {

    string s;cin>>s;

    int q;cin>>q;

    int ary[200010];

    vector<P> que;

    int kazu=0;
    rep(i,q) {
        int a;cin>>a;
        if (a==1) {
            ary[i]=1;
        } else {
            kazu++;
            int b;char c;
            cin>>b>>c;
            ary[i]=2;
            que.push_back(P(b,c));
        }
    }
    
    string start="",end="";

    int cnt=0;
    int ord=0;
    rep(i,q) {
        if (ary[q-i-1]==1) {
            cnt++;
        } else {
            if (que[que.size()-ord-1].first==1) {
                if (cnt%2==0) {
                    start=start+que[que.size()-ord-1].second;
                } else {
                    end=que[que.size()-ord-1].second+end;
                }
            } else {
                if (cnt%2==0) {
                    end=que[que.size()-ord-1].second+end;
                } else {
                    start=start+que[que.size()-ord-1].second;
                }
            }
            ord++;
        }
    }

    if (cnt%2==0) {
        cout<<start+s+end<<endl;
    } else {
        reverse(s.begin(),s.end());
        cout<<start+s+end<<endl;
    }

    // cout<<start<<" "<<end<<endl;

}

Measured memory_bytes: 3952
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll m=1e9+7,f[200005],ans=1,k;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}
vii v[200005];

ll npr(ll n,ll r)
{
	if(r<0||n<0||r>n)return 0;
	return (f[n]*p(f[n-r],m-2))%m;
}

void dfs(int at,int p=0,int h=0)
{
	if(h==0)
	{
		ans=(ans*k)%m;
		ans=(ans*npr(k-1,v[at].size()))%m;
	}
	else
	{
		ans=(ans*npr(k-2,v[at].size()-1))%m;
	}
	//o2(at,ans);on;
	tr(v[at],it)
	{
		if((*it)!=p)
		dfs(*it,at,h+1);
	}
}





int main()
{ios_base::sync_with_stdio(false);
f[0]=1;
rep(i,1,200004)f[i]=(f[i-1]*1ll*i)%m;
int n;
cin>>n>>k;
rep(i,1,n-1)
{
	int x,y;
	cin>>x>>y;
	v[x].pb(y);
	v[y].pb(x);
}
dfs(1);
ol(ans);

return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

template<int um> class UF {
public:
    vector<int> par,rank;
    UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
    int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
    int operator()(int x,int y) {
        if((x=operator[](x))==(y=operator[](y))) return x;
        if(rank[x]<rank[y]) return par[x]=y;//rankが小さいxの親をyにする
        rank[x]+=rank[x]==rank[y]; return par[y]=x;//rankがxとyで一緒ならrank++
    }
    bool same(int x,int y){return operator[](x)==operator[](y);}
};
#define N 100005
//UF<N>uf;//Nはconst intじゃないとダメ
//uf(a,b);//aとbをつなぐ
//uf.same(a,b);//aとbが連結成分か判定
//uf[i];//iの親をreturn

int main(){fastio
    ll n,m;cin>>n>>m;
    UF<N>uf;
    rep(i,1,m){
        ll x,y,z;cin>>x>>y>>z;
        uf(x,y);
    }
    set<ll>s;
    rep(i,1,n){
        s.insert(uf[i]);
    }
    cout<<s.size()<<endl;
    
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    int cnt = n;
    char pre_c = 'A';
    for(auto c : s)
    {
        if(pre_c == c)
        {
            cnt--;
        }
        else
        {
            pre_c = c;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
// #include <numeric>
using namespace std;

#define ll long long

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

int main()
{
    ll a, b, n;
    cin >> a >> b;
    n = gcd(a, b);

    ll ans = 1;
    for (ll i = 2; i * i < n; i++)
    {
        if (!(n % i))
        {
            ans++;
            while (!(n % i)) n /= i;
        }
    }

    if (n != 1) ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
int main(){
	int b,n,i,min,max,ans=-214783648,tmp;
	scanf("%d",&n);
	scanf("%d",&tmp);
	max = min = tmp;
	for(i=1; i<n; i++){
		scanf("%d",&tmp);
		max = tmp;
		b = max - min;
		if(min > tmp)min = tmp;
		if(n == 2 || ans < b)ans = b;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 596
/*zxj*/
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
using namespace std;
#define csh(a,n) memset(a,n,sizeof(a));
string arr[1000000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		char abc[11];
		cin>>abc;
		sort(abc,abc+strlen(abc));
		arr[i]=abc;
	}
	sort(arr,arr+n);
	ll sum=0;
	ll p=0;
	for(int i=0;i<n;i++){
		if(i!=n){
			if(arr[i]==arr[i+1]){
				p++;
			}
			else{
				p++;
				if(p!=1){
					sum+=p*(p-1)/2;
				}
				p=0;
			}
		}
		else{
			p++;
			if(p!=1){
				sum+=p*(p-1);
			}
		}
	}
	cout<<sum<<endl;
}

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

const int INF=0x3f3f3f3f;
using ll=long long;
#define pb push_back
#define mp make_pair

const int MAX_N=1e5+2;
int N, M;
vector<int> g[MAX_N];
int dp[MAX_N];

int dfs(int v)
{
	int &res = dp[v];
	if(res != -1) return res;
	res = 0;
	for(int i=0; i<g[v].size();++i){
		res = max(res, dfs(g[v][i])+1);
	}
	return res;
}

void solve()
{
	memset(dp, -1, sizeof(dp));
	for(int i=1;i<=N;++i) if(dp[i]<0) {
		dp[i] = dfs(i);
	}
	int ans = 0;
	for(int i=1;i<=N;++i) ans = max(ans, dp[i]);
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int x, y;
	for(int i=0;i<M;++i){
		cin >> x >> y;
		g[x].pb(y);
	}
	solve();
	return 0;
}

Measured memory_bytes: 8192
N = int(input())
d_list = []
for i in range(N):
    di = int(input())
    d_list.append(di)

d_list.sort(reverse=True)

ex_d = d_list[0]
count = 1

for mochi_d in d_list:
    if ex_d != mochi_d:
        count += 1
    ex_d = mochi_d

print(count)


Measured memory_bytes: 2940
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
even = v.select.with_index{|v, i| i.even?}
odd = v.select.with_index{|v, i| i.odd?}

odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse

#最頻値が異なるなら素直に出力
if odd2[0]!=even2[0]
  p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え 
  ans1, ans2 = n/2, n/2
  if odd2[1]
    ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size
  end

  if even2[1]
    ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size
  end

  puts [ans1,ans2].min
end

Measured memory_bytes: 27380
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            int a, b, A, B, C, max;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            A = a + b;
            B = a - b;
            C = a * b;

            max = 0;

            if (A > B && A>C || A==B && A>C || A==C && A>B)
                max = A;
            if (B > A && B > C || B == C && B > A)
                max = B;
            if (C > A && C > B)
                max = C;
            if (A==B && A==C)
                max = A;


            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
    ll n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,0,s.sz-1){
      if(s[i]==s[i+1])n--;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

const FACT_MAX: usize = 300000;
const MOD: i64 = 998244353;

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };

    #[allow(unused)]
    pub static RFACT: Vec<i64> = {
        let mut rfac = vec![1; FACT_MAX+1];
        rfac[FACT_MAX] = FACT.with(|fact| {
            pow_mod(fact[FACT_MAX], MOD-2, MOD)
        });

        for i in (1..FACT_MAX).rev() {
            rfac[i] = (rfac[i+1] * (i+1) as i64) % MOD;
        }
        rfac
    }
}

#[allow(dead_code)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m {
        return 0;
    }
    FACT.with(|fact| RFACT.with(|rfact| fact[n] * rfact[n - m] % MOD * rfact[m] % MOD))
}

fn main() {
    let (n, m) = parse_line!(usize, usize);

    println!("{}", combi(n, 2) + combi(m, 2));
}


Measured memory_bytes: 12540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace NikkeiPGKing
{
    class Program
    {
        static void Main(string[] args)
        {
            Problem2.Problem2Read();
        }


    }
      public sealed class Problem2
    {
        public static void Problem2Read()
        {
            Console.ReadLine();
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();
            Console.WriteLine( Problem2Solve(a , b, c));
        }

        public static int Problem2Solve(string a, string b, string c)
        {
            int cnt = 0;
            for (int i = 0; i < a.Length; i++)
            {
                cnt += DiffSteps(a[i], b[i], c[i]);
            }

            return cnt;
        }

        public static int DiffSteps(char a, char b, char c)
        {
            if (a == b && b == c)
            {
                return 0;
            }

            if (a == b || b == c || c == a)
            {
                return 1;
            }

            return 2;
        }

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <stack>
#include <map>
#include <string> 
#include <set>
#include <iomanip>
#define eps 1e-5
#define N 100005 
#define pi acos(-1)
#define e 2.71828182845904523536
using namespace std;

typedef struct{
	int x,y;
	bool flag;
}point;
int mapp[101][101];
bool vist[101];
int finds[101];
struct Rule{
	bool operator()(const point&a,const point &b)
	{
		if (a.x==b.x) return a.y<b.y;
		return a.x<b.x;
	}
};
struct Rule2{
	bool operator()(const point&a,const point &b)
	{
		if (a.x==b.x) return a.y>b.y;
		return a.x<b.x;
	}
};
point a[101],b[101];
int n;
bool find1(int x)
{
	for (int i=1;i<=n;i++)
	{
		if (mapp[x][i]&&(!vist[i]))
		{
			vist[i]=true;
			if ((!finds[i])||find1(finds[i]))
			{
				finds[i]=x;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	scanf("%d",&n);
	memset(b,0,sizeof(b));
	for (int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	for (int i=1;i<=n;i++)
		scanf("%d%d",&b[i].x,&b[i].y);
	memset(mapp,0,sizeof(mapp));
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		{
			if (a[i].x<b[j].x&&a[i].y<b[j].y)
			{
				mapp[i][j]=1;
			}
		}
	int ans1=0;
	memset(finds,0,sizeof(finds));
	for (int i=1;i<=n;i++)
	{
		memset(vist,false,sizeof(vist));
		if (find1(i)) ans1++;
	}
	int ans2=0;
	for (int i=1;i<=n;i++) 
		if (finds[i]) ans2++;
	printf("%d\n",min(ans1,ans2));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int x;cin>>x;
if(x>=400&&x<=599)
cout<<8;
else if(x>=600&&x<=799)
cout<<7;
else if(x>=800&&x<=999)
cout<<6;
else if(x>=1000&&x<=1199)
cout<<5;
else if(x>=1200&&x<=1399)
cout<<4;
else if(x>=1400&&x<=1599)
cout<<3;
else if(x>=1600&&x<=1799)
cout<<2;
else if(x>=1800&&x<=1999)
cout<<1;

}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
#define pi acos(-1)
const int N=100005;
const ll mod=1e9+9;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int n,x;
int mn;
int main()
{
	mn=0x7fffffff;
	n=read();x=read();
	for(int i=1;i<=n;i++){
		int tp=read();
		mn=min(mn,tp);
		x-=tp;
	}
	cout<<x/mn+n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if(N < 105) cout << 0;
    else if(N < 135) cout << 1;
    else if(N < 165) cout << 2;
    else if(N < 189) cout << 3;
    else if(N < 195) cout << 4;
    else cout << 5;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
input = gets
N = (input.chomp).to_i
input = readlines
A = (input[0].split).map(&:to_i)
i = 1
max = A[0]
min = A[0]
while i < N
  if max < A[i] then
    max = A[i]
  end
  if A[i] < min then
    min = A[i]
  end 
  i += 1
end
p max -min    

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int main()
{
    int i,count=0;
    char a[4],b[4];
    scanf("%s%s", a,b);
    for(i=0;i<3;i++)
    {
        if(a[i]==b[i])count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void);

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(x >= r && (x + r) <= W && y >= r && (y + r) <= H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return(0);
}


Measured memory_bytes: 2148
from random import random
import math
import re
from fractions import Fraction

N = int(input())
ca, cb = 0, 0
for _ in range(N):
    a, b = map(int, input().split(" "))
    if ca == 0 and cb == 0:
        ca, cb = a, b
    else:
        r = int(math.ceil(max(Fraction(ca, a), Fraction(cb,b))))
        # print a, b, Fraction(ca, a), math.ceil(Fraction(ca,a))
        ca, cb = a*r, b*r
        # print ca, cb, x
print (ca + cb)


Measured memory_bytes: 7920
import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main 
{
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=true;
	static Reader in=new Reader();
	public static void main(String[] args) throws IOException
	{
		int n=ni();
		int a[]=new int[n+2];
		for(int i=1; i<=n; i++)
			a[i]=ni();
		int b[]=new int[n+1];
		long an=0;
		for(int i=0; i<=n; i++)
		{
			b[i]=Math.abs(a[i+1]-a[i]);
			an+=b[i];
		}
		long c[]=new long[n];
		for(int i=1; i<=n; i++)
		{
			c[i-1]=an-Math.abs(a[i]-a[i-1])-Math.abs(a[i+1]-a[i])+Math.abs(a[i-1]-a[i+1]);
			pr(c[i-1]);
		}
		System.out.println(ans);
	}
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static int ni(){return in.nextInt();}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 48136
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007; 
long long power(long long a, long long n){
	long long ans = 1; long long mul = a; 
	while(n){
		if(n & 1){
			ans *= mul; ans %= MOD; 
		}
		n >>= 1; 
		mul = mul * mul % MOD; 
	}
	return ans; 
}
int main(){
	long long N, K; cin >> N >> K; 
	long long A[100010] = {}; // すべてiの倍数の個数
	for(long long i = 1; i <= K; i++){
		long long tmp = K / i; 
		A[i] = power(tmp, N); 
	}
	long long B[100010] = {}; // gcdがiの個数
	for(long long i = K; i >= 1; i--){
		B[i] = A[i]; 
		for(long long j = 2; i * j <= K; j++){
			B[i] -= B[i * j]; 
			if(B[i] < 0) B[i] += MOD; 
		}
	}
	long long ans = 0; 
	for(long long i = 1; i <= K; i++){
		ans += i * B[i] % MOD; 
		ans %= MOD; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 5200
import numpy as np
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
sc = np.array([[0]*(W+2)] + [[0] + i + [0] for i in s] + [[0]*(W+2)])
for i in range(1, H+1):
    for p in range(1, W+1):
        if sc[i][p] == '.':
            sums = 0
            for e in sc[i-1:i+2,p-1:p+2]:
                sums += list(e).count('#')
            sc[i][p] = str(sums)
for i in sc[1:H+1,1:W+1]:
    print(''.join(i))

Measured memory_bytes: 12444
#include<iostream>
using namespace std;
int main() {
	while (1) {
		int H, W;
		cin >> H >> W;
		if (H == 0 && W == 0) { break; }
		for (int i = 0; i<H; i++) {
			for (int j = 0; j<W; j++) {
				if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string o,e,ans;

main() {
    cin >> o >> e;
    rep(i,(int)(o.size()+e.size())) {
        if (i%2) ans.pb(e[i/2])
        else ans.pb(o[i/2])
    }
    ct(ans)
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

inline void swap(int &a, int &b){
    int temp = a;
    a = b;
    b = temp;
}

int main(){
    const int DATASET_COUNT = 3000;

    int a, b;
    for(int i=0; i<DATASET_COUNT; ++i)
    {
        cin >> a >> b;
        if(a==0 && b==0) break;
        if(a>b) swap(a, b);
        cout << a << " " << b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

  int N,M,X,Y;
  cin >> N >> M >> X >> Y;

  vector<int> x(N + 1),y(M + 1);
  rep(i,N) cin >> x[i];
  rep(i,M) cin >> y[i];
  x[N] = X;
  y[M] = Y;

  if(vmax(x) < vmin(y))
    cout << "No War" << endl;
  else
    cout << "War" << endl;



ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 504
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val Cs = in.next

  val rs = Cs.count(_ == 'R')

  val (_, _, min) = (0 until N).foldLeft((0, rs, rs)){case ((ws, rs, min), i) =>
    if (Cs(i) == 'R') (ws, rs - 1, math.min(min, math.max(ws, rs - 1)))
    else (ws + 1, rs, math.min(min, math.max(ws + 1, rs)))
  }

  println(min)
}

Measured memory_bytes: 59272
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, M;

  while (cin >> N >> M) {
    vector<int> target(M);

    for (int i = 0; i < M; i++) {
      cin >> target[i];
    }

    vector<int> score(N, 0);

    for (int game = 0; game < M; game++) {
      int missCnt = 0;

      for (int i = 0; i < N; i++) {
        int B;
        cin >> B;

        if (target[game] == B) {
          score[i]++;
        } else {
          missCnt++;
        }
      }

      score[target[game] - 1] += missCnt;
    }

    for (int i = 0; i < N; i++) {
      cout << score[i] << endl;
    }
  }
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = ll(1e9 + 7);



int main() {
	string s;
	cin >> s;

	bool u = true;
	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i + 1] == s[i]) u = false;
	}

	cout << (u ? "Good" : "Bad") << endl;
}


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

#define pb push_back
#define mp make_pair

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)(1e6 + 5);
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e9 + 11);

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust";
    else
        cout << "win";
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
n_s = len(S)
n_t = len(T)
flag = 0
if n_s <= 10 or n_s >= 1:
    if  n_t == n_s + 1 and S == T[:-1]:
        flag = 1

if flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9108
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
        }
        HashMap<Integer, Integer> evenmap = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> oddmap = new HashMap<Integer, Integer>();
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                int cnt;
                if (evenmap.containsKey(v[i]))
                    cnt = evenmap.get(v[i]) + 1;
                else
                    cnt = 1;

                evenmap.put(v[i], cnt);
            } else {
                int cnt;
                if (oddmap.containsKey(v[i]))
                    cnt = oddmap.get(v[i]) + 1;
                else
                    cnt = 1;

                oddmap.put(v[i], cnt);
            }
        }
        int evmax = 0, evsec = 0, evmaxnum = 0;
        int odmax = 0, odsec = 0, odmaxnum = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                int cnt = evenmap.get(v[i]);
                if (cnt > evmax) {
                    evsec = evmax;
                    evmax = cnt;
                    evmaxnum = v[i];
                } else if (v[i] != evmaxnum && cnt > evsec) {
                    evsec = cnt;
                }
            } else {
                int cnt = oddmap.get(v[i]);
                if (cnt > odmax) {
                    odsec = odmax;
                    odmax = cnt;
                    odmaxnum = v[i];
                } else if (v[i] != odmaxnum && cnt > odsec) {
                    odsec = cnt;
                }
            }
        }
        // ArrayList<Integer> evcnt = new ArrayList<Integer>(evenmap.values());
        // Collections.sort(evcnt, Comparator.reverseOrder());
        // ArrayList<Integer> odcnt = new ArrayList<Integer>(oddmap.values());
        // Collections.sort(odcnt, Comparator.reverseOrder());
        if (evmaxnum != odmaxnum) {
            System.out.println(N - evmax - odmax);
        } else {
            System.out.println(Math.min(N - evmax - odsec, N - evsec - odmax));
        }

    }
}

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

int main() {
    bool si=true;
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++){
        if(s1[i]!=s2[i]){
            si=false;
            break;
        }
    }
    if(si){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)1e9+7;

int main()
{
    //read;
    i64 x;
    cin>>x;
    for(int i=0;i<=200;i++)
    {
        for(int j=-200;j<=200;j++)
        {
            if(pow(i,5)-pow(j,5)==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }

}


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

int main() {
    ll n, a, b,ama,ans;
    cin >> n >> a >> b;

    ama = n % (a + b);
    ans = a * (n / (a + b)) + min(ama, a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

max_x = max(a,b)
min_x = min(a,b)
max_y = max(c,d)
min_y = min(c,d)


if max_x >= 0 and min_x >= 0:
    if max_y >= 0 and min_y >= 0:
        x = max_x
        y = max_y
    elif max_y >= 0 and min_y < 0:
        x = max_x
        y = max_y
    else:
        x = min_x
        y = max_y

elif max_x >= 0 and min_x < 0:
    if max_y >= 0 and min_y >= 0:
        x = max_x
        y = max_y
    elif max_y >= 0 and min_y < 0:
        if max_x * max_y >= min_x * min_y:
            x = max_x
            y = max_y
        else:
            x = min_x
            y = min_y
    else:
        x = min_x
        y = min_y
else:
    if max_y >= 0 and min_y >= 0:
        x = max_x
        y = min_y
    elif max_y >= 0 and min_y < 0:
        x = min_x
        y = min_y
    else:
        x = min_x
        y = min_y

print(x*y)

Measured memory_bytes: 9260
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
typedef long long ll;
typedef int64_t in;

using namespace std;


int main(){
    ll n,l; cin >> n >> l;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i,n){
        cout << s[i];
    }
    cout << "\n";

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++) cin >> w[i];
  int ans = 1e9;
  for(int i = 1; i < n; i++){
    int l = 0, r = 0;
    for(int j = 0; j < i; j++){
      l += w[j];
    }
    for(int j = i; j < n; j++){
      r += w[j];
    }
    ans = min(ans, abs(l - r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;

	bool yes = false;
	if (s == t) {
		yes = true;
	}
	else {
		for (int i = 0; i < s.size(); ++i) {
			char b = s.back();
			s.pop_back();
			s.insert(s.begin(), b);
			if (s == t) {
				yes = true;
				break;
			}
		}
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

typedef vector<int> VI;

int ns, nl;
int E[11][11];
int EC[11];
int answer1;
VI answer2;

int cnt;
VI path;
int G[11][11];
bool U[11][11];

void solve( int s ) {
    if ( cnt > answer1 ) {
        answer1 = cnt;
        answer2 = path;
    }

    for ( int i = 0; i < EC[s]; i++ ) {
        int t = E[s][i];
        if ( U[s][t] || U[t][s] ) continue;
        U[s][t] = U[t][s] = true;
        path.push_back(t+1);
        cnt += G[s][t];
        solve(t);
        cnt -= G[s][t];
        path.pop_back();
        U[s][t] = U[t][s] = false;
    }
}

int main() {
    while ( cin >> ns >> nl ) {
        if ( ns == 0 && nl == 0 ) break;
        for ( int i = 0; i < ns; i++ ) {
            EC[i] = 0;
        }
        for ( int i = 0; i < nl; i++ ) {
            int a, b, c;
            cin >> a >> b >> c;
            a -= 1;
            b -= 1;
            E[a][EC[a]++] = b;
            E[b][EC[b]++] = a;
            G[a][b] = G[b][a] = c;
        }

        answer1 = -1;
        answer2.clear();
        for ( int s = 0; s < ns; s++ ) {
            for ( int i = 0; i < ns; i++ ) {
                for ( int j = 0; j < ns; j++ ) {
                    U[i][j] = false;
                }
            }
            cnt = 0;
            path.clear();
            path.push_back(s+1);
            solve(s);
        }
        cout << answer1 << endl;
        for ( int i = 0; i < (int)answer2.size(); i++ ) {
            cout << answer2[i];
            if ( i + 1 < (int)answer2.size() ) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a = -1, b = -1;
		int num;
		bool ans = true;
		for (int j = 0; j < 10; j++) {
			if (a > b)swap(a, b);
			cin >> num;
			if (num > b)b = num;
			else if (num > a)a = num;
			else ans = false;
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3056
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%d %d %d %d\n", x2 - (y2 - y1), y2 + (x2 - x1), (x2 - (y2 - y1)) - (x2 - x1), y1 + (x2 - x1));




	return(0);
}

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

using namespace std;

#define all(a) a.begin(),a.end()
#define fori(i,n) for(int i=0;i<n;i++)
#define forb(i,s,t) for(int i=s;i<t;i++)
#define fore(e,v) for(auto &e : v)
#define maxv(v) *max_element(all(v))
#define uniques(v) si s(all(ais));v.assign(all(s))
#define inp(i) scanf("%i",&i)
#define debug(x) cout<<#x<<" "<<x<<endl;
#define start_clock clock_t begin = clock();
#define end_clock cout<<double(clock()-begin)/CLOCKS_PER_SEC<<endl;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<ll> llv;
typedef set<int> si;

int main () {
	int n;
	cin>>n;
	vi ais(n+1);
	vi bis(n);
	fori(i,n+1)cin>>ais[i];
	fori(i,n)cin>>bis[i];
	ll ans = 0;
	fori(i,n) {
		int can = bis[i];
		int t1 = min(can, ais[i]);
		can -= t1;
		int t2 = min(can, ais[i+1]);
		ais[i+1]-=t2;
		ans += (ll)t1+(ll)t2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int A, B;
	char S[15];
	while(scanf("%d%d%s",&A,&B,S)!=EOF){
		if(strlen(S)<A+B+1){
			printf("No\n");
			continue;
		}
		
		
		int flag = 1;
		for(int i = 0; i < A; i++){
			if(!('0'<=S[i] && S[i]<='9')){
				flag = 0;
				break;
			}
		}
		
		if(flag){
			for(int i = A+1; i < A+B; i++){
				if(!('0'<=S[i] && S[i]<='9')){
					flag = 0;
					break;
				}
			}
		}
		
		if(flag && S[A] != '-') flag = 0;
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

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

int a[3010];
ll dp[3010][3010];
bool flg[3010][3010];
ll f(int l, int r){
  if (flg[l][r]) {
    return dp[l][r];
  }
  flg[l][r] = true;

  ll ans;
  if (l==r) {
    ans = a[l];
  } else {
    ans = max( a[l] - f(l+1,r), a[r] - f(l,r-1) );
  }
  return dp[l][r] = ans;
}

int main() {
  int n;
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  cout << f(0,n-1) << endl;
}


Measured memory_bytes: 80000