akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, i, k;
    cin >> n;
    int a[n+1];
    a[0] = -1000000000;
    for(i=0; i<n; i++){
        cin >> a[i+1];
    }
    sort(a, a+n+1);
    if(n == 2){
        cout << a[2] << ' ' << a[1];
    }else{
        cout << a[n] << ' ';
        if(a[n-1]%2 == 0){
            k = lower_bound(a, a+n, a[n]/2) - a;
            if(abs(a[n] - a[k]*2) > abs(a[n] - a[k-1]*2)){
                cout << a[k-1];
            }else{
                cout << a[k];
            }
        }else{
            k = upper_bound(a, a+n, (a[n]-1)/2) - a;
            if(abs(a[n] - a[k]*2) > abs(a[n] - a[k-1]*2)){
                cout << a[k-1];
            }else{
                cout << a[k];
            }
        }
    }
    return 0;
}

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

int n,m,dp[1010][1010];
char c[1010][1010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(c[i][j]=='#') dp[i][j]=0;
			else if(i==1&&j==1) dp[i][j]=1;
			else if(i==1) dp[i][j]=dp[i][j-1];
			else if(j==1) dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				if(dp[i][j]>=MOD) dp[i][j]-=MOD;
			}
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int

int main(void){
  while(true){
    int N;
    cin >> N;
    if(N==0){
      break;
    }

    vector<vector<int>> tt;
    tt.assign(N,vector<int>(N+1,0));
    for (size_t i = 0; i < N; i++) {
      for (size_t j = 0; j < N+1; j++) {
        cin >> tt[i][j];
      }
    }

    int bitmax,tmp;
    bitmax = 1<<(N+1)-1;

    vector<vector<int>> MinTime;
    MinTime.assign(bitmax,vector<int>(N,0));

    for (size_t bit = 0; bit < bitmax; bit++) {
      for (size_t t = 0; t < N; t++) {
        tmp = tt[t][0];
        for (size_t b = 0; b < N; b++) {
          if((1<<b) & bit){
            tmp = min(tt[t][b+1],tmp);
          }
        }
        MinTime[bit][t] = tmp;
      }
    }

    int ans = INT_MAX;
    int now;
    vector<int> dp;
    dp.assign(bitmax,INT_MAX);
    dp[0] = 0;
    for (size_t bit = 0; bit < bitmax; bit++) {
      now = dp[bit];
      for (size_t t = 0; t < N; t++) {
        if(bit & (1<<t)){
          continue;
        }else{
          dp[bit+(1<<t)] = min(dp[bit+(1<<t)],now+MinTime[bit][t]);
        }
      }
    }
    cout << dp[bitmax-1] << endl;
  }
}



Measured memory_bytes: 9792
from operator import itemgetter

N = int(input())
X=[]
S=[]
P=[]

for n in range(N):
    X.append([n+1])

for n in range(N):
    s, p = map(str, input().split())
    S.append(s)
    P.append(int(p))

for n, m in enumerate(S):
    X[n].append(m)

for n, m in enumerate(P):
    X[n].append(m)

X.sort(key=lambda x:(x[1], -x[2]))

for n in range(N):
    print(X[n][0])


Measured memory_bytes: 3064
# S = input()
# print('Heisei' if S <= '2019/04/30' else 'TBD')

# n,m,c=map(int,input().split())
# b=list(map(int,input().split()))
# e = [[int(i) for i in input().split()] for i in range(n)]

# array=[None]*3
# print(array)

# print('{0:.10f}'.format(11))

n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xmax=-1000
ymin=1000

for i in range(0,n):
	if a[i]>xmax:
		xmax=a[i]

for i in range(0,m):
	if b[i]<ymin:
		ymin=b[i]

flag=0

for t in range(x+1,y+1):
	if xmax<t:
		if ymin>=t:
			flag=1
			break

if flag==1:
	print("No War")
else:
	print("War")


