akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int a;
  cin>>a;

  cout<<(a+pow(a,2)+pow(a,3))<<endl;
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll Q;
    cin >> Q;

    map<string, ll> mp;

    while(Q--){
        ll a;
        cin >> a;
        string key;

        if(a==0){
            cin >> key;
            // insert
            ll x; cin >> x;
            mp[key] = x;
        }
        else if(a==1){
            cin >> key;
            // get
            if(mp.count(key)){
                p(mp[key]);
            }else{
                p(0);
            }
        }
        else if(a==2){
            cin >> key;
            // delete
            mp.erase(key);
        }
        else{
            // dump
            string L, R;
            cin >> L >> R;

            auto it = mp.lower_bound(L);
            auto end = mp.upper_bound(R);
            for(; it!=end; it++){
                p2((*it).first, (*it).second);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 27820
# -*- coding: utf-8 -*-

import itertools

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

trans = [a, b, c, d, e]
toshi = [n, 0, 0, 0 ,0, 0]
t = 0


t_min = min(trans)

t = n // t_min + 4
if n % t_min > 0:
    t +=1


print(int(t))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int n;

void koch(int n, double p1[], double p2[]) {
    if (n == 0)
        return;
    double s[2], t[2], u[2];
    s[0] = (p1[0] * 2 + p2[0] * 1) / 3;
    s[1] = (p1[1] * 2 + p2[1] * 1) / 3;
    t[0] = (p1[0] * 1 + p2[0] * 2) / 3;
    t[1] = (p1[1] * 1 + p2[1] * 2) / 3;
    u[0] = (t[0] - s[0]) * cos(M_PI / 3) - (t[1] - s[1]) * sin(M_PI / 3) + s[0];
    u[1] = (t[0] - s[0]) * sin(M_PI / 3) + (t[1] - s[1]) * cos(M_PI / 3) + s[1];

    koch(n - 1, p1, s);
    cout << s[0] << " " << s[1] << endl;
    koch(n - 1, s, u);
    cout << u[0] << " " << u[1] << endl;
    koch(n - 1, u, t);
    cout << t[0] << " " << t[1] << endl;
    koch(n - 1, t, p2);
}

int main() {
    cin >> n;
    double p1[2] = {0, 0}, p2[2] = {100, 0};
    cout << p1[0] << " " << p1[1] << endl;
    koch(n, p1, p2);
    cout << p2[0] << " " << p2[1] << endl;
}


Measured memory_bytes: 3244
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26188
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long,long long>& a,
         pair<long long,long long>& b)
{
    return a.second < b.second;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,ans;
    cin>>n;
    if(n%1000==0)
    {
        ans = 0;
    }
    else
    {
        int k = (n/1000)+1;
        ans = (k*1000)-n;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(){
  int i, j, k, u, v, n, A[100][100];
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++)
      A[i][j] = 0;
  }
  for(i = 0; i < n; i++){
    scanf("%d",&u);
    scanf("%d", &k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      A[u-1][v-1] = 1;
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j > 0) printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int func();
 
int main(){
    int dice[100][6];
    int n;
    int i,j;
    int flag=1;
     
    scanf("%d", &n);
    for(i=0;i<n;i++)for(j=0;j<6;j++)scanf("%d", &dice[i][j]);
 
    for(i=1;i<n;i++){
        flag = func(dice[0],dice[i]);
        if(flag){
            printf("No\n");
            return 0;
        }
    }
 
    printf("Yes\n");
    return 0;
}
 
int func(int a_dice[], int b_dice[]){
    int surface[24][3]={{1,2,3},{2,3,1},{3,1,2},
                        {1,3,5},{3,5,1},{5,1,3},
                        {1,5,4},{5,4,1},{4,1,5},
                        {1,4,2},{4,2,1},{2,1,4},
                        {6,2,4},{2,4,6},{4,6,2},
                        {6,4,5},{4,5,6},{5,6,4},
                        {6,5,3},{5,3,6},{3,6,5},
                        {6,3,2},{3,2,6},{2,6,3}};
    int i;
 
    for(i=0;i<24;i++){
        if((a_dice[surface[i][0]-1]==b_dice[0]) && (a_dice[surface[i][1]-1]==b_dice[1])  && (a_dice[surface[i][2]-1]==b_dice[2])){
            if((a_dice[6-surface[i][0]]==b_dice[5]) && (a_dice[6-surface[i][1]]==b_dice[4])  && (a_dice[6-surface[i][2]]==b_dice[3])){
                return 1;
            }
        }
    }
    return 0;
}


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

double f(double x){
  if(x < 0){x *= (-1);}
  return x;
}

int main(){
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> v1 (n+10);
  vector<int> vn (n+10);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    if(a == 1){v1[b] = 1;}
    if(b == 1){v1[a] = 1;}
    if(a == n){vn[b] = 1;}
    if(b == n){vn[a] = 1;}
  }
  bool f = true;
  
  for(int i = 0; i < n + 10; i++){
    if(v1[i] == vn[i] && v1[i] == 1){cout << "POSSIBLE" << endl; f = false; break;}
  }
  if(f){cout << "IMPOSSIBLE" << endl;}
}       

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	int N;
    int x,y,t;
    int px=0,py=0,pt=0;
    std::cin>>N;
    for(int l1=0;l1<N;l1++){
        int mintime;
        int xlong,ylong,tlong;
        scanf("%d%d%d",&t,&x,&y);
        xlong=px-x; if(xlong<0)xlong*=-1;
        ylong=py-y; if(ylong<0)ylong*=-1;
        tlong=t-pt;
        mintime=xlong+ylong;
        if(mintime==0){
            tlong--;
            mintime=1;
        }
        int amari=tlong-mintime;
        if(amari<0||(amari>0&&amari%2==1)){
            std::cout<<"No"<<std::endl;
            return 0;
        }
        px=x;py=y;pt=t;
    }
    std::cout<<"Yes"<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t N;
  cin>>N;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(N%1000==0)cout<<0<<endl;
  else cout << 1000-(N%1000) << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}


int main()
{	 
	int n, m, x, i;
	long long ans = 0;	
	
	n = read();
	m = read();
	for(i = 1; i < n; i++){
		x = read();
		if(x >= m) m = x;
		else ans += m - x;
	}
	printf("%lld\n", ans);
		
	return 0;
}

Measured memory_bytes: 1580
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/10 19:26:09 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int main()
{
    IOS;
	int n,a,b;
    char s[100010];
    cin>>n>>a>>b>>s;
    int ab=a+b;
    for (int j=0;j<n;++j)
    {
        if ((s[j]=='a'&&ab>0)||(s[j]=='b'&&b>0&&ab>0)) cout<<"Yes\n",--ab;
        else cout<<"No\n";
        if (s[j]=='b') --b;
    }
    cout<<flush;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int m;
  cin>>m;
  vector<int> B(m);
  cin>>B;

  int ans = A < B;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct FGC{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  typedef function<bool(T,T)> C;
  F &f;
  G &g;
  C &c;
  FGC(F &f,G &g,C &c):f(f),g(g),c(c){}
};
template<typename T, typename E>
struct SkewHeap{
  SkewHeap *l,*r;
  T val;
  E add,e;
  FGC<T, E> &fgc;
  
  SkewHeap(T val,E e,FGC<T,E> &fgc):
    val(val),add(e),e(e),fgc(fgc){l=r=NULL;}
  
  void eval(){
    if(add==e) return;
    if(l) l->add=fgc.g(l->add,add);
    if(r) r->add=fgc.g(r->add,add);
    val=fgc.f(val,add);
    add=e;
  }
  
  T top(){
    return fgc.f(val,add);
  }
  
};

template<typename T, typename E>
SkewHeap<T, E>* meld(SkewHeap<T, E> *a,SkewHeap<T, E> *b){
  if(!a) return b;
  if(!b) return a;
  if(a->fgc.c(a->top(),b->top()))  swap(a,b);
  a->eval();
  a->r=meld(a->r,b);
  swap(a->l,a->r);
  return a;
}

template<typename T, typename E>
SkewHeap<T, E>* pop(SkewHeap<T, E>* a){
  a->eval();
  auto res=meld(a->l,a->r);
  //free(a);
  return res;
};
//END CUT HERE

signed main(){
  using Heap = SkewHeap<int, int>;
  
  FGC<int, int>::F f=[](int a,int b){return a+b;};
  FGC<int, int>::G g=[](int a,int b){return a+b;};
  FGC<int, int>::C c=[](int a,int b){return a<b;};
  FGC<int, int> fgc(f,g,c);
  
  Heap* base = new Heap(0,0,fgc);
  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      base=meld(base, new Heap(x,0,fgc));
    }
    if(s=="extract"){
      x=base->top();
      base=pop(base);
      cout<<x<<endl;
    }
  }
  return 0;
}
/*
  verified on 2018/01/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C&lang=jp
*/



Measured memory_bytes: 73504
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll q;
    cin >> q;

    while(q--) {

        ll a, b;
        cin >> a >> b;

        if (a == b || a + 1 == b) {
            cout << 2 * a - 2 << endl;
        } else {
            ll p = a * b;
            ll res = sqrt(p);
            if(res * res == p)res--;
            if (res * (res + 1) >= p)cout << 2 * res - 2 << endl;
            else cout << 2 * res - 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
 
using namespace std;
 
int main()
{
	int_least32_t a, b;
	cin >> a >> b;
 
	if(a == 1) {
		a = 14;
	}
 
	if(b == 1) {
		b = 14;
	}
	
	if(a > b) {
		cout << "Alice" << endl;
	}
	else if(b > a) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl; 
	}
}

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

int main() {
  string s;
  cin>>s;
  sort(s.begin(), s.end());
  if (s[0] == 'a' && s[1] =='b' && s[2] == 'c') {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

ll const MAX_N = 1e5 + 10;
bool done[MAX_N];

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

vector<vll> E;
ll ans;

void func(ll f, ll u, ll p, ll K) {
	//ll p = 1;
	//for (ll q : E[f]) {
	//	if (done[q]) {
	//		p++;
	//	}
	//}
	ans = (ans * (K - p)) % MOD;
	done[u] = true;

	p = 2;
	for (ll v : E[u]) {
		if (!done[v]) {
			func(u, v, p, K);
			p++;
		}
	}
}

int main() {
	ll i, j;
	ll N, K;
	cin >> N >> K;
	if (N == 1) {
		cout << K << endl;
		return 0;
	}
	vll A, B;
	E.assign(N, vll());
	for (i = 0; i < N - 1; i++) {
		ll a, b;
		cin >> a >> b;
		A.push_back(a - 1);
		B.push_back(b - 1);
		E[a - 1].push_back(b - 1);
		E[b - 1].push_back(a - 1);
	}
	for (i = 0; i < MAX_N; i++) {
		done[i] = false;
	}

	ll s;
	for (i = 0; i < N; i++) {
		if (E[i].size() == 1) {
			s = i;
			break;
		}
	}

	ans = K;
	done[s] = true;
	func(s, E[s][0], 1, K);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12008
#include<cstdio>
inline int Min(int x,int y){return x<y?x:y;}
int n,a[100000];
int s[16],Ans,S;
int f[1<<16];
int main(){
	int x,y,z;
	scanf("%d",&n);
	for(int i=1;i<n;++i) scanf("%d%d%d",&x,&y,&z), a[x]^=z, a[y]^=z;
	for(int i=0;i<n;++i) if(a[i]) Ans+=s[a[i]], s[a[i]]^=1;
	for(int i=1;i<16;++i) S^=s[i]<<i;
	for(int l=1;l<=15;++l) for(int i=1;i<1<<16;++i) if(__builtin_popcount(i)==l&&(i&1)==0){
		f[i]=(-1u)>>1;
		for(int j=1;j<16;++j) if(i>>j&1)
			for(int k=j+1;k<16;++k) if(i>>k&1)
				f[i]=Min(f[i],f[i^(1<<j)^(1<<k)^(1<<(j^k))]+1+(i>>(j^k)&1));
	}
	printf("%d",Ans+f[S]);
	return 0;
}

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

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

	long long ret = 0;
	long long a = sqrt(n);
	for (long long i = 2; i < a; ++i) {
		long long count = 0;
		long long check = 1;
		long long check2 = 2;
		while (n % i == 0) {
			n /= i;
			++count;
			if (count == check) {
				++ret;
				check = check + check2++;
			}
		}
	}
	if (n != 1) {
		++ret;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
lint mod=998244353;
int main()
{
    
    int n,m;
    cin>>n>>m;
    if(n==0) cout<<m*(m-1)/2;
    else if (m==0) cout<<n*(n-1)/2;
    else 
    cout<<n*(n-1)/2+m*(m-1)/2;


}


Measured memory_bytes: 256
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

struct node{
	ll num,index;
}s[N],t[N];

int cmp(node a,node b)
{
	if(a.num == b.num)
		return a.index < b.index;
	return a.num < b.num;
}
ll vis[N];
int main()
{
	ll i,j,k,n,sum1 = 0,sum2 = 0;
	sl(n);
	for(i = 1;i <= n;i++)
		sl(s[i].num),sum1 += s[i].num;
	for(j = 1;j <= n;j++)
		sl(t[j].num),sum2 += t[j].num;
	if(sum1 < sum2)
	{
		return 0*puts("-1");
	}
	for(i = 1;i <= n;i++)
		vis[i] = s[i].num-t[i].num;

	sort(vis+1,vis+1+n);
	ll ans = 0,now = n,flag = 0;
	for(i = 1;i <= n;i++)
	{
		if(vis[i] < 0)
		{
			ans++;
			if(!flag)
				ans++,flag = 1;
			if(vis[now] >= abs(vis[i]))
				vis[now] += vis[i];
			else
			{
				ans++;
				ll temp = vis[i]+vis[now];
				now--;
				vis[now] += temp;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximumVolume solver = new CMaximumVolume();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximumVolume {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            double l = in.nextInt();
            out.println(l * l * l / 27);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll mr = n/2;
    ll ml = mr-1;
    vi x(n);
    vi y(n);
    rep(i, n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(all(y));
    mr = y[mr];
    ml = y[ml];

    rep(i, n){
        if(x[i] <= ml) cout << mr << endl;
        else cout << ml << endl;
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define vec(type) vector<type>

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

    sort(a.begin(), a.end());
    for (int i = 0; i < n-1; i++) {
        if (a[i] == a[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3944
using System;
//using System.Collections.Generic;
//using System.Linq;
//using Vector = CGL.Point;
//using Line = CGL.Segment;
//using Polygon = System.Collections.Generic.List<CGL.Point>;


namespace CGL
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = scan;
            var p1 = new Point(p[0], p[1]);
            var p2 = new Point(p[2], p[3]);
            var s = new Segment(p1, p2);
            var q = scan[0];
            for (int i = 0; i < q; i++)
            {
                p = scan;
                var P = new Point(p[0], p[1]);
                var Q = s.Reflection(P);
                Console.WriteLine(Q.x+" "+Q.y);
            }
        }
        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
    
    struct Point
    {
        static readonly double EPS = 1E-10;
        public double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public static Point operator +(Point a, Point b) { return new Point(a.x + b.x, a.y + b.y); }
        public static Point operator -(Point a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(double k, Point a) { return new Point(k * a.x, k * a.y); }
        public static Point operator /(double k, Point a) { return new Point(a.x / k, a.y / k); }
        
        public double Abs { get { return Math.Sqrt(Norm); } }  
        public double Norm { get { return x * x + y * y; } }

        public static bool operator <(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Point a, Point b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Point a, Point b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public override bool Equals(object p){  return Math.Abs(x - ((Point)p).x) < EPS && Math.Abs(y - ((Point)p).y) < EPS; }
        public override int GetHashCode(){ return x.GetHashCode() ^ y.GetHashCode(); }

        public double Dot(Point p) { return x * p.x + y * p.y; }
        public double Cross(Point p) { return x * p.y - y * p.x; }

    }
    struct Segment
    {
        public Point p1, p2;
        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
        public Point Projection(Point p)
        {
            Point b = p2 - p1;
            double r = b.Dot(p - p1) / b.Norm;
            return p1 + r * b;
        }
        public Point Reflection(Point p)
        {
            return p + 2 * (Projection(p) - p);
        }

    }
    /*struct Circle
    {
        public Point c; double r;
        public Circle(Point c, double r)
        {
            this.c = c;
            this.r = r;
        }

    }*/
}

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N;
	cin>>N;
	vector<ll> a(N);
	rep(i,N){
		cin>>a[i];
	}
	ll mx = -1e18;
	vector<int> ag;
	rep(t,2){
		vector<int> v;
		ll sm = 0;
		for(int i=t;i<N;i+=2){
			if(a[i]>=0){
				sm += a[i];
				v.pb(i);
			}
		}
		if(!v.empty() && mx<sm){
			mx = sm;
			ag = v;
		}
	}
	if(ag.empty()){
		int x = 0;
		rep(i,N) if(mx<a[i]){
			mx = a[i];
			x = i;
		}
		ag = {x};
	}
	cout<<mx<<endl;
	vector<int> op;
	int L = ag.front(), R = ag.back();
	rep(i,N-1-R) op.pb(N-1-i);
	rep(i,L) op.pb(0);
	for(int i=L+2;i<=R;i+=2){
		if(a[i]>=0) op.pb(1);
		else op.pb(2);
	}
	cout<<op.size()<<endl;
	for(int x: op) cout<<x+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, W; cin >> N >> W;
    vector<P> vw(N);
    rep(i, N) {
        cin >> vw[i].first >> vw[i].second;
    } 

    // i+1品使って、j重みまでで最大の
    vector<vector<int>> dp(N+1, vector<int>(W+1));
    repr(i, 1, N+1) {
        repr(j, 1, W+1) {
            if (j-vw[i-1].second >= 0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-vw[i-1].second] + vw[i-1].first);
                dp[i][j] = max(dp[i][j], dp[i][j-vw[i-1].second] + vw[i-1].first);
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    // rep(i, W+1) cout << dp[i] << " ";
    /*
    rep(i, N) {
        rep(j, W) {
            cout << dp[i+1][j+1] << " ";
        }
        cout << endl;
    }
    */
    // cout << endl;
    cout << dp[N][W] << endl;
    return 0;
}


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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long N;
  cin >> N;

  auto div = [&](long n) {
    vector<long> ret;
    for (long i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        ret.push_back(i);
        if (i * i != n) ret.push_back(n / i);
      }
    }
    sort(begin(ret), end(ret));
    return ret;
  };

  long ans = 0;
  for (auto a : div(N)) {
    --a;
    if (!a) continue;
    if (N / a == N % a) ans += a;
  }
  cout << ans << "\n";
}

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

int main()
{
    int n,ans=0;
    cin>>n;
    string str = to_string(n);
    int i=1;
    if (n<10) {cout<<n; return 0;}
    while(i*100<=n)
    {
        ans +=i*9;
        i*=100;
    }
    if(str.size()%2 == 1) ans+=n - i +1;
    else ans+= i*9;
    cout<<ans;
    return 0;
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


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

    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);

    ll co=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(abs(a.at(j)-a.at(k))<a.at(i)&&a.at(i)<a.at(j)+a.at(k)){
                    if(a.at(i)==a.at(j)||a.at(j)==a.at(k)||a.at(k)==a.at(i))continue;
                    co++;
                }
            }
        }
    }

    cout<<co<<endl;
}



Measured memory_bytes: 3632
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
#define mod (ll)(1e9+7)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll r,c,x,y;
    cin>>r>>c>>x>>y;
    cout<<(r*c)-((x*c)+(y*r)-(x*y));
    return 0;
}


Measured memory_bytes: 256
global nodes

class Node:
    def _init__(self):
        self.left = -1
        self.right = -1
    def set(self,arg_node_left,arg_node_right):
        self.left =arg_node_left
        self.right =arg_node_right
    
def Preorder(node_id):
    print(" %d"%(node_id),end="")
    if nodes[node_id].left != -1:
        Preorder(nodes[node_id].left)
    if nodes[node_id].right != -1:
        Preorder(nodes[node_id].right)

def Inorder(node_id):
    if nodes[node_id].left != -1:
        Inorder(nodes[node_id].left)
    print(" %d"%(node_id),end="")
    if nodes[node_id].right != -1:
        Inorder(nodes[node_id].right)

def Postorder(node_id):
    if nodes[node_id].left != -1:
        Postorder(nodes[node_id].left)
    if nodes[node_id].right != -1:
        Postorder(nodes[node_id].right)
    print(" %d"%(node_id),end="")

V = int(input())
nodes = [Node() for _ in range(V)]
in_num = [0]*V
for loop in range(V):
    node_id,left,right = map(int,input().split())
    nodes[node_id].set(left,right)
    if left != -1:
        in_num[left] += 1
    if right != -1:
        in_num[right] += 1

root = -1 #rootを探す
for i in range(V): 
    if in_num[i] == 0:
        root = i
        break

print("Preorder")
Preorder(root)
print()

print('Inorder')
Inorder(root)
print()

print('Postorder')
Postorder(root)
print()


Measured memory_bytes: 5616
#<D>
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for n in range(N)], key = lambda x: x[0])
#print(X)
hq = []
ans, j = 0, 0

for i in range(1, M + 1): #M - i日後にするバイトを決める
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1]) # 候補の追加
        j += 1
    if len(hq):
        ans += - heappop(hq) #候補があるなら候補から最大値を取り出す
print(ans)
    

Measured memory_bytes: 30924
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final double a = scanner.nextDouble();
        final double b = scanner.nextDouble();
        final double x = scanner.nextDouble();

        if (x >= a * a * b / 2) {
            final double y = 2 * (a * a * b - x) / (a * a);

            final double rad = Math.atan2(y, a);
            final double degree = Math.toDegrees(rad);

            System.out.println(degree);
        } else {
            final double y = 2 * x / (a * b);
            final double rad = Math.atan2(b, y);
            final double degree = Math.toDegrees(rad);

            System.out.println(degree);
        }
    }
}


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

typedef pair<double,double> P;

P solve(double a, double b, double p, double c, double d, double q){
  P res;
  double tmp = a * d - b * c;
  res.first = (p * d - b * q) / tmp;
  res.second = (a * q - p * c) / tmp;
  return res;
}

double myRound(double x){
  int y = (int)round(x * 1000);
  return y / 1000.0;
}

int main(){
  double a, b, p, c, d, q;

  while(cin >> a >> b >> p >> c >> d >> q){
    double tmp = a * d - b * c;
    double x = (d * p - b * q) / tmp;
    double y = (a * q - c * p) / tmp;

    printf("%.3f %.3f\n", myRound(x), myRound(y));
  }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
    using namespace std; 
    typedef long long int ll; 
     
    int main() {
       ll N; 
       cin >> N;
       ll A[N],B[N]; 
       ll S=0; 
       for(int i=0; i<N; i++){
           cin>> A[i]; 
           S+= A[i]; 
       }
       ll T=0;  
       for(int j=0; 2*j<=N-3; j++){
         T = T + A[2*j]; 
       }
       B[N-1] = S - 2*T;
      for(int j=N-2; j>=0; j--){
        B[j] = 2*A[j] - B[j+1];
      }
       
      for(int j=0; j<=N-1; j++){
       cout<< B[j] << " "; 
      }
                }

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
//最大公約数
long long GCD(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(GCD(b, a%b));
   }
}
int main(){
  long long N,X;
  cin >> N >> X;
  if(N == 1){
    long long a;
    cin >> a;
    cout << abs(a-X) << endl;
    return 0;
  }
  vector<long long>vec(N+1);
  vec[N] = X;
  for(long long i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  long long gccd = GCD(vec[2]-vec[1],vec[1]-vec[0]);
  for(long long i=0; i<N; i++){
    gccd = GCD(gccd,vec[i+1]-vec[i]);
  }
  cout << gccd << endl;
}
  


Measured memory_bytes: 3984
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string A,B,C;
	cin>>A>>B>>C;
	
	int a=0,b=0,c=0;
	char turn='a';
	char ans;
	bool series=true;
	while(series){
		switch(turn){
			case 'a':
			if(a==A.size()){
				ans='A';
				series=false;
			}else{
				turn=A.at(a);
				a++;
			}
			break;
			case 'b':
			if(b==B.size()){
				ans='B';
				series=false;
			}else{
				turn=B.at(b);
				b++;
			}
			break;
			case 'c':
			if(c==C.size()){
				ans='C';
				series=false;
			}else{
				turn=C.at(c);
				c++;
			}
			break;
			
		}
		
	}
	ce(ans)
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define re(i,n) for(int i=1;i<=n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to; int cost; };
int dp1[200005],dp2[200005];
signed main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	s.push_back('#');
	dp1[a - 1] = 1;
	rep(i, n) {
		if (i + 1<n&&s[i + 1] == '.') {
			dp1[i + 1] += dp1[i];
			dp1[i + 1] %= mod;
		}
		if (i + 2<n&&s[i + 2] == '.') {
			dp1[i + 2] += dp1[i];
			dp1[i + 2] %= mod;
		}
	}
	dp2[b - 1] = 1;
	rep(i, n) {
		if (i + 1<n&&s[i + 1] == '.') {
			dp2[i + 1] += dp2[i];
			dp2[i + 1] %= mod;
		}
		if (i + 2<n&&s[i + 2] == '.') {
			dp2[i + 2] += dp2[i];
			dp2[i + 2] %= mod;
		}
	}
	if (c < d) {
		if (dp1[c - 1] && dp2[d - 1])puts("Yes");
		else puts("No");
	}
	else {
		int flg = 0;
		for (int i = b - 2; i < d-1; i++) {
			if (s[i] == '.'&&s[i + 1] == '.'&&s[i + 2] == '.')flg++;
		}
		if (dp1[c - 1] && dp2[d - 1] && flg)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 3588
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

void print(Vec v){
	for(ll i : v){
		if(i) cout << 'S';
		else cout << 'W';
	}
	cout << endl;
}

bool check(ll t, Vec v, string s){
	ll n = v.size();
	ll f = t+1, b = t-1;
	f += n; f %= n;
	b += n; b %= n;

	if(v[t] == 1){
		if(s[t] == 'o' && v[f] == v[b]) return true;
		if(s[t] == 'x' && v[f] != v[b]) return true;
	}else{
		if(s[t] == 'o' && v[f] != v[b]) return true;
		if(s[t] == 'x' && v[f] == v[b]) return true;
	}
	return false;
}

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

	//hitsuji:1,okami:0
	Vec a(n);
	rep(i, 4){
		ll x = i%2, y = i/2;
		a[0] = x, a[1] = y;
		REP(j, 2, n){
			if(a[j-1] == 1){
				if(s[j-1] == 'o') a[j] = a[j-2];
				else a[j] = !a[j-2];
			}else{
				if(s[j-1] == 'x') a[j] = a[j-2];
				else a[j] = !a[j-2];
			}
		}

		if(check(0, a, s) && check(n-1, a, s)){
			print(a);
			return 0;
		}
	}

	co(-1);
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

string s;

int main(){
	cin>>s;
	while(s.size()){
		if(s.size()>=5&&s.substr(s.size()-5)=="dream"){s.erase(s.size()-5,5);continue;}
		if(s.size()>=7&&s.substr(s.size()-7)=="dreamer"){s.erase(s.size()-7,7);continue;}
		if(s.size()>=5&&s.substr(s.size()-5)=="erase"){s.erase(s.size()-5,5);continue;}
		if(s.size()>=6&&s.substr(s.size()-6)=="eraser"){s.erase(s.size()-6,6);continue;}
		break;
	}
	if(s.size()){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}
		

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

int n;

struct unionfind{
    vector<int> d;
    unionfind(int n=0) : d(n, -1){}
    int find(int x) {//根を返す関数
        if(d[x]<0) return x;
        return d[x]=find(d[x]);//d[x]にfind[d[x]]の値を代入してそれを返している．これにより根に全ての子を繋げられる．
    }
    bool unite(int x, int y){
        x=find(x);y=find(y);
        if(x == y) return false;
        if(d[x]>d[y]) swap(x, y);//-なので逆にしている
        d[x]+=d[y];//連結成分サイズを保持している
        d[y]=x;//yの根をxにしている
        return true;
    }
    bool same(int x, int y){return find(x)==find(y);}//同じかどうかを判定
    int size(int x){return -d[find(x)];}//連結成分の数を返す
};

ll choose(ll a){
    return a*(a-1)/2;
}

int main(void){
    int m;
    cin>>n>>m;
    vector<pair<int, int> > br(m);
    rep(i, m){
        int a, b;
        cin>>a>>b;
        --a;--b;
        br[i]=pair<int,int>(a, b);
    }
    ll nC2=choose(n);
    reverse(br.begin(), br.end());
    /*逆から構築していく*/
    unionfind uf(n);
    vector<ll> answer(m);
    answer[0]=nC2;
    ll ans=nC2;
    rep(i, m-1){
        if(!uf.same(br[i].first, br[i].second)){
            ans-=uf.size(br[i].first)*uf.size(br[i].second);
        }
        uf.unite(br[i].first, br[i].second);
        answer[i+1]=ans;
    }
    reverse(answer.begin(), answer.end());
    rep(i, m) cout<<answer[i]<<endl;
    return 0;


}

Measured memory_bytes: 3328
/* AOJ 0039
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0039
 *
 */

#include <stdio.h>

#define DEBUG 0


/* 大きい数字の前にあって引き算を表す小さな数字は一回の引き算あたりひとつしかありません。*/

/* 実際のローマ数字ではI はV かX から、X はL かC から、C はD かM からしか引き算しません */
/* 同じローマ数字は４つ以上（または５つ以上）足し並べることはありません。*/

int r2i(char r){
    switch(r){
        case 'I':
            return 1;
        break;
        case 'V':
            return 5;
        break;
        case 'X':
            return 10;
        break;
        case 'L':
            return 50;
        break;
        case 'C':
            return 100;
        break;
        case 'D':
            return 500;
        break;
        case 'M':
            return 1000;
        break;
        default:
        break;
    }
}


int roman2num(char* s){
    int r;
    int next;
    int cur;
    r = 0;

    while(s){
        if(!*(s+1)){
            r += r2i(*s);
            break;
        }
        cur = r2i(*s);
        next = r2i(*(s+1));
        if(next > cur){
            r-= cur;
        }else{
            r+= cur;
        }

        s++;
    }
    return r;
}


int main(){
    char buf[101]; /* 与えられるローマ数字の文字列の長さはおのおの100 以下です。*/
    int n;

    while(scanf("%s", &buf) == 1){
        if(DEBUG)
            printf("%s\n", buf);
        n = roman2num(buf);
        printf("%d\n", n);
    }
    return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll N;
vector<ll> h;
vector<ll> memo;

ll solve(ll n)
{
    if (memo.at(n) != -1)
    {
        return memo.at(n);
    }
    if (n == 1)
    {
        return memo.at(n) = memo.at(0) + abs(h.at(0) - h.at(n));
    }

    ll res1 = solve(n - 1) + abs(h.at(n - 1) - h.at(n));
    ll res2 = solve(n - 2) + abs(h.at(n - 2) - h.at(n));
    return memo.at(n) = min(res1, res2);
}

int main()
{
    cin >> N;
    h.resize(N);
    memo.resize(100010, -1);
    rep(0, i, N)
    {
        cin >> h.at(i);
    }
    memo.at(0) = 0;
    cout << solve(N - 1) << endl;
}

Measured memory_bytes: 9548
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int h,a;
  cin >> h >> a;
  cout << (h+a-1)/a << 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 num[] = new int[3];

        int c = 0;
        for (int i = 0; i < 3; i++) {
            int n = sc.nextInt();
            if(n > 5) {
                num[2] = n;
            } else {
                num[c++] = n;
            }
        }

        if(num[0] == 5 && num[1] == 5 && num[2] == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}

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

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

using ll = long long;
using namespace std;

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

    bool answer = (s == "AAA") || (s == "BBB");

    cout << (answer ? "No" : "Yes") << endl;
}


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

int main()
{
	size_t N;

	std::cin >> N;

	std::vector<int64_t> A;
	std::vector<int64_t> B;
	std::vector<int64_t> C;

	for (size_t i = 0; i < N; ++i) {
		size_t a;  std::cin >> a; A.emplace_back(a);
	}
	for (size_t i = 0; i < N; ++i) {
		size_t b;  std::cin >> b; B.emplace_back(b);
	}
	for (size_t i = 0; i < N - 1; ++i) {
		size_t c;  std::cin >> c; C.emplace_back(c);
	}

	int64_t a = 0;
	for (size_t i = 0; i < N; ++i) {
		a += B[A[i] - 1];
		if (i != 0) {
			if (A[i - 1] == A[i] - 1) {
				a += C[A[i] - 2];
			}
		}
	}

	std::cout << a << std::endl;

	return 0;
}


Measured memory_bytes: 256
toInt :: (String -> Int)
toInt x = read x ::Int

chk :: Int -> Int -> Int
chk l r = minimum $ map (\i -> minimum $ map (\j -> (i * j) `mod` 2019) [(i+1)..r]) [l..(r-1)]

main :: IO ()
main = do
    x <- getLine
    let
        [l, r] = (map $ toInt) $ words x
        ml = l `mod` 2019
        mr = r `mod` 2019
        ans = if (r `div` 2019) - (l `div` 2019) >= 1 
            then 0
            else chk ml mr

    print ans


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

int dp[3010][3010];

void printLCS(const string& s, const string& t,
              int m, int n, string& ans){
  if( m==0 || n==0 )
    return;

  if( s[m-1] == t[n-1] ){
    ans = s[m-1] + ans;
    printLCS(s,t,m-1,n-1,ans);
  }else{
    if( dp[m][n-1] > dp[m-1][n] )
      printLCS(s,t,m,n-1,ans);
    else
      printLCS(s,t,m-1,n,ans);
  }
}

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

  for(int i = 0; i <= s.size(); i++)
    dp[i][0] = 0;
  for(int j = 0; j <= t.size(); j++)
    dp[0][j] = 0;

  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < t.size(); j++){
      if( s[i] == t[j] ){
        dp[i+1][j+1] = dp[i][j]+1;
      }else{
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  printLCS(s, t, s.size(), t.size(), ans);
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 35968