akhauriyash/Code-Regression huggingface dataset:
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    int n,l;
    cin>>n>>l;
    vector <int> vec;
    int a[n];
    iter_(i,n)  cin>>a[i];

    iter_(i,n-1){
        if(a[i]+a[i+1]>=l){
            iter_(j,i)
                vec.push_back(j);
            for(int j=n-2;j>=i;j--)
                vec.push_back(j);
            break;
        }
    }
    if(vec.empty())
        cout<<"Impossible"<<endl;
    else{
        cout<<"Possible"<<endl;
        iter_(j,vec.size()){
            cout<<vec[j]+1<<endl;
        }
    }
}



Measured memory_bytes: 4228
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#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 int INF = 1001001001;

int main() {
  int N, M;
  cin >> N >> M;

  int ans = N*(N-1)/2 + M*(M-1)/2;
  cout<< ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=3e3+10,M=1e9+7;
string s1,s2;
int n1,n2;
int dp[mxN][mxN];
int solve(int a,int b){
    if(a==0 || b==0)return 0;
    if(dp[a][b]>=0)return dp[a][b];

    if(s1[a-1]==s2[b-1])return dp[a][b]=1+solve(a-1,b-1);
    return dp[a][b]=max(solve(a-1,b),solve(a,b-1));
}

// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>s1>>s2;
    n1=sz(s1);
    n2=sz(s2);
    solve(n1,n2);
    int idx=dp[n1][n2];
    //cout<<idx<<"\n";
    char ans[idx+1];
    ans[idx]='\0';
    
    int i=n1,j=n2;
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            ans[idx-1]=s1[i-1];
            i--;j--;idx--;
        }
        else if(dp[i-1][j]>dp[i][j-1])i--;
        else j--;
    }
    cout<<ans;
}

Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll S,W;
    cin >> S >> W;
    if (S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const ll N = 3e5 + 7;
long long n , m , a , cnt;
vector< string >v;
string z ="O";
int main() {
    cin >> n >> m;
    while( n > 0  )
        n-=m,cnt++;
    cout << cnt;
}


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

int main(int argc, char const *argv[])
{
	int r,g,b;
	cin >> r >> g >> b;
	int c,d;
	c = r * 100 + g*10 + b;
	d = c % 4;
	if (d == 0)
	{
		cout << "YES" << endl;
		/* code */
	}
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
def kth_smallest(a, k):
    accum = 0
    i = 0
    while accum < k:
        current = a[i][0]
        accum += a[i][1]
        i += 1
    return current


if __name__ == '__main__':
    n, k = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    a.sort()
    print(kth_smallest(a, k))

Measured memory_bytes: 27872
N = int(input())
lst = []
 
 
for i in range(N):
  lst.append(int(input()))
 
M = lst[1] - lst[0]
m = lst[0]
 
for j in range(1, N):
    M = max([M, lst[j] - m])
    m = min([m, lst[j]])
             
print(M)


Measured memory_bytes: 13592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

const ll MaxN=1e5+5;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll c[505],s[505],f[505];
ll ans[505];
ll t;

int main(){
	IOS();
	ll n;
	cin>>n;
	REP(i,n-1) cin>>c[i]>>s[i]>>f[i];
	for(int i=0;i<n-1;i++){
		t=0;
		for(int j=i;j<n-1;j++){
			if(t<s[j]) t=s[j];
			else if(t%f[j]==0);
			else t=t+f[j]-t%f[j];
			t+=c[j];
			debug(t,c[j],f[j]);
		}
		cout<<t<<endl;
	}
	cout<<0<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int masu[] = new int[N];
        for(int i = 0 ; i < N ; i++)
            masu[i] = sc.nextInt();
        int M = sc.nextInt();
        int move[] = new int[M];
        for(int i = 0 ; i < M ; i++)
            move[i] = sc.nextInt();
        for(int i = 0 ; i < M ; i++)
        {
            if(move[i] == N)
            {
                if(masu[move[i] - 1] < 2019)
                    masu[move[i] - 1]++;
            }
            else
            {
                if(masu[move[i] - 1] + 1 != masu[move[i]])
                    masu[move[i] - 1]++;
            }
        }
        for(int i = 0 ; i < N ; i++)
            System.out.println(masu[i]);
    }
}


Measured memory_bytes: 26616
#include <iostream>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <functional>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first 
#define  sec second
#define  inf 0x3f3f3f3f
#define  E 2.7182818284590452353602874713527
using namespace std;
 
 /**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
/********************************Head----Template**********************************************/
 
namespace  model{
    const int mod=2;
    ll ksm(ll a,ll b){
        int ans=1;a%=mod;
        while(b){
            if(b&1) ans=ans*a%mod;
            b>>=1;
            a=a*a%mod;
        }
        return ans;
    }
    const int maxn=1e5+7;
    ll fac[maxn+10],inv_fac[maxn+10];
 
    void init(){
        fac[0]=1;
        for(int i=1;i<=maxn;i++) fac[i]=(fac[i-1]*i)%mod;
        inv_fac[maxn]=ksm(fac[maxn],mod-2);
        for(int i=maxn-1;i>=0;i--) inv_fac[i]=(inv_fac[i+1]*(i+1))%mod;
    }
 
    ll C(int n,int m){
        if(n < 0 || m < 0 || m > n) return 0;
        if(m == 0 || m == n) return 1;
        return fac[n]*inv_fac[n-m]%mod*inv_fac[m]%mod;
    }
}

 
int main (){
    int n,m,l,r;
	cin>>n>>m>>l>>r;
	cout<<n*m-(l*m+n*r-l*r)<<endl;	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	while(1){
		int d,w;
		cin >> d >> w;
		if( d == 0 ) break;
		int e[10][10];
		rep(i,0,d) rep(j,0,w) cin >> e[i][j];

		ll ans = 0;
		for(int s_d = 0 ; s_d < d ; s_d++ ){
			for(int s_w = 0 ; s_w < w ; s_w++ ){
				for(int g_d = s_d+2 ; g_d < d; g_d++ ){
					for(int g_w = s_w+2 ; g_w < w ; g_w++){
						int min_h = INF;

						for(int j = s_w ; j <= g_w ; j++ ){
							min_h = min(e[s_d][j] , min_h );
							min_h = min(e[g_d][j] , min_h );
						}


						for(int i = s_d ; i <= g_d ; i++ ){
							min_h = min(e[i][s_w] , min_h );
							min_h = min(e[i][g_w] , min_h );
						}

						bool f = 0;
						ll sum = 0;
						for(int i = s_d+1; i <= g_d-1 ; i++ ){
							for( int j = s_w+1 ; j <= g_w-1 ; j++ ){
								if( e[i][j] >= min_h ) f = 1;
								sum += min_h - e[i][j];
							}
						}

						//cout << s_d << " " << s_w << " " << g_d << " " << g_w << " " << min_h << " " << sum << endl;
						if( f ) continue;

						ans = max( ans , sum );
					}
				}
			}
		}
		cout << ans << endl;
	}
	ret 0;
}


Measured memory_bytes: 3064
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

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

	const int k0 = K;
	while (K <= B) {
		if (K >= A) {
			COL("OK");
			return 0;
		}
		K += k0;
	}

	COL("NG");
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

//int is_war(int vedtor)
int main(void){
    // Your code here!
    int n,m,i,a,b;
    scanf("%d %d ",&n,&m);
    int x[n+1],y[m+1];
    scanf("%d %d\n",&x[n],&y[m]);
    a=x[n],b=y[m];
    
    for(i=0; i<n; i++){
        scanf("%d ",&x[i]);
        a>x[i]? (a=a):(a=x[i]);
    }
    
    for(i=0; i<m; i++){
        scanf("%d ",&y[i]);
        b<y[i]? (b=b):(b=y[i]);
    }
    
    a>=b? printf("War\n"):printf("No War\n");
}



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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] A, B, C;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        A = cin.ArrayInt(N);
        B = cin.ArrayInt(N);
        C = cin.ArrayInt(N);
        Array.Sort(A);
        Array.Sort(B);
        Array.Sort(C);
    }
    static void solve()
    {
        input();
        int[] dpA = new int[N];
        int r = 0;
        for(int i = 0; i < N; i++)
        {
            while (r < N && A[i] >= B[r])
                r++;
            dpA[i] = r;
        }

        long[] dpB = new long[N];
        r = 0;
        for(int i = 0; i < N; i++)
        {
            while (r < N && B[i] >= C[r])
                r++;
            dpB[i] = N - r;                 
        }

        for (int i = N - 2; i >= 0; i--)
            if(dpB[i] > 0)
                dpB[i] += dpB[i + 1];


        long ans = 0;
        for(int i = 0; i < N; i++)
            if(dpA[i] < N)
                ans += dpB[dpA[i]];
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 42428
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
int inf=1e18+7;
class Edge{
public:
//int s;
int t;
long long len;
long long fee;
};
class Node{
    public:
    int no;//node番号
    long long dist;//startからの距離
    long long money;
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    int C;int D;
    void in_edge(int in_t,int in_len,int in_fee){
        Edge in;in.t=in_t;in.len=in_len;in.fee=in_fee;
        edge.push_back(in);
    }
    void build(int i,int s){
        no=i;dist=inf;comp=true;money=s;
    }
};
bool operator >(const Node& a,const Node &r){
        return a.dist > r.dist;
    }
void dijkstra(vector<vector<Node>> &node,int s,int S,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    rep(i,n+1){
        rep(j,5001){
            node[i][j].build(i,j);
        }
    }
    node[s][S].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s][S]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.no;
        int l=buf.money;
        if(node[k][l].comp){
            node[k][l].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k][l].edge[i].t;
                int buf_len=node[k][l].edge[i].len;
                int buf_fee=node[k][l].edge[i].fee;
                if(l<buf_fee)continue;
                if(node[buf_t][l-buf_fee].dist>node[k][l].dist+buf_len){
                node[buf_t][l-buf_fee].dist=node[k][l].dist+buf_len;
                que.push(node[buf_t][l-buf_fee]);
                }
            }
            if(l+buf.C<5001){
                if(node[buf.no][l+buf.C].dist>buf.dist+buf.D){
                    node[buf.no][l+buf.C].dist=node[k][l].dist+buf.D;
                    que.push(node[buf.no][l+buf.C]);
                }
            }
        }
    }
}
signed main(){
    int n,m,s;cin>>n>>m>>s;
    if(s>5000)s=5000;
    vector<vector<Node>> node(n+1,vector<Node>(5001));
    rep(i,n+1){
        rep(j,5001){
            node[i][j].build(i,j);
        }
    }
    rep(i,m){
        int u,v,a,b;cin>>u>>v>>a>>b;
        rep(j,5001){
            node[u][j].in_edge(v,b,a);
            node[v][j].in_edge(u,b,a);
        }
    }
    rep1(i,n){
        int c,d;cin>>c>>d;
        rep(j,5001){
            node[i][j].C=c;
            node[i][j].D=d;
        }
    }
    dijkstra(node,1,s,n);
    for(int i=2;i<=n;i++){
        int res=inf;
        rep(j,5001){
            if(node[i][j].dist<res){
                res=node[i][j].dist;
            }
        }
        cout<<res<<"\n";
    }
    return 0;
}

