akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python
import sys,heapq
if 'pypy' in sys.version.lower():
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
	COMPILE=123456789012
	def compile(a,b,c):
		return ((a+COMPILE)<<18) | (b<<9) | c
	def decompile(a):
		return ((a>>18)-COMPILE,(a>>9)&511,a&511)
else:
	def compile(a,b,c):
		return (a,b,c)
	def decompile(a):
		return a
	if sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point, None

if __name__ == '__main__': entry_point([])

Measured memory_bytes: 6364
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	int train = A * N;
	cout<< min(train, B) << endl;
}

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    string A, B, C;
    cin >> n >> A >> B >> C;
    
    int ans = 0;
    
    for(int i=0; i<n; i++)
    {
        if(A[i] == B[i] && B[i] == C[i])
            continue;
        
        if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i])
            ans++;
        else
            ans += 2;
    }

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


Measured memory_bytes: 256
/*
    Author : Simanta Deb Turja
    Created On: 21/06/20
    Atcoder Beginner Contest 171
*/

#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;
using ld = long double;

template <typename T> inline T Min (T a, T b, T c) { 
    return min(a, min(b, c)); 
}
template <typename T> inline T Min (T a, T b, T c, T d) { 
    return min(a, min(b, min(c, d))); 
}
template <typename T> inline T Max (T a, T b, T c) { 
    return max(a, max(b, c)); 
}
template <typename T> inline T Max (T a, T b, T c, T d) { 
    return max(a, max(b, max(c, d))); 
}

template <typename T> inline T Ceil(T a, T b) { 
    return ((a % b == 0) ? (a / b) : (a / b + 1)); 
} 
template <typename T> inline T Floor(T a, T b) { 
    return a / b; 
}

template <typename T> inline T Power (T a, T p) { 
    T res = 1, x = a; 
    while ( p ) { 
        if ( p & 1 ) res = ( res * x ); 
        x = ( x * x ); p >>= 1;
    }
    return res; 
}
template <typename T> inline T BigMod (T a,T p,T M) { 
    a %= M; T ret = (T)1; 
    while (p) { 
        if (p & 1) ret = (ret * a) % M; 
        a = (a * a) % M;  p = p >> 1;
    } 
    return ret;
}
template <typename T> inline T InverseMod (T a,T M) { 
    return BigMod (a, M - 2, M); 
}

template <typename T> inline T gcd ( T a, T b ) { 
    a = abs(a); b = abs(b); 
    while ( b ) { 
        a = a % b; swap ( a, b ); 
    } 
    return a;
}
template <typename T> inline T lcm(T x,T y) { 
    return (((x)/gcd((x),(y)))*(y)); 
}


template< typename T1, typename T2, typename T3 > struct Pair { 
    T1 first; T2 second; T3 third; 
};
template< typename T1, typename T2, typename T3, typename T4 > struct Pair4 { 
    T1 first; T2 second; T3 third; T4 fourth; 
};


using ii = pair <int, int>;
using iii = Pair <int, int, int>;
using iiii = Pair4 <int, int, int, int>;

#define endl '\n'

const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const int MOD = (ll)1e9 + 7;
const int N = (int)4e5 + 10;


