akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int p[10000],c[9999],n;
  r(i,10000)p[i]=i*i;
  while(cin>>n,n){
    memset(c,0,sizeof(c));
    vector<int>v;
    r(i,n-1)v.push_back(p[i+1]%n);
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    r(i,v.size())r(j,i)if(i!=j){
      int x=v[i]-v[j];
      if(x<0)x+=n;
      else if(x>(n-1)/2)x=n-x;
      c[x]+=2;
    }
    r(i,(n-1)/2)cout<<c[i+1]<<endl;
  }
}

Measured memory_bytes: 3308
n = int(input())
x = list(map(int,input().split()))
INF = 114514191981036436433-4

ans = INF
for i in range(1,101):
    a = 0
    for j in range(n):
        a += (x[j] - i) ** 2
        
    ans = min(ans,a)
    
print(ans)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

ll n, m, l, r, d, p, q;
#define N 110000
bool jud = true;
vector<ll> kyori(N, 0);
vector<bool> reached(N, false);
vector<vector<ll>> rightl(N);
vector<vector<ll>> rightdis(N);
vector<ll> leftl(N,0);

void dfs(ll x){
	ll p = rightl.at(x).size();
	if (p != 0){
		REP(i,p){
			q = rightl.at(x).at(i);
			if (reached.at(q) == false){
				//cout << x << "first" << q << endl;
				reached.at(q) = true;
				kyori.at(q) = kyori.at(x)+rightdis.at(x).at(i);
				dfs(q);
			}
			else{
				//cout << x << "already" << q << endl;
				if (kyori.at(q) != kyori.at(x)+rightdis.at(x).at(i)){
					//cout << x << "false" << q << endl;
					jud = false;
				}
			}
		}
	}
}