Measured memory_bytes: 88016
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

ll n;

int main() {
    FASTIO;
    cin >> n;
    vector<ll> A(n), sum;
    for(auto& a : A) cin >> a;
    sort(ALL(A));

    sum = A;
    rep(i, n - 1) sum[i + 1] += sum[i];

    ll cnt = 0;
    for(int i = n - 1; i > 0; --i) {
        if(A[i] <= sum[i - 1] * 2) {
            ++cnt;
        }
        else break;
    }

    OUT(cnt + 1);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <utility>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

stack<int> S1;
stack<pair<int, int>> S2;
int k = 0;
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '\\') {
            S1.push(i);
        } else if (s[i] == '/' && !S1.empty()) {
            int j = S1.top(); S1.pop();
            pair<int, int> newPair = make_pair(j, i-j);
            while (!S2.empty() && S2.top().first > j) 
            {
                newPair.second += S2.top().second;
                S2.pop();
            }
            S2.push(newPair);
        }
    }

    vector<int> v;
    while(!S2.empty()) {
        v.push_back(S2.top().second);
        S2.pop();
    }
    reverse(v.begin(), v.end());
    printf("%d\n", accumulate(v.begin(), v.end(), 0));
    printf("%d", v.size());
    for (int i = 0; i < v.size(); i++) printf(" %d", v[i]);
    printf("\n");
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	string s,t;
	cin>>s>>t;
	bool ret=false;
	int idx=-1;
	rep(i,s.size()-t.size()+1){
		bool flag=true;
		rep(j,t.size()){
			if(s[i+j]=='?' || s[i+j]==t[j]) continue;
			flag=false;
			break;
		}
		if(flag) ret=true,idx=i;
	}
	if(!ret){
		cout << "UNRESTORABLE" << endl;
    	return 0;
	}
	rep(i,t.size()){
		if(s[i+idx]=='?') s[i+idx]=t[i];
	}
	rep(i,s.size()){
		if(s[i]=='?') s[i]='a';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x)
{
  S[++top] = x;
}
int pop()
{
  top--;
  return S[top + 1];
}