Measured memory_bytes: 3064
A,V = [int(v) for v in input().split()]
B,W = [int(v) for v in input().split()]
T = int(input())

if A > B:
    V *= -1
    W *= -1

A_d = V * T + A
B_d = W * T + B

if A < B:
    if A_d >= B_d: 
        print("YES")
    else:
        print("NO")
elif A > B:
    if A_d <= B_d: 
        print("YES")
    else:
        print("NO")
else:
    print("YES")


Measured memory_bytes: 9196
#include<stdio.h>
int main(void)
{
	int d,l;
	scanf("%d %d",&d,&l);
	if(d%l==0){
		printf("%d\n",d/l);
	}
	else{
		printf("%d\n",d/l+d%l);
	}
	return 0;
}


Measured memory_bytes: 2132
#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;}
typedef long long ll;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int N;
ll a[100000];
bool Awin(){
	ll S=0;
	int od=0,odid=-1;
	rep(i,N){
		S+=a[i];
		if(a[i]%2==1) od++,odid=i;
	}
	if((S-N)%2==1) return 1;
	assert(od!=0);
	if(od>1) return 0;
	if(a[odid]==1) return 0;
	a[odid]--;
	ll g=a[0];
	rep(i,N) g=gcd(g,a[i]);
	rep(i,N) a[i]/=g;
	return !Awin();
}
bool solve(){
	cin>>N;
	rep(i,N) cin>>a[i];
	if(N==1){
		return 0;
	}
	return Awin();
}
int main(){
	if(solve()) puts("First");
	else puts("Second");
}


Measured memory_bytes: 1152
//=================================
// Created on: 2018/09/20 11:46:12
//=================================
#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 1000000007;
template <ll mod = MOD>
class ModCombination
{
public:
    ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)
    {
        for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; }
    }
    ll combination(const std::size_t n, const std::size_t k) const { return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod; }

private:
    std::vector<ll> fact, inv, inv_fact;
};

int main()
{
    int R, C;
    std::cin >> R >> C;
    ModCombination<> mod(100000);
    int ay, ax, by, bx;
    std::cin >> ay >> ax >> by >> bx;
    auto get = [&](const int a, const int b, const int L) {
        const int delta = std::abs(a - b);
        int D = std::min({delta, 1 + b, L - b});
        ll comb = 0;
        using P = std::pair<int, int>;
        std::queue<P> q;
        constexpr int INF = 1 << 30;
        std::vector<int> used(L, INF);
        q.push({0, a}), used[a] = 0;
        while (not q.empty()) {
            const auto p = q.front();
            const int d = p.first, s = p.second;
            used[s] = std::min(used[s], d);
            q.pop();
            if (s == b) { (comb += 1) %= MOD; }
            if (d == D) { continue; }
            if (used[0] > d + 1) { q.push({d + 1, 0}); }
            if (used[L - 1] > d + 1) { q.push({d + 1, L - 1}); }
            if (s > 0 and used[s - 1] > d + 1) { q.push({d + 1, s - 1}); }
            if (s < L - 1 and used[s + 1] > d + 1) { q.push({d + 1, s + 1}); }
        }
        return std::pair<int, ll>{D, comb};
    };
    auto p1 = get(ay, by, R);
    auto p2 = get(ax, bx, C);
    const int D = p1.first + p2.first;
    const ll c = mod.combination(D, p1.first);
    std::cout << D << " " << c * (p1.second * p2.second % MOD) % MOD << std::endl;
    return 0;
}



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

int main()
{
int i;
int N;
int X;
int m;
int iSum;
int iMin;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> X;

	iSum = 0;
	iMin = 1000;
	for( i = 0; i < N; i++ )
	{
		cin >> m;
		iSum += m;
		iMin = min( iMin, m );
	}

	X -= iSum;

	cout << X / iMin + N << endl;

	return 0;
}






Measured memory_bytes: 256
import java.util.*;

