akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long n,W,i,j;
    cin>>n>>W;
    long long *val=new long long[n+1];
    long long *wt=new long long[n+1];
    for(i=1;i<=n;i++) cin>>wt[i]>>val[i];
    long long **dp=new long long*[n+1];
    for(i=0;i<=n;i++) dp[i]=new long long[W+1];
    for(j=0;j<=W;j++) dp[0][j]=0;
    for(i=0;i<=n;i++) dp[i][0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=W;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(wt[i]<=j) dp[i][j]=max(dp[i][j],val[i]+dp[i-1][j-wt[i]]);
        }
    }
    cout<<dp[n][W];
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    int A,B,C,K;
    cin >> A>>B>>C>>K;

    for (int i = K; i > 0;i--)
    {
        if(B <= A){
            B = B * 2;
        }
        else{
            C = C * 2;
        }

        //cout << A << " " << B << " " << C << endl;
        //cout << i << endl;
    }
    if(A < B && B < C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3620
#include <cstdio>

const int maxn = 100005;
int a[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int t = a[i];
        if (a[t] == i) ans++;
    }
    printf("%d\n", ans / 2);
    return 0;
}


Measured memory_bytes: 512
S = input()[::-1]
D = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]]
while True:
    for d in D:
        if S.startswith(d):
            S = S.replace(d, "", 1)
            break
    else:
        break
print("YNEOS"[S!=""::2])

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll n; cin >> n;
    ll mn = 4 * a; mn = min(mn, 2 * b); mn = min(mn, c);
    ll ans;
    if (2 * mn < d) {
        ans = mn * n;
    }
    else {
        ans = (n/2) * d + (n%2) * mn;
    }
    out(ans);








    

    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin>>n;
    string s;
    if(n==0)cout<<0;
    while(n!=0){
        s+=to_string(abs(n)%2);
        n-=abs(n)%2;
        n/=-2;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int n;
     
    bool l[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            l[i][j] = false;
        }
    }
 
    cin >> n;
 
    for(int i = 0; i < n; i++){
        char mark;
        int number;
        cin >> mark >> number;
        switch(mark){
            case 'S': l[0][number-1] = true; break;
            case 'H': l[1][number-1] = true; break;
            case 'C': l[2][number-1] = true; break;
            case 'D': l[3][number-1] = true; break;
        }
    }
 
    //0:S
    for(int j = 0; j < 13; j++){
        if(l[0][j] == false){
            cout << "S " << j+1 << endl;
        }
    }
 
    //1:H
    for(int j = 0; j < 13; j++){
        if(l[1][j] == false){
            cout << "H " << j+1 << endl;
        }
    }
 
    //2:C
    for(int j = 0; j < 13; j++){
        if(l[2][j] == false){
            cout << "C " << j+1 << endl;
        }
    }
 
    //3:D
    for(int j = 0; j < 13; j++){
        if(l[3][j] == false){
            cout << "D " << j+1 << endl;
        }
    }
 
    return(0);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int L;
    cin >> L;

    cout << fixed;
    cout << pow((L/3.0),3) << endl;

    return 0;    
}


Measured memory_bytes: 256
while 1:
    n=int(input())
    m=int(input())
    friend=[[0 for i in range(1)] for j in range(n+1)]
    if n==m==0:break
    for i in range(m):
        a,b=map(int,input().split())
        friend[a].append(b)
        friend[b].append(a)
    friend_1st=friend[1]
    friend_2nd=friend_1st[:]
    for i in friend_1st:
        friend_2nd.extend(friend[i])
    ans=list(set(friend_2nd))
    if 0 in ans:ans.remove(0)
    if 1 in ans:ans.remove(1)
    print(len(ans))


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long ok = *max_element(A.begin(), A.end()), ng = 0;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      int cut = 0;
      for (int i = 0; i < N; i++) {
        cut += (A.at(i) + mid - 1) / mid - 1;
      }
      (cut <= K) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}


Measured memory_bytes: 3932
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
string alph="abcdefghijklmnopqrstuvwxyz";