int main(){
  int a,b;
  char s[100];
  top = 0;

  while(scanf("%s", s) != EOF)
    {
      if(s[0] == '+')
	{
	  a = pop();
	  b = pop();
	  push(a + b);
	}
      else if(s[0] == '-')
	{
	  b = pop();
	  a = pop();
	  push(a - b);
	}
      else if(s[0] == '*')
	{
	  a = pop();
	  b = pop();
	  push(a * b);
	}
      else {
	push(atoi(s));
      }
    }

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

  return 0;
}



  



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int n, ans = 0, t = 0, A, x = 1000, o = 0;
	
	cin>>n;
	
	rep(i,n){
		cin>>A;
		ans += A;
		if(A%2==1){
			x = min(x,A);
		}
	}
	if(ans%2==1) ans -= x;
	
	cout<<ans/2<<endl;
	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m, n | m) {
        vector<P> v(n);
        rep(i, n) cin >> v[i].se >> v[i].fi;
        sort(v.rbegin(), v.rend());

        int p = 0;
        rep(i, n) {
            if (v[i].se <= m) {
                m -= v[i].se;
            } else {
                v[i].se -= m;
                m = 0;
                p += v[i].se * v[i].fi;
            }
        }

        cout << p << endl;
    }

    return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

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

    N %= 500;
    if (N <= A)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
    }

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    if s[2]==s[3] and s[4]==s[5]:print("Yes")
    else:print("No")