class Main {
	static Scanner sc;
	static int n, m;
	static ArrayList<Integer>[] targets;
	static int[] constraints;
	static Boolean[] states;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();

		targets = new ArrayList[m];
		for (int i = 0; i < m; i++) {
			int k = sc.nextInt();
			ArrayList<Integer> target = new ArrayList<Integer>();
			for (int j = 0; j < k; j++) {
				target.add(sc.nextInt() - 1);
			}
			targets[i] = target;
		}
		constraints = new int[m];
		for (int i = 0; i < m; i++) {
			constraints[i] = sc.nextInt();
		}

		states = new Boolean[n];
		int ans = dfs(0);
		System.out.println(ans);
	}

	public static int dfs(int index) {
		if (index == n) {
			if (check()) {
				return 1;
			} else {
				return 0;
			}
		}

		int sum = 0;
		states[index] = false;
		sum += dfs(index + 1);
		states[index] = true;
		sum += dfs(index + 1);
		return sum;
	}

	public static Boolean check() {
		for (int i = 0; i < m; i++) {
			int count = 0;
			for (int j = 0; j < targets[i].size(); j++) {
				if (states[targets[i].get(j)]) {
					count++;
				}
			}
			if (count % 2 != constraints[i]) {
				return false;
			}
		}
		return true;
	}
}


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

