akhauriyash/Code-Regression huggingface dataset:
def solve():
    ans = []
    for i, (x, y) in enumerate(s):
        if num[x]>num[y]: x, y = y, x
        if num[x]==num[y] and i < n-1:
            if y == s[i+1][0] or y == s[i+1][1]:
                x, y = y, x
        num[x]+=1
        num[y]-=1
        ans.append(x)
        if num[y]<0: return False
    return ans
from collections import defaultdict
import sys
n, a, b, c = map(int, input().split())
num = defaultdict(int)
s = [input() for _ in range(n)]
num['A'] = a
num['B'] = b
num['C'] = c
id = ['A', 'B', 'C']
ans = solve()
if ans:
    print('Yes')
    print(*ans, sep = '\n')
else:
    print('No')

Measured memory_bytes: 92664
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int N, M;
	cin >> N >> M;
	vector<int> n(N+1);

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

	for (int i = 1; i <= N; i++) {
		printf("%d\n", n[i]);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int  a,b;
  cin >> a >> b;
  if (a>0)cout << "Positive" <<endl;
  else if(b>=0) cout << "Zero" <<endl;
  else {
    if ((b-a)%2==0)cout << "Negative" <<endl;
    else cout << "Positive" <<endl;
  
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;
int n, w[101];


signed main()
{

 	FLASH

 	cin>>n;
 	int sum = 0;
 	fr(i, 1, n +1){
 		cin>>w[i];
 		sum += w[i];
 	}


 	int here = 0, ans = mod;

 	fr(i, 1, n){
 		here += w[i];
 		ans = min(abs(sum - 2*here), ans);
 	}

 	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;
const int MAX=10010;

int a, b, c;

inline void readx(int &x){
	register int k=1; x=0; register char ch=0;
	while(ch<'0' | ch>'9') { ch=getchar(); if(ch=='-') k=-1; }
	while(ch>='0' && ch<='9') { x=x*10+ch-48; ch=getchar(); }
	x*=k;
}

inline void vip(int &a, int &b){
	register int x=a; a=b; b=x;
}

int main(){
	readx(a); readx(b); readx(c);
	if(a<b){
		vip(a, b);
	}
	if(b<c){
		vip(b, c);
	}
	if(b>a){
		vip(b, a);
	}
	printf("%d", abs(a-b)+abs(b-c));
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int n;
	int x, y;
	cin >> n;
	vector<int> num(n);

	rep(i, 0, n) {
		int a;
		cin >> num[i];
	}

	vector<int> co = num;

	sort(co.begin(),co.end());
	x = co[n / 2 - 1]; y = co[n / 2];
	
	rep(i, 0, n) {
		if (num[i]<=x) cout << y << endl;
		else cout << x << endl;
	}



	return 0;
}

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

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> v(3);
    rep(i,n) {
        int p;
        cin >> p;
        if(p <= a) v[0]++;
        else if(p <= b) v[1]++;
        else v[2]++;
    }
    cout << *min_element(v.begin(),v.end()) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N,K;
    cin >> N >> K;
    vector<ll> H;
    for(int i = 0;i< N;i++){
        ll h;
        cin >> h;
        H.push_back(h);
    }
    sort(H.begin(),H.end());
    ll count = 0;
    for(int i = 0; i< N - K;i++){
        count+= H[i];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	int a[n+1],ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
      if(i%2 && a[i]%2) ans++;
	}
	cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
typedef long double ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k;
  cin>>k;
  printf("%.9llf",k/3*k/3*k/3);
  
   
   
  return 0;
}

Measured memory_bytes: 256
import queue
N=int(input())
M=[input().split()[2:]for _ in[0]*N]
q=queue.Queue();q.put(0)
d=[-1]*N;d[0]=0
while not q.empty():
 u=q.get()
 for v in M[u]:
  v=int(v)-1
  if d[v]<0:d[v]=d[u]+1;q.put(v)
for i in range(N):print(i+1,d[i])


Measured memory_bytes: 7008
#include<iostream>
using namespace std;
long long int __gcd(int a, int b)
{
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    else return __gcd(b,a%b);
}
int main()
{
    int n; cin >> n;

    long long int sum = 0LL;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+= __gcd(__gcd(i,j),k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int cakes = 4;
        int donuts = 7;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= a; j++) {
                int total = (i * cakes) + (j * donuts);
                if (total == a) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


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

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

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

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  string ans="";
  while(n>0){
    ll tmp=n%26;
    if(tmp==0){
      n-=26;
      n/=26;
      ans+='z';
    }
    else{
      n-=tmp;
      n/=26;
      tmp--;
      ans+=('a'+tmp);
    }
    // cout<<n<<' '<<ans<<endl;
    
  }
  reverse(all(ans));
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)

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

const int MAX = 1e5+10;

int N;
int A[MAX];
int dp1[MAX], dp2[MAX];


int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    dp1[1] = A[0];
    REP (i, N-2) dp1[i+2] = gcd(dp1[i+1], A[i+1]);
    dp2[N-2] = A[N-1];
    REPR (i, N-2) dp2[i] = gcd(dp2[i+1], A[i+1]);
    
    int ans = max(dp1[N-1], dp2[0]);
    REP (i, N-2) ans = max(ans, gcd(dp1[i+1], dp2[i+1]));
    cout << ans << endl;
}

Measured memory_bytes: 1408
n=input()
N=int(n)
n=list(n)
n=[int(i) for i in n]
s=len(n)
if(s==6):
    print(90909)
elif(s==5):
    print(9+900+N-9999)
elif(s==4):
    print(909)
elif(s==3):
    print(9+N-99)
elif(s==2):
    print(9)
else:
    print(N)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> intpair;
typedef std::pair<long long, long long> llpair;

#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i, n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using namespace std;

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

	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;

		int ans = 0;
		bool flag = true;
		rep(i, n) {
			int k;
			cin >> k;
			if (k > 0) ++ans;
			if (k > 1) flag = false;
		}

		if (flag) {
			cout << "NA" << "\n";
		}
		else {
			cout << ++ans << "\n";
		}
	}

	return 0;
 }


