akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define MAX_N 500
#define MAX_K 500
#define MAX_V 1002
#define INF 1000000000


struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V]; 
void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int N, K;
bool can[MAX_N][MAX_K];
void solve() {
    int s = N + K, t = s + 1;
    for (int i = 0; i < N; i++) {
        add_edge(s, i, 1);
    }
    for (int i = 0; i < K; i++) {
        add_edge(N + i, t, 1);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            if (can[i][j]) {
                add_edge(i, N + j, 1);
            }
        }
    }
    printf("%d\n",max_flow(s,t));
}

int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a % b == 0)
        return b;
    return gcd(b,a % b);
}

int inb[500],inr[500];

bool input(){
    scanf("%d%d",&N,&K);
    if(N == 0 && K == 0)
        return false;
    REP(i,N)
        scanf("%d",&inb[i]);
    REP(i,K)
        scanf("%d",&inr[i]);

    memset(can,false,sizeof(can));
    REP(i,N){
        REP(j,K){
            if(gcd(inb[i],inr[j]) > 1)
                can[i][j] = true;
        }
    }
    REP(i,N + K + 2){
        while(!G[i].empty()){
            G[i].pop_back();
        }
    }
    return true;
}

int main(){
    while(input()){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9720
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int a, b, c;
    string ans;
    
    cin >> a >> b >> c;
    
    if(a == b || b == c || c == a) ans = "Yes";
    else ans = "No";
    
    if(a == b && b == c) ans = "No";
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,a,b;
  scanf("%d %d %d\n",&n,&a,&b);

  int t,tmp,count;
  count=0;
  for (size_t i = 1; i <= n; i++) {
    t=i;

    tmp = t%10;
    while ((t / 10) != 0) {

      tmp += (t/10)%10;
      t /= 10;
    }
    if (a<=tmp && tmp <=b) {
      count+=i;
    }
  }
  printf("%d\n",count );
  return 0;
}


Measured memory_bytes: 384
import sys

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

def main():
	a,b = MI()
	n = (b-a)/(a-1)
	if(b==1):print(0)
	elif(a>b):print(1)
	elif(n%1==0):print(int(n)+1)
	else:print(int(n)+2)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();
    int n, m;
    cin >> n >> m;

    while(n > 0){
        map<int, int> mp;
        vector<int> h(n+1, 0), w(m+1, 0);
        rep(i, n) cin >> h[i+1];
        rep(i, m) cin >> w[i+1];
        rep(i, n) h[i+1] += h[i];
        rep(i, m) w[i+1] += w[i];

        rep(i, n)REP(j, i+1, n+1){
            int now = h[j]-h[i];
            mp[now]++;
        }

        LL ans = 0;
        rep(i, m)REP(j, i+1, m+1){
            int now = w[j]-w[i];
            ans += mp[now];
        }
        cout << ans << endl;
        cin >> n >> m;
    }
}


Measured memory_bytes: 20948
#include<ios>
#include<string.h>

int main(){
    int iN,iM;
    char sS[100][11],sT[100][11];
    scanf("%d",&iN);
    for(int i=0;i<iN;i++){
        scanf("%s",sS[i]);
    }
    scanf("%d",&iM);
    for(int i=0;i<iM;i++){
        scanf("%s",sT[i]);
    }
    int iMax = 0;
    for(int i = 0;i<iN;i++){
        int iC = 1;
        for (int j = 0;j<iN;j++){
            if (i==j) continue;
            if (strcmp(sS[i],sS[j]) == 0) iC++;
        }
        for (int j= 0;j<iM;j++){
            if (strcmp(sS[i],sT[j]) == 0) iC--;
        }
        if (iMax < iC) iMax = iC;
    }
    printf("%d\n",iMax);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };

    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };

    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };

    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }

private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }

private:
    int* number;
    int* checkTable;
};

int main(int argc, const char * argv[]) {
        Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d", &tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d", &inputed[i]);

    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (char c : s) {
    sum += c - '0';
  }
  if (sum %9) cout << "No\n";
  else cout << "Yes\n";
}

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

const Int inf = 1LL<<55;

Int n;
Int p[111];
vector<Int> graph[111];

unordered_map<Int, Int> mp;

using Pi = pair<Int, Int>;

Pi val[111][222][222];
Int dp_min[111][222][222];
Int dp_max[111][222][222];
bool visited[111][222][222];