int main() {
  double n, a, b;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> v;
  for(int i = 0;i < n;i++) {
    cin >> a;
    v.push(a);
  }
  while(v.size() > 1) {
    b = v.top();
    v.pop();
    b += v.top();
    v.pop();
    v.push(b / 2);
  }
  cout << v.top() << endl;
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

ll n;

int main(){
    ios::sync_with_stdio(0);
	cin >> n;
	if (n < 1200){
		cout << "ABC";
	}
	else if(n < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    scanf("%d %d %d", &n,&a,&b);
    int sum=0;
    for(int i=0;i<=n;i++){
        int x=i;
        int check=0;
        while(x!=0){
            check+=x%10;
            x/=10;
        }
        if(check>=a && check<=b){
            sum+=i;
        }
    }
    printf("%d", sum);
}

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 != m2 && d1 > d2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
}

int main(void)
{
    solve();
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool sieve[101000];

int main() {
    sieve[0] = sieve[1] = true;
    FOR(i, 2, 101000) {
        if (sieve[i]) continue;
        for (int j = i+i; j < 101000; j += i) {
            sieve[j] = true;
        }
    }
    int n, p;
    while (cin >> n >> p) {
        if (n == -1 && p == -1) break;
        p--;
        vi prime;
        FOR(i, n+1, 101000) {
            if (!sieve[i]) {
                prime.push_back(i);
                if (SZ(prime) > 100) break;
            }
        }
        vi m;
        REP(i, SZ(prime)) FOR(j, i, SZ(prime)) {
            m.push_back(prime[i]+prime[j]);
        }
        SORT(m);
        cout << m[p] << endl;
    }
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
long long h,w;
int main() {
	scanf("%lld%lld",&h,&w);
	if(h==1 || w==1) {
		cout<<1;
		exit(0);
	}
	long long a=(w+1ll)/2,b=w/2;
	cout<<((h/2ll)*(a+b))+((h&1ll)*a);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N,i,A,i2,j2,f,n=0;
  cin >> N;
  string S[N];
  for (i=0;i<N;++i) {
    cin >> S[i];
  }
  for (A=0;A<N;++A) {
    f=0;
    for (i2=0;i2<N;++i2) {
      if (f>0) {
        break;
      }
      for (j2=0;j2<i2+1;++j2) {
        if (S[(i2+A)%N][(j2)%N]!=S[(j2+A)%N][(i2)%N]) {
          f=1;
          break;
        }
      }
    }
    if (f==0) {
      n+=N;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 512
#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 ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(ALL(a));
  cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 3616
import math
import itertools
GCD_over_150=[4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692]
 
N=int(input())
if N<150:
	GCD=[]
	GCD1=[]
	for i in range (1,N+1):
		GCD.append(i)
	for i in itertools.product(GCD,repeat=3):
		GCD1.append(math.gcd(math.gcd(i[0],i[1]),i[2]))
	print(sum(GCD1))    
else:
    print(GCD_over_150[N-150])

Measured memory_bytes: 22620
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  string s;cin>>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3))
    cout<<"Bad"<<endl;
  else
    cout<<"Good"<<endl;
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

bool box[100100] = {true};
int cnt[100100];

signed main() {
  int N = in(), M = in();
  REP(i, N) { cnt[i] = 1; }
  REP(i, M) {
    int x = in() - 1, y = in() - 1;
    box[y] |= box[x];
    cnt[x]--;
    cnt[y]++;
    if (cnt[x] == 0) box[x] = false;
  }
  int ans = 0;
  REP(i, N) {
    if (cnt[i] && box[i]) { ans++; }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int r; scanf("%d", &r);
	printf("%f\n", 2*r*atan2(0,-1));
}

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

signed main(void)
{
	long long n, k, x, y;
	cin >> n >> k;
	
	if (k == 0)
		cout << n << endl;
	else
	{
		x = n % k; 
		y = abs(x - k);
		if (x > y)
			cout << y << endl;
		else
			cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int x;
	cin >> x;
	if (x) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, m;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 reader;
    reader >= n >= m >m>= xs; 
  }
  void solve() {
    std::vector<long> count(112345, 0);
    for(auto x : xs) {
      count[x[0]] += 1;
      count[x[1]] += 1;
    }
    bool res = true;
    for(long z : count) {
      if( z % 2 == 1 ) res = false;
    }
    puts(res ? "YES" : "NO");
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}



Measured memory_bytes: 2688
args = input()
nums = args.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
blue_calc = int(n / (a + b))
blue_mod = n % (a + b)
if blue_mod < a:
  print(a * blue_calc + blue_mod)
  exit()
print(a * blue_calc + a)   

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    double x[100],y[100];
    double p1=0,p2=0,p3=0,pe=0,p;
    for(int i=0;i<n;i++)cin >>x[i];
    for(int i=0;i<n;i++)cin >>y[i];
    for(int i=0;i<n;i++)p1+=fabs(x[i]-y[i]);
    for(int i=0;i<n;i++)p2+=pow(fabs(x[i]-y[i]),2.0);
    for(int i=0;i<n;i++)p3+=pow(fabs(x[i]-y[i]),3.0);
    for(int i=0;i<n;i++){
        p=fabs(x[i]-y[i]);
        if(p>pe)pe=p;
    }
    p2=sqrt(p2);
    p3=cbrt(p3);
    printf("%lf\n",p1);
    printf("%lf\n",p2);
    printf("%lf\n",p3);
    printf("%lf\n",pe);
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  int ans = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == T[i]){
      ans++;
   }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>

using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
int main(){
    ll A,B,C,K,ans = 0;
    cin >> A >> B >> C >> K;
    ll card = 0;
    while (card != K){
        if (A > 0){
            A--,card++,ans++;
            continue;
        }else if (B > 0){
            B--,card++;
            continue;
        }else if (C > 0){
            C--,card++,ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++){
        F[i]=F[i-1]+F[i-2];
    }
    cout<<F[n]<<endl;
    return 0;
}


Measured memory_bytes: 3100
object Main extends App {
  val Array(k, s) = io.StdIn.readLine().split(' ').map(_.toInt)
  var count = 0
  for (l <- 0 to k) {
    val c = s - l * 2
    if (0 <= c && c <= k) count += 1
    for (r <- l+1 to k) {
      val c = s - (l + r)
      if (0 <= c && c <= k) count += 2
    }
  }
  println(count)
}

Measured memory_bytes: 28000
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
const int MAXN = 1e5+7;
int a[MAXN], n,freq_par[MAXN], freq_impar[MAXN],tot_par=0,tot_impar=0;
vector<pii> par,impar;
int main(){
    fastio; cin>>n;
    bool flag = true;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        if(flag && a[i]!=a[1])flag=false;
    }
    if(flag){
        cout<<n/2<<endl;
        return 0;
    }
    //all equal is special case
    for(int i=1; i<=n; i+=2){
        freq_impar[a[i]]++;
        tot_impar++;
    }
    for(int i=1;i<MAXN;i++){
        if(freq_impar[i] > 0)impar.push_back({freq_impar[i], i});
    }
    sort(impar.begin(), impar.end());
    for(int i=2; i<=n; i+=2){
        freq_par[a[i]]++;
        tot_par++;
    }
    for(int i=1;i<MAXN;i++){
        if(freq_par[i] > 0)par.push_back({freq_par[i], i});
    }
    sort(par.begin(), par.end());
    int tp = (int)par.size()-1;
    int ti = (int)impar.size()-1;
    if(par[tp].second != impar[ti].second){
        cout<< tot_par - par[tp].first + tot_impar - impar[ti].first<<endl;
    }else{
        if(tp==0)cout<<tot_par - par[tp].first + tot_impar - impar[ti-1].first<<endl;
        else if(ti==0)cout<<tot_par - par[tp-1].first + tot_impar - impar[ti].first<<endl;
        else cout << min(tot_par - par[tp-1].first + tot_impar - impar[ti].first, tot_par - par[tp].first + tot_impar - impar[ti-1].first)<<endl;
    }
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  if((int)a.size()!= n) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

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

using namespace std;

int mod = 1000000007;

long long mpow(long long a, long long b);

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int b;
	for (int i = 0; i < n; i++) {
		cin >> b;

		a[b]++;
	}

	if (n % 2 == 1) {
		if (a[0] != 1) {
			cout << 0 << endl;
			return 0;
		}

		for (int i = 2; i < n; i += 2) {
			if (a[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	} else {
		for (int i = 1; i < n; i += 2) {
			if (a[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	cout << mpow(2, n / 2) << endl;

	return 0;
}

long long mpow(long long a, long long b)
{
	long long ans = 1;
	while (b != 0) {
		if ((b & 1) == 1) {
			ans *= a;
			ans %= mod;
		}
		a *= a;
		a %= mod;
		b >>= 1;
	}

	return ans;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    vector<string> ans(h);
    REP(i, b) ans[i] = string(a, '0') + string(w-a, '1');
    REP(i, h-b) ans[i+b] = string(a, '1') + string(w-a, '0');

    REP(i, h) cout << ans[i] << endl;

    return 0;
}


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


int main() {
  int n,m;
  cin >>n>>m;
  vector<long>a(n),b(n),c(n),d(n);
  rep(i,n){
    cin>>a.at(i)>>b.at(i)>>c.at(i);
  }
  long ans=-1001001001001001001;
  long now=0;
  
  rep(i,n){
    d[i]=a[i]+b[i]+c[i];
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  rep(i,m){
    now+=d[i];
  }
  ans=max(ans,now);
  now=0;
  reverse(d.begin(),d.end());
  rep(i,m){
    now-=d[i];
  }
  ans=max(ans,now);
  now=0;
  
  rep(i,n){
    d[i]=a[i]-b[i]+c[i];
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  rep(i,m){
    now+=d[i];
  }
  ans=max(ans,now);
  reverse(d.begin(),d.end());
  now=0;
  rep(i,m){
    now-=d[i];
  }
  ans=max(ans,now);
  now=0;
  
  rep(i,n){
    d[i]=a[i]+b[i]-c[i];
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  rep(i,m){
    now+=d[i];
  }
  ans=max(ans,now);
  now=0;
  reverse(d.begin(),d.end());
  rep(i,m){
    now-=d[i];
  }
  ans=max(ans,now);
  now=0;
  
  rep(i,n){
    d[i]=-a[i]+b[i]+c[i];
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  rep(i,m){
    now+=d[i];
  }
  ans=max(ans,now);
  now=0;
  reverse(d.begin(),d.end());
  rep(i,m){
    now-=d[i];
  }
  ans=max(ans,now);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;

struct edge{int to,cost;};
vector<edge>G[2500];
const int inf=1e15;

signed main(){
    int n,m,p,a,b,c;
    cin>>n>>m>>p;
    while(cin>>a>>b>>c)
        G[--a].push_back((edge){--b,p-c});
    int dist[2500];
    for(int i=0;i<n;i++)
		dist[i]=inf;
	dist[0]=0;
	for(int i=0;i<=n*2;i++){
		for(int v=0;v<n;v++){
			for(auto x:G[v]){
				int u=x.to;
				if(dist[v]!=inf&&dist[u]>dist[v]+x.cost){
					dist[u]=dist[v]+x.cost;
					if(i>=n&&u==n-1){
						cout<<-1<<endl;
						return 0;
					}
				}
			}
		}
	}
    cout<<max(0ll,-dist[n-1])<<endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int a = sc.NextInt();

        Console.WriteLine(n % 500 <= a ? "Yes" : "No");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner scn = new Scanner(System.in);
	int a,b,n;

	while(true){
	    a=0;b=0;n=scn.nextInt();

	    if(n==0) break;

	    for(int i=0; i<n; i++){
		int ta = scn.nextInt();
		int tb = scn.nextInt();

		if(ta>tb)
		    a += ta+tb;
		else if(ta<tb)
		    b += ta+tb;
		else{
		    a += ta;
		    b += tb;
		}
	    }

	    System.out.println(a+" "+b);
	}
    }
} 

Measured memory_bytes: 12000
def resolve():
    n, k = map(int, input().split())
    s, p, r = map(int, input().split())
    point_dict = {'s': s, 'p': p, 'r': r}
    t = list(input())

    subs = [[] for _ in range(n)]
    for i in range(n):
        m = i % k
        subs[m].append(t[i])
    point = 0
    for sub in subs:
        i_b = None
        for i in sub:
            if i_b != i:
                point += point_dict[i]
                i_b = i
            else:
                i_b = None
    print(point)
    
resolve()

Measured memory_bytes: 14892
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
const int mod = 1e9 + 7;
inline int mul(ll x, ll y) {return x * y % mod;}
inline int add(ll x, ll y) {return (x + y) % mod;}
ll qpow(ll a, ll b)
{
    ll res = 1;
    while (b) {if (b & 1) res = mul(res, a); a = mul(a, a); b /= 2;}
    return res;
}
vector<int>G[MAXN];
ll ans[MAXN], sz[MAXN];
ll fac[MAXN], inv[MAXN];
ll C(int n, int m)
{
    return mul(fac[n], mul(inv[m], inv[n - m]));
}
void dfs1(int u, int f)
{
    sz[u] = 1; int tot = 0;
    for (int v : G[u]) if (v != f)
    {
        dfs1(v, u), sz[u] += sz[v];
        if (tot == 0) tot = sz[v];
        else 
        {
            tot += sz[v];
            ans[1] = mul(ans[1], C(tot, sz[v]));
        }
    }
}
int n;
void dfs2(int u, int f)
{
    for (int v : G[u]) if (v != f)
    {
        ans[v] = mul(mul(ans[u], sz[v]), qpow(n - sz[v], mod - 2));
        dfs2(v, u);
    }
}
int main()
{
    int N = 2e5 + 1;
    fac[0] = 1; for (int i = 1; i <= N; i++) fac[i] = mul(fac[i - 1], i);
    inv[N] = qpow(fac[N], mod - 2); for (int i = N; i; i--) inv[i - 1] = mul(inv[i], i);
    scanf("%d", &n);
    for (int i = 1, u, v; i < n; i++) 
    {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans[1] = 1; dfs1(1, 0);
    dfs2(1, 0);
    for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 20212
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int N;
    cin >> N;
    string holder;
    multiset<string> storage;
    for (int i = 0; i < N; i++) {
        cin >> holder;
        storage.insert(holder);
    }
    cout << "AC x " << storage.count("AC") << endl;
    cout << "WA x " << storage.count("WA") << endl;
    cout << "TLE x " << storage.count("TLE") << endl;
    cout << "RE x " << storage.count("RE") << endl;
    return 0;
}



Measured memory_bytes: 11436
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

vector<ll> a;

ll memo[3000][3000][2];
bool checked[3000][3000][2];

ll dfs(ll front,ll back,bool first){
    if(front == back)return (first ? a[front] : -a[front]);
    if(checked[front][back][first])return memo[front][back][first];
    ll ans = 0;
    if(first){
        ans = max(a[front]+dfs(front+1,back,0),a[back]+dfs(front,back-1,0));
    }
    else{
        ans = min(dfs(front+1,back,1)-a[front],dfs(front,back-1,1)-a[back]);
    }
    checked[front][back][first] = 1;
    return memo[front][back][first] = ans;
}

signed main(){
    ll N;
    cin >> N;
    a.resize(N);
    FOR(i,0,N)cin >> a[i];
    cout << dfs(0,N-1,1) << endl;
}

Measured memory_bytes: 158080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int x, y, z;
	int res=0;
	int i, j;
	scanf("%d %d %d", &x, &y, &z);
	for (i = x - z; i >= y + z;)
	{
		i = i - z - y;
		res++;
	}
	printf("%d\n", res);
	return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
string S;

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

	cin >> N >> S;

	string ans;
	FOR(i,0,4){
		string ans;
		ans += i / 2 ? 'S' : 'W';
		ans += i % 2 ? 'S' : 'W';
		FOR(j,2,N){
			if((ans [j - 1] == 'W') ^ (ans [j - 2] == 'W') ^ (S [j - 1] == 'x')){
				ans += 'W';
			}
			else{
				ans += 'S';
			}
		}
		bool ok = true;
		if((ans [N - 2] == 'W') ^ (ans [N - 1] == 'W') ^ (ans [0] == 'W') != (S [N - 1] == 'x')){
			ok = false;
		}
		if((ans [N - 1] == 'W') ^ (ans [0] == 'W') ^ (ans [1] == 'W') != (S [0] == 'x')){
			ok = false;
		}
		if(ok){
			cout << ans << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 748
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a+b)>(c+d))
		cout<<"Left"<<endl;
	else if((a+b)==(c+d))
		cout<<"Balanced"<<endl;
	else
		cout<<"Right"<<endl;
	return 0;
}

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

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

Measured memory_bytes: 12016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	ll cnt = 0;
	ll sum = 0;

	for (ll i = 0; i < N; i++) {
		sum += A.at(i);
	}

	for (ll i = 0; i < N; i++) {
		if (A.at(i) >= (sum + 4 * M - 1) / (4 * M)) cnt++;
	}

	if (cnt >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

Y = Y // 1000

ok = False
for x in range(N+1):
    tmp = Y - 10 * x
    for y in range(N-x+1):
        z = tmp - 5 * y
        if x + y + z == N:
            print(x, y, z)
            ok = True
            break
    if ok:
        break

if not ok:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	long long a,b,d;
	cin>>a>>b;
	d=b-a+1;
	if(a<b)
	{
		if(a>0&&b>0)
		{
			cout<<"Positive"<<endl;
		}
		else
		{
			if(a<=0&&b>0)
			{
				cout<<"Zero"<<endl;
			}
			else
			{
				if(a<0&&b<=0)
				{
					if(b==0)
					{
						cout<<"Zero"<<endl;
					}
					else
					{
						if(d%2==0)
						{
							cout<<"Positive"<<endl;
						}
						else
						{
							cout<<"Negative"<<endl;
						}
					}
				}
			}
		}
	}
	else
	{
		return 0;
	}
	return 0;	
}

Measured memory_bytes: 256
s = input()

d = len(s)
ans = [0] * 10
tmp = 0
for i in range(d):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans[tmp] += 1
    else:
        tmp += 1
print(max(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1100005, INF = 1<<25;

int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];

int __orzzzzzzz(int t)
{
    return t&(t^(t-1));
}

int sum(int end)
{
    int f_25313_f=0;
    while(end>0)
    {
        f_25313_f+=in[end];
        end-=__orzzzzzzz(end);
    }
    return f_25313_f;
}

void g_254413_f(int fffff ,int ___cnt)
{
    while(fffff<=n)
    {
        in[fffff]+=___cnt;
        fffff+=__orzzzzzzz(fffff);
    }
}

void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        g_254413_f(i,1);
    }
    LL f_25313_f = 0;
    int v, u, size;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++)
    {
        if(!used[i])
        {
            s = str[i];
            size = g[s].size();
            u = g[s][size-1];
            if(i == u)
            {
                f_25313_f += (sum(n) - sum(i))/2;
            }
            else
            {
                f_25313_f += sum(n) - sum(u);
            }
            g_254413_f(u, -1);
            g_254413_f(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld", f_25313_f);
    puts("");
}

int main()
{
    while(scanf("%s", str+1) != EOF)
    {
        n = strlen(str+1);
        memset(cc, 0, sizeof(cc));

        for(int i=1; i<129; i++)
            g[i].clear();

        for(int i=1; i<=n; i++)
        {
            cc[str[i]]++;
            g[str[i]].push_back(i);
        }

        int flag = 0;
        for(int i=0; i<26; i++)
        {
            if(cc['a'+i]%2) flag++;
            if(cc['A'+i]%2) flag++;
        }
        if(flag > 1)
        {
            printf("-1");
            puts("");
            continue;
        }
        else
        {
            solve();
        }
    }
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		ll a,b,c,k;
		cin>>a>>b>>c>>k;
		ll ans=0;
		ans+=min(k,a);
		k-=min(k,a);
		if(k>0)
		{
			k-=min(k,b);
		}
		if(k>0)
		{
			ans-=k;
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    string s;
    while(1){
        getline(cin,s);
        if(s=="END OF INPUT") break;
        int c=0;
        LP(i,s.size()+1){
            if(s[i]==' '||i==s.size()){
                cout<<c;
                c=0;
            }
            else c++;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int y[maxn],idx[maxn];
int ans[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int x,yy;
    cin>>x>>yy;
    y[x] = yy;
    idx[x] = i;
  }
  int mi = n+1;
  int st = 1;
  for(int i=1;i<=n;i++){
    mi = min(mi, y[i]);
    if(mi == n-i+1){
      for(int j=st;j<=i;j++){
        ans[idx[j]] = i-st+1;
      }
      st = i+1;
    }
  }
  for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
  return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}
double mini=0.00000000000001;
double memo[1000000];
double n;

double j2(ll i){
    if(abs(memo[i])>mini) return memo[i];
    if(i==0) return 1;
    return j2(i-1)/2;
}

int main(){
    ll n,m;cin>>n>>m;
    ll a[n],b[n];
    vector<pair<ll,ll>> pa;
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        pa.push_back(make_pair(a[i],b[i]));
    }
    sort(pa.begin(),pa.end());
    ll count=0;
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(count+pa[i].second<m){
            ans+=pa[i].first*pa[i].second;
            count+=pa[i].second;
        }else{
            ans+=pa[i].first*(m-count);
            i=n+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3444
#include <stdio.h>

int main() {
	
	int H, W, N;
	scanf("%d", &H);
	scanf("%d",&W);
	scanf("%d", &N);
	int temp, count = 0;
	
	H > W ? temp = H : temp = W;
	
	for(int i = 0; i < N; i += temp){
		count++;
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1656