int main(){
	cin >> n >> m;
	REP(i,m){
		cin >> l >> r >> d;
		rightl.at(l-1).pb(r-1);
		rightdis.at(l-1).pb(d);
		leftl.at(r-1)++;
	}

	REP(i,n){
		if (leftl.at(i) == 0){
			//cout << i << endl;
			reached.at(i) = true;
			dfs(i);
		}
	}
	//cout << "reached=";
	//REP(i,n) cout << reached.at(i) << " ";
	//cout << endl;

	bool jud2 = true;
	REP(i,n) if (reached.at(i) == false) jud2 = false;

	if (jud && jud2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 19584
N,M = map(int,input().split())
G = dict([(i,[]) for i in range(N+1)])
lh = []
for i in range(M):
  a,b = map(int,input().split())
  lh.append([a,b])
  G[a].append(b)
  G[b].append(a)

def bfs(p):
  seen = [False for i in range(N+1)]
  l = [p]
  while len(l)>0:
    v = l.pop(0)
    for i in G[v]:
      if seen[i] == False:
        seen[i] = True
        l.append(i)
      else:
        continue  
  if sum(seen) != N:
    return 1
  else:
    return 0  

cnt = 0
for h in lh:
  a,b = h[0],h[1]
  G[a].remove(b)
  G[b].remove(a)
  cnt += bfs(1)
  G[a].append(b)
  G[b].append(a)
print(cnt)  

Measured memory_bytes: 3064
import sys
from collections import deque
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N, W = map(int, readline().split())
    vs = [0]*N; ws = [0]*N; ms = [0]*N
    for i in range(N):
        vs[i], ws[i], ms[i] = map(int, readline().split())

    V0 = max(vs)
    V = sum(v * min(V0, m) for v, m in zip(vs, ms))

    dp = [W+1]*(V + 1)
    dp[0] = 0
    for i in range(N):
        v = vs[i]; w = ws[i]; m = ms[i]
        c = min(V0, m)
        ms[i] -= c
        for k in range(v):
            que = deque()
            push = que.append
            popf = que.popleft; popb = que.pop

            for j in range((V-k)//v+1):
                a = dp[k + j*v] - j * w
                while que and a <= que[-1][1]:
                    popb()
                push((j, a))

                p, b = que[0]

                dp[k + j*v] = b + j * w
                if que and p <= j-c:
                    popf()

    *I, = range(N)
    I.sort(key=lambda x: ws[x]/vs[x])
    *S, = [(vs[i], ws[i], ms[i]) for i in I]

    ans = 0
    def greedy():
        yield 0
        for i in range(V + 1):
            if dp[i] > W:
                continue
            rest = W - dp[i]
            r = i
            for v, w, m in S:
                m = min(m, rest // w)
                r += m * v
                rest -= m * w
            yield r
    write("%d\n" % max(greedy()))
solve()


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

using namespace std;
using ll = long long;

int main() {
	int M, D;
	cin >> M >> D;
	int ct = 0;
	
	for(int i=1; i<=M; i++) {
		for(int j=1; j<=D; j++) {
			if(j/10 >= 2 && j%10 >= 2 && ((int)(j/10) * (j%10) == i)) {
				ct++;
			}
		}
	}
	
	cout << ct << endl;
	
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()
ans = 10 ** 18
for i in range(N - K + 1):
    h1 = H[i]
    h2 = H[i + K - 1]
    ans = min(ans, h2 - h1)
print(ans)

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

typedef pair<int, int> P;

int find(vector<int> &root, int x){
    if (root[x] == x) return x;
    root[x] = find(root, root[x]);
    return root[x];
}

void unions(vector<int> &root, vector<int> &rank, int x, int y){
    x = find(root, x);
    y = find(root, y);
    if (rank[x] >= rank[y]) root[y] = x;
    else root[x] = y;
    if (rank[x] == rank[y]) rank[x]++;
}

int binarysearch(vector<P> &ans, int x, int y){
    int ng = - 1;
    int ok = (int)ans.size();
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (ans[mid].first > x || (ans[mid].first == x && ans[mid].second >= y)) ok = mid;
        else ng = mid;
    }
    int result = 0;
    while (1){
        if (ans[ok].first == x && ans[ok].second == y) result++;
        else break;
        ok++;
        if (ok >= (int)ans.size()) break;
    }
    return result;
}

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    vector<int> root1(n+1);
    vector<int> root2(n+1);
    for (int i = 0; i <= n; i++){
        root1[i] = i;
        root2[i] = i;
    }
    vector<int> rank1(n+1, 0);
    vector<int> rank2(n+1, 0);

    int p, q;
    for (int i = 0; i < k; i++){
        cin >> p >> q;
        unions(root1, rank1, p, q);
    }
    for (int i = 0; i < l; i++){
        cin >> p >> q;
        unions(root2, rank2, p, q);
    }

    vector<P> ans(n);
    for (int i = 1; i <= n; i++){
        ans[i-1] = {find(root1, i), find(root2, i)};
    }
    sort(ans.begin(), ans.end());

    for (int i = 1; i <= n; i++){
        p = find(root1, i);
        q = find(root2, i);
        cout << binarysearch(ans, p, q);
        if (i != n) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

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

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()


int main() {
	string S;
	cin >> S;
	cout<<count(S.begin(), S.end(), '+')-count(S.begin(),S.end(),'-');
	

	return 0;
}

Measured memory_bytes: 256
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  int n;
  cin >> n;
  long long ans = 0;
  vector<long long> F(n+1); //F[i] = f(i)

  rep2(i, 1, n+1){//one_base
    rep2(j, 1, n/i + 1){//one_base
      F[i*j] += 1;
    }
  }

  rep1(i, n+1){
    ans += i*F[i];
  }

  cout << ans;
}


Measured memory_bytes: 81400
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, a, b; cin >> n >> m >> a >> b;
    vector<int> D(n);
    for(int i = 0; i < n; i++) cin >> D[i];
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        if(D[i] >= a) v.push_back(D[i]);
        else break;
    }
    int num = n - v.size();
    if(num >= m) cout << v.size() << endl;
    else
    {
        int ans = 0;
        int pos = v.size() - 1;
        while(v.size())
        {
            if(v[pos] <= b)
            {
                v.pop_back();
                pos--;
            }
            else
            {
                ans = v.size();
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}





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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	map<int, int> occ;
	F0R(i, N) occ[arr[i]]++;

	int total = 0;
	for (auto p : occ) {
		if (p.second >= p.first) total += p.second - p.first;
		else total += p.second;
	}
	print(total);
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b,x;
  cin >> a >> b >> x;
  if (a*a*b <= 2*x){
    double s = (a*a*b - x) / a;
    double t = 2*s / (a*a);
  
    //cout << s << " " << t << endl;
    cout << fixed << setprecision(10);
    cout << atan(t) * 57.2957795130 << endl;
  }
  else{
    double s = x / a;
    double t = b*b / (2*s);
    
    //cout << s << " " << t << endl;
    cout << fixed << setprecision(10);
    cout << atan(t) * 57.2957795130 << endl;
  }
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, h;
  cin >> n >> h;
  vector <pair <ll, ll>> v(n, pair <ll, ll> ());
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    v.at(i) = make_pair(a, -b);
  }
  sort(v.begin(), v.end());
  pair <ll, ll> p = v.at(n-1);
  p.second = -p.second;
  vector <ll> b(n-1);
  rep(i, n-1) b.at(i) = -v.at(i).second;
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  ll res = 0;
  rep(i, n-1) {
    if (h > 0) {
      if (h <= p.second) {
        h = 0;
        res++;
      } else if (p.first <= b.at(i)) {
        h -= b.at(i);
        res++;
      }
    }
  }
  if (h > 0) {
    if (h-p.second > 0) {
      h -= p.second;
      res++;
      if (h%p.first) res += h/p.first + 1;
      else res += h/p.first;
    } else res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

        if (s == "-")
            break;

        int count;
        cin >> count;

        for (int i = 0; i < count; i++) {
            unsigned long h;
            cin >> h;
            s = s.substr(h) + s.substr(0,h);
        }

        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int main(void){
    int x,y,hoge;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
            break;
        if(x>y){
            hoge=x;
            x=y;
            y=hoge;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vll A(X), B(Y), C(Z); cin >> A >> B >> C;
	sort(begin(A), end(A));
	sort(begin(B), end(B));
	sort(begin(C), end(C));
	ll ok = -1, ng = 1e12;

	while (abs(ok-ng)>1) {
		ll limit = (ok+ng)/2;
		ll cnt = 0;
		for (int i = 0; i < X; i++) {
			for (int j = 0; j < Y; j++) {
				int k = lower_bound(begin(C), end(C), limit - A[i] - B[j]) - begin(C);
				cnt += Z-k;
			}
		}
		if (cnt >= K) ok = limit;
		else ng = limit;
	}

	vll ans;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			int k = lower_bound(begin(C), end(C), ok - A[i] - B[j]) - begin(C);
			for (; k < Z; k++) {
				ans.push_back(A[i] + B[j] + C[k]);
			}
		}
	}
	sort(rbegin(ans), rend(ans));
	for (int i = 0; i < K; i++) {
		cout << ans[i] << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 134504
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a[10000];
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a[i]);
    n -= a[i];
  }
  if (n < -1)
    n=-1;
  printf("%d",n);
}

Measured memory_bytes: 1736
<?php

list($a[], $a[], $a[], $N) = explode(" ", trim(fgets(STDIN)));

$dp[0][0] = 1;
for($i = 1; $i <= 3; $i++){
    for($j = 0; $j <= $N; $j++){
        @$dp[$i][$j] = $dp[$i - 1][$j] + $dp[$i][$j - $a[$i-1]];
    }
}
echo $dp[3][$N];


Measured memory_bytes: 4728
/**
 *    author:  tourist
 *    created: 29.12.2019 20:59:57       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> b(n);
  vector<pair<int, int>> c(n);
  for (int i = 0; i < n; i++) c[i] = make_pair(~a[i], i);
  sort(c.begin(), c.end());
  int mn = n;
  for (int i = 0; i < n; i++) {
    int j = c[i].second;
    mn = min(mn, j);
    b[mn] += (i + 1LL) * (~c[i].first - (i == n - 1 ? 0 : ~c[i + 1].first));
  }
  for (int i = 0; i < n; i++) {
    cout << b[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3072
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))

X=[]
for i in range(N):
    cnt=0
    for j in range(i):
        if A[i]<A[j]:
            cnt+=1
    X.append(cnt)

Y=A
Y.sort()

ans=0
mod=10**9+7
for i in range(N):
    Z=bisect.bisect_left(Y,A[i])
    ans+=(K*(K-1)//2)*Z+X[i]*K
    ans%=mod
print(ans)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

struct st{int a,b,c;};

map<pii,int> solve(vector<st> v){
	map<pii,int> mp;
	rep(i,1<<v.size()){
		int ta=0,tb=0,tc=0;
		int t = i;
		rep(j,v.size()){
			if(t%2==0){
				ta+=v[j].a;
				tb+=v[j].b;
				tc+=v[j].c;
			}
			t/=2;
		}
		if(mp.count(pii(ta,tb)))mp[pii(ta,tb)] = min(mp[pii(ta,tb)],tc);
		else mp[pii(ta,tb)] = tc;
	}
	return mp;
}

int main(){
	int n;
	int x,y;
	cin>>n>>x>>y;
	
	vector<st> va,vb;
	rep(i,n/2){
		int a,b,c;
		cin>>a>>b>>c;
		va.pb(st{a,b,c});
	}
	rep(i,n-(n/2)){
		int a,b,c;
		cin>>a>>b>>c;
		vb.pb(st{a,b,c});
	}
	
	map<pii,int> mpa,mpb;
	mpa = solve(va);
	mpb = solve(vb);
	
	
	
	
	int ans = INF;
	int c=1;
	while(x*c<=500&&y*c<=500){
		int p=x*c,q=y*c;
		for(auto e:mpa){
			if(mpb.count(pii(p-e.first.first,q-e.first.second))){
				ans = min(ans,e.second+mpb[pii(p-e.first.first,q-e.first.second)]);
			}
		}
		c++;
	}
	if(ans==INF)cout<<-1<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

int main() {
  string ss;
  cin >> ss;
  bool n = 0;
  bool s = 0;
  bool e = 0;
  bool w = 0;
  for(char c : ss) {
    if(c == 'N') {
      n = true;
    }
    else if (c == 'S') {
      s = true;
    }
    else if(c == 'E') {
      e = true;
    }
    else if(c == 'W') {
      w = true;
    }
  }
  if((n == s) && (e == w)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first 
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n<0)return 0;if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(),x.end()
#define Return(x) {cout << x << endl; return 0;}


int__ main() {
    int a,b,c; cin >> a >> b >> c;
    cout << c << " " <<  a << " " <<  b << endl;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

ll f(ll n, ll p) {
  ll ret = 0;
  if (n == 0) return 0;
  ll t = n%p;
  ret += f(t, __builtin_popcountll(t));
  return ret + 1;
}

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

  ll d = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == '1') d++;
  }

  vector<vector<ll>> a(n, vector<ll>(2));
  {
    for (int j=0; j<2; j++) {
      ll e = d;
      if (j == 0) e++;
      else e--;
      if (e <= 0) continue;
      ll t = 1;
      for (int i=0; i<n; i++) {
        a[n-i-1][j] = t % e;
        t = (t*2) % e;
      }
    }
  }

  vector<ll> sum(2);
  for (int j=0; j<2; j++) {
    ll e = d;
    if (j == 0) e++;
    else e--;
    if (e <= 0) continue;
    for (int i=0; i<n; i++) {
      if (s[i] == '1') (sum[j] += a[i][j]) %= e;
    }
  }

  for (int i=0; i<n; i++) {
    ll e = d;
    ll idx = s[i] - '0';
    ll t = sum[idx];
    if (idx) {
      e--;
      if (e <= 0) {
        cout << 0 << endl;
        continue;
      }
      t = (t + e - a[i][idx]) % e;
    } else {
      e++;
      t = (t + a[i][idx]) % e;
    }
    cout << f(t, __builtin_popcountll(t))+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 14480
/**
 * GRL_1-A - Shortest Path - Single Source Shortest Path
 */

#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using ULL = unsigned long long;

const ULL INF = 1UL << 63;

struct edge {
    int to;
    ULL cost;
};

typedef pair<ULL, int> P;

int main() {

    int V, E, r;
    cin >> V >> E >> r;

    vector<edge> G[V];
    ULL cost[V];

    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(edge{t, (ULL) d});
    }

    fill(cost, cost + V, INF);
    cost[r] = 0;

    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(make_pair(0, r));

    while (!pq.empty()) {

        P p = pq.top();
        pq.pop();

        if (p.first > cost[p.second]) continue;

        for (edge e : G[p.second]) {
            if (p.first + e.cost < cost[e.to]) {
                cost[e.to] = p.first + e.cost;
                pq.push(P(cost[e.to], e.to));
            }
        }
    }

    for (int i = 0; i < V; i++) {
        if (cost[i] != INF) {
            cout << cost[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}


Measured memory_bytes: 19492
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define mod 1e9+7
#define debug(x) cout<<x<<endl;
#define fi first
#define se second
int main(){
	ll n; cin>>n;
    string x;
	map<string,ll> m;
	while(n--) cin>>x,sort(x.begin(),x.end()),m[x]++;
	ll ans=0;
	for(auto it:m){
		ll p=it.second;
		ans+=(p*(p-1))/2;
	}
	cout<<ans;
}


Measured memory_bytes: 11280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
      
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n,k;
  cin>>n>>k;
  int h,sum=0;

  rep(i,n){
    cin>>h;
    if(h>=k){
      sum++;
    }
  }
  cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  vector<int> v;
  if(n==0)
    cout<<x;
  else{
  for(int i=0;i<n;i++){
   int c;
    cin>>c;
    v.push_back(c);
  }
    vector<int>::iterator it;
       vector<int>::iterator itr;
   
    int i=-1;
    while(1){
      i++;
      it = std::find (v.begin(), v.end(),x-i); 
       itr = std::find (v.begin(), v.end(),x+i); 
      if (it == v.end()&&itr == v.end()){ 
        cout<<min(x-i,x+i);
        break;
      }
      else if (it == v.end()&&itr != v.end()) {
        cout<<x-i;
        break;
      }
      else if(it!= v.end()&&itr== v.end()){
       cout<<x+i;
        break;
      }
      else
        continue;
   
    }
 
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		if(x<y){
			printf("%d %d\n",x,y);
		}
		
		else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 2588
inputs = input().split()
stack = []

for i in inputs:
    if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()

        if i == "+":
            ans = a + b
        elif i == "-":
            ans = a - b
        elif i == "*":
            ans = a * b
        elif i == "/":
            ans = a / b

        stack.append(ans)

print(stack.pop())


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
 
int main() {
	
	string s;
	cin >> s;
	long long l1 = 0;
	while (l1 < s.size() && s[l1] == '1') l1++;
	
	long long k;
	cin >> k;
	if (l1 >= k) cout << 1 << endl;
	else cout << s[l1] << endl;
	
}


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

int main()
{
    ll N;
    ll ans = pow(10, 12);
    cin >> N;
    for (int i = 1; i <= sqrt(N); ++i)
    {
        if (N % i == 0)
        {
            ans = min(ans, i + (N / i));
        }
    }
    cout << ans - 2 << endl;
}

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

using int_ = int;
#define int int_least64_t

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

  int n, m; cin >> n >> m;
  string s; cin >> s;
  vector<pair<char, char> > events;
  for (int i=0; i<m; ++i) {
    char a, b; cin >> a >> b;
    events.emplace_back(a, b);
  }

  auto simulate = [&](int i) -> int {
                   if (i == -1) return -1;
                   if (i == n) return n;
                   for (auto& td : events) {
                     char t = td.first, d=td.second;
                     int dir = d=='R'?1:-1;
                     if (t == s[i]) {
                       i += dir;
                     }
                     if (i == -1) return -1;
                     if (i == n) return n;
                   }
                   return i;
                 };

  // invariant: simulate(l)==-1
  int l=0, r=n;
  while (r-l>1) {
    int m=(l+r)/2;
    if (simulate(m)==-1)
      l = m;
    else
      r = m;
  }
  int lmax=l;

  // invariant: simulate(r)==n
  l=0, r=n;
  while (r-l>1) {
    int m=(l+r)/2;
    if (simulate(m)==n)
      r = m;
    else
      l = m;
  }
  int rmax=r;
  // for (int i=0; i<n; ++i)
  //   cout << simulate(i) << ' ';
  // cout << "" << '\n';
  cout << rmax - lmax - 1 << '\n';
}



Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b=='A')cout << "T"<< endl;
  if(b=='T')cout << "A"<<endl;
  if(b=='C')cout << "G"<< endl;
  if(b=='G') cout << "C" << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int maxN = 4000;
const ll MOD = 998244353;
ll dp[maxN][maxN] = {{0}};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, s;
	cin>>n>>s;
	ll ans = 0;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		for (int j = 0; j <= s; j++) {
			dp[i+1][j] = dp[i][j];
		}
		for (int j = a[i]; j <= s; j++) {
			dp[i+1][j] += dp[i][j-a[i]];
			dp[i+1][j] %= MOD;
			// cout<<dp[i+1][j]<<' ';
		}
		dp[i+1][a[i]] += i+1;
		dp[i+1][a[i]] %= MOD;
		for (int j = 0; j <= s; j++){
			// cout<<dp[i+1][j]<<' ';
		}
		// cout<<'\n';
	}
	for (int i = 1; i <= n; i++) {
		ans += dp[i][s];
		ans %= MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

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

int main(void){
  int n, k;
  cin >> n >> k;
  
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end(), greater<int>());
  
  int ans = 0;
  
  for(int i = 0; i < k; i++) {
    ans += v.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	int i, count;
	count = 0;

	for (i = a; i <= b; i++) {
		if (c % i == 0)
			count++;
	}
	cout << count << endl;	
}



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

main() {
	int x, y, a, b, c;
	cin>>x>>y>>a>>b>>c;
	vector<int>p;
	vector<int>q;
	vector<int>r;
	for(int i=0; i<a; i++){
		int x;
		cin>>x;
		p.pb(x);
	}
	for(int i=0; i<b; i++){
		int x;
		cin>>x;
		q.pb(x);
	}
	for(int i=0; i<c; i++){
		int x;
		cin>>x;
		r.pb(x);
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	reverse(p.begin(), p.end());
	reverse(q.begin(), q.end());
	reverse(r.begin(), r.end());
	int p1=x-1;
	int p2=y-1;
	int ans=0;
	for(int i=0; i<=p1; i++){
		ans+=p[i];
	}
	for(int i=0; i<=p2; i++){
		ans+=q[i];
	}
	int p3=0;
	while(p3<c){
		if(p1>=0 && p2>=0){
			if(p[p1]>q[p2] && r[p3]>q[p2]){
				ans+=r[p3];
				ans-=q[p2];
				p2--;
				p3++;
				continue;
			}
			if(p[p1]<=q[p2] && r[p3]>p[p1]){
				ans+=r[p3];
				ans-=p[p1];
				p1--;
				p3++;
				continue;
			}
			break;
		}
		if(p1<0 && p2<0){
			break;
		}
		if(p1<0){
			if(q[p2]<r[p3]){
				ans+=r[p3];
				ans-=q[p2];
				p2--;
				p3++;
				continue;
			}
			break;
		}
		if(p2<0){
			if(p[p1]<r[p3]){
				ans+=r[p3];
				ans-=p[p1];
				p3++;
				p1--;
				continue;
			}
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vector<int> num(N,0);
    vector<vector<int>> lr(Q, vector<int>(2));

    for (int i = 0; i < Q; ++i) cin >> lr[i][0] >> lr[i][1];

    for (int j = 1; j < N; ++j) {
        num[j] = num[j-1];
        if((S[j-1]=='A')&&(S[j]=='C')) num[j]++;
    }

    for (int k = 0; k < Q; ++k) {
        cout << num[lr[k][1]-1] - num[lr[k][0]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e3+5;
int32_t main()
{
    IOS;
    int x;
    cin>>x;
    int k=x%11;
    int ans=x/11;
    if(k==0)
    {
        cout<<ans*2<<endl;
        return 0;
    }
    if(k>6)
    {
        cout<<(ans+1)*2<<endl;
        return 0;
    }
    else
        cout<<ans*2+1<<endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,x,y,sum,pos,k,w[ohara],v[ohara],W,dp[105][ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>W;
    rep(i,n)cin>>w[i]>>v[i];
    rep(i,n+1){
        rep(j,100005){
            dp[i][j]=LINF;
        }
    }
    dp[0][0]=0;
    dp[0][v[0]]=w[0];
    rrep(i,1,n){
        rrep(j,0,100005){
            if(j>=v[i]){
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    rep(i,100005){
        if(dp[n-1][i]<=W)ans=i;
    }
    //Cout(dp[n-1][17]);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 291840
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func divsor(n int) []int {
	ret := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			ret = append(ret, n/i)
		}
	}
	sort.Ints(ret)
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()

	x := divsor(M)
	// out(N, x)

	for i := len(x) - 1; i >= 0; i-- {
		if M/x[i] >= N {
			out(x[i])
			return
		}
	}
}


Measured memory_bytes: 640
n = int(input())
list_a = list(map(int, input().split()))
list_ans = [0] * 3
for number in list_a:
    if number % 4 == 0:
        list_ans[2] += 1
    elif number % 2 == 0:
        list_ans[1] += 1
    else:
        list_ans[0] += 1

if list_ans[2] >= list_ans[0]:
    print("Yes")
elif list_ans[2] == list_ans[0] - 1:
    if list_ans[1] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main() {
  long num1,num2,a,b,temp,r,gcd;
  long lcm,aa;
  long long bb;
  cin >> num1 >> num2;
  a = num1;
  b = num2;
  
  
  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }
  
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  gcd = b;
  lcm = num1 * num2 / gcd;
  aa = num1 * num2;
  bb = num1 * num2;
  //cout << gcd << endl;
  cout << lcm << endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

void transplant(Node u,Node v)
{
  if(u->parent==NIL)
    {
      root=v;
    }
  else if(u==u->parent->left)
    u->parent->left=v;
  else
    u->parent->right=v;
  if(v!=NIL)
    v->parent=u->parent;
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL)
    transplant(z,z->right);
  else if(z->right==NIL)
    transplant(z,z->left);
  else
    {
      y=treeMinimum(z->right);
      if(y->parent!=z)
	{
	  transplant(y,y->right);
	  y->right=z->right;
	  y->right->parent=y;
	}
      transplant(z,y);
      y->left=z->left;
      y->left->parent=y;
    }


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key)
	x=x->left;
      else
	x=x->right;
    }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;



}

void inorder(Node u){
  if(u!=NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }

}
void preorder(Node u){
   if(u!=NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20612
#include<iostream>
#define TRUE 1
#define FALSE 0
int main(){
  int n,i,j,in,cards[4][13];
  char c;
  for(i=0; i<4; i++) for(j=0; j<13; j++) cards[i][j] = FALSE;
  std::cin >> n;
  for(i=0; i<n; i++){
    std::cin >> c >> in;
    switch(c){
      case 'S':
      cards[0][in-1] = TRUE;
      break;
      case 'H':
      cards[1][in-1] = TRUE;
      break;
      case 'C':
      cards[2][in-1] = TRUE;
      break;
      case 'D':
      cards[3][in-1] = TRUE;
      default:
      break;
    }
  }
  for(i=0; i<4; i++) for(j=0; j<13; j++){
    if(!cards[i][j]){
      switch(i){
        case 0:
        std::cout << "S ";
        break;
        case 1:
        std::cout << "H ";
        break;
        case 2:
        std::cout << "C ";
        break;
        case 3:
        std::cout << "D ";
        break;
        default:
        break;
      }
      std::cout << j + 1 << "\n";
    }
  }
  std::cout << std::flush;
  return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#include <utility>
typedef long long ll;

int main(void) {
  ll i, j, k, n, q, c, s, t, x;
  scanf("%lld%lld", &n, &q);
  ll f = 1;
  std::pair<ll, ll> seg[4 * n];
  while(f < n) f *= 2;
  for(i = f; i < f * 2; ++i) seg[i].first = 2147483647, seg[i].second = 0;
  for(i = 0; i < f; ++i) seg[i].first = -1, seg[i].second = -1;
  for(i = 1; i <= q; ++i) {
    scanf("%lld", &c);
    if(!c) {
      scanf("%lld%lld%lld", &s, &t, &x);
      ll r = s + f;
      while(1) {
        ll las, ra = 1;
        while(!(r % 2)) r /= 2;
        while(ra <= r) ra *= 2;
        ra /= 2;
        las = f / ra * (r + 1 - ra) - 1;
        while(las > t) {
          r *= 2;
          ra *= 2;
          las = f / ra * (r + 1 - ra) - 1;
        }
        seg[r].first = x;
        seg[r].second = i;
        if(las == t) break;
        r++;
      }
    } else {
      scanf("%d", &s);
      int now = s + f, nowa, nown = -1;
      while(now) {
         if(seg[now].second > nown) nowa = seg[now].first, nown = seg[now].second;
         now /= 2;
      }
      printf("%lld\n", nowa);
    }
  }
  return 0;
}


Measured memory_bytes: 8988
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

const int N = 1e6 + 10;
int n, from[N], pref[N];
int get_sum(int l, int r) {
  return pref[r] - pref[l - 1];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	cin >> n;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << 0 << '\n';
    exit(0);
  }
  vector<pair<int, int>> kek;
  kek.pb({t[0] - 'a', 1});
  for (int i = 2; i <= n; i++) {
    if (t[i - 1] - 'a' != kek.back().F) {
      kek.pb({t[i - 1] - 'a', i});
    }
  }
  int ptr = n;
  for (int i = SZ(kek) - 1; i >= 0; i--) {
    ptr = min(ptr, kek[i].S);
    while (ptr && s[ptr - 1] - 'a' != kek[i].F) {
      ptr--;
    }
    if (ptr == 0) {
      cout << -1 << '\n';
      exit(0);
    }
    from[i] = ptr;
    pref[ptr]++;
  }
  for (int i = 1; i <= n; i++) {
    pref[i] += pref[i - 1];
  }
  for (int i = 0; i + 1 < SZ(kek); i++) {
    kek[i].S = kek[i + 1].S - 1;
  }
  kek.back().S = n;
  int ans = 0;
  for (int i = 0; i < SZ(kek); i++) {
    if (from[i] == kek[i].S) {
      continue;
    }
    int l = -1, r = n - kek[i].S;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (get_sum(from[i] + 1, kek[i].S + mid) <= mid) {
        r = mid;
      }
      else {
        l = mid;
      }
    }
    ans = max(ans, r + 1);
  }
  cout << ans << '\n';
} 

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

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

#define MAXN
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;

int main()
{
	int n, x = 0, y = 0, lastt = 0, t, tx, ty; bool flag = true;
	
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d %d %d", &t, &tx, &ty);
		int dx = abs(x - tx);
		int dy = abs(y - ty);
			
		if (dx + dy <= t - lastt)
		{
			if ((t - lastt - dx - dy) & 1) flag = false;
		}
		else flag = false;
		
		//cout << flag << " " << t - lastt - dx - dy << endl;
		x = tx, y = ty, lastt = t;
	}
	puts(flag? "Yes":"No");
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

ans = []

cnt=0

if D == 0:
    for i in range(1, 1500000):
        if i%100 != 0:
            cnt += 1
            if cnt == N:
                print(i)
                break
    
else:
    for i in range(1, 1500000):
        if i%(100**D) == 0 and  i%(100**(D+1)) != 0:
            cnt += 1
            if cnt == N:
                print(i)
                break

Measured memory_bytes: 3060
N , M = map(int,input().split())
L = []
for _ in range(M):
    m = tuple(map(int,input().split()))
    L.append(m)
if N == 1:
    for ans in range(0,10):
        ans = str(ans)
        for x in L:
            if ans[x[0] - 1] != str(x[1]):
                break
        else:
            print(ans)
            exit()
    print(-1)
    exit()
else:
    for ans in range(10 ** (N - 1),10 ** N ):
        ans = str(ans)
        for x in L:
            if ans[x[0] - 1] != str(x[1]):
                break
        else:
            print(ans)
            exit()
    print(-1)
    exit()



Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

const int MAX = 1e7 ;

class UFT{
	public :
	int par[MAX] ;
	int rank[MAX] ;
	int size[MAX] ;
	bool root[MAX] ;
	int group ;
	int tree ;
	
	void init(int n){
		for(int i=0;i<n;i++){
			par[i] = i ;
			size[i] = 1 ;
			rank[i] = 0 ;
			root[i] = true ;
		}
		group = n ;
		tree = n ;
	}
	
	int find(int x){
		if(x==par[x]) return x ;
		else return par[x] = find(par[x]) ;
	}
	
	bool same(int x,int y){
		return find(x)==find(y) ;
	}
	
	void unite(int x,int y){
		x = find(x) ;
		y = find(y) ;
		if(x==y){
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
		}else{
			if(rank[x]==rank[y]){
				rank[x]++ ;
				par[y] = x ;
				size[x] += size[y] ;
				root[y] = false ;
				if(root[x]){
					tree-- ;
				}
			}else if(rank[x]>rank[y]){
				par[y] = x ;
				size[x] += size[y] ;
				root[y] = false ;
				if(root[x]){
					tree-- ;
				}
			}else{
				par[x] = y ;
				size[y] += size[x] ;
				root[x] = false ;
				if(root[y]){
					tree-- ;
				}
			}
			group-- ;
		}
	}
} ;

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll l(m,vll(0)) ;
	for(int i=0;i<n;i++){
		ll k ; cin >> k ;
		for(int j=0;j<k;j++){
			ll a ; cin >> a ;
			a-- ;
			l.at(a).emplace_back(i) ;
		}
	}
	static UFT uft ;
	uft.init(n) ;
	for(int i=0;i<m;i++){
		for(int j=1;j<l.at(i).size();j++){
			uft.unite(l.at(i).at(j),l.at(i).at(j-1)) ;
		}
	}
	cout << (uft.group==1?"YES":"NO") << endl ;
}

Measured memory_bytes: 7932
def li():
    return [int(x) for x in input().split()]

H, W, K = li()
c = [list(input()) for x in range(H)]

ans = 0
for maskRow in range(2**H):
    for maskCol in range(2**W):
        black = 0
        for i in range(H):
            for j in range(W):
                # maskRowのi番目のフラグが立っていない
                # かつ
                # maskColのj番目のフラグが立っていない
                # かつ
                # c[i, j]が#と一致
                if not maskRow & (1 << i) and not maskCol & (1 << j) and c[i][j] == "#":
                    black += 1
        if black == K:
            ans += 1

print(ans)

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

int main() {
	int n,m,data[100],ndata[100]={0};cin>>n>>m;
        for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
ndata[a-1]++;ndata[b-1]++;

}
for(int i=0;i<n;i++){
cout<<ndata[i]<<endl;
}
}

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

ll f(ll x) {
	if (x == 1) return 1;
	return 2 * f(x / 2) + 1;
}

int main() {
	ll x;
	cin >> x;
	cout << f(x) << endl;
	return 0;
}


Measured memory_bytes: 256