Measured memory_bytes: 3232
#include<stdio.h>
int main()
{
	int a[7],b[7];
	for(int i=0;i<7;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(int i=0;i<7;i++){
		printf("%d\n",a[i]-b[i]);
	}
	return 0;
}

Measured memory_bytes: 1028
n,y = gets.split(' ').map(&:to_i)
y = y/1000
ans = '-1 -1 -1'

for c in 0..y
key = 10 * n - y - 9 * c
	if key % 5 == 0
		b = key / 5
		a = n - b - c
		if c <= n && b >= 0 && a >= 0
			ans = a.to_s + ' ' + b.to_s + ' ' + c.to_s
			break
		end
	end
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int a,b,c;
	while(~scanf("%d/%d/%d",&a,&b,&c))
	{
		printf("2018/%02d/%02d\n",b,c);
	}
	return 0;
}

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

bool is_prime(int num){
  if( num == 2 )return true;
  else if( num <= 1 || num % 2 == 0 )return false;
  int i = 3;
  while( i <= sqrt(num) ){
    if( num % i == 0)return false;
    i = i + 2;
  }
  return true;
}


int main(){
  int n;
  cin >> n;
  vector<int> num(n);
  rep(i,n){
    cin >> num.at(i);
  }

  int c = 0;
  rep(i,n){
    if( is_prime(num.at(i)) ) {
      c++;
    }
  }
  cout << c << endl;
}


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

using namespace std;

