akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    rep(i,n+1){
        if(i*108/100==n){
            cout<<i<<endl;
            return;
        }
    }
    cout<<":("<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

count = 0
first = 0

while first < n:
    for i in range( n-1, first, -1 ):
        if a[i] < a[i-1]:
            t = a[i]
            a[i] = a[i-1]
            a[i-1] = t
            count += 1
    first += 1

print(*a)
print(count)

Measured memory_bytes: 7624
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
int main() {
    int n;
    int k;
    cin >> n >> k;
    int ar[n];
    int dp[n];
    for (int i = 0; i < n; i ++) {
        cin >> ar[i];
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i ++) {
       for (int j = i + 1; j < min(n,i+k+1); j ++) {
           dp[j] = min(dp[j], dp[i] + abs(ar[j]-ar[i]));
       } 
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4336
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  int64_t result = 0;
  if (N % 2 == 0) {
    N /= 2;
    int64_t p = 5;
    while (p <= N) {
      result += N / p;
      p *= 5;
    }
  } else {
    result = 0;
  }
  cout << result << endl;
  return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pDD pair < D , D >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    ll a , b ;
    cin >> a >> b ;

    if ( b <= 1 ) { cout << 0 ; line ; R; }

    ll sum = 0 ;
    ll ans = 0 ;
    while ( sum < b )
    {
        ans++ ;
        sum += a ;

        if ( sum >= b ) break ;
        sum -- ;
    }

    cout << ans ; line
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N, D, X;
int main() {
    cin >> N >> D >> X;
    int sum = X;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        int days=1;
        while(days<=D){
            sum++;
            days+=a;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
cnt = 0
diff = abs(x) - abs(y)
if diff == 0:
    if x * y < 0:
        cnt += 1
elif diff > 0:
    cnt += diff
    if x > 0:
        cnt += 1
    if y > 0:
        cnt += 1
else:
    cnt += -diff
    if x < 0:
        cnt += 1
    if y < 0:
        cnt += 1
print(cnt)


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

int N;
float pi = 3.1415926535897;


int co(float l[2], float r[2], int i, float radian, float lo) {
	if (i == N) {
		cout << l[0] << " " << l[1] << endl;
		return 0;
	}
	lo /= 3;
	float nl[2], nr[2], nt[2];
	nl[0] = l[0] * 2 / 3 + r[0] / 3;
	nl[1] = l[1] * 2 / 3 + r[1] / 3;
	nr[0] = r[0] * 2 / 3 + l[0] / 3;
	nr[1] = r[1] * 2 / 3 + l[1] / 3;
	nt[0] = (l[0] + r[0]) / 2;
	nt[1] = (l[1] + r[1]) / 2;
	nt[0] += lo * sqrt(3) / 2 * cos(radian + pi / 2);
	nt[1] += lo * sqrt(3) / 2 * sin(radian + pi / 2);
	i++;
	co(l, nl, i, radian,lo);
	co(nl, nt, i, radian+pi/3,lo);
	co(nt, nr, i, radian-pi/3,lo);
	co(nr, r, i, radian,lo);
	return 0;
}

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

	cin >> N;
	float l[2], r[2];
	l[0] = 0;
	l[1] = 0;
	r[0] = 100;
	r[1] = 0;
	co(l, r, 0, 0,100);
	cout << r[0] << " " << r[1] << endl;
}



Measured memory_bytes: 3344
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = LI()
    t = max(a)

    return t * 9 + sum(a)


print(main())


Measured memory_bytes: 6476
#include<stdio.h>
int main(void)
{
	int n,d1,d2,i,x,p,y;
	scanf("%d",&n);
	while(n!=0){
		x=0;  y=0;
		for(i=0;i<n;i++){
		scanf("%d %d %d",&p,&d1,&d2);
			if(y<d1+d2){
				x=p;  y=d1+d2;
			}
		}
		printf("%d %d\n",x,y);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 2672
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> V(N);
    REP(i,N){
        cin>>V[i];
    }
    int back_sum=0;
    int front_sum=0;

    REP(i,N){
        back_sum+=V[i];
    }
    int recgap0=back_sum;
    REP(i,N-1){
        back_sum-=V[i];
        front_sum+=V[i];
        recgap0>=abs(back_sum-front_sum)?recgap0=abs(back_sum-front_sum):0;
    }
    cout<<recgap0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
	string s,t,n;
	int i,j;
	cin>>s>>t;
	i=s.length(); j=t.length();
	n=t.substr(0,j-1);
	if(s==n)
	std::cout << "Yes" << std::endl;
	else
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 2048;
const int maxm = 100010;
char s[maxn][maxn];
int sum_node[maxn][maxn];
int sum_edgex[maxn][maxn];
int sum_edgey[maxn][maxn];
int n,m;
inline void init(){
    rep(i,1,n) rep(j,1,m){
        if(s[i][j] == '1') sum_node[i][j] = 1;
        else sum_node[i][j] = 0;
        sum_node[i][j] += sum_node[i-1][j] + sum_node[i][j-1] - sum_node[i-1][j-1];
    }
    rep(i,1,n) rep(j,1,m){
        if(s[i][j] == '1' && s[i-1][j] == '1') sum_edgex[i][j] = 1;
        else sum_edgex[i][j] = 0;
        if(s[i][j] == '1' && s[i][j-1] == '1') sum_edgey[i][j] = 1;
        else sum_edgey[i][j] = 0;
        sum_edgex[i][j] += sum_edgex[i-1][j] + sum_edgex[i][j-1] - sum_edgex[i-1][j-1];
        sum_edgey[i][j] += sum_edgey[i-1][j] + sum_edgey[i][j-1] - sum_edgey[i-1][j-1];
        //printf("sum_edgex[%d][%d] = %d\n",i,j,sum_edgex[i][j]);
        //printf("sum_edgey[%d][%d] = %d\n",i,j,sum_edgey[i][j]);
    }
}
inline int calc(int x2,int y2,int x1,int y1,int s[2048][2048]){
    return s[x2][y2] - s[x1-1][y2] - s[x2][y1-1] + s[x1-1][y1-1];
}
int main(){
    read(n);read(m);int q;read(q);
    rep(i,1,n) scanf("%s",s[i]+1);
    init();
    int x1,x2,y1,y2;
    while(q--){
        read(x1);read(y1);read(x2);read(y2);
        if(x1 > x2) swap(x1,x2);
        if(y1 > y1) swap(y1,y2);
        int ans = 0;
        ans -= calc(x2,y2,x1,y1+1,sum_edgey);
        ans -= calc(x2,y2,x1+1,y1,sum_edgex);
        //printf("%d\n",ans);
        ans += calc(x2,y2,x1,y1,sum_node);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 54912
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = mul(ans, i);
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(N);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    if (N < M) {
        cout << "No" << endl;
        return 0;
    }
    rep(i,N-M+1){
        rep(j,N-M+1){
            rep(k,M){
                rep(l,M){
                    if(B[k][l] != A[i+k][j+l]){
                        goto next;
                    }
                    if(k==M-1&&l==M-1){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
            }
            next:;
        }
    }
    cout <<"No"<<endl;
    
    
    return 0;
}


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

long long M[301][301], M1[301][301];
long long n, m, l, oo = 1<<30;

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

    long long a, b, c;
    for(long long i=1;i<=n;i++){
        fill(M[i]+1,M[i]+301,oo);
        M[i][i]=0;
    }

    for (long long i = 1; i <= m; i++){
        cin >> a >> b >> c;

        M[a][b] = M[b][a] = min(M[a][b], c);
    }

    for(long long k=1;k<=n;k++)
        for(long long i=1;i<=n;i++)
            for(long long j=1;j<=n;j++)
                M[i][j] = min(M[i][j], M[i][k]+M[k][j]);

    for(int i=1;i<=n;i++){
        M1[i][i] = oo;
        for(int j=i+1;j<=n;j++){
            if(M[i][j]<=l){
                M1[i][j]=1;
                M1[j][i]=1;
            }
            else{
                M1[i][j]=oo;
                M1[j][i]=oo;
            }
        }
    }

    for(long long k=1;k<=n;k++)
        for(long long i=1;i<=n;i++)
            for(long long j=1;j<=n;j++)
                M1[i][j] = min(M1[i][j], M1[i][k]+M1[k][j]);

    cin >> m;

    while (m--){
        cin >> a >> b;

        if(M1[a][b]==oo)
            cout<<-1<<'\n';
        else cout<<M1[a][b]-1<<'\n';
    }
}


Measured memory_bytes: 1920
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int H = in.nextInt();
        int A = in.nextInt();
        int count = 0;
        while(H>0)
        {
            H=H-A;
            count++;
        }

        System.out.println(count);


    }


 }












Measured memory_bytes: 35848
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
int MOD = 1000000007;
int INF = ((int)1<<31)-1;
int getLIS(vector<int> &a)
{
	int N = a.size();
	vector<int> dp(N, INF);
	for (int i = 0; i < N; ++i) {
		*upper_bound(dp.begin(), dp.begin() + N, a[i]) = a[i];
	}

	return lower_bound(dp.begin(), dp.begin() + N, INF) - dp.begin();
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	reverse(A.begin(), A.end());
	cout << getLIS(A);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define  double long double
#define mod 1000000007
#define pi acos(-1)
using namespace std;

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

  	int a, b;
  cin >> a >> b;
    int i = (b-1 + a - 2)/(a-1);
    cout << i;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int a, b;

void solve()
{
    cin >> a >> b;
    if (a<b) {
        while (b--) {
            cout << a;
        }
    }else{
        while (a--) {
            cout << b;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 100005
#define ll long long
#define slld(t) scanf("%I64d",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%I64d\n",t)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define vi vector<int>
#define vpii vector<pii >
#define vll vector<ll>
#define clr(x) memset(x,0,sizeof(x))
#define fil(x) memset(x,MAX,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I <= (B); ++I)
using namespace std;
const ll INF = 2147483647;
ll digitsum (ll num)
{
    ll sum = 0 ;
    while (num != 0)
    {
        sum+=(num%10);
        num/=10;
    }
    return sum;
}
bool isPrime[MAX+1];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}
#define matrix vector< vector<ll> >
matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }
    return ans;
}
matrix matpwr(matrix &a, ll p)
{
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;
    while(p)
    {
        if(p&1) ans = matmul(ans, a);
        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}
ll pwr(ll base, ll p, ll mod = MOD)
{
   ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}
const int N = 2e5+5 ;
int n ;
int dist[N];
set<int> s[N];
set<int> :: iterator it ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("a.in", "r", stdin); 
    //freopen("a.out", "w", stdout);

    int r, g, b ;
    cin >> r >> g >> b ;
    int num = 100*r+10*g+b ;
    if(num%4) cout<<"NO";
    else cout<<"YES" ;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>

int A[100001];

int main(void) {
	int i, N, a, ans,count = 0, double_count = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a);
		if (A[a] == 0 || A[a] == 1) {
			A[a]++;
		} 
		else {
			A[a]--;
		}
	}

	for (i = 1; i <= 100000; i++) {
		if (A[i] == 2) {
			double_count++;
		}
		count += A[i];
	}

	ans = count - double_count - (double_count % 2);
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(){

    string ans1 = "vowel";
    string ans2 = "consonant";

    string aiueo = "aiueo";

    char c;
    cin >> c;

    REP(i,aiueo.size()){
        if(c == aiueo[i]){
            cout << ans1 <<endl;
            return 0;
        }
    }
    cout << ans2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int N;
string s;

int main(int argc, char const *argv[]) {
	cin >> N >> s;
	string oo[4] = {"SSS", "WSW", "SWW", "WWS"};
	string xx[4] = {"SSW", "WSS", "SWS", "WWW"};
	string res = s;
	for (int i = 0; i < s.size(); i++) res[i] = 'S';
	res += "SS";

	for (int i = 0; i < s.size(); i++) {
		string sub = res.substr(i, 3);
		bool flag = false;
		if (s[i] == 'o') {
			for (int j = 0; j < 4; j++) {
				if (sub == oo[j]) flag = true;
			}
		}
		else {
			for (int j = 0; j < 4; j++) {
				if (sub == xx[j]) flag = true;
			}
		}
		if (!flag) {
			if (res[i+2] == 'S') res[i+2] = 'W';
			else res[i+2] = 'S';
		}
	}

	if (res[res.size()-1] == 'S' && res[res.size()-2] == 'S') {
		cout << res.substr(1, s.size()) << endl;
		return 0;
	}

	res[0] = 'W';
	for (int i = 1; i < res.size(); i++) res[i] = 'S';

	for (int i = 0; i < s.size(); i++) {
		string sub = res.substr(i, 3);
		bool flag = false;
		if (s[i] == 'o') {
			for (int j = 0; j < 4; j++) {
				if (sub == oo[j]) flag = true;
			}
		}
		else {
			for (int j = 0; j < 4; j++) {
				if (sub == xx[j]) flag = true;
			}
		}
		if (!flag) {
			if (res[i+2] == 'S') res[i+2] = 'W';
			else res[i+2] = 'S';
		}
	}

	if (res[res.size()-1] == 'S' && res[res.size()-2] == 'W') {
		cout << res.substr(1, s.size()) << endl;
		return 0;
	}

	res[0] = 'W';
	for (int i = 1; i < res.size(); i++) res[i] = 'W';

	for (int i = 0; i < s.size(); i++) {
		string sub = res.substr(i, 3);
		bool flag = false;
		if (s[i] == 'o') {
			for (int j = 0; j < 4; j++) {
				if (sub == oo[j]) flag = true;
			}
		}
		else {
			for (int j = 0; j < 4; j++) {
				if (sub == xx[j]) flag = true;
			}
		}
		if (!flag) {
			if (res[i+2] == 'S') res[i+2] = 'W';
			else res[i+2] = 'S';
		}
	}

	if (res[res.size()-1] == 'W' && res[res.size()-2] == 'W') {
		cout << res.substr(1, s.size()) << endl;
		return 0;
	}

	res[0] = 'S';
	for (int i = 1; i < res.size(); i++) res[i] = 'W';

	for (int i = 0; i < s.size(); i++) {
		string sub = res.substr(i, 3);
		bool flag = false;
		if (s[i] == 'o') {
			for (int j = 0; j < 4; j++) {
				if (sub == oo[j]) flag = true;
			}
		}
		else {
			for (int j = 0; j < 4; j++) {
				if (sub == xx[j]) flag = true;
			}
		}
		if (!flag) {
			if (res[i+2] == 'S') res[i+2] = 'W';
			else res[i+2] = 'S';
		}
	}

	if (res[res.size()-1] == 'W' && res[res.size()-2] == 'S') {
		cout << res.substr(1, s.size()) << endl;
		return 0;
	}
	else cout << "-1" << endl;

	return 0;
}

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

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

    int N;
    cin >> N;
    int up = ceil(N / 1.08);
    int down = floor(N / 1.08);
    int X;
    if ((X = up * 1.08) == N)
        cout << up << '\n';
    else if ((X = down * 1.08) == N)
        cout << down << '\n';
    else
        cout << ":(\n";

    return 0;
}

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

typedef long long int ll;

#define pb push_back
#define mp make_pair

const ll maxs = 3005;
ll inf = 1e18;

ll cost[maxs][maxs];
ll dp[maxs][maxs];
ll n;


void warshall()
{
    for(ll k=1;k<=n;k++)
        for(ll i=1;i<=n;i++)
            for(ll j=1;j<=n;j++)
                if( dp[i][j] > dp[i][k] + dp[k][j] )
                    dp[i][j] = dp[i][k] + dp[k][j];
}

// Use when new roads to be build 
void update(ll s,ll d,ll w)
{
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if( dp[i][j] > dp[i][s] + w + dp[d][j] )
                dp[i][j] = dp[i][s] + w + dp[d][j];
                
            if( dp[i][j] > dp[i][d] + w + dp[s][j] )
                dp[i][j] = dp[i][d] + w + dp[s][j];
            
        }
    }

}

int main()
{
    ll x,y;
    cin>>n>>x>>y;
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
           cost[i][j] = abs(i-j);
            dp[i][j] = cost[i][j];
        }
    }
   
    
  /*  for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;    
    } */    

       
    update(x,y,1);

    ll res[n+1];
    memset(res,0,sizeof res);
    for(ll i=1;i<n+1;i++){
        for(ll j=i+1;j<=n;j++){
            res[dp[i][j]]++;
        }
    }

    for(ll i=1;i<n;i++)
        cout << res[i] << endl;

        
	return 0;
}

Measured memory_bytes: 96128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <numeric>
#include <type_traits>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const int INF = 10000000;

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

int main(){
    ll a, b; cin >> a >> b;
    ll x = gcd(a, b);
    cout << a*b/ x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N =2e5+5;
ll t[2*N],h[N],b[N],n,ans=0;
pair<ll,ll> a[N];

ll query(ll l, ll r)
{
	ll ret=0;
	for(l+=n,r+=n;l<r;l>>=1,r>>=1)
	{
		if(l&1)ret=max(ret,t[l++]);
		if(r&1)ret=max(ret,t[--r]);
	}
	return ret;
}

ll update( ll x, ll v)
{
	x+=n;
	while(x>=1)
	{
		t[x]=max(t[x],v);
		x>>=1;
	}
}


int main()
{
    ios_base::sync_with_stdio(false);

    clr(t);
	cin>>n;forn(i,n){cin>>h[i];a[i].F=h[i];a[i].S=i;}forn(i,n)cin>>b[i];
	sort(a,a+n);
	forn(i,n)
	{
		//cout<<a[i].F<<" "<<a[i].S<<" ";
		ll x=a[i].S;
		ll k=query(0,x);//cout<<k<<" ";
		ll v=k+b[x];
		ans=max(ans,v);
		update(x,v);//cout<<query(x,x+1)<<endl;
		//cout<<x<<" "<<v<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9728
// Sakhiya07 - Yagnik Sakhiya

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

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>

#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
string s;
ll dp[N][2];
ll solve1(ll id,ll free)
{
    if(id==s.size())   return 1;
    ll ans = dp[id][free];
    if(ans!=-1)   return ans;
    ans = 0;
    if(free==0)
    {
        ans = (ans + 3*solve1(id+1,0))%MOD;
    }
    else
    {
        ll range = s[id] - '0';
        if(range==0)   
        {
            ans = solve1(id+1,free);
        }
        else
        {
            ans = (ans + solve1(id+1,0))%MOD;
            ans = (ans + 2*solve1(id+1,1))%MOD;
        }    
    }
    return dp[id][free] = ans;
}
void solve()
{
    memset(dp,-1,sizeof(dp));
    cin >> s;
    ll ans = solve1(0,1);
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 8272
#include <iostream>
using namespace std;
string check(int arr[])
{
	for(int i = 0; i < 'z'-'a'+1; i++)
		if( arr[i] % 2 != 0)
			return "No";
	return "Yes";
}
int main()
{
	string s;
	cin >> s;
	int arr['z'-'a'+1]{};
	for(int  i = 0; i < s.size(); i++)
		arr[s[i]-'a']++;
	cout << check(arr);
}
  

Measured memory_bytes: 256
import sys
N = int(input())
As = list(map(int, input().split()))
cnt = 0
for i, a in enumerate(As):
    if i+1 != a:
        if As[a-1] == i+1:
            cnt +=1
        else:
            print("NO")
            sys.exit()

if cnt//2 <= 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int rsl = 0;
    string tmp = "";
    rep(i, 0, S.size()) {
        if(i % 2 == 0) tmp += '1';
        else tmp += '0';
    }

    rep(i, 0, S.size()) {
        if(S[i] != tmp[i]) rsl += 1;
    }

    int a = S.size() - rsl;
    cout << min(rsl, a) << endl;

}


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

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

    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    vector<int> sum(N);
    for (int i = 0; i < N; i++) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
        sum.at(i) = x.at(i) + y.at(i);
    }

    bool flag = false;
    for (int i = 0; i < N; i++) {
        if (t.at(i) >= sum.at(i) && t.at(i) % 2 == sum.at(i) % 2) {
            continue;
        }
        else {
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var dp = Enumerable.Repeat((int)1e9, N).ToArray();
            dp[0] = 0;
            dp[1] = Math.Abs(H[1] - H[0]);
            for (var i = 2; i < N; i++)
            {
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(H[i - 1] - H[i]));
                dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(H[i - 2] - H[i]));
            }
          
            Console.WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 35696
# coding:utf-8

n = int(input())

if n == 0:
    print(0)
    exit()

ans = ''
while abs(n) > 0:
    if n % 2 != 0:
        ans += '1'
        n -= 1
        n //= -2
    else:
        ans += '0'
        n //= -2

print(ans[::-1])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int maxn=1e5+100;
vector<int>g[maxn];
int n,vis[maxn],par[maxn];
map<pair<int,int>,int>mp;
vector<pair<int,int>>V;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
        V.emplace_back(x,y);
    }
    queue<int>que;
    que.push(0);
    vis[0]=1;
    int K=0;
    while(!que.empty()){
        int u=que.front(); que.pop();
        if(K<g[u].size()) K=g[u].size();
        int cur=1;
        for(auto v:g[u]){
            if(vis[v]) continue;
            if(par[u]==cur) cur++;
            par[v]=mp[make_pair(u,v)]=mp[make_pair(v,u)]=cur++;
            vis[v]=1;
            que.push(v);
        }
    }
    printf("%d\n",K);
    for(auto p:V) printf("%d\n",mp[p]);
    return 0;
}

Measured memory_bytes: 20084
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll A[9];
    REP(i,9) A[i]=1LL<<50;
    ll N;
    cin>>A[1]>>A[2]>>A[4]>>A[8];
    cin>>N;
    N*=100;
    REP(i,9){
        REP(k,9) if(k*i<9){
            A[k*i]=min(A[k*i],k*A[i]);
        }
    }
    ll ans=0;
    for(int i=8;i>=1;--i){
        ans+=(N/(25*i))*A[i];
        N-=(N/(25*i))*(25*i);
    }
    cout<<ans<<endl;
}


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

using i64 = long long int;

int dir[2][300005]={0};

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=1;i<=n;++i){
        dir[0][n-i+1] = dir[0][n-i+2] + (s[n-i] == 'E' ? 1 : 0);
        dir[1][i] = dir[1][i-1] + (s[i-1] == 'W' ? 1 : 0);
    }

    int ans = n;
    for(int i=1;i<=n;++i){
        ans = min(ans, dir[1][i-1] + dir[0][i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3076
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1),i=new(n(2))(r.readFileSync("/dev/stdin","utf8").split(/\s+/g));n(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3);t.exports=class{constructor(t){this.inp=new r(t)}n(){return this.inp.deq()}ni(){return parseInt(this.inp.deq(),10)}add(t){this.inp.enq(t)}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.ni(),n=new Array(e),r=0;r<e;r++)n[r]=[];for(var i=0;i<e-1;i++){var o=t.ni(),s=t.ni(),u=t.ni();n[o-1].push([s-1,u]),n[s-1].push([o-1,u])}for(var f=t.ni(),a=t.ni(),c=new Array(e).fill(-1),l=[[a-1,0]];l.length>0;)for(var p=l.pop(),d=n[p[0]].length,h=0;h<d;h++){var v=n[p[0]][h];if(-1==c[v[0]]){var y=p[1]+v[1];c[v[0]]=y,l.push([v[0],y])}}for(var b=[],g=0;g<f;g++){var m=t.ni()-1,x=t.ni()-1,j=c[m]+c[x];b.push(j)}console.log(b.join("\n"))}}]);