Pi dfs(Int v, Int a, Int b) {
  if(visited[v][mp[a]][mp[b]]) return val[v][mp[a]][mp[b]];
  visited[v][mp[a]][mp[b]] = true;  
  if(graph[v].empty()) {
    dp_min[v][mp[a]][mp[b]] = 1;
    dp_max[v][mp[a]][mp[b]] = 1;
    val[v][mp[a]][mp[b]] = Pi(p[v], p[v]);
    //cout<<v<<" "<<val[v][mp[a]][mp[b]].first<<" "<<val[v][mp[a]][mp[b]].second<<endl;
    return val[v][mp[a]][mp[b]];
  }
  val[v][mp[a]][mp[b]] = Pi(-inf, inf);
  dp_min[v][mp[a]][mp[b]] = inf;
  dp_max[v][mp[a]][mp[b]] = -inf;  
  do {
    Pi a_tmp = Pi(a, a), b_tmp = Pi(b, b);
    Int mn = 0, mx = 0;
    bool f_mn = true, f_mx = true;
    for(Int u : graph[v]) {
      if(f_mn) {
	Int x = -dfs(u, -b_tmp.first, -a_tmp.first).first;
	mn += dp_min[u][mp[-b_tmp.first]][mp[-a_tmp.first]];
	if(x >= b_tmp.first) {
	  a_tmp.first = x;
	  f_mn = false;
	} else if(x > a_tmp.first) {
	  a_tmp.first = x;
	}
      }
      if(f_mx) {
	Int x = -dfs(u, -b_tmp.second, -a_tmp.second).second;
	mx += dp_max[u][mp[-b_tmp.second]][mp[-a_tmp.second]];	
	if(x >= b_tmp.second) {
	  a_tmp.second = x;
	  f_mx = false;
	} else if(x > a_tmp.second) {
	  a_tmp.second = x;
	}
      }
    }
    if(dp_min[v][mp[a]][mp[b]] >= mn) {
      dp_min[v][mp[a]][mp[b]] = mn;
      val[v][mp[a]][mp[b]].first = max(val[v][mp[a]][mp[b]].first, a_tmp.first);
    }
    if(dp_max[v][mp[a]][mp[b]] <= mx) {
      dp_max[v][mp[a]][mp[b]] = mx;
      val[v][mp[a]][mp[b]].second = min(val[v][mp[a]][mp[b]].second, a_tmp.second);
    }
  }while(next_permutation(graph[v].begin(), graph[v].end()));
  //cout<<v<<" "<<val[v][mp[a]][mp[b]].first << " " << val[v][mp[a]][mp[b]].second << endl;
  return val[v][mp[a]][mp[b]];
}

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

  cin >> n;
  for(Int i = 0; i < n; ++i) cin >> p[i];
  for(Int i = 0; i < n; ++i) {
    Int k; cin >> k;
    for(Int j = 0; j < k; ++j) {
      Int t; cin >> t; --t;
      graph[i].push_back(t);
    }
    sort(graph[i].begin(), graph[i].end());
  }
  vector<Int> vec;
  vec.push_back(-inf);
  vec.push_back(inf);
  for(Int i = 0; i < n; ++i) {
    vec.push_back(p[i]);
    vec.push_back(-p[i]);
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for(Int i = 0; i < n; ++i) {
    mp[p[i]] = lower_bound(vec.begin(), vec.end(), p[i])-vec.begin();
    mp[-p[i]] = lower_bound(vec.begin(), vec.end(), -p[i])-vec.begin();
  }
  memset(visited, false, sizeof(visited));
  dfs(0, -inf, inf);
  cout << dp_min[0][mp[-inf]][mp[inf]] << " " << dp_max[0][mp[-inf]][mp[inf]] << endl;
  
  return 0;
}



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

#define  ll   long long
#define  pb  push_back
#define  mp  make_pair
#define  MAX  500006
#define  MAX1  10000008
#define  mem(a,v)   memset(a,v,sizeof(a))

template <typename T>
T mymax (T a,T b){return (a>b)?a:b;}
template <typename T>
T mymin (T a,T b){return (a<b)?a:b;}
template <typename T>
T myabs (T a){return (a<0)?(-1*a):a;}
template <typename T>
T mysqrt (T x){if (x == 0 | x == 1)return x;int start = 1, End = x, ans;while (start <= End){int mid = (start + End) / 2;if (mid*mid == x)return mid;if (mid*mid < x){start = mid + 1;ans = mid;}else End = mid-1;}return ans;}

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}