bool OK(int i, int N) {
  while (i > 0) {
    int r = i % 10;
    if (r == 0 || N < r) return false;
    i /= 10;
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  int count = 0;
  for (int i = 100; i <= 999; i++) {
    if (OK(i, N)) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

const ll mod=1e9+7;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=0;
    rep(i,60){
        ll zero=0,one=0;
        rep(j,n){
            if(a[j]>>i&1) one++;
            else zero++;
        }
        ll tp=1;
        rep(j,i) tp=tp*2%mod;
        sum+=(one*zero%mod)*tp%mod;
        sum%=mod;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
string str;
int t[7],u[7],v[10],a=0,sum=0,want,n,m,cnt=0;
int change(int x){return (x%10)+(x/10);}

void dfs(int x){
  if(x==a){
    sum=0;
    for(int i=0;i<a;i++){
      if(t[i]){
	sum+=u[i];
      }else{
	sum+=change(u[i]*2);
      }
    }
    if((sum%10)==want)cnt++;
    return;
  }
  for(int i=0;i<m;i++){
    u[x]=v[i];
    dfs(x+1);
  }
}


int main(){
  cin>>n>>str;
  for(int i=0;i<n;i++){
    if(str[i]=='*')t[a++]=(n-i)%2;
    else if((n-i)%2)sum+=(str[i]-'0');
    else sum+=change((str[i]-'0')*2);
  }
  want=(10-(sum%10))%10;
  cin>>m;
  for(int i=0;i<m;i++)cin>>v[i];
  dfs(0);
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1332
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  bool x;
  cin >> x;
  cout << !x << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
int main(){
	int n,r,c=0;
	int A[100];
	int flag = 1;
	int i = 0;
	int temp;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	i=0;
	while (flag){
		flag = 0;
		for(int j = n-1; j>=i+1 ;j--){
			if (A[j] < A[j-1]){
				temp=A[j];
				A[j]=A[j-1];
				A[j-1]=temp;
				flag = 1;
				r++;
			}

		}
		i++;
	}
	for(i=0;i<n;i++){
		if(c==1){
			printf(" ");
		}
		printf("%d",A[i]);
		c=1;
	}
	printf("\n%d\n",r);
	return 0;
}

Measured memory_bytes: 2728
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];
int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[0]=0;
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1) sum+=M[i][p[i]];
    }
    return sum;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;
            cin >> e;
            M[i][j]=(e==-1)? INFTY : e;
        }
    }
    cout << prim() << endl;
    return 0;
}


Measured memory_bytes: 3136
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    if n%1000 == 0:
        print(0)
    else:
        print(1000-n%1000)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;

int main() {
 int N;
 cin>>N;
 if(N==1){cout<<"Hello World"<<endl;}
 else{
   int A,B;
   cin>>A>>B;
   cout<<A+B<<endl;
   }
return 0;}

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

int main() {
  while(1) {
    int n, m, a[1000]={},check=0,max=0,v[1000000]={},k=0;
    cin >> n >> m;
    if(n==0&&m==0) break;

    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=0; i<=n; i++) {
      for(int j=i; j<=n; j++) {
	v[k]=a[i]+a[j];
	k++;
      }
    }
    sort(v, v+k);

    for(int i=0; i<k; i++){
      if (v[i]>m) break;      
      int t=distance(v,upper_bound(v, v+k, m-v[i]));
      if(v[i]+v[t]<=m && max<v[i]+v[t]) max = v[i]+v[t];
      if(t+1<k && v[i]+v[t+1]<=m && max<v[i]+v[t+1]) max = v[i]+v[t+1];
      if(t-1>=0 && v[i]+v[t-1]<=m && max<v[i]+v[t-1]) max = v[i]+v[t-1];
    }
    cout << max << endl;
  }
  return 0;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;
    vector<char> c(N);

    stack<int> R_pos;
    queue<int> W_pos;

    for(int i=1; i<=N; i++){
        char RW; cin >> RW;
        if(RW == 'R'){
            //R
            R_pos.push(i);

        }else{
            //W
            W_pos.push(i);
            
        }
    }

    int ans = 0;
    while(R_pos.empty() == false && W_pos.empty() == false && R_pos.top() > W_pos.front()){
        ans++;
        R_pos.pop();
        W_pos.pop();
    }
    cout << ans << endl;

}

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N=int(input())
G=[]
for i in range(N):
    x,y=map(int,input().split())
    G.append((x,y,i))

Gx=sorted(G,key=lambda x:x[0])
Gy=sorted(G,key=lambda x:x[1])