//++++++++++++++++++Template Ends Here++++++++++++++++++

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector <int> arr(n);
    vector <int> freq(N, 0);
    ll sum = 0LL;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        sum += (ll)arr[i];
        freq[arr[i]]++;
    }
    int q;
    cin >> q;
    while (q--) {
        ll bi, ci;
        cin >> bi >> ci;
        sum -= (freq[bi] * bi);
        freq[ci] += freq[bi];
        sum += (freq[bi] * ci);
        freq[bi] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 5308
n_5 = 0
n_7 = 0

a = map(int, input().split())
for i in a:
    if i == 5:
        n_5 += 1
    elif i == 7:
        n_7 += 1

if n_5 == 2 and n_7 == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  i64 r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
/**
* Copyright(c)
* All rights reserved.
* Author : zzy
* Date : 2020-03-07-20.13.55
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int a, b;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> a >> b;
    int ans1 = -1, ans2 = -1;
    for (int i = 1; i <= 1000000; ++i) {
        int ta = i * 8 / 100;
        int tb = i / 10;
        if (ta == a && tb == b) {
            ans1 = i;
            break;
        }
    }
    if (ans1 == -1 ) cout << -1 << '\n';
    else cout << ans1 << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

check = [[0,1,2],[3,4,5],[6,7,8],
        [0,3,6],[1,4,7],
        [2,5,8],
        [0,4,8],[2,4,6]]

for tmp in check:
    count = 0
    for num in tmp:
        i = num//3
        j = num%3
        if(a[i][j] in b) == False:
            break
        count+=1
        if(count == 3):
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 38484
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    ll ans = 0;
    ll u = 0;
    ll R = 0;
    rep(L, n) {
        while(R < n) {
            bool flag = false;
            rep(i, 30) {
                if(u & 1<<i) {
                    if(a[R] & 1<<i) {
                        flag = true;
                        break;
                    }
                }
            }
            if(flag) {
                break;
            }
            u += a[R];
            R++;
        }
        ans += R-L;
        u -= a[L];
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

ll o=0;
bool isPrime(int n)
{
	// Corner cases
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;

	// This is checked so that we can skip
	// middle five numbers in below loop
	if (n % 2 == 0 || n % 3 == 0)
		return false;

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

	return true;
}
void ors(ll n)
{
	// Print the number of 2s that divide n
	ll r=1;
	ll chkon=0;
	while (n % 2 == 0)
	{
		chkon++;
		if(chkon==r){
			o++;
			r++;
			chkon=0;

		}
		n/=2;
	}
	chkon=0;
	r=1;

	// n must be odd at this point. So we can skip
	// one element (Note i = i +2)
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		// While i divides n, print i and divide n
		while (n % i == 0)
		{
			chkon++;
			if(chkon==r){
				o++;
				r++;
				chkon=0;
			}
			n/=i;
		}
		chkon=0;
		r=1;
	}
	if(n>2){
		o++;
	}

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t;
	cin>>t;
	ors(t);
	cout<<o<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdint.h>

#define MAX_N (20000)
int main(void)
{
    uint32_t i, N, a[MAX_N], b[MAX_N], p[MAX_N];
    uint32_t stride;
    scanf("%u", &N);
    stride = N;
    for (i = 0; i < N; i++) {
        uint32_t val;
        scanf("%u", &val);
        p[i] = val - 1;
    }
    for (i = 0; i < N; i++) {
        a[i] = (i * stride) + 1;
        b[i] = ((N - 1 - i) * stride) + 1;
    }
    for (i = 0; i < N; i++) {
        const uint32_t idx = p[i];
        a[idx] += i;
    }
    for (i = 0; i < N; i++) {
        printf("%u ", a[i]);
    }
    putchar('\n');
    for (i = 0; i < N; i++) {
        printf("%u ", b[i]);
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 768
def check_prime_number(num):
	if num == 1:
		return 0

	for i in range(2,int(num**0.5)+1):	
		if num % i == 0:
			return 0
	return 1

if __name__ == '__main__':
	num = int(input())
	c = 0
	for i in range(num):
		d = int(input())
		c += check_prime_number(d)
	print(c)


Measured memory_bytes: 5704
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1

print(count)

Measured memory_bytes: 3060
def dist(X,Y):
    return abs(X[0]-Y[0])+abs(X[1]-Y[1])
N = int(input())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[2],reverse=True)
for i in range(101):
    for j in range(101):
        flag=0
        x0,y0,h0 = A[0]
        H = h0+dist((i,j),(x0,y0))
        for k in range(1,N):
            x,y,h = A[k]
            if h>0 and H==h+dist((i,j),(x,y)):
                continue
            elif h>0 and H!=h+dist((i,j),(x,y)):
                flag=1
                break
            elif h==0 and H<=dist((i,j),(x,y)):
                continue
            elif h==0 and H>dist((i,j),(x,y)):
                flag = 1
                break
        if flag==0:
            Cx = i
            Cy = j
            break
    if flag==0:break
print(Cx,Cy,H)

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

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


int main() {
 	ll a;
 	double b;
 	cin >> a >> b;

 	ll bb = b * 100.0 + 0.00000001;

 	cout << a * bb / 100 << endl;


	return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <math.h>

int main(void){
  int i = 2, j = 0, n, s[10], count;

  scanf("%d", &n);
  count = n;
  while(n != 1){
    if(n % i == 0){
      while(n % i == 0){
	n /= i;
      }
      s[j++] = i;
      i++;
    }else if(i > sqrt(n)){
      s[j++] = n;
      break;
    }else{
      i++;
    }
  }

  for(i = 0; i < j; i++){
    count -= count / s[i];
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 592
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=1e5+10;
int a[N],ma=0,n;
int read(){
	int ans=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-48;c=getchar();}
	return ans*f;
}
/*-----------------------------------------------------*/
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
bool dfs(int p){
	int mc=0,flag=1;
	for(int i=1;i<=n;i++)if(a[i]%2){a[i]--;break;}
	int gc=a[1];
	for(int i=2;i<=n;i++)gc=gcd(gc,a[i]);
	for(int i=1;i<=n;i++){a[i]/=gc;if(!(a[i]%2))mc++;if(a[i]==1)flag=0;}
 	if(mc%2)return !p;
	if(!flag||n-mc!=1)return p;
	return dfs(p^1);
}
int main(){
	n=read();int mc=0;bool flag=1;
	for(int i=1;i<=n;i++){
		a[i]=read();if(a[i]%2==0)mc++;
		else {
			ma++;if(a[i]==1)flag=0;
		}
	} 
	if(mc%2)printf("First");
	else {
		if(ma!=1||!flag)printf("Second");
		else if(dfs(1))printf("First");
		else printf("Second");
	}
	return 0;
}

Measured memory_bytes: 640
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]

    if H == 1 or W == 1:
        res = 1
    elif H % 2 == 1 and W % 2 == 1:
        res = H * W // 2 +1
    else:
        res = H * W // 2

    print(res)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

            set <ll> s;
            vector  <ll> v;
            ll x;
            ll n;
            cin>>n;
            fo(i,n)
            {
                cin>>x;
                if(s.count(x))
                    {v.pb(x);s.erase(x);}
                else
                    s.insert(x);
            }
            ll ans=0;
            sort(v.begin(),v.end());
            if(v.size()>=2)
            {
                ll n=v.size();
                ans=v[n-1]*v[n-2];
            }
            cout<<ans;

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





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

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