Measured memory_bytes: 119408
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> a[100];
int main(){
	int t=0,g;
	string f;
	while(cin>>a[t].first>>a[t].second)t++;
	sort(a,a+t);
	cout<<a[0].first<<endl<<a[0].second;
	for(int i=1;i<t;i++){
		bool n=false;
		f=a[i].first,g=a[i].second;
		if(i)if(f==a[i-1].first)n=true;
		if(n)cout<<" "<<g;
		else cout<<endl<<f<<endl<<g;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1228
/*
 * main.c
 *
 *  Created on: 2019/06/02
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
	printf("%d\n",180*(N-2));
    return 0;
}


Measured memory_bytes: 128
N= int(input())
E = [input().split()[2:] for _ in [0]*N]
Q = [0]
L = [0] + [-1]*N
def func(ide):
    global Q
    for i in E[ide]:
        i = int(i) - 1
        if L[i] < 0 :L[i] = L[ide] +1 ;Q += [i]
    

while Q:top = Q.pop(0);func(top)

for i in range(N):print(i + 1 ,int(L[i]))



Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999
int main() {
	int a = 0, b = 0, c = 0, n = 0;
	int ar[100000] = {};
	std::string str;
	std::cin >> a >> b;
	n += a - 1;
	if (b >= a) {
		n++;
	}
	std::cout << n << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    string A,B,C;
    cin >> A >> B >> C;
    int ans = 0;
    REP(i,N)
    {
        int count[3] = {1,1,1};
        char a,b,c;
        a = A[i];
        b = B[i];
        c = C[i];
        if(b == a)
        {
            count[1]++;
        }
        if(c == a) count[0]++;
        if(c == b) count[1]++;

        ans += 3 - (*max_element(begin(count), end(count)));

    }

    cout << ans << endl;

}


Measured memory_bytes: 256
var N,
    RISHI = 0.05,
    MIN = 1000,
    money = 100000;
    
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on("data",function(chunk){
    N = Number(chunk);
    for (var i = 0; i < N; i++) {
    money = Math.ceil((money + money * RISHI) / MIN) * MIN;    
    }
    console.log(money)
})

Measured memory_bytes: 15444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	ll a, b,n;
	cin >>n>>a>>b;
	ll agc = n;
	if (a < b)swap(a, b);
	ll x = a - b;
	if (x % 2 == 1) {
		if (n - a <= b - 1) agc = (n-(b+n-a)+2)/2+n-a;
		else  agc =(a-(b-1)+1)/2+b-1;
	}
	else  agc = x / 2;

	cout << agc << endl;
	return 0;
}


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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-5
#define inf 1e14

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n;
string s;

int main()
{
    cin >> n >> s;
    int r = count(all(s), 'R');
    int b = count(all(s), 'B');
    cout << (r > b ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int n;
int a[10000],b[10000];
vector<int> c;
vector<int> ch[10000];
int ans[10000];
int cnt=0;
void dfs(int now){
	ans[now]=c[cnt];
	cnt++;
	for(int i=0;i<ch[now].size();i++){
		if(ans[ch[now][i]]==0){
			dfs(ch[now][i]);
		}
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		ch[a[i]].push_back(b[i]);
		ch[b[i]].push_back(a[i]);
	}
	for(int i=0;i<n;i++){
		int d;
		cin>>d;
		c.push_back(d);
	}
	sort(c.rbegin(),c.rend());
	int sum=0;
	for(int i=1;i<n;i++){
		sum+=c[i];
	}
	cout<<sum<<endl;
	dfs(0);
	for(int i=0;i<n;i++){
		cout<<ans[i];
		if(i==n-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;
bool b[10];
int n, a[10];
void f(int k) {
	if (k == n) {
		for (int i = 0; i < n; i++) {
			if (i)cout << ' '; cout << a[i];
		}cout << endl;
	}
	for (int i = 1; i <= n; i++)if (!b[i]) {
		b[i] = 1;
		a[k] = i;
		f(k + 1);
		b[i] = 0;
	}
	return;
}
signed main() {
	cin >> n; f(0);
}


Measured memory_bytes: 3124
#include<iostream>
#include<queue> 
using namespace std;
int map[5][5];
int dx[5]={0,0,1,-1},dy[5]={1,-1,0,0};
queue<int> a1,a2,a3,a4,a5,a6,a7,a8,a9,jx,jy;
queue<int> a;
bool pd[45000000];
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++) {
		    cin>>map[i][j];
		    if(i==1 && j==1) a1.push(map[i][j]);
		    else if(i==1 && j==2) a2.push(map[i][j]);
		    else if(i==1 && j==3) a3.push(map[i][j]);
		    else if(i==2 && j==1) a4.push(map[i][j]);
		    else if(i==2 && j==2) a5.push(map[i][j]);
		    else if(i==2 && j==3) a6.push(map[i][j]);
		    else if(i==3 && j==1) a7.push(map[i][j]);
		    else if(i==3 && j==2) a8.push(map[i][j]);
		    else if(i==3 && j==3) a9.push(map[i][j]);
		    if(map[i][j]==0){
		    	jx.push(i);
		    	jy.push(j);
		    	a.push(0);
		    }
		}
	}
	int jishu=0;
	jishu=a1.front();
	jishu=jishu*9+a2.front();
	jishu=jishu*9+a3.front();
	jishu=jishu*9+a4.front();
	jishu=jishu*9+a5.front();
	jishu=jishu*9+a6.front();
	jishu=jishu*9+a7.front();
	jishu=jishu*9+a8.front();
	pd[jishu]=1;
	jishu=0;
	while(a1.front()!=1  || a2.front()!=2 || a3.front()!=3 || a4.front()!=4 || a5.front()!=5 || a6.front()!=6 || a7.front()!=7 || a8.front()!=8 || a9.front()!=0){
		for(int i=0;i<=3;i++){
			if(jx.front()+dx[i]>=1 && jx.front()+dx[i]<=3 && jy.front()+dy[i]>=1 && jy.front()+dy[i]<=3){
				map[1][1]=a1.front();
		        map[1][2]=a2.front();
		        map[1][3]=a3.front();
		        map[2][1]=a4.front();
		        map[2][2]=a5.front();
		        map[2][3]=a6.front();
		        map[3][1]=a7.front();
		        map[3][2]=a8.front();
		        map[3][3]=a9.front();
				
				map[jx.front()][jy.front()]=map[jx.front()+dx[i]][jy.front()+dy[i]];
				map[jx.front()+dx[i]][jy.front()+dy[i]]=0;
				
				jishu=map[1][1];
	            jishu=jishu*9+map[1][2];
	            jishu=jishu*9+map[1][3];
	            jishu=jishu*9+map[2][1];
	            jishu=jishu*9+map[2][2];
	            jishu=jishu*9+map[2][3];
	            jishu=jishu*9+map[3][1];
	            jishu=jishu*9+map[3][2];
	            
				if(pd[jishu]==1) continue;
	            else pd[jishu]=1;
			    
				for(int i1=1;i1<=3;i1++){
			    	for(int i2=1;i2<=3;i2++){
			    		if(i1==1 && i2==1) a1.push(map[i1][i2]);
		                else if(i1==1 && i2==2) a2.push(map[i1][i2]);
		                else if(i1==1 && i2==3) a3.push(map[i1][i2]);
		                else if(i1==2 && i2==1) a4.push(map[i1][i2]);
		                else if(i1==2 && i2==2) a5.push(map[i1][i2]);
		                else if(i1==2 && i2==3) a6.push(map[i1][i2]);
		                else if(i1==3 && i2==1) a7.push(map[i1][i2]);
		                else if(i1==3 && i2==2) a8.push(map[i1][i2]);
		                else a9.push(map[i1][i2]);
			    	}
			    }
			    jx.push(jx.front()+dx[i]);
			    jy.push(jy.front()+dy[i]);
			    a.push(a.front()+1);
			}
		
		}
		a1.pop(); 
		a2.pop(); 
		a3.pop(); 
		a4.pop(); 
		a5.pop(); 
		a6.pop(); 
		a7.pop(); 
		a8.pop(); 
		a9.pop(); 
		jx.pop();
		jy.pop();
		a.pop();
	} 
	cout<<a.front()<<endl;
	return 0;
} 

Measured memory_bytes: 26508
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
    ll X;
    cin>>X;
    ll ans=0;
    ans+=X/500*1000;
    X%=500;
    ans+=X/5*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=2e5+10;

    const double PI=acos(-1);
    int pos[N];
    void main()
    {
        int n=qread(),L=qread();
        fo(i,1,n) pos[i]=qread();
        double ansx=0,ansy=0;
        fo(i,1,n) fo(j,i+1,n)
        {
            int a=j-i-1;ansx+=a*cos(PI*2/L* (pos[i]+pos[j]-L)/2 );ansy+=a*sin(PI*2/L* (pos[i]+pos[j]-L)/2 );
            int b=(i-1)+(n-j);ansx+=b*cos(PI*2/L* (pos[i]+pos[j])/2 );ansy+=b*sin(PI*2/L* (pos[i]+pos[j])/2 );
        }
        ll all=1ll*n*(n-1)*(n-2)/2/3;printf("%.15lf %.15lf",ansx/all,ansy/all);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
import heapq
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for i in range(N)]

# おいしさ順にソート
sushi.sort(key=lambda x: x[1], reverse=True)

# 取りうる最大の種類数
MAX_various = min(K, len(set([t for t, d in sushi])))

# 食べる寿司を管理
eat = []
# 食べた寿司の種類を管理
various = set()
# 食べなかった寿司を管理
remain_sushi = []

score = 0
# 最大種類食べる
cnt = 0
for t, d in sushi:
    if (t not in various) and (cnt != MAX_various):
        score += d
        heapq.heappush(eat, d)
        various.add(t)
        cnt += 1
    else:
        remain_sushi.append([t, d])

score += len(various) ** 2

# 最大種類食べてもK個食べたことにならない場合、不足分をここで補充
for t, d in remain_sushi[:K - MAX_various]:
    score += d
    heapq.heappush(eat, d)
remain_sushi = remain_sushi[K - MAX_various:]

# 残り物でおいしい順に、寿司を交換しながら一番いい解を探す
ans = score
various = len(various)
for t, d in remain_sushi:
    add_ans = ans - eat[0] + d - (various ** 2) + (various - 1) ** 2
    if add_ans > ans:
        heapq.heapreplace(eat, d)
        ans = add_ans
        various -= 1

print(ans)


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

map<string, int> days;

int main() {
  days["SUN"] = 7;
  days["MON"] = 6;
  days["TUE"] = 5;
  days["WED"] = 4;
  days["THU"] = 3;
  days["FRI"] = 2;
  days["SAT"] = 1;

  string S;
  cin >> S;
  cout << days[S] << endl;
  return 0;
}



Measured memory_bytes: 256
N,T = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]
L.sort()
flag = False
for i in range(N):
  if (L[i][1] > T):
    None
  else:
    flag = True
    break
if flag:
  print(L[i][0])
else:
  print('TLE')

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

int main(){
int H,W;
while(true){
std::cin>>H>>W;
if(H==0&&W==0)break;
for(int i=1;i<1+H;i++){
for(int j=1;j<1+W;j++){
if(i%2==1&&j%2==1)std::cout<<"#";
else if(i%2==0&&j%2==0){
    std::cout<<"#";
    }else if(i%2==1&&j%2==0){
        std::cout<<".";
    }else {
        std::cout<<".";
    }
}
std::cout<<std::endl;
}
std::cout<<std::endl;
}
return 0;
}


Measured memory_bytes: 3072