newG=[]
for i in range(N-1):
    now=Gx[i]
    next=Gx[i+1]
    dist=abs(now[0]-next[0])
    newG.append((dist,now[2],next[2]))

for i in range(N-1):
    now=Gy[i]
    next=Gy[i+1]
    dist=abs(now[1]-next[1])
    newG.append((dist,now[2],next[2]))

newG.sort()

uf=UnionFind(N)
count=N
ans=0
for c,i,j in newG:
    if count==0:
        break

    if not uf.same(i,j):
        ans+=c
        uf.union(i,j)
        count-=1

print(ans)







Measured memory_bytes: 45256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        ans += (d - 1) / a + 1;
    }
    cout << ans << endl;
}

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;
  string s;
  cin >> n >> s;
  int ans = 0;
  REP(i, n){
    set<char> l, r;
    REP(j, i) l.insert(s[j]);
    FOR(j, i, n) r.insert(s[j]);
    int count = 0;
    for(char c : l){
      if(r.count(c)) count++;
    }
    chmax(ans, count);
  }
  cout << ans << endl;
  return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  int n = in(), m = in();
  int stu[n];
  rep(i, n) stu[i] = in();

  rep(j, m) {
    int i = 0, k = j + 1;
    while (i != n - 1) {
      if (stu[i] % k > stu[i + 1] % k) swap(stu[i], stu[i + 1]);
      ++i;
    }
  }
  rep(i, n) print(stu[i]);

  return (0);
}

Measured memory_bytes: 3164
import  collections
a, b = map(int, input().split(" "))
if a == 1 and b == 1:
    print(1000000)
else:
    di = collections.defaultdict(lambda :0)
    di[1] = 300000
    di[2] = 200000
    di[3] = 100000
    print(di[a] + di[b])

Measured memory_bytes: 3444
S = input()
left = int(S[:2])
right = int(S[2:])
# print(left, right)
if 1 <= left <= 12 and 1 <= right <= 12:
    print("AMBIGUOUS")
elif 1 <= left <= 12:
    print("MMYY")
elif 1 <= right <= 12:
    print("YYMM")
else:
    print("NA")


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length(), k;
  cin >> k;

  long long a = 0, b = 0;
  bool a2b = false, b2b = false;

  { // a
    string t = s;
    for (int i = 1; i < n; i++) {
      if (t[i] == t[i - 1]) {
        t[i] = '.';
        a++;
      }
    }
    if (t[n - 1] == s[0]) a2b = true;
  }
  { // b
    string t = s;
    t[0] = '.';
    b++;
    for (int i = 1; i < n; i++) {
      if (t[i] == t[i - 1]) {
        t[i] = '.';
        b++;
      }
    }
    if (t[n - 1] == s[0]) b2b = true; 
  }
  cerr << a << ' ' << b << endl;

  long long ans = a; k--;
  if (!a2b) {
    ans += a * k;
  } else if (b2b) {
    ans += b * k;
  } else {
    ans += b * ((k + 1) / 2);
    ans += a * (k / 2);
  }

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,u;
  ll A,B,M;
  cin >> A >> B >> M;
  ll mina=MOD,minb=MOD;
  vll a(A),b(B),x(M),y(M),c(M);
  for (int i = 0; i < A; i++) {
      cin >> a[i];
      mina = std::min(a[i], mina);
  } 
  for (int i = 0; i < B; i++) {
      cin >> b[i];
      minb = std::min(b[i], minb);
  }
  ll min=mina+minb;
  for (int i = 0; i < M; i++) {
      cin >> x[i] >> y[i] >> c[i];
      min = std::min(a[x[i]-1] + b[y[i]-1] - c[i], min);
  }

  cout << min << endl; 
  
}

Measured memory_bytes: 4224
S = input()

cnt = 0

if S.count('R') == 0:
    cnt = 0
elif S.count('R') == 1:
    cnt = 1
elif S.count('R') == 3:
    cnt = 3
else :
    if S[1] == 'R':
        cnt = 2
    else :
        cnt = 1
        
print(cnt)