main()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader stdReader = 
                    new BufferedReader( new InputStreamReader(System.in));
            String sStr = stdReader.readLine();

            String[] inputStr = sStr.split(" ");
            int input1 = Integer.valueOf(inputStr[0]).intValue();
            int input2 = Integer.valueOf(inputStr[1]).intValue();
            int input3 = Integer.valueOf(inputStr[2]).intValue();

            int[] unsortedInt = {input1, input2, input3};
            Arrays.sort(unsortedInt);
            
            StringBuilder sb = new StringBuilder();
            for(int i: unsortedInt) {
                sb.append(" ");
                sb.append(i);
            }
            sb.deleteCharAt(0);
            System.out.println(sb.toString());

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } 
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  for(int i = 0;i < n;i++){
    ll l = -1 * d * i + c * (n - i - 1);
    ll r = -1 * c * i + d * (n - i - 1);
    if(l <= b - a && b - a <= r){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

int main ()
{
    int e, dp[1000001];
    for (int i = 0; i < 1000001; i++) {
        dp[i] = i;
    }

    for (int i = 0; i < 101; i++) {
        dp[i * i * i] = min(i, dp[i * i * i]);
        for (int j = 0; i * i * i + j * j < 1000001 && j < 1001; j++) {
            dp[j * j] = min(j, dp[j * j]);
            dp[i * i * i + j * j] = min(i + j, dp[i * i * i + j * j]);
        }
    }

    for (int i = 1; i < 1000001; i++) {
        dp[i] = min(dp[i-1] + 1, dp[i]);
    }

    while (cin >> e, e) {
        cout << dp[e] << endl;
    }

    return 0;
}

Measured memory_bytes: 5064
def examA():
    A = LI()
    ans = max(A)-min(A)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38384
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int h, w; cin >> h >> w;

	vector<string> grid(h);
	rep(i, h){
		cin >> grid[i];
	}
	bool ans = false;
	rep(bit, 1 << h+w-2){
		vector<string> my_grid(h);
		rep(i, h){
			rep(j, w){
				my_grid[i].push_back('.');
			}
		}
		int x=0, y=0;
		my_grid[y][x] = '#';
		if(__builtin_popcount(bit) != h-1) continue;
		rep(i, h+w-2){
			if(bit >> i & 1){
				y++;
			}
			else{
				x++;
			}
			my_grid[y][x] = '#';
		}
		bool ok = true;
		rep(i, h){
			// print(my_grid[i]);
			rep(j, w){
				if(grid[i][j] == '#' && my_grid[i][j] != '#'){
					ok = false;
				}
			}
		}
		// cout << endl;
		if(ok) ans = ok;
	}

	if(ans){
		cout << "Possible" << endl;
	}
	else{
		cout << "Impossible" << endl;
	}
	return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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(void) {
    int a, b, c;
    cin >> a >> b >> c;

    int g = gcd(a, b);
    if(c%g==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){

  int sum=0;
  int tmp;
  char tmp1;
  cin>>tmp;
  sum=tmp;
  while(cin>>tmp1,tmp1!='='){
    cin>>tmp;
    if(tmp1=='+')sum+=tmp;
    if(tmp1=='-')sum-=tmp;
    if(tmp1=='/')sum/=tmp;
    if(tmp1=='*')sum*=tmp;
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 1160
#include <stdio.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define rrep(i, n) for (i = n - 1; i >= 0; i--)
#define int long long

signed main() {
	int n;
	scanf("%lld", &n);
	int i;
	static int a[100000], b[100000];
	rep(i, n) scanf("%lld %lld", &a[i], &b[i]);

	int t, ans = 0;
	rrep(i, n) {
		if ((a[i] + ans) % b[i]) {
			t = b[i] - ((a[i] + ans) % b[i]);
			ans += t;
		}
	}

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

Measured memory_bytes: 1664
W, H, N = map(int, raw_input().split())
x = []
y = []
a = []
for i in xrange(N):
    mem = map(int, raw_input().split())
    x.append(mem[0])
    y.append(mem[1])
    a.append(mem[2])

t, b, r, l = H, 0, W, 0

for (xi, yi, ai) in zip(x, y, a):
    if ai == 1:
        l = (l < xi) and xi or l
    elif ai == 2:
        r = (xi < r) and xi or r
    elif ai == 3:
        b = (b < yi) and yi or b
    elif ai == 4:
        t = (yi < t) and yi or t
        
h = (r > l) and r - l or 0
v = (t > b) and t - b or 0
print h * v
    


Measured memory_bytes: 2696
s = list(input())
cnt = 0
while(1):
    tmp = 0
    for i in range(1,len(s)-1):
        if s[i-1] != s[i+1]:
            cnt += 1
            tmp = 1
            s.pop(i)
            break
    if tmp == 0:
        break

if cnt % 2 == 0:
    print("Second")
else:
    print("First")

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

int main(){
	int N;
	cin >> N;
	
	int L[N], i;
	for(i=0; i<N; i++){
		cin >> L[i];
	}
	
	int max=0, sum=0;
	for(i=0; i<N; i++){
		sum += L[i];
		if(L[i]>max)	max = L[i];
	}
	
	if(sum-max > max)	cout << "Yes" << endl;
	else			cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

constexpr int MAX_N = 100100;

using namespace std;

int n;
char arr[MAX_N];

char opt[4][MAX_N];

int main() {
    scanf(" %d", &n);
    for (int i = 0; i < n; i++) {
        scanf(" %c", &arr[i]);
    }

    opt[0][0] = 'S';
    opt[0][1] = 'S';
    opt[1][0] = 'S';
    opt[1][1] = 'W';
    opt[2][0] = 'W';
    opt[2][1] = 'S';
    opt[3][0] = 'W';
    opt[3][1] = 'W';

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            if (opt[j][i] == 'S' && opt[j][i + 1] == 'S') {
                if (arr[i] == 'o') {
                    opt[j][i + 2] = 'S';
                } else {
                    opt[j][i + 2] = 'W';
                }
            } else if (opt[j][i] == 'S' && opt[j][i + 1] == 'W') {
                if (arr[i] == 'o') {
                    opt[j][i + 2] = 'W';
                } else {
                    opt[j][i + 2] = 'S';
                }
            } else if (opt[j][i] == 'W' && opt[j][i + 1] == 'S') {
                if (arr[i] == 'o') {
                    opt[j][i + 2] = 'W';
                } else {
                    opt[j][i + 2] = 'S';
                }
            } else {
                if (arr[i] == 'o') {
                    opt[j][i + 2] = 'S';
                } else {
                    opt[j][i + 2] = 'W';
                }
            }
        }
    }

    int which = -1;

    for (int i = 0; i < 4; i++) {
        if (opt[i][0] == opt[i][n] && opt[i][1] == opt[i][n + 1]) {
            which = i;
            break;
        }
    }

    if (which == -1) {
        printf("-1\n");
    } else {
        for (int i = 1; i <= n; i++) {
            printf("%c", opt[which][i]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mz make_ZT
#define fi fisrt
#define se second

using namespace std;

const int N=3e5+5;
const int M=3e5+1;

int h,w,m,aa,ab,ans;
int p[N],q[N];
map <long long,int> mp;
signed main()
{
	cin>>h>>w>>m;
	for (int i=h;i>=1;i--) p[i]=i;
	for (int j=w;j>=1;j--) q[j]=j;
	for (int i=1;i<=m;i++)
	{
		cin>>aa>>ab;
		mp[aa*M+ab]++;
		p[aa]+=M;
		q[ab]+=M;
	}
	sort(p+1,p+h+1);
	sort(q+1,q+w+1);
	for (int i=h;i>=1;i--) 
	{
		for (int j=w;j>=1;j--) 
		{
			if (mp[(p[i]%M)*M+q[j]%M]==0) {cout<<p[i]/M+q[j]/M<<endl;return 0;}
			else ans=p[i]/M+q[j]/M-1;
			if (q[j]/M>q[j-1]/M) break;
		}
		if (p[i]/M>p[i-1]/M) break;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 27044
//?????´???????????????????°???????????????´????????¬??\????????¨??????????????????
#include<stdio.h>
#include<limits.h>

void swap(int *a, int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
	return;
}

void show(int A[], int n){
	int i;
	for( i = 0; i < n; i++ ){ printf("%5d", A[i]); }
	printf("\n");
	return;
}

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	int i, j, k;
	for( i = 0; i < n1; i++ ){ L[i] = A[left+i]; }
	for( i = 0; i < n2; i++ ){ R[i] = A[mid+i]; }
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	for( k = left; k < right; k++ ){
		if( L[i] <= R[j] ){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
	return;
}

void mergeSort(int A[], int left, int right){
	if( left+1 <  right ){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
	return;
}

int minimumCostSort(int A[], int sorted[], int n){
	int i, j;
	int min, minj, target, targetj;
	int cost = 0, addCost = 0;
	int swaptimes = 0;
	for( i = 0; i < n; i++ ){
		min = sorted[i];
		//sorted???i?????????????´????A??????????????????(minj)????????????
		for( j = 0; j < n; j++ ){
			if( A[j] == min ){
				minj = j;
				break;
			}
		}
		addCost = 0;
		while( minj != i ){
			target = sorted[minj];
			for( j = 0; j < n; j++ ){
				if( A[j] == target ){
					targetj = j;
					break;
				}
			}
			cost += A[minj] + A[targetj];
			swap(&A[minj], &A[targetj]);
			swaptimes++;
			minj = targetj;
			//show(A, n);
		}
		//????°???????????????£??????????????£????????????????????????????????????????????????????????????????????§?????????????????§?????????
		if( 2 * (sorted[i]+sorted[0]) + swaptimes * sorted[0] < swaptimes * sorted[i] ){
			cost += 2 * (sorted[i]+sorted[0]) + swaptimes * sorted[0] - swaptimes * sorted[i];
		}
		swaptimes = 0;
	}
	return cost;
}

int main(){
	int n, i;
	int w[1000], sorted[1000];
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d", &w[i]);
		sorted[i] = w[i];
	}
	mergeSort(sorted, 0, n);
	//show(w, n);
	//show(sorted, n);
	printf("%d\n", minimumCostSort(w, sorted, n));
	return 0;
}

Measured memory_bytes: 608
/*
ID:xmydada1
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N],b[N],m,n,ans=0,ans1=0,ans2=0,p,c=0,x;
#define reg register
inline int read() {
	reg int s = 0, t = 0;
	reg char ch = getchar();
	while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
	while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
	return t ? -s : s;
}

inline void print(reg long long x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
}
int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(reg int i=1; i<=n; i++) {
		a[i]=read();
	
	}
	while(1) {
			for(reg int i=1; i<=n; i++) {
		if(a[i]%2==1)ans++;
		else ans1++;
		if(a[i]==1)ans2++;
	}
		if(ans2==1&ans1==n-ans2) {
			if(ans1%2==0)c^=1;
			break;
		} else if(ans1%2==1)break;
		else if(ans>1&&ans1%2==0) {
			c=c^1;break;
		}
		else 
		{
			for(int i=1;i<=n;i++)
			if(a[i]%2==1)a[i]--;
			x=a[1];
			for(int i=2;i<=n;i++)
			x=__gcd(x,a[i]);
			for(int i=1;i<=n;i++)
			a[i]/=x;
			c^=1;
		}
		ans=0;ans1=0;ans2=0;

	}
    if(c==0)printf("First\n");
    else printf("Second\n");
	return 0;
}


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

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

  int ans = 0, mi = 1e9;

  for (int i = L; i < L + N; i++) {
    ans += i;
    if (abs(i) < abs(mi)) mi = i;
  }

  cout << ans - mi << "\n";
}

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

int main() {
    map<int, int> m;
    int a, b, c; cin >> a >> b >> c;
    m[a]++;
    m[b]++;
    m[c]++;
    if (m[5] == 2 && m[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll x;
    cin >> x;

    int res = 0;

    for (ll a = -500; a <= 500; a++)
    {
        for (ll b = -500; b <= 500; b++)
        {
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++)
    {
        if (ch == '\\')
        {
            S1.push(i);
        }
        else if (ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            int a = i - j;
            sum += a;

            while (S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }
    vector<int> ans;
    while (S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++)
    {
        cout << " ";
        cout << ans.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3184
#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 main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    rep(i, n)
    {
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> dpb(n + 10);
    rep(i,n){
        dpb[i] = c.end()-upper_bound(c.begin(),c.end(),b[i]);
    }
    for(int i = n-2;i>=0;i--){
        dpb[i]+=dpb[i+1];
    }
    ll ans = 0;
    rep(i,n){
        ans+=dpb[upper_bound(b.begin(),b.end(),a[i]) - b.begin()];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[111][111];
signed main(){
  int n;
  cin>>n;
  int r[n],c[n];
  for(int i=0;i<n;i++) cin>>r[i]>>c[i];
  int INF=1LL<<55LL;
  for(int i=0;i<111;i++) fill_n(dp[i],111,INF);
  for(int i=0;i<n;i++) dp[i][i+1]=0;
  for(int i=2;i<=n;i++)
    for(int j=0;j<=n-i;j++)
      for(int k=1;k<i;k++)
	dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k][j+i]+(r[j]*r[j+k]*c[j+i-1]));
  cout<<dp[0][n]<<endl;
  return 0;
}

Measured memory_bytes: 3216
MOD = 10**9 + 7
FACT = []
INV = []
def conv(s,t)
  (FACT[s] * INV[s-t] % MOD) * INV[t] % MOD
end
def calc_fact(n)
  FACT[0] = 1
  INV[0] = pow(FACT[0], MOD-2)
  for i in 1..n
    FACT[i] = FACT[i-1] * i % MOD
    INV[i] = pow(FACT[i], MOD-2)
  end
end
def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end

n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
calc_fact(n)
a.sort!
min_sum = 0
max_sum = 0
for i in 0..n-k
  min_sum += a[i] * conv(n-(i+1),k-1)
  max_sum += a[n-1-i] * conv(n-(i+1),k-1)
  min_sum %= MOD
  max_sum %= MOD
end
ans = max_sum - min_sum
ans %= MOD
puts ans

Measured memory_bytes: 14104
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    vl six;
    vl nine;
    vl dp(n+1);
    rep(i,n+1){
        dp[i] = i;
    }
    ll tmp = 6;
    while(tmp <= n) {
        six.push_back(tmp);
        tmp *= 6;
    }
    tmp = 9;
    while(tmp <= n){
        nine.push_back(tmp);
        tmp *= 9;
    }
    REP(i,1,n+1){
        rep(j,six.size()){
            if(i-six[j]>=0) dp[i] = min(dp[i],dp[i-six[j]]+1);
        }
    }
    REP(i,1,n+1){
        rep(j,nine.size()){
            if(i-nine[j]>=0) dp[i] = min(dp[i],dp[i-nine[j]]+1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x*a[i])//gcd(x, a[i])
    return x


n = int(input())
a = list(map(int, input().split()))

A = lcm(a);
ans = 0

for i in a:
    ans+=A//i

print(ans%(10**9+7))


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int x, a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> x >> a >> b;
	cout << (abs(x-a) < abs(x-b) ? "A" : "B") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char
to_grade(int m, int f, int r)
{
	if (m == -1 || f == -1)        return 'F';
	else if (m+f >= 80)            return 'A';
	else if (m+f >= 65)            return 'B';
	else if (m+f >= 50)            return 'C';
	else if (m+f >= 30 && r >= 50) return 'C';
	else if (m+f >= 30)            return 'D';
	else                           return 'F';
}

int
main()
{
	for (;;)
	{
		int m, f, r;
		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 & r == -1)
			break;

		char glade = to_grade(m, f, r);
		printf("%c\n", glade);
	}
	
	return 0;
}

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

int main(){
    vector<int> v(3);
    for(int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0]-v[2] << endl;

    return 0;
}

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

int InsertionSort(vector<int>& a,int d)
{
    int N=a.size(),res=0;
    for(int i=d;i<N;i++){
        int j=i,val=a[i];
        while(j-d>=0 and a[j-d]>val) a[j]=a[j-d],j-=d,res++;
        a[j]=val;
    }
    return res;
}

void ShellSort(vector<int>& a)
{
    int N=a.size();

    vector<int> diff={1};
    for(int i=1;;i++){
        int d=(pow(3,i+1)-1)/2;
        if(d<N) diff.push_back(d);
        else break;
    }
    reverse(diff.begin(),diff.end());

    int cnt=0;
    for(int d:diff) cnt+=InsertionSort(a,d);

    cout<<diff.size()<<endl;
    for(int d:diff) cout<<d<<' '; cout<<endl;
    cout<<cnt<<endl;
}

int main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    ShellSort(a);
    for(int i=0;i<N;i++) cout<<a[i]<<' '; cout<<endl;
    return 0;
}


Measured memory_bytes: 6704