int main ()
{
    fastIO();
    ll a,b,c,n,m,k,p,q,r;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    float x,y,z;
    ll Max= 0,Max1=-1e18+1;
    ll Min = 1e18;
    string s,s1,s3,s4;
    int Ab[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cin>>n;

    cout<<Ab[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
string s;
long long i, k;
int main() {
	cin>>s>>k;
	for(i=0; i<s.size() && s[i]==s[0]; i++);
	if(i==s.size()) {cout<<s[0]; return 0;}
	for(i=0; s[i]=='1'; i++);
	cout<<(i<k ? s[i] : '1');
	return 0;
}

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

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

int main(){
    int n, y;
    cin >> n >> y;
    int yukichi = y / 10000;
    for(int i = yukichi; i>=0; i--){
        int rest_money = y - 10000 * i;
        int rest_paper = n - i;
        int ichiyo = rest_money / 5000;
        for(int j = ichiyo; j>=0; j--){
            int last_money = rest_money - 5000 * j;
            int last_paper = rest_paper - j;
            if(last_money == 1000 * last_paper){
                printf("%d %d %d\n", i, j, last_paper);
                return 0;
            }
        }
    }
    printf("%d %d %d\n", -1, -1, -1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 +5,M = 2e5 + 5;
int n,m,h[N],ans,vis[N];
int fir[N],to[M << 1],nxt[M << 1];
int main() {
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1;i <= n;++i)
		cin >> h[i],vis[i] = 1;
	for(int i = 1,u,v;i <= m;++i) {
		cin >> u >> v;
		if(h[u] <= h[v]) vis[u] = 0;
		if(h[v] <= h[u]) vis[v] = 0;
	}
	for(int i = 1;i <= n;++i)
		if(vis[i]) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4436
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
 
using namespace std;
 
#define x first
#define y second
#define NMAX 100005
#define INF 1000000007
#define MOD 1000000007
 
int n, v[NMAX], have;
long long answer;
 
int main (){
 
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
        scanf("%d",&v[i]);
    have = 0;
    answer = 1;
    for(int i = 1; i <= n; i++){
        if(v[i] < 2 * have){
            answer = answer * have % MOD;
            //printf("%d %d %lld\n", i, have, answer);
        }
        else if(v[i] <= 2 * have){
            answer = answer * (have + 1) % MOD;
        }
        else
            have++;
    }
    //printf("%d\n", have);
    while(have){
        answer = answer * have % MOD;
        have--;
    }
    
    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 512
H, W = map(int, input().split())
hmax = H
board = []
for _ in range(H):
	line = list(input().rstrip())
	if '#' in line:
		board.append(line)
	else: hmax -= 1

cnt = [0] * W
for line in board:
	for w, px in enumerate(line):
		if px == '.': cnt[w] += 1

for line in board:
	for w, px in enumerate(line):
		if cnt[w] == hmax: continue
		else: print(px, end='')
	print()

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

int main() {
   int n, m;
   cin >> n >> m;
   int a[m];
   int count = 0;
   rep (i, m) {
       cin >> a[i];
       count += a[i];
   }

   if (n >= count) {
       cout << n - count << endl;
   } else {
       cout << -1 << endl;
   }
}

Measured memory_bytes: 3568
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    val H = LongArray(N) { nextLong() }.sorted()
    val ans = (0..N - K).map { H[it + K - 1] - H[it] }.min()!!
    println(ans)
}

Measured memory_bytes: 63972
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=1e5+10;

int main()
{
	boost;
	ll n;
	cin>>n;
	cout<<(n*n-n)/2;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size() - 1) cout << V.at(i) << " "; cout << endl 

int
main()
{
  string S, T;
  cin >> S;
  cin >> T;

  S += S;

  bool flg = false;
  for (int i = T.size(); 0 < i; i--) {
    if (flg) break;

    if (T == S.substr(i, T.size())) flg = true;
  }

  if (flg) ANS("Yes");
  else ANS("No");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;

int modd=1e9+7;

int main(){
  int n; cin>>n; int len=pow(2,n);

  int arr[n][n];
  for(int i=0; i<n; i++) for(int j=0; j<n; j++) cin>>arr[i][j];

  long long dp[len+1]; dp[0]=1;
    for(int j=1; j<=len; j++) dp[j]=0;

  int mask[n]; for(int i=0; i<n; i++) mask[i]=0;
  int csb=0;

  for(int i=0; i<len-1; i++){
    for(int j=0; j<n; j++){
        if(mask[j]==0 && arr[csb][j]==1) dp[i|(1<<j)]=(dp[i|(1<<j)]+dp[i])%modd;
    }
    for(int j=0; j<n; j++){ if(mask[j]==0){ mask[j]=1; csb++; break; } mask[j]=0; csb--; }
  }

  cout<<dp[len-1]<<endl;
}


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

i = 1
cnt = 1
flag = False
while True:
    cnt += 1
    if i == n:
        flag = True
        break
    if i > n:
        break
    i += cnt

# nがkC2(kは自然数) <-> 構築可能
if not flag:
    print("No")
    exit()

print("Yes")
print(cnt)
li = [[] for i in range(cnt)]
num = 1
for i in range(cnt):
    tmp_num = num
    for _ in range(cnt - i - 1):
        li[i].append(tmp_num)
        tmp_num += 1
    for j in range(i+1, cnt):
        li[j].append(num)
        num += 1
for li2 in li:
    print(len(li2), *li2)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    if(a == b && b != c){
        cout << "Yes" << endl;
    }
    else if(a == c && a != b){
        cout << "Yes" << endl;
    }
    else if(b == c && b != a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
    char s[1000],t[1000],u[1000];
    int a,b;
    scanf("%s",s);
    scanf("%s",t);
    scanf("%d%d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0) printf("%d %d\n",a-1,b);
    if(strcmp(t,u)==0) printf("%d %d\n",a,b-1);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
    int d,i,x;
    long long int a=0,s=0;

    while(scanf("%d",&d)!=EOF){
    a=d;
    x=600/d;
    for(i=0;i<x-1;i++){
        s=s+(d*a*a);
        a+=d;
    }
        printf("%lld\n",s);
        s=0;
    }
        return 0;
}

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


int N;
int bench[5]={105, 135,165,189,195};
int main(){
	cin >> N;
	if(N<bench[0]) {
		cout << 0 << endl;
		return 0;
	}
	else if (bench[0]<= N && N < bench[1]){
		cout << 1 << endl;
		return 0;
	}
	else if (bench[1]<= N && N <bench[2]){
		cout << 2 << endl;
		return 0;
	}
	else if (bench[2]<= N && N <bench[3]){
		cout << 3 << endl;
		return 0;
	}
	else if (bench[3]<= N && N <bench[4]){
		cout << 4 << endl;
		return 0;
	}
	else if (bench[4]<= N){
			cout << 5 << endl;
			return 0;
		}
}

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

for i in range(N):
	if A[i]%4==0:
		A[i]=4
	elif A[i]%4!=0 and A[i]%2==0:
		A[i]=2
	else:
		A[i]=1
if A.count(2)==0:
	if A.count(4)+1<A.count(1):
		print("No")
	else:
		print("Yes")
else:
	if A.count(4)<A.count(1):
		print("No")
	else:
		print("Yes")	

Measured memory_bytes: 14252
N, M, Q = gets.split.map(&:to_i)
Ary = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
result = 0

(1..M).to_a.repeated_combination(N) do |perm|
  perm.sort!

  tmp_result = 0
  Ary.each do |line|
    if perm[line[1] - 1] - perm[line[0] - 1] == line[2]
      tmp_result += line[3]
    end
  end

  if result < tmp_result
    result = tmp_result
  end
end

puts result


Measured memory_bytes: 14756
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	
	if(a < 10) {
		a = 100 * (10 - a);
		b = b + a;
		printf("%d", b);
	} else {
		printf("%d", b);
	}
	
	return 0;
}

Measured memory_bytes: 1720
n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0

def enqueue(u, t):
    global tail
    Q[tail] = [u, t]
    tail = (tail + 1) % MAX

def dequeue():
    global head
    x,t = Q[head]
    head = (head + 1) %MAX
    return [x,t]
for i in range(n):
    P = list(input().split())
    enqueue(P[0], int(P[1]))

elaps = 0
while head != tail:
    u,t = dequeue()
    c = min(q, t)
    t -= c
    elaps += c
    if t > 0:
        enqueue(u,t)
    else:
        print(u + " " + str(elaps))

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


def is_prime(num):
    i = 2
    while i ** 2 <= num:
        if num % i == 0:
            return False
        i += 1
    return True


candi = []
for i in range(2, 55556):
    if is_prime(i) and i % 5 == 1:
        candi.append(i)

print(*candi[:n])


Measured memory_bytes: 3060
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;
   VI L(N);
   REP(i, N)
      cin >> L[i];
   sort(L.begin(), L.end());

   int res = 0;
   REP(i, N) {
      FOR(j, i+1, N-1) {
         if (L[i] == L[j]) continue;
         FOR(k, j+1, N-1) {
            if (L[k] == L[j]) continue;
            if (L[i] + L[j] > L[k])
               ++res;
         }
      }
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 3660
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
vi v;
set<ll>st;
void fun(ll num,ll digit,ll len,ll cur_len)
{
	if(cur_len==len)
	{
		if(st.find(num)==st.end())
		{
			v.pb(num);
			st.insert(num);
		}
		return;
	}
	if(digit==0)
	{
		fun(num*10+0,0,len,cur_len+1);
		fun(num*10+1,1,len,cur_len+1);
		return;
	}
	if(digit==9)
	{
		fun(num*10+8,8,len,cur_len+1);
		fun(num*10+9,9,len,cur_len+1);
		return;
	}
	fun(num*10+digit-1,digit-1,len,cur_len+1);
	fun(num*10+digit,digit,len,cur_len+1);
	fun(num*10+digit+1,digit+1,len,cur_len+1);
}
void solve()
{
	ll n;
	cin>>n;
	rep(i,0,10)
	{
		rep(j,1,10)
		{
			fun(j,j,i+1,1);
			if(i==9 && j==3)
				break;
		}
	}
	cout<<v[n-1]<<endl;
	// rep(i,0,20)
	// cout<<v[i]<<" ";
	// cout<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

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

using namespace std;

const int MaxN = 1000005;
const long long Mod = 1000000007;

long  long n;
long long f[MaxN];

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    long long sum = n;
    f[n] = n;
    for (int i = n - 1; i >= 1; --i)
    {
        f[i] = (sum - f[i + 2] + i + (i != n - 1) + (n - 1) * (n - 1) + Mod * Mod) % Mod;
        sum = (sum + f[i])%Mod;
    }
    cout << f[1];
    return 0;
}

Measured memory_bytes: 8064
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	IOS;
	int n;	cin >> n;
	map<string, int> m;
	for(int i = 1; i <= n; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}	
	int ans = 0;
	for(auto i: m)
		ans += i.se*(i.se-1)/2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 11264
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a = input()

if a[0] == a[1] and a[1] == a[2]:
    j(0)
j(1)

Measured memory_bytes: 5692
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int i = 2;
	while (i)
	{
		if (i % 2 == 0)
		{
			C -= B;
			if (C <= 0)
				{
					cout << "Yes" << '\n';
					break;
				}
		}
		else
		{
			A -= D;
			if (A <= 0)
			{
					cout << "No" << '\n';
					break;
			}
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
const int VMAX = 106, EMAX = 10000;
const long long int INF = 100000000000;

long long int dist[VMAX][VMAX];

void init(int V) {
  REP(j, V) REP(i, V) {
    dist[i][j] = (i == j ? 0 : INF);
  }
}

void wf(int V) {
  REP(k, V) REP(i, V) REP(j, V) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
}

bool has_negcycle(int V) {
  REP(i, V) {
    if (dist[i][i] < 0) return true;
  }
  return false;
}

int main() {
  int V, E;
  cin >> V >> E;
  
  init(V);
  REP(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  wf(V);
  
  if (has_negcycle(V)) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, V) {
      REP(j, V) {
        if (dist[i][j] >= INF / 2) {
          cout << "INF";
        } else if (dist[i][j] == 0) {
          cout << 0;
        } else {
          cout << dist[i][j];
        }
        if (j < V - 1) cout << " ";
      }
      cout << endl;
    }
  }
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	map< ll,ll >v;
	ll n,x; cin >> n;
	bool ok = 1;
	for(int i = 0; i < n; i++){
		cin >> x;
		v[x]++;
		if(v[x]>1)ok=0;
	}
	if(ok)cout << "YES" << endl;
	else cout << "NO" << endl;
}	


Measured memory_bytes: 12800
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed           as V
import           Text.Printf

main :: IO ()
main = do
  [x, y, z, k] <- map read . words <$> getLine
  [as, bs, cs] <- replicateM 3 $ map read . words <$> getLine
  mapM_ print $f as bs cs k

f as bs cs k =
  let ab = take k . sortOn Down $ [ a + b | a <- as, b <- bs ]
  in  take k . sortOn Down $ [ a + c | a <- ab, c <- cs ]


Measured memory_bytes: 628220
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    long ans;
    const long mod = 1000000007; 

    int m = max(K-1, N-K+1);
    vector < vector <long> > dp(m+1, vector<long>(1,1));
    
    for(int i=1;i<=m;i++){
        for(int j= 1; j<i;j++){
            dp[i].emplace_back((dp[i-1][j-1] + dp[i-1][j]) % mod);
        }
        dp[i].emplace_back(1);
    }

    for(int i=1; i <= K ;i++){
        if(N-K < i-1) cout << 0 << endl;
        else cout << dp[K-1][i-1] * dp[N - K +1][i] % mod << endl;
    }
    
    return 0;
}

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

int main(){
    int x;
    cin >> x;
    if(x==22) cout << "Christmas Eve Eve Eve" << endl; 
    else if(x==23) cout << "Christmas Eve Eve" << endl; 
    else if(x==24) cout << "Christmas Eve"<< endl;
    else cout << "Christmas" << endl;

    }

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    s[5]= ' ';
    s[13]= ' ';
    cout << s <<endl;
}

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

void DFS(const Graph &G,int u,int v,vector<vector<bool>> &seen,vector<int> y, vector<int> x,int h,int w){//深さ優先探索。
//引数は順にグラフ、始点(注目点)、探索済みかどうか、y変位、x変位、y方向のグリッドサイズ、x方向のグリッドサイズ
  
  seen[u][v]=true;

  rep(k,8){
    int yd=u+y[k],xd=v+x[k];
    if(yd<0||h<=yd||xd<0||w<=xd) continue;//グラフの外側はスルー
    if(seen[yd][xd]) continue;//もう探索した場所はスルー
    if(G[yd][xd]==0) continue;//陸地でないならスルー
    DFS(G,yd,xd,seen,y,x,h,w);
  }
  return ;
}
 
int main() {

  while(1){

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

  if(w==0&&h==0) break;

  Graph G(h,vector<int> (w));//Grid

  rep(i,h){
    rep(j,w){
    cin >> G[i][j];
    }
  }//入力終了

  vector<vector<bool>> seen(h,vector<bool>(w,false));//探索済み
  int ans=0;//島の数

  vector<int> x={1,-1,0,0,1,1,-1,-1};
  vector<int> y={0,0,1,-1,-1,1,1,-1};

  rep(i,h){
    rep(j,w){
      if(seen[i][j]) continue;
      if(G[i][j]==0) continue;
      DFS(G,i,j,seen,y,x,h,w);

      ans++;//DFS一つ終わるたびに島+1
    }
  }
    cout << ans << endl;
  
  }
  return 0;
}


Measured memory_bytes: 3844
#入力し文字一つ一つにわける
str1 = [a for a in input()]
str2 = []

#文字を数字に変換し、シーザー暗号を変換して戻す
for num in str1:
    num1 = ord(num)
    if num1 < 68:
        num1 += 26
    num1 -= 3
    str2.append(chr(num1))
    
#出力
str2 = "".join(str2)
print(str2)



Measured memory_bytes: 5580
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
string digit(int p, int n, int k){
  // p shinsu, n keta, k banme
  int digit = p;

  string s;
  if(k==0){s="0";}
  while(k>0){
    s.push_back((k%digit)+'0');
    k -= k%digit;
    k /= digit;
  }

  while(s.size()<n){
    s.push_back('0');
  }
  return s;
}

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


  rep(i,4){
    string tmp=digit(2, 2, i);
    //prt(tmp);
    rep(j,n){
      if(j==0) continue;
      if(tmp[j]=='0'){
        if(s[j]=='o') tmp.pb(tmp[j-1]);
        else tmp.pb((tmp[j-1]=='1' ? '0' : '1'));
      } else {
        if(s[j]=='o') tmp.pb((tmp[j-1]=='1' ? '0' : '1'));
        else tmp.pb(tmp[j-1]);
      }
    }
    if(tmp[n]!=tmp[0]) continue;
    if(((s[0]=='o' && tmp[0]=='0') && tmp[n-1]==tmp[1]) ||
       ((s[0]=='o' && tmp[0]=='1') && tmp[n-1]!=tmp[1]) ||
       ((s[0]=='x' && tmp[0]=='0') && tmp[n-1]!=tmp[1]) ||
       ((s[0]=='x' && tmp[0]=='1') && tmp[n-1]==tmp[1])){
      tmp.pop_back();
      rep(j,n){
        if(tmp[j]=='0') tmp[j]='S';
        else tmp[j]='W';
      }
      prt(tmp);
      return 0;
    }
  }

  prt(-1);
}


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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int n = (int)s1.size();
	int m = (int)s2.size();
	if (n > m) {
		cout << "GREATER";
		return 0;
	}else if (n < m) {
		cout << "LESS";
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		if (s1[i] > s2[i]) {
			cout << "GREATER";
			return 0;
		}
		if (s1[i] < s2[i]) {
			cout << "LESS";
			return 0;
		}	
	}
	cout << "EQUAL";
}



















Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rem (x) x % 1000000007;

#define fillInt(xs, x)        \
  for (int i = 0; i < x; i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < x; i++) \
    scanf("%ld", &xs[i]);
#define sortv(xs) sort(S.begin(), S.end());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

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

  int A, B, Q;
  cin >> A >> B >> Q;

  vector<long> S(A), T(B), X(Q);
  fillLong(S, A);
  fillLong(T, B);
  fillLong(X, Q);

  sortv(S);
  sortv(T);

  for (int i = 0; i < X.size(); i++)
  {
    long x = X[i];
    long m = 1000000000000;

    int s = lbv(S, x);

    if (s != 0)
    {
      long s1 = S[s - 1];
      int t1 = lbv(T, s1);
      long t11 = T[max(t1 - 1, 0)];
      long t12 = T[min(t1, B - 1)];

      m = min(
          abs(s1 - x) + abs(t11 - s1),
          m);
      m = min(
          abs(s1 - x) + abs(t12 - s1),
          m);
    }

    if (s != A)
    {
      long s2 = S[s];
      int t2 = lbv(T, s2);
      long t21 = T[max(t2 - 1, 0)];
      long t22 = T[min(t2, B - 1)];

      m = min(
          abs(s2 - x) + abs(t21 - s2),
          m);
      m = min(
          abs(s2 - x) + abs(t22 - s2),
          m);
    }

    int t = lbv(T, x);

    if (t != 0)
    {
      long t1 = T[t - 1];
      int s1 = lbv(S, t1);
      long s11 = S[max(s1 - 1, 0)];
      long s12 = S[min(s1, A - 1)];

      m = min(
          abs(t1 - x) + abs(s11 - t1),
          m);
      m = min(
          abs(t1 - x) + abs(s12 - t1),
          m);
    }

    if (t != B)
    {
      long t2 = T[t];
      int s2 = lbv(S, t2);
      long s21 = S[max(s2 - 1, 0)];
      long s22 = S[min(s2, A - 1)];

      m = min(
          abs(t2 - x) + abs(s21 - t2),
          m);
      m = min(
          abs(t2 - x) + abs(s22 - t2),
          m);
    }

    printf("%ld\n", m);
  }
  return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll N, C;
vector<ll> Xs;
vector<ll> Vs;

vector<ll> clock_gains;
vector<ll> clock_max_gains;
vector<ll> anticlock_gains;
vector<ll> anticlock_max_gains;

ll clockwise() {
    ll gain = 0;
    ll max_gain = 0;
    clock_gains.resize(N);
    clock_max_gains.resize(N);
    REP(n, N) {
        if (n == 0) {
            gain += Vs[n] - Xs[n];
        }
        else {
            gain += Vs[n] - (Xs[n] - Xs[n-1]);
        }
        max_gain = max(max_gain, gain);
        clock_gains[n] = gain;
        clock_max_gains[n] = max_gain;
    }
    return max_gain;
}

ll anticlockwise() {
    ll gain = 0;
    ll max_gain = 0;
    anticlock_gains.resize(N);
    anticlock_max_gains.resize(N);
    for(int n = N-1; n >= 0; --n) {
        if(n == N-1) {
            gain += Vs[n] - (C - Xs[n]);
        }        
        else {
            gain += Vs[n] - abs(Xs[n] - Xs[n+1]);
        }
        max_gain = max(max_gain, gain);
        anticlock_gains[n] = gain;
        anticlock_max_gains[n] = max_gain;
    }
    return max_gain;
}

ll clockwise_and_anticlockwise() {
    // i番目まで時計方向
    ll ans = 0;
    REP(i, N-1) {
        ll gain = clock_gains[i];
        gain -= Xs[i];
        gain += anticlock_max_gains[i+1];
        ans = max(ans, gain);
    }
    return ans;
}
ll anticlockwise_and_clockwise() {
    // i番目まで逆時計方向
    ll ans = 0;
    FOR(i, 1, N) {
        ll gain = anticlock_gains[i];
        gain -= (C - Xs[i]);
        gain += clock_max_gains[i-1];
        ans = max(ans, gain);
    }
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    cin >> N >> C;
    Xs.resize(N);
    Vs.resize(N);
    REP(n, N) cin >> Xs[n] >> Vs[n];

    ll ans1 = clockwise();
    ll ans2 = anticlockwise();
    ll ans3 = clockwise_and_anticlockwise();
    ll ans4 = anticlockwise_and_clockwise();

    
    cout << max(max(max(ans1,ans2),ans3),ans4) << endl;

    return 0;
}


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




  int abs(int x){
      if(x>=0)
      return x;
      else
      return -x;

  }
  int min(int a,int b){
      if(a>=b){
          return b;
      }
      return a;
  }
    int frog(int arr[],int k,int n){
        int dp[n+1];
        for(int i=0;i<n;i++)
        dp[i]=0;
        for (int i = 2; i <=n; i++) {
			dp[i] = INT_MAX;
			for (int j = i - 1; j >= 1 && (i - j) <= k; j--) {
                if(dp[j]!=INT_MAX)
				dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
			}

		}
		return dp[n];

    }

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

   int k;
   cin>>k;

   int a[n+1];
   for(int i=1;i<=n;i++)
   cin>>a[i];

   cout << frog(a,k,n) << endl;
}

Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int n, a;
    cin >> n >> a;
    int ans = n * n - a;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N, A, B; 
	cin >> N >> A >> B; 
	int a = 0, b = 0, c = 0; 
	for(int i = 0; i < N; i++){
		int p; 
		cin >> p; 
		if(p <= A) 
			a++;
		else if(p <= B) 
			b++;
		else 
			c++;
	}
	cout << min({a, b, c}) << endl; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
int main(){
	int a = read(), b = read();
	for (register int i = b - a + 1; i <= b + a - 1; ++i) printf("%d ", i);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
using namespace std;

typedef long long ll;

const ll P=1e11;

ll re[100][100];

ll C(ll n,ll m){
	return re[n][m];

	if(m>n)	return 0;
	if(re[n][m]!=-1)	return re[n][m];
	if(m==0||m==n)	return 1;
	if(m==1)	return n;
	return re[n][m]=(C(n-1,m)+C(n-1,m-1));
}


int main(){
	memset(re,0,sizeof(re));
	int N,P;
	re[0][0]=1;
	for(int i=1;i<60;i++){
		re[i][0]=1;
		for(int j=1;j<=i;j++){
			re[i][j]=re[i-1][j]+re[i-1][j-1];
		}
	}
	
	//cout<<re[50][25]<<endl;
	
	scanf("%d%d",&N,&P);
	int N0=0,N1=0,d;
	for(int i=0;i<N;i++){
		scanf("%d",&d);
		if(d&1)	N1++;
		else N0++;
	}
	ll ans=1,temp;
		for(int i=0;i<N0;i++)	ans=(ans<<1);
	if(P==1){
		temp=0;
		for(int i=1;i<=N1;i+=2){
			temp+=C(N1,i);
		}
	}else{
		temp=0;
		for(int i=0;i<=N1;i+=2){
			temp+=C(N1,i);
		}
	}
	printf("%lld",ans*temp);
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

b = []
n.times do |i|
  if((n-i)%2 == 1)
    b.unshift(a[i])
  else
    b.push(a[i])
  end
  # b.reverse!
end

puts b.join(' ')


Measured memory_bytes: 25444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define dve(ko, koo, kooo, koooo) vector<vector<ko>> koo(kooo, vector<ko>(koooo, 0))
#define tve(ha,haa,haaa,haaaa,haaaaa) vector<vector<vector<ha>>> haa(haaa,vector<vector<ha>(haaaa,vector<ha>(haaaaa,0)))
#define for(k,ro,roo) for(int k=ro;k<roo;++i)
#define rv(su) reverse(su.begin(),su.end())
typedef unsigned long long int uli;
typedef long long int lli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  lli n;cin>>n;
  string ans;
  while(n>0){
    --n;
    ans+=('a'+n%26);
    n/=26;
  }
  rv(ans);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3664