Measured memory_bytes: 9108
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	fast();

	int n, x, y; cin>>n>>x>>y;
	int cnt[n] = {0};
	for(int i = 1;i<=n;i++){
		for(int j = i+1; j<=n; j++){
			int dist = j-i;
			dist = min(dist, abs(i-x) + 1 + abs(j-y));
			dist = min(dist, abs(j-x) + 1 + abs(i-y));
			cnt[dist]++;
		}
	}
	for(int i = 1;i<n;i++){
		cout<<cnt[i]<<endl;
	}
	// int cnt[n+2] = {0};
	// int cir = y-x+1;
	// for(int i = x+1; i<=y-1; i++){
	// 	int mindist = min(i-x, cir-(i-x));
	// 	cnt[mindist+1]++;
	// 	cnt[mindist+1+(x-1)]--;
	// 	mindist = min(y-i, cir-(y-i));
	// 	cnt[1+mindist]++;
	// 	cnt[mindist+1+(n-y)]--;
	// }

	// for(int i = 1;i<n;i++){
	// 	cnt[i] += cnt[i-1];
	// 	// cout<<cnt[i]<<endl;
	// }

	// for(int i = 1;i<=(cir-1)/2; i++){
	// 	cnt[i] += cir;
	// }
	// int m = n - (y-x-1);
	// for(int i = 1;i<n;i++){
	// 	cnt[i] += max(m-i,0);
	// }
	// cnt[1]--;
	// for(int i = 1;i<n;i++){
	// 	cout<<cnt[i]<<endl;
	// }
	return 0;
}	

Measured memory_bytes: 256
N = int(input())
S = list(input())

lst = [chr(ord('a') + i) for i in range(26)]
lst_up = list(map(str.upper,lst))

for i in range(len(S)):
    if int(lst_up.index(S[i])+N+1) <= len(lst_up):
        S[i] = lst_up[lst_up.index(S[i])+N]
    elif  int(lst_up.index(S[i])+N+1) > len(lst_up):
        S[i] = lst_up[lst_up.index(S[i])+N-26]

lst_2 = "".join(S)
print(lst_2)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	int S = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		S += A[i];
	}
	vector<int> dp1(S + 1, 0);
	dp1[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = S; j >= A[i]; j--) {
			dp1[j] = (dp1[j] + dp1[j - A[i]]) % MOD;
		}
	}

	vector<int> dp(S + 1, 0);
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		dp[0] = (dp[0] * 2) % MOD;
	}
	int inv2 = (MOD + 1) / 2;
	for (int i = 0; i < N; i++) {
		for (int j = S; j >= A[i]; j--) {
			dp[j] = (dp[j] + inv2 * dp[j - A[i]]) % MOD;
		}
	}




	int all3 = 1;
	int all2 = 1;
	for (int i = 0; i < N; i++) {
		all3 = (all3 * 3) % MOD;
		all2 = (all2 * 2) % MOD;
	}
	all2 = (all2 * 3) % MOD;
	int all = all3 - all2 + 3 + MOD;
	while (all >= MOD)all -= MOD;
	cerr << all << endl;


	for (int i = 0; i < S; i++) {
		if (i * 2 >= S) {
			res = (res + dp[i] + 2 * (MOD - dp1[i])) % MOD;
		}
		
	}
	res = (all - 3 * res + 5 * MOD) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;