signed main(){
    string s;
    cin>>s;
    int ans=1;
    for(int i=0; i<26; i++){
        ans=1;
            for(int j=0; j<s.size();j++){
                if(alph[i]==s[j]){
                    ans=0;
                    break;
                }
    }
        if(ans){
            cout<<alph[i]<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    string S, SS, T, C;
    cin >> SS >> T;
        C="|";
        for(int j=0; j<(SS.length()-T.length()+1); j=j+1)
        {
            int satisfy=1;
            for(int i=0; i<T.length(); i=i+1)
            {
                if(SS[i+j]!=T[i] && SS[i+j]!='?')
                {
                    satisfy=0;
                }
            }
            if (satisfy == 1)
            {
                S="";
                for(int s=0; s<SS.length(); s=s+1)
                {
                    if(SS[s]!='?')
                    {
                        S+=SS[s];
                    }
                    else
                    {
                        S+='a';
                    }
                }
                for(int t=0; t<T.length(); t=t+1)
                {
                    S[j+t]=T[t];
                }
                if(S<C)
                {
                    C="";
                    for(int n=0; n<S.length(); n=n+1)
                    {
                        C+=S[n];
                    }
                }
            }
        }
        if(C=="|")
        {
            cout << "UNRESTORABLE" << endl; 
        }
        else
        {
            cout << C << endl;
        }
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
#include<numeric>
#include <iomanip>
#include<string.h>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;


int main() {
    string s;
    ll k;
    cin>>s>>k;
    for(int i=0;i<s.length();i++){
        if(s[i]!='a'&&'z'-s[i]+1<=k){
            k-=('z'-s[i]+1);
            s[i]='a';
        }
    }
    k%=('z'-'a'+1);
    while(k--){
        s[s.length()-1]++;
        if(s[s.length()-1]>'z'){
            s[s.length()-1]='a';
        }
    }
    cout<<s<<endl;
    
    return 0;
}


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

using namespace std;

int main(void) {
	long long N, x;
	vector<long long> a;
	cin >> N >> x;
	for(int i = 0; i < N; ++i) {
		long long t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	int result = 0;
	for(int i = 0; i < N; ++i) {
		if(a[i] <= x) {
			x -= a[i];
			++result;
		} else {
			break;
		}
		if(i == N - 1 && x != 0) --result;
	}
	cout << result << '\n';
	return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  cout<<((n+1)/2)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << '\n';
}


Measured memory_bytes: 3644
from collections import defaultdict

def resolve():
	N = int(input())
	A = list(map(int, input().split()))
	a_max = max(A)+1
	B = defaultdict(int)
	for i in range(N):
		a = A[i]
		if B[a]>1:
			B[a] = 2
		else:
			for j in range(a, a_max, a):
				B[j] += 1
	Y = 0
	for a in A:
		if B[a]==1:
			Y+=1
	print(Y)
resolve()

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

int main() {
	//cout << "" << endl; // prints
	int N;
	cin >> N;
	int ans = 0;
	for(int i = 1; i < N-1; i++){
		int NN = N - i;
		int yks = 0;
		int flag1 = 0;
		for(int k = 1; NN >= k*k; k++){
			if(NN % k == 0){
				yks++;
				//cout << k << endl;
			}
			if(NN == k * k){
				flag1 = 1;
			}
		}
		if(flag1 == 1){
			ans += ((yks-1)*2)+1;
		}else if(flag1 == 0){
			ans += yks*2;
		}
		//cout << ans << endl;
	}
	ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> v(N);
	ll ans = 0;
	for (int i = 0;i < N;i++)
		cin >> v[i];
	vector<ll> c(N);
	for (int i = 0;i < N;i++)
		cin >> c[i];
	for (int i = 0;i < N;i++)
		if (v[i] > c[i])
			ans += v[i] - c[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    vector<ll> d(s.size());
    bool jg=true;
    char c = s[0];
    for(int i=0;i<s.size();i++){
        d[s[i]-'a']++;
        if(s[i]!=c) jg = false;
    }
    if(jg){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1LL<<60;
    for(int i=0;i<26;i++){
        if(d[i]==0)continue;
        string tmpt="",nt = s;
        for(int l=0;l<s.size();l++){
            ll ct = 0;
            for(int j=0;j<nt.size()-1;j++){
                if(nt[j]==i+'a' || nt[j+1] == i+'a'){
                    tmpt+=(char)i+'a';
                    ct++;
                }
                else tmpt+=nt[j];
            }
            if(ct==tmpt.size()){
                ans=min(ans,(ll)s.size()-ct);
                break;
            }
            nt=tmpt;
            tmpt="";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// abc048_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, x;
    cin >> N >> x;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll ans = 0;
    ll tmp = A[0];
    REPN(i, 1, N){
        ll sm = tmp + A[i];

        ll diff = sm > x ? sm - x : 0;
        A[i] -= diff;
        ans += diff;
        
        if (A[i] < 0){
            A[i] = 0;
        }

        tmp = A[i];
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<61;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
//vector< vector<int> > v (max1, vector<in t>(max2) );

int main() {
	int n,y;
	cin >> n >> y;
	y = (int)y/1000;
	if (n * 10 < y or n > y) {
		cout << -1 << " " << -1 << " " << -1 << endl;
		return 0;
	}
	int v;
	rep(i, n+1)for (int j = 0; j <= n - i;++j) {
		if (i * 10 + n - i > y)break;
		if ((i * 10) + ((n - i) * 5) < y)break;
		v = (i * 10 + j * 5) + (n - i - j);
		//cout << "i:" << i << " j:" << j << " k:" << n-i-j << " v:" << v << endl;
		if (v == y) {
			cout << i << " " << j << " " << n - i - j << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	int i;
	cin >> i;
}

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

const int INF = (1<<31)-1;

struct segtree{
  int n;
  int data[262143];
  segtree(int n_){
    n = 1;
    while(n_>n) n*=2;
    for(int i=0;i<n*2-1;i++) data[i] = INF;
  }
  void update(int k,int a){
    k+=n-1;
    data[k] = a;
    while(k>0){
      k = (k-1)/2;
      data[k] = min(data[2*k+1],data[2*k+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return INF;
    if(a<=l&&r<=b) return data[k];
    return min(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
};

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  segtree st(n);
  for(int i=0;i<q;i++){
    int cmd,x,y;
    scanf("%d %d %d",&cmd,&x,&y);
    if(cmd==0) st.update(x,y);
    else if(cmd==1) printf("%d\n",st.query(x,y+1));
  }
  return 0;
}

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

int dist(P a, P b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    vector<P> na(100), ma(100);
    int n, m;
    cin >> n >> m;
    rep(i, n) {
        int a, b; cin >> a >> b;
        na[i] = P(a, b);
    }
    rep(i, m) {
        int a, b; cin >> a >> b;
        ma[i] = P(a, b);
    }
    rep(i, n) {
        P a = na[i];
        ll mi = 1e10;
        int ans=-1;
        rep(j, m) {
            P b = ma[j];
            if (mi > dist(a, b)) {
                mi = dist(a, b);
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }

}


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

nums = [3, 5, 7]

def iter_nums():
    xs = nums
    base = 10
    while 1:
        for x in xs:
            yield x
        xs = [n * base + x for n in nums for x in xs]
        base *= 10

def calc(N):
    result = 0
    for n in iter_nums():
        if n > N:
            break
        s = str(n)
        if "3" in s and "5" in s and "7" in s:
            result += 1
    return result

result = calc(N)

print(result)

Measured memory_bytes: 6704
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
ar=[0]
br=[0]
for i in range(n):
  ar.append(ar[i]+a[i])
for i in range(m):
  br.append(br[i]+b[i])

ans=0
j=0
cnt=0
# print(ar)
# print(br)
for i in range(n+1):
  now=ar[i]
  cnt=i
  nokori=k-now

  if nokori<0:
    continue

  while(br[j]<=nokori):
    if j<m:
      j+=1
    else:
      break
    
  if nokori<br[j]:
    j-=1


  ans=max(ans,j+i)
print(ans)





Measured memory_bytes: 47492
#include<iostream>
#include<vector>
#include<string>
#include<list>
#include<algorithm>

using namespace std;

int main() {
	long a, b;
	long N, M,K;
	vector<long>  human(0);
	long sum = 0;
	long ans = 0;

	cin >> N ;

	for (long i = 0; i < N; i++) {
		human.push_back(0);
	}

	for (long i = 1; i <= N; i++)
	{
		cin >> a;

		human.at(a-1) =  i;
	}
	
	for (long i = 0; i < N; i++) {
		cout << human.at(i) << " ";
	}
}

Measured memory_bytes: 1780
n=int(input())

s1=list(input())

s2=list(input())

ans = n*2

flag = False

for i in range(n):
    for j in range(n):
        if s1[i:n]==s2[j:n-i]:
            ans -= len(s1[i:n])
            flag = True
            break
    if flag:
        break

print(ans)

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>

int main()
{
    int64_t A, B;
    std::cin >> A >> B;

    int64_t x = A * B;

    if (A < B) {
        std::swap(A,B);
    }

    int64_t r = A % B;
    while (r != 0) {
        A = B;
          B = r;
      r = A % B;
    }

    std::cout << x/B << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A[base10_6];
ll B[base10_6]={};
ll C;
ll N;
ll M;
ll K;

int main(){

    
    cin >> N;
    rep(ni,N-1){
        cin >> A[ni];
        B[A[ni]]++;
    }
    for( int ni = 1 ; ni <=N ; ni++ ){
        cout << B[ni] << endl;
    }
    

}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define rep(i,n) ;for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

vector<int> ans(8,0);

void dfs(vector<int> p,int i){
        if(i == 8){
                rep(j,8){
                         ans.at(j) = p.at(j);
                }
                return ;        
        }
        if(p.at(i) >= 0) dfs(p,i+1);
        else{
                rep(j,8){
                         bool ok = 1;
                        rep(k,8){
                                 if(p.at(k) == -1) continue;
                                if(p.at(k)+(i-k) == j || p.at(k)-(i-k) == j || p.at(k) == j){
                                ok = 0;
                                break;
                                }
                        }
                        if(ok){
                                p.at(i) = j;
                                dfs(p,i+1);
                                p.at(i) = -1;
                        }
                }
        }
}
        


int main() {
        int k;
        cin >>k;
         vector<int> p(8,-1)               
        rep(i,k){
                 int r,c;
                cin >> r >>c;
                p.at(r) = c;
        }
        //rep(i,8) cout << p.at(i) <<endl;
        dfs(p,0);
        
        rep(i,8){
                        rep(j,8){
                                 if(ans.at(i) == j) cout << "Q"  ;
                        else cout << "."  ;
                }
                cout << endl;
        }
        
        return 0;
}



Measured memory_bytes: 3160
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s, t = rr(), rr()
lent = len(t)
ans = inf
for i in range(len(s)-lent+1):
    cnt = 0
    for a, b in zip(s[i:i+lent], t):
        if a!=b:
            cnt += 1
    ans = min(ans, cnt)
print(ans)












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

bool hasThree(int x) {
  while (x) {
    if (x % 10 == 3) {
      return true;
    }
    x /= 10;
  }
  return false;
}

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

  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || hasThree(i)) {
      cout << " " << i;
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
const long long MOD = 1000000007LL;
int main(){
    string s;
    cin >> s;
    s = '0'+s;
    long long ans = 0;
    bool fl = false;
    for(int i=s.size()-1;i>=0;i--){
        int nownum = (s[i]-'0');
        if(fl) nownum++;
        if(nownum<5){
            ans+=nownum;
            fl = false;
        }
        else if(nownum==5){
            ans+=5;
            if(int(s[i-1]-'0')>=5){
                fl = true;
            }
            else fl = false;
        }
        else{
            ans+=(10-nownum);
            fl = true;
        }
    }
    cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    long long int k;
    cin >> k;
    int ans;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != '1'){
            ans = s[i]-'0';
            break;
        }else if(i == k-1){
            ans = 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct bian{
	int next,point;
}b[410000];
int p[210000],len,n,m,flag,pd[210000],si=0;
void ade(int k1,int k2){
	b[++len]=(bian){p[k1],k2}; p[k1]=len;
}
void add(int k1,int k2){
	ade(k1,k2); ade(k2,k1);
}
void dfs(int k1,int k2){
	if (pd[k1]!=-1){
		if (pd[k1]!=k2) flag=1;
		return;
	}
	si++;
	pd[k1]=k2;
	for (int i=p[k1];i;i=b[i].next){
		int j=b[i].point;
		dfs(j,k2^1);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for (;m;m--){
		int k1,k2; scanf("%d%d",&k1,&k2); add(k1,k2);
	}
	memset(pd,0xff,sizeof pd);
	int num1=0,num2=0,num3=0;
	for (int i=1;i<=n;i++)
		if (pd[i]==-1){
			flag=0; si=0; dfs(i,0);
			if (flag==0){
				if (si==1) num3++;
				else num2++;
			} else num1++;
		}
	cout<<2ll*num3*(n-num3)+1ll*num3*num3+1ll*(num1+num2)*(num1+num2)+1ll*num2*num2<<endl;
	return 0;
}

Measured memory_bytes: 6400
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int d = sc.nextInt();
                int n = sc.nextInt();
                n += n / 100;
                d = (int)Math.pow(100 , d);
                System.out.println(d * n);
                sc.close();
        }
}//0=48
//鶏になれ

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


int main(){
    int n =5;
    vector <int> a(n);
    int ans = 0;
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(a[i]==0){
            ans = i;
            break;
        }
    }
    ans +=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vector<ll> h(n); rep (i, n) cin >> h[i];
    vector<bool> bad(n);
    rep (i, m) {
        int a, b; cin >> a >> b; a--; b--;
        if (h[a] >= h[b]) bad[b] = true;
        if (h[a] <= h[b]) bad[a] = true;
    }
    int ans = n; rep (i, n) if (bad[i]) ans--;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long res = K*(long)Math.pow(K-1, N-1);
		System.out.println(res);
	}
}


Measured memory_bytes: 21716
// In the name of Allah the Most Merciful.

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

typedef long long ll;

string ar[111];
int n , m;
int level[111][111];

bool possible(int i , int j)
{
    if(i<0||j<0)return false;
    if(i>=n||j>=m)return false;
    if(ar[i][j]=='#')return false;
    if(level[i][j]!=0)return false;
    return true;
}

void bfs()
{
    memset(level , 0 , sizeof(level));
    level[0][0] = 1;

    queue<int>current;
    current.push(0);
    current.push(0);

    while(!current.empty()){

        int i = current.front();
        current.pop();
        int j = current.front();
        current.pop();

        if(possible(i+1 , j)){

            level[i+1][j] = level[i][j]+1;
            current.push(i+1);
            current.push(j);
        }

        if(possible(i-1 , j)){

            level[i-1][j] = level[i][j]+1;
            current.push(i-1);
            current.push(j);
        }

        if(possible(i , j+1)){

            level[i][j+1] = level[i][j]+1;
            current.push(i);
            current.push(j+1);
        }

        if(possible(i , j-1)){

            level[i][j-1] = level[i][j]+1;
            current.push(i);
            current.push(j-1);
        }
    }
}

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

    cin >> n >> m;

    for(int i=0;i<n;i++){

        cin >> ar[i];
    }

    int counter = 0;

    for(int i=0;i<n;i++){

        for(int j=0;j<m;j++){

            if(ar[i][j]=='#')counter++;
        }
    }

    bfs();

    if(level[n-1][m-1]==0)cout << -1 << endl;
    else cout << n*m-counter-level[n-1][m-1] << endl;

    return 0;
}


Measured memory_bytes: 384
//Only for codeforces
#include<bits/stdc++.h>
using namespace std;
//#define ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define mod2 998244353
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
//#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define tr(it,ct) for(auto &(it) : (ct))
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;

int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}


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

 const int N=1e+5;
 

void solve()
{ 
  int n,x,y,z; cin>>n; int dp[n+1][3]; dp[0][1]=dp[0][2]=dp[0][0]=0;
  rep(i,1,n+1)
  {
    cin>>x>>y>>z;
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+x;
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+y;
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+z;
  }
 cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}


signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0); 
   
  
  int t=1;
   
//  cin>>t;
rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   solve();
   
   if(i<t)
   cout<<"\n";
  }

 
 return 0; 
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll a,b;
    cin >> a >> b;

    cout << a * b / 2 << endl;
    return 0;
}

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

int main(){
    int a, b, k;

    cin >> a >> b >> k;
    // a = 8;
    // b = 12;
    // k = 2;
    int max_value = 100;
    vector<int> v;
    for (int i = 1; i <= max_value; i++){
        if ((a % i == 0) && (b % i == 0)){
            v.push_back(i);
        }
    }
    cout << v[v.size() - k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;

int main() {
	
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	multiset<ll> st;
	for (ll i = 0; i < n; i++)
	{
		st.insert(a[i]);
	}

	ll num;
	for (ll i = 0; i < m; i++)
	{
		auto it = st.end();
		it--;
		num = *it;
		st.erase(it);
		num /= 2;
		st.insert(num);
	}

	ll sum = 0;
	for (auto it = st.begin(); it != st.end(); it++)
	{
		sum += *it;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(void)
{
	long long a,b;
	scanf("%d %d",&a,&b);
	long long i,j;
	long long min = 100000000;
	if((a / 2019) != (b / 2019))
		min = 0;
	else
	{
		for(i = a;i<b;i++)
		{
			for(j = a+1;j<=b;j++)
			{
				long long  c = ((i*j) % 2019);
				if(min > c)
					min = c;
			}
		}
	}
	printf("%ld",min);
	return 0;
}

Measured memory_bytes: 128
"""
nodes
0 ... start
k*num + 1 ~ (k+1)*num ... j=k (k <= m)
num * (m + 1) + 1 ... end
"""
from heapq import heappush, heappop
def main():
  INF = 10 ** 20
  while True:
    n, m = map(int, input().split())
    if n == 0:
      break
    lines = []
    acc = 1
    for _ in range(n):
      lst = list(map(int, input().split()))
      k = lst[0]
      line = [(acc + i, lst[i * 2 + 1], lst[i * 2 + 2]) for i in range(k)]
      acc += k
      lines.append(line)
  
    num = acc - 1
    edges = [[] for _ in range(num * (m + 1) + 2)]
    for line1, line2 in zip(lines, lines[1:]):  
      for acc1, x1, d1 in line1:
        for acc2, x2, d2 in line2:
          cost = (d1 + d2) * abs(x1 - x2)
          n1 = acc1
          n2 = acc2
          for j in range(m + 1):
            edges[n1].append((n2, cost))
            n1 += num
            n2 += num
    
    for line1, line2 in zip(lines, lines[2:]):  
      for acc1, x1, d1 in line1:
        for acc2, x2, d2 in line2:
          cost = (d1 + d2) * abs(x1 - x2)
          n1 = acc1
          n2 = acc2 + num
          for j in range(m):
            edges[n1].append((n2, cost))
            n1 += num
            n2 += num
  
    for acc, _, _ in lines[0]:
      edges[0].append((acc, 0))
    if m >= 1:
      for acc, _, _ in lines[1]:
        edges[0].append((acc + num, 0))

    end = num * (m + 1) + 1
    for acc, _, _ in lines[-1]:
      b = acc
      for j in range(m + 1):
        edges[b].append((end, 0))
        b += num
    for acc, _, _ in lines[-2]:
      b = acc
      for j in range(m):
        edges[b].append((end, 0))
        b += num
    
    def search():
      que = []
      heappush(que, (0, 0))
      costs = [INF] * (num * (m + 1) + 2)
      costs[0] = 0
      while que:
        total, node = heappop(que)
        for to, cost in edges[node]:
          new_total = total + cost
          if to == end:
            print(new_total)
            return
          if costs[to] > new_total:
            costs[to] = new_total
            heappush(que, (new_total, to))
    search()
main()  


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

using namespace std;

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;

#define pb push_back

ll a[5];

int main() {
    ll N;
    cin >> N;
    ll cM = 1e16;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        cM = min(cM, a[i]);
    }

    cout << (N + cM - 1) / cM + 4 << endl;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 200001;
int vis[101];
int32_t main()
{

   IOS
    int x;
    cin>>x;
    for(int i = -2000;i<=2000;i++){
      for(int j = -2000;j<=2000;j++){
        int a = i;
        int b =  j;

        for(int k = 1;k<=4;k++)
          {
            a*=i;
            b*=j;
          }
        if(a-b == x){
          cout<<i<<" "<<j<<endl;
          return 0;
        }
      }
    }
} 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
string a;
int b=0,c=0;
cin>>a;
for(int i=0;i<a.size();i++){
	if(i%2==0){
		if(a[i]=='0')
		b++;
		else
		c++;
	}
	else{
		if(a[i]=='1')
		b++;
		else
		c++;
	}
}
cout<<min(b,c);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	cin>>n;
	int a[105];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}	
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=a[i+1]){
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  if(n==2){
    cout << s << endl;
  }else{
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
  return 0;
}

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


int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%2)cout<<(a+b)/2+1<<endl;
	else cout<<(a+b)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
  Contest 075
  B - Minesweeper
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    int h = 0 , w = 0;
    std::cin >> h >> w;
    std::cin.ignore();
    std::vector<std::string> grid;
    while (h--) {
        std::string s;
        std::getline(std::cin, s);
        grid.emplace_back(s);
    }

    for (int r = 0; r < static_cast<int>(grid.size()); ++r) {
        for (int c = 0; c < static_cast<int>(grid[r].size()); ++c) {
            if (grid[r][c] == '.') {
                int count = 0;
                if (r - 1 >= 0 && grid[r - 1][c] == '#')
                    ++count;
                if (r + 1 < static_cast<int>(grid.size()) && grid[r + 1][c] == '#')
                    ++count;
                if (c - 1 >= 0 && grid[r][c - 1] == '#')
                    ++count;
                if (c + 1 < static_cast<int>(grid[r].size()) && grid[r][c + 1] == '#')
                    ++count;
                if (r - 1 >= 0 && c - 1 >= 0 && grid[r - 1][c - 1] == '#')
                    ++count;
                if (r - 1 >= 0 && c + 1 < static_cast<int>(grid[r].size()) && grid[r - 1][c + 1] == '#')
                    ++count;
                if (r + 1 < static_cast<int>(grid.size()) && c - 1 >= 0 && grid[r + 1][c - 1] == '#')
                    ++count;
                if (r + 1 < static_cast<int>(grid.size()) && c + 1 < static_cast<int>(grid[r].size()) && grid[r + 1][c + 1] == '#')
                    ++count;
                std::cout << count;
            } else {
                std::cout << "#";
            }
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int h, w, x;

bool isin(int i, int j){
	return i >= 0 && j >= 0 && i < h && j < w;
}

int count(VVI p, VVI &c){
	REP(i,h) REP(j,w) c[i][j] = 0;
	c[0][0] = 1;
	queue<P> que;
	que.push(P(0,0));
	int res = 1;
	int di[] = {1, -1, 0, 0}, dj[] = {0, 0, 1, -1};
	while (!que.empty()){
		P a = que.front();
		que.pop();
		int i = a.first, j = a.second;
		REP(k,4){
			int ii = i+di[k], jj = j+dj[k];
			if (!isin(ii,jj) || p[ii][jj] != p[0][0] || c[ii][jj]) continue;
			c[ii][jj] = 1;
			res++;
			que.push(P(ii,jj));
		}
	}
	return res;
}

int dfs(VVI p, int t){
	VVI c(p);
	int res = count(p, c);
	if (t == 0) return res;
	if (t == 1){
		REP(i,h) REP(j,w) if (c[i][j]) p[i][j] = x;
		return dfs(p, 0);
	}
	FOR(k,1,6){
		VVI p_temp(p);
		REP(i,h) REP(j,w) if (c[i][j]) p_temp[i][j] = k;
		res = max(res, dfs(p_temp, t-1));
	}
	return res;
}


int main(){
	while (cin >> h >> w >> x && h){
		VVI p(h, VI(w));
		REP(i,h) REP(j,w) cin >> p[i][j];
		cout << dfs(p, 5) << endl;
	}
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;

    //cout << fixed << setprecision(6) << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18,MOD = 1000000007;

long long mod_pow(long long x, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

long long mod_inv(long long x)
{
	return mod_pow(x, MOD - 2);
}

//mod_inv(x)でxの逆元をとれる

signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	REP(i,N)cin>>a[i];
	vector<int>bit(60,0);
	REP(i,N){
		REP(j,60){
			if(a[i]&(1ll<<j))bit[j]++;
		}
	}
	int ans = 0;
	REP(i,N){
		REP(j,60){
			if(a[i]&(1ll<<j))bit[j]--;
			int t = bit[j];
			int f = N - i - 1 - bit[j];
			if(a[i]&(1ll<<j))ans += mod_pow(2,j)*f;
			else ans += mod_pow(2,j)*t;
			ans %= MOD;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560