int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    REP(i,M){
        int a,b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(auto next: G[0]){
        for(auto nn: G[next]){
            if(nn == N-1){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 15064
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            string t = ReadLine();

            int ans = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == t[i]) ans++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int 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^48),ch=getchar();
	x*=f;
	return;
}
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
	int k,x;
	cin>>k>>x;
	if(k*500>=x) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}

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

int A1, A2, A3;
void solve(){
    cin >> A1 >> A2 >> A3;
    int sum = A1 + A2 + A3;

    if(sum < 22){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
    
}
int main(){

    solve();
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<vector<int>> b(k, vector<int>(k, 0)), w(k, vector<int>(k, 0));
  REP(i, n){
    int x, y;
    char c;
    cin >> x >> y >> c;
    bool f = (c == 'B');
    x %= 2*k;
    y %= 2*k;
    if(x >= k){
      x -=k;
      f = !f;
    }
    if(y >= k){
      y -= k;
      f = !f;
    }
    if(f) b[x][y]++;
    else w[x][y]++;
  }
  vector<vector<int>> bsum(k+1, vector<int>(k+1, 0)), wsum(k+1, vector<int>(k+1, 0));
  REP(i, k) REP(j, k){
    bsum[i+1][j+1] = b[i][j]+bsum[i+1][j]+bsum[i][j+1]-bsum[i][j];
    wsum[i+1][j+1] = w[i][j]+wsum[i+1][j]+wsum[i][j+1]-wsum[i][j];
  }
  int ans = 0;
  REP(i, k+1) REP(j, k+1){
    int p = bsum[i][j];
    p += wsum[k][j] - wsum[i][j];
    p += wsum[i][k] - wsum[i][j];
    p += bsum[k][k] - bsum[k][j] - bsum[i][k] + bsum[i][j];
    int q = wsum[i][j];
    q += bsum[k][j] - bsum[i][j];
    q += bsum[i][k] - bsum[i][j];
    q += wsum[k][k] - wsum[k][j] - wsum[i][k] + wsum[i][j]; 
    chmax(ans, max(p, q));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LD a, b, x, ans;
    cin >> a >> b >> x;
    if (2 * x >= a * a * b)
    {
        ans = atan(2 * (b / a - x / (a * a * a))) * 180 / PI;
    }
    else
    {
        ans = atan((b * b * a) / (2 * x)) * 180 / PI;
    }
    cout.precision(18);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
<?php
list($n) = ints();
$a = ints();
rsort($a);
$ans = 0;
for ($i = 0; $i < $n * 2; $i += 2) $ans += $a[$i + 1];
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 46100
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>

#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;



int N, A[10000][10000],id[10000][10000];
vector<int> to[600000];
int dp[600000]; bool visited[600000];//longest path from v
int dfs(const int v) {
	if (visited[v])return dp[v];
	visited[v] = true;
	dp[v] = -1;
	int res = 1;
	for (int u : to[v]) {
		int x = dfs(u);
		if (x == -1)return -1;
		res = max(res, x+1);
	}
	dp[v] = res;
	
	return res;
}
int toId(int i,int j) {
	if (i > j)swap(i, j);
	return id[i][j];

}
int main() {
	cin >> N;
	rep(i, N) {
		rep(j, N-1) {
			int x;
			cin >> x;
			x--;
			A[i][j] = x;
		}
	}

	int V = 0;
	rep(i, N) {
		rep(j, N) {
			if (i < j) {
				id[i][j] = V++;
			}
		}
	}
	rep(i, N){
		rep(j, N - 2) {
			int v = toId(i, A[i][j]);
			int u = toId(i, A[i][j + 1]);
			to[v].push_back(u);

		}
	}
	int ans = 0;
	rep(i, V) {
		int res = dfs(i);
		if (res == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans = max(ans, res);
	}


	cout << ans << endl;

	
	




	
	


}

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

using namespace std;

static void solve()
{
  string str;
  cin >> str;
  int m = 0, e = 0;
  bool cat = true;
  for(int i = 0; i < str.size(); i++) {
    if (!m && (i || str[i] != 'm') || !cat) {
      cat = false;
      break;
    }
    switch (str[i]) {
    case 'm':
      m++;
      break;
    case 'e':
      e++;
      if (m < e) cat = false;
      break;
    case 'w':
      m--;
      e--;
      if (m < 0 || e < 0) cat = false;
    }
  }
  if (m || e) cat = false;
  if (cat) cout << "Cat\n";
  else cout << "Rabbit\n";
}

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

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

char g[800][801];
int dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };

int main(){
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	f(i, 0, n)scanf("%s", g[i]);
	pair<int, int> s;
	f(i, 0, n)f(j, 0, m)if (g[i][j] == 'S') { s = make_pair(i, j); g[i][j] = 1; break; }
	queue<pair<int, pair<int, int> > > q;
	q.push(make_pair(0, s));
	while (!q.empty()){
		int a = q.front().second.first, b = q.front().second.second, c = q.front().first;
		q.pop();
		if (c == k)continue;
		f(i, 0, 4){
			int x = a + dx[i], y = b + dy[i];
			if (x == -1 || x == n || y == -1 || y == m || g[x][y] != '.')continue;
			g[x][y] = 1;
			q.push(make_pair(c + 1, make_pair(x, y)));
		}
	}
	int an = 1e9;
	f(i, 0, n)f(j, 0, m)if (g[i][j] == 1)an = min(an, min(i, min(j, min(n - (i + 1), m - (j + 1)))));
	an = (an + k - 1) / k;
	printf("%d\n", an + 1);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k;cin>>n>>k;
  int g,mn;
  cin>>g;
  mn=g;
  if(n==1){
    if(k==g){
      P("POSSIBLE");
      return 0;
    }else{
      P("IMPOSSIBLE");
      return 0;
    }
  }
  REP(i,n-1){
    int a;cin>>a;
    g=gcd(a,g);
    mn=max(a, mn);
  }
  if(k%g==0 && k<=mn){
    P("POSSIBLE");
  }else{
    P("IMPOSSIBLE");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#define ll long long int
using namespace std;
int main(void) {
  double a, b, c, d, e, f;
  double x=0;
  double a_s=0, a_w=0;
  cin>>a>>b>>c>>d>>e>>f;
  for(int i=0; 100*a*i<=f;i++) {
    double aa=100*a*i;
    for(int j=0; aa+100*b*j<=f; j++) {
      double w=aa+100*b*j;
      for(int k=0; c*k<=e*w/100; k++) {
	double cc=c*k;
	for(int l=0; cc+d*l<=e*w/100;l++) {
	  double s=cc+d*l;
	  if(s<=e*w/100 and w+s<=f) {
	    if(x<=100*s/(w+s)) {
	      x=100*s/(w+s);
	      a_s=s;
	      a_w=w;
	    }
	  }
	}
      }
    }
  }
  cout<<a_w+a_s<<" "<<a_s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> m;
    rep(i,n) {
        cin >> a[i];
        m[a[i]]++;
    }
    int odd = 0,even = 0;
    for(auto itr = m.begin();itr != m.end();itr++){
        if(itr->second % 2 == 0){
            even += 1;
        }
        else{
            odd += 1;
        }
    }

    cout << odd - even%2 + even << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#define MAX 201

int a[MAX];
int n;

void init(int n){
	int i;
	for(i=0;i<2*n;i++){
		a[i]=i+1;
	}
}

void shaffle(){
	int i;
	int temp[MAX];
	
	for(i=0;i<n;i++){
		temp[i*2]=a[i];
	}
	for(i=0;i<n;i++){
		temp[i*2+1]=a[n+i];
	}
	for(i=0;i<2*n;i++){
		a[i]=temp[i];
	}
}

void cut(int k){
	int i;
	int temp[MAX];
	for(i=0;i<2*n-k;i++){
		temp[i]=a[k+i];
	}
	for(i=0;i<k;i++){
		temp[2*n-k+i]=a[i];
	}
	for(i=0;i<2*n;i++){
		a[i]=temp[i];
	}
}

int main(void)
{
	int m,k;
	int i;
	
	scanf("%d",&n);
	
	init(n);
	
	scanf("%d",&m);
	
	for(i=0;i<m;i++){
		scanf("%d",&k);
		if(k==0){
			shaffle();
		}
		else{
			cut(k);
		}
	}
	
	for(i=0;i<2*n;i++){
		printf("%d\n",a[i]);
	}
	
	return 0;
}

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

int main() {

string S, T;

cin >> S;
cin >> T;

bool ans = false;

for(int i = 0; i < S.size(); i++){
  if(S == T){
    ans = true;
    break;
  }
  S = S.back() + S.substr(0, S.size() - 1);
  //cout << S << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

int main() {

	long long A;
	long long B;
	long long K;

	cin >> A;
	cin >> B;
	cin >> K;

	long long ansT;
	long long ansA;

	if (A - K >= 0) {
		ansT = A - K;
		ansA = B;
	}
	else {
		ansT = 0;
		ansA = B - (K - A);
		if (ansA < 0) {
			ansA = 0;
		}
	}
	
	cout << ansT << "\t" << ansA << endl;

	return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
    int A,B;
    cin>>A >>B;
    if((A<10)&&(B<10)){
        cout<<A*B;
    }else {
        cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  
  string t;
  cin>>t;
  int n=t.length(); 
  
  rep(i,n){
    if(t[i]=='P')cout<<'P';
    else cout<<'D';
  }

}


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

using namespace std;

int main(){
    long long ans = 0;
    string s;
    cin >> s;
    int n;
    n = s.length()-1;
    for(int i = 0 ; i < (1 << n) ; i++){
        long long a = s[0]-'0';
        long long b = 0;
        for(int j = 0; j < n ; j++){
            if(i&(1<<j)){
                b+=a;
                a = s[j+1]-'0';
            }else{
                a = a*10+(s[j+1]-'0');
            }
        }
        b+=a;
        ans+=b;

    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define MOD 1000000007
#define N 1000001
#define M 1003
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

vector <int> g[N];
int indeg[N];

int hsh(int x, int y){
	return (min(x, y)*1000 + max(x, y));
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, i, j, last, cur, x, y;
	cin>>n;
	for(i=0; i<n; i++){
		cin>>last; last--;
		for(j=0; j<n-2; j++){
			cin>>cur; cur--;
			x = hsh(i, last);
			y = hsh(i, cur);
			g[x].pb(y);
			indeg[y]++;
			last = cur;
		}
	}
	vector <int> sor, temp;
	for(i=0; i<N; i++){
		if(indeg[i] == 0) sor.pb(i);
	}
	int done = 0, ans = 0;
	while(sor.size()){
		ans++;
		done += sor.size();
		temp.clear();
		for(auto it : sor){
			for(auto ne : g[it]){
				indeg[ne]--;
				if(indeg[ne] == 0) temp.pb(ne);
			}
		}
		sor = temp;
	}
	if(done != N){
		ans = -1;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N;
   cin >> N;
   vector<vector<int>> dp(N, vector<int>(N));
   vector<vector<bool>> alive(N, vector<bool>(N));
   for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
         dp[i][j] = min({i + 1, N - i, j + 1, N - j});
         alive[i][j] = true;
      }
   }
   vector<int> xd = {-1, 0, 0, +1};
   vector<int> yd = {0, -1, +1, 0};
   long long ans = 0;
   for (int i = 0; i < N * N; ++i) {
      int p; cin >> p;
      --p;
      int x = p / N, y = p % N;
      ans += dp[x][y] - 1;
      --dp[x][y];
      alive[x][y] = false;
      vector<pair<int, int>> bfs;
      bfs.emplace_back(x, y);
      for (int z = 0; z < bfs.size(); ++z) {
         tie(x, y) = bfs[z];
         for (int d = 0; d < 4; ++d) {
            int nx = x + xd[d];
            int ny = y + yd[d];
            if (max(nx, ny) >= N || min(nx, ny) < 0) continue;
            if (dp[nx][ny] > dp[x][y] + alive[nx][ny]) {
               dp[nx][ny] = dp[x][y] + alive[nx][ny];
               bfs.emplace_back(nx, ny);
            }
         }
      }
   }
   cout << ans << "\n";
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 0;
  for(int i=1; i<=N; i++) {
    ans += i*(1+N/i)*(N/i)/2;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void print_ans(int a,int b,int c){
	if (a - b > 0){
		cout << c << " " << a - b << endl;
	}
}

int main() {
		int cost; cin >> cost;
	do{
		int ten,fifty,hund,fivehund;
		cin >> ten >> fifty >> hund >> fivehund;
		int first_ten = ten;;
		ten = ten + fifty * 5 + hund * 10 + fivehund * 50;
		ten -= cost / 10;
		int ans_ten = 0;
		int ans_fifty = 0;
		int ans_hund = 0;
		int ans_fivehund = 0;
		ans_fivehund = (ten * 10) / 500;
		ten -= ans_fivehund * 50;
		ans_hund = (ten * 10) / 100;
		ten -= ans_hund * 10;
		ans_fifty = (ten * 10) /50;
		ten -= ans_fifty * 5;
		ans_ten = ten;

		print_ans(first_ten,ans_ten,10);
		print_ans(fifty,ans_fifty,50);
		print_ans(hund,ans_hund,100);
		print_ans(fivehund,ans_fivehund,500);
		cin >> cost;
		if (cost != 0){
		cout << endl;
		}
	}while(cost != 0);

	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define inf 1e8
#define maxn int(1e6+5)
#define ll long long
#define eps 1e-8
#define mod int(1e9+7)
#define xrn_love_hcy_forever main
using namespace std;
ll f[maxn],s[maxn],ans=0;
int xrn_love_hcy_forever() {
	ll n;
	int i,j;
	scanf("%lld",&n);
//	f[1]=s[1]=n;
//	f[2]=(n*n)%mod;
//	s[2]=(s[1]+f[2]);
//	/*
	f[1]=s[0]=f[2]=f[0]=1;
	s[1]=2;
	s[2]=3;
//	*/
//	cout<<f[2]<<endl;
	for(i=3; i<=n; i++) {
		f[i]=(f[i-1]+s[i-3])%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
//	ans=ans*(n-1)%mod;
//	ans%=mod;
//	ans=ans*(n-1)%mod;
//	ans%=mod;
//	cout<<f[n]<<endl;
	ans=(ans+(n-1)%mod*f[n-1]%mod)%mod;
	ans+=f[n]%mod;
//	cout<<ans<<endl;
	for(i=0; i<=n-2; i++) ans=(ans+f[i]*((n-1)*(n-1)%mod+i+1)%mod)%mod;
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 15872
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(0, len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        for k in range(j + 1, len(l)):
            length = l[i] + l[j] + l[k]
            max_len = max(l[i], l[j], l[k])
            rest = length - max_len
            if max_len < rest and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9096
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B, C = map(int, input().split())
    if A < C < B or A > C > B:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main() {
  int N, D;
  cin >> N >> D;
  
  if (N % (2 * D + 1) == 0)
    cout << N / (2 * D + 1) << endl;
  else if (N % (2 * D + 1) > 0)
    cout << N / (2 * D + 1) + 1 << endl;
}

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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int T;
    cin >> T;
    typedef pair<int64_t, int64_t> P;
    while(T--){
        int64_t N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;
        
        int64_t cost[6] = {0};
        cost[2] = A;
        cost[3] = B;
        cost[5] = C;

        int64_t ans = 1e18;
        priority_queue<P, vector<P>, greater<P>> que;
        map<int64_t, int64_t> memo;

        auto insert = [&](int64_t v, int64_t n){
            if(v < ans && (!memo.count(n) || v < memo[n])){
                que.emplace(v, n);
                memo[n] = v;
            }
        };

        que.emplace(0, N);
        while(que.size()){
            auto p = que.top(); que.pop();
            int64_t v = p.first, n = p.second;
            if(v >= ans) break;
            if(n <= 2e18/D) chmin(ans, v+n*D);
            for(int d : {2, 3, 5}){
                int r = n%d;
                int64_t v2 = v + r*D + cost[d];
                insert(v2, n/d);
                v2 = v + (d-r)*D + cost[d];
                insert(v2, n/d+1);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4520
/**
 *    author: yuhongtao
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
#define fi first
#define se second
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=2147483647;
const int maxn=2e5+5;
const int mod=1e9+7;//greater<ll>//小根堆 
//priority_queue<ll,vector<ll>,less<ll> > q;
//vector<int> vt[205];
//pair<int,int> p,tmp;
//map<int,int> m;
int main(){
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	long  double angle = fabs(30*c-5.5*d);
	long double ans = a*a+b*b-2*a*b*cos(angle*pi/180);
	printf("%.20lf\n",(double)sqrt(ans)); 
}

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

using i64 = int64_t;

using Graph = vector<vector<int>>;

void dfs(int prev, int u, int d, vector<pair<int, int>> &v, const Graph &tree){
    v[u-1].first = d;
    for(auto to: tree[u]){
        if(to == prev)continue;
        dfs(u, to, d+1, v, tree);
    }
}

int main(){
    int n;
    cin >> n;
    Graph tree(n+1, vector<int>());
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> c(n);
    for(int i=0;i<n;++i){
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    vector<pair<int, int>> v(n);
    for(int i=0;i<n;++i)v[i].second = i+1;
    dfs(0, 1, 0, v, tree);
    sort(v.rbegin(), v.rend());

    vector<int> ans(n+1);
    for(int i=0;i<n;++i){
        ans[v[i].second] = c[i];
    }

    int m = 0;
    for(int i=1;i<=n;++i){
        for(auto to: tree[i]){
            m += min(ans[i], ans[to]);
        }
    }

    cout << m / 2 << endl;
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << ans[i+1];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int x, y;
  scanf("%d %d", &x, &y);
  int p = x + y;
  int m = x - y;
  int s = x * y;
  int ans = p;
  if(ans < m){
    ans = m;
  }
  if(ans < s){
    ans = s;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int n, k, m;

Int dp[165][165][165];

bool between(int a, int b, int c){
    return a < b && b < c;
}

int main(){
    cin >> n >> k >> m;
    if(k % 2 == 0){
        vector<Int> dp(n+1, 0);
        dp[0] = 1;
        for(int i = 1;i <= n;i++){
            for(int j = max(0, i - k/2-1);j < i;j++){
                dp[i] += dp[j];
                dp[i] %= m;
            }
        }
        cout << dp[n/2 + 1] * dp[n-n/2 + 1] % m << endl;
    }
    else{
        int goal = n+3;
        n+=10;
        dp[0][2][1] = 1;
        for(int a = 0;a <= n;a++){
            for(int b = a+2;b <= n;b+=2){
                for(int c = !(a%2);c < b;c+=2){
                    for(int d = c+2;d <= n;d+=2){
                        if(d-2 > c && between(a, d-2-k, b) && between(a, d-2+k, b))break;
                        if(d-2 > c && b-2 > a&& between(a, d-2-k, b) && between(c, b-2-k ,d))break;
                        
                        if(b > d)(dp[a][b][d] += dp[a][b][c]) %= m;
                        else (dp[c][d][b] += dp[a][b][c])%= m;
                    }
                }
            }
        }
        cout << dp[goal][goal+2][goal+1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 34944
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t x;
    cin >> x;

    for (auto n = x;; ++n) {
        bool is_prime = true;
        for (int64_t p = 2; p * p <= n; ++p) {
            if (n % p == 0) {
                is_prime = false;
                break;
            }
        }

        if (is_prime) {
            cout << n << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    
    int l = read<int>(), r = read<int>(),d = read<int>();
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i%d == 0) ans++;
    }
    cout<<ans<<endl;
} 



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

int main() {
    int n; cin >> n;
    int ans = 0;
    for (int coin: {25, 10, 5, 1}) {
        ans += n / coin;
        n %= coin;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  A.begin(), A.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))


#define forr(i,n) for(i=0; i<n; i++)
#define whilee(i,t) while(i!=t)
//#define pb(x) push_back(x);

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //vector <int> A;
    //deque <int> A;
    //queue <int> A;
    //stack <int> A;
    //set <int> A;
    //map <int,int> A;
    //pair <int,int> A ;
    //vector <pair <int,int>> A ;
    //string S, T;
    int i, j, k, a, b, c, l, m, n, p, q, r, s, t, x, y, z, ans, cnt;
    cin>>n>>m;
    int A[n][2], B[m][2];
    forr(i,n)
    {
        cin>>A[i][0]>>A[i][1];
    }
    forr(i,m)
    {
        cin>>B[i][0]>>B[i][1];
    }
    forr(i,n)
    {
        cnt=INT_MAX;
        forr(j,m)
        {
            x=(abs(A[i][0]-B[j][0]))+(abs(A[i][1]-B[j][1]));
            if(x<cnt)
            {
                cnt=x;
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll l=2,r=2;
    for(int i=n-1;i>=0;i--){
        l=(l+a[i]-1)/a[i]*a[i];
        r=r/a[i]*a[i]+a[i]-1;
    }
    if(l>=r){
        cout << -1 << endl;
        return 0;
    }
    cout << l << " " << r << endl;
}

Measured memory_bytes: 640
# vim: set fileencoding=utf-8:


def main():
    O = input()
    E = input()

    ans = ''
    for o, e in zip(O, E):
        ans += o + e

    if len(O) > len(E):
        ans += O[-1]
    elif len(O) < len(E):
        ans += E[-1]
    elif len(O) == len(E):
        pass

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060