int main()
{
	cin >> N;
	int a = (N+111-1)/111;
	cout << a*111 << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main()
{
	int A,B,C;
	int count = 0;
	scanf("%d %d %d",&A,&B,&C);

	while(1) {
		if ( count == C || B < A ) break;
		count++;
		B -= A;
	}

	printf("%d\n",count);
  	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int c = a+b;
  int d = c%2;
  if (d==0){
    cout << c/2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}



Measured memory_bytes: 256
/*input
3 3
1
3
1
3
1
3åç
*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mod 998244353
#define int long long
int A[1000]= {0};
signed main() {
	int n,k;
	cin>>n>>k;
	while(k--) {
		int q;
		cin>>q;
		while(q--) {
			int x;
			cin>>x;
			A[x]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++) if(!A[i]) ans++;
		cout<<ans<<endl;
}

Measured memory_bytes: 3624
from copy import deepcopy

def bubblesort(C,N):
    A = deepcopy(C)
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if int(A[j][1]) < int(A[j-1][1]):
                A[j],A[j-1] = A[j-1],A[j]
    return A

def selectionsort(C,N):
    A = deepcopy(C)
    for i in range(N):
        minj = i
        for j in range(i,N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        A[i],A[minj] = A[minj],A[i]
    return A


def main():
    N = int(input())
    C = list(input().split())
    bs = bubblesort(C,N)
    print(*bs)
    print("Stable")
    ss = selectionsort(C,N)
    print(*ss)
    if bs == ss:
        print("Stable")
    else:
        print("Not stable")

if __name__ == "__main__":
    main()



Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d, e;
    cin >> a >> b;
    c=a+b;
    d=a-b;
    e=a*b;
    if(a==0 and b==0)
    {
        cout << 0 << endl;
    }
    else if(b==0 and (a>0))
    {
       cout << c << endl;
    }
    else if(c>d and c>e)
    {

        cout << c << endl;
    }
    else if(d>c and d>e)
    {
        cout << d << endl;
    }
    else if(e>c and e>d)
    {
        cout << e << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    i64 a , b , c , k;
    cin >> a >> b >> c >> k;
    i64 max = 0;
    if( k <= a) max = k;
    else if( k <= a + b) max = a;
    else max = a - ( k - a - b);
    cout << max << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(){
	double wa,a;
	int i;
	
	while(0<=scanf("%lf",&a)){
		wa=a;
		for(i=2;i<11;i++){
			if(i%2==0){
				a=2*a;
				wa+=a;
			}else{
				a=a/3;
				wa+=a;
			}
		}
		printf("%.8lf\n",wa);
	}
	return 0;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n, k;
	cin >> n >> k;
	vb snuke(n, false);
	int d;
	loop(k) {
		cin >> d;
		int x;
		loop(d) cin >> x, snuke[x - 1] = true;
	}
	int ans = 0;
	loop(n) if (!snuke[i]) ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.rbegin(), a.rend());
	int ans = a[0];
	int left = ((n - 2));
	for (int i = 1; i + 1 < n; i++) {
		ans += min((int)2, left) * a[i];
		left -= min((int)2, left);
	}
	cout << ans << endl;
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  int ans=0;
  rep(i,n-1) ans+=a[i];
  ans+=a[n-1]/2;
  out(ans);
}

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


Measured memory_bytes: 256
/*input 
10000000000
*/


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

 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))

#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll n,i,j,k,m,h,r, c;
ll x,y;


void solve() 
{
    cin>>n;

for(i=0;i<1000;i++)
{
    for(j=-1000;j<1000;j++)
    {
        if(pow(i,5)-pow(j,5)==n)
        {
            cout<<i<<" "<<j;
            return;
        }
    }
}
} 
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;
int h=T;
    while(T--){
//cout<<"Case #"<<(h-T)<<": ";
        solve();
cout<<endl;
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;
const int MOD = 1000000007;

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

    int s;
    cin >> s;
    ll dp[s];
    dp[0]=1;
    dp[1]=0;
    dp[2]=0;
    for (int i=3; i<=s; ++i) {
        dp[i] = dp[i-1] + dp[i-3];
        dp[i] %= MOD;
    }
    cout << dp[s] << endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

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

		int value = a * b;

		if(value % 2 == 1) {
			System.out.println("Odd");
		}else {
			System.out.println("Even");
		}
	}
}

Measured memory_bytes: 21076
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;

my @a;
{
    my $in = <STDIN>;
    @a = split(" ", $in);
}
my $gcd = sub
{
    my ($x, $y) = @_;
    
    while ($x>0 && $y>0)
    {
        if ($y > $x)
        {
            $y %= $x;
        }
        else
        {
            $x %= $y;
        }
    }
    return $x if $x>0;
    return $y if $y>0;
};
my (@l, @r);
$l[0] = $a[0];
$r[$n-1] = $a[$n-1];
for (my $i=1; $i<$n; $i++)
{
    $l[$i] = $gcd->($l[$i-1], $a[$i]);
    $r[$n-$i-1] = $gcd->($r[$n-$i], $a[$n-$i-1]);
}
my $ans = 0;
for (my $i=0; $i<$n; $i++)
{
    my $c = 0;
    $c = $gcd->($c, $l[$i-1]) if $i>0;
    $c = $gcd->($c, $r[$i+1]);
    $ans = $c if $ans<$c;
}
print "$ans\n";

Measured memory_bytes: 30028
import math
MOD = 10**9+7

N, M = map(int,input().split())
if abs(N-M) > 1:
    print(0)
else:
    if abs(N-M) == 1:
        print(math.factorial(N)*math.factorial(M) % MOD)
    else:
        print(2*math.factorial(N)**2 % MOD)


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans2 = 1;
    ll ans = 1;
    int i = 1;
    while(ans2 <= N) {
        ans = i * i;
        ans2 = (i+1) * (i+1);
        i++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
odd = []
even = []
for i, j in enumerate(map(int, input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(collections.Counter(odd).items(), reverse=True, key=lambda x: x[1])
even = sorted(collections.Counter(even).items(), reverse=True, key=lambda x: x[1])

if len(odd) == 1 and len(even) == 1 and odd[0][0] == even[0][0]:
    print(n // 2)
elif odd[0][0] == even[0][0]:
    if odd[0][1] == even[0][1]:
        for i in range(2):
            if odd[i][1] == even[i][1]:
                continue
            elif odd[i][1] > even[i][1]:
                print((n // 2 - odd[1][1]) + (n // 2 - even[0][1]))
                break
            elif odd[i][1] < even[i][1]:
                print((n // 2 - odd[0][1]) + (n // 2 - even[1][1]))
                break
        else:
            print((n // 2 - odd[0][1]) + (n // 2 - even[1][1]))
else:
    print((n // 2 - odd[0][1]) + (n // 2 - even[0][1]))


Measured memory_bytes: 20144
#include <iostream>
#include <string>

using namespace std;

int main(){
  int map[26]={0};
  int  MAP[26]={0};
  int N;
  string str;
  cin >> N >> str;
  for(int i=0;i<str.size();i+=2){
    map[str[i]-'a']++;
  }
  int count =0;
  for(int i=0;i<26;i++){
    int count2=0;
    if(map[i]==0||MAP[i]==1){
      continue;
    }
    if(map[i]==1){
      count+=2;
      MAP[i]=1;
      continue;
    }
    for(int j=i+1;j<26;j++){
      if(map[i]==map[j]){
        if(count2==0){
          count+=6;
        }
        count2++;
        MAP[j]=1;
        count+=2;
      }
    }
    MAP[i]==1;
    if(count2==0){
      count+=4;
    }
  }
  cout << count-1 << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,ans[100010];
	vector<P> vec[100010];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int p,y;
		cin >> p >> y;
		vec[p - 1].emplace_back(y,i);
	}
	for(int i = 0;i < n;i++){
		sort(all(vec[i]));
		for(int j = 0;j < vec[i].size();j++){
			P p = vec[i][j];
			ans[p.second] = (i + 1) * 1000000 + j + 1;
		}
	}
	for(int i = 0;i < m;i++) printf("%012lld\n",ans[i]);
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const int MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;}

int a, b, c;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> a >> b >> c;
    if (a % 2 && b % 2 && c % 2) {
        int mn = min ({a, b, c});
        int mx = max ({a, b, c});
        cout << mn * 1ll * (a + b + c - mn - mx);
    }
    else cout << 0;
    return 0;
}


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

int main() {
int A,B  ;
    cin >> A >> B ;
 int N;
 int count =0;
  
  for (int i=A; i<=B; i++){
    N=i ;
    string X=to_string(N);
   if (X[0]==X[4]&&X[1]==X[3])
     count ++;
  }
  cout << count << endl;  
}


Measured memory_bytes: 256