akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


# Union Find（経路圧縮有）
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 親が同じか判別
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 根を繋ぎ直す
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 親が同じか判別
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 連結成分の大きさを返す
    def size(self, x):
        return -self.parents[self.find(x)]


def kruskal(max_node, edge):
    """
    :param max_node: UnionFind木に渡す頂点数です
    :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
    :return: 最小全域木のコストの和
    """
    edge.sort()
    uf = UnionFind(max_node)
    cost_sum = 0
    for cost, node1, node2 in edge:
        if not uf.same(node1, node2):
            cost_sum += cost
            uf.union(node1, node2)
    return cost_sum


def resolve():
    n = int(input())
    X, Y = [], []
    for i in range(n):
        x, y = map(int, input().split())
        X.append([x, i])
        Y.append([y, i])

    X.sort()
    Y.sort()
    cost = []
    for i in range(n - 1):
        cost.append([abs(X[i][0] - X[i + 1][0]), X[i][1], X[i + 1][1]])
        cost.append([abs(Y[i][0] - Y[i + 1][0]), Y[i][1], Y[i + 1][1]])

    res = kruskal(n, cost)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 62428
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll M;

int main()
{
  std::cin >> M;

  std::cout << 48-M << std::endl;

  return 0;
}

Measured memory_bytes: 256
import math
while True:
    num = int(input())
    if num == 0:
        break
    
    l = [int(x) for x in input().split()]
    average = sum(l)/len(l)
    div = 0
    for i in l:
        div += (i - average) **2
    
    div = math.sqrt(div/len(l))
    print(div)
    


Measured memory_bytes: 5712
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,d,x,t;cin>>n>>d>>x;
    int ans = 0;
    REP(i,n){
        cin>>t;
        if(d%t!=0) ans += d/t+1;
        else ans += d/t;
    }
    cout << ans + x << endl;
    return 0;
}

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

x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

p=max(x)
q=min(y)

Z=max(p,X)+1

if Z<=Y and Z<=q:
    print("No War")
else:
    print("War")

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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

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

  int sum =0;

  for (int i = 1; i < K+1; i++) {
    for (int j = 1; j < K+1; j++) {
      for (int k = 1; k < K+1; k++) {
        a = i;
        b = j;
        c = k;
        a = gcd(a, b);
        a = gcd(a, c);
        sum += a;
      }
    }
  }
  cout << sum << endl;;

  return 0;
}


Measured memory_bytes: 3636
class CumulativeSum2D:
    def __init__(self, size: int):
        self.size = size
        self.data = [[0 for _ in range(N + 1)] for _ in range(N + 1)]

    def add(self, l: int, r: int, v: int):
        self.data[l][r] += v

    def build(self):
        for l in range(self.size):
            for r in range(self.size):
                self.data[l + 1][r + 1] += self.data[l + 1][r]
                self.data[l + 1][r + 1] += self.data[l][r + 1]
                self.data[l + 1][r + 1] += -self.data[l][r]

    def query(self, l: int, r: int) -> int:
        """(l, r] x (l, r]
        """
        return self.data[r][r] + self.data[l][l] - self.data[l][r] - self.data[r][l]


def atcoder_express2(
        N: int, M: int, Q: int, data: list, queries: list) -> list:
    # 二次元累積和
    S = CumulativeSum2D(N)
    for l, r in data:
        S.add(l, r, 1)
    S.build()

    return [S.query(p-1, q) for p, q in queries]


if __name__ == "__main__":
    M, Q = 0, 0
    N, M, Q = map(int, input().split())
    data = [tuple(int(s) for s in input().split()) for _ in range(M)]
    queries = [tuple(int(s) for s in input().split()) for _ in range(Q)]
    ans = atcoder_express2(N, M, Q, data, queries)
    for a in ans:
        print(a)


Measured memory_bytes: 47672
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    vector<ll> A(N);
    vector<Pa> ANUML(N);
    rep(i,N){
        cin>>A.at(i);
        ANUML.at(i)=make_pair(A.at(i),i);
    }
    sort(ALLOF(ANUML));
    reverse(ALLOF(ANUML));
    rep(i,N){
        if(i==ANUML.at(0).second) cout<<ANUML.at(1).first<<endl;
        else cout<<ANUML.at(0).first<<endl;
    }
    return 0;
}


Measured memory_bytes: 6272
import java.util.*;class Main{public static void main(String[]z){for(Scanner s=new Scanner(System.in);s.hasNext();){z=s.next().split(",");int[]l=new int[11];int a,b,i;for(i=-1;i++<9;)l[i+1]=new Integer(z[i])+l[i];a=new Integer(z[10]);b=new Integer(z[11]);for(i=1;i<11;++i)if(a*l[10]/(double)(a+b)<=l[i])break;System.out.println(i);}}}

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

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

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

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


int n, b, t=0;

void solve()
{
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> b;
        if (b!=i) t++;
    }
    if (t>2) nout("NO");
    else nout("YES");

}

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

Measured memory_bytes: 256
// atcoder/abc088/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  while (true) {
    bool f = true;
    int g[3][3];
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        f = f && (cin >> g[i][j]);
      }
    }
    if (!f) break;

    bool x = false;
    for (int a0 = 0; a0 <= 100; ++a0) {
      for (int a1 = 0; a1 <= 100; ++a1) {
        for (int b0 = 0; b0 <= 100; ++b0) {
          for (int b1 = 0; b1 <= 100; ++b1) {
            int a2 = g[2][0] - b0;
            int b2 = g[0][2] - a0;

            if (g[0][0] != a0 + b0) continue;
            if (g[0][1] != a0 + b1) continue;
            if (g[0][2] != a0 + b2) continue;

            if (g[1][0] != a1 + b0) continue;
            if (g[1][1] != a1 + b1) continue;
            if (g[1][2] != a1 + b2) continue;

            if (g[2][0] != a2 + b0) continue;
            if (g[2][1] != a2 + b1) continue;
            if (g[2][2] != a2 + b2) continue;

            x = true;
          }
        }
      }
    }
    cout << (x ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,C,D,P,a,b,c=0;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	a=A*P;
	c=P-C;
	if(c<=0){
		
	c=0;
	}
	b=B+c*D;
	if(a<=b){
	printf("%d\n",a);
	}
	else{
	printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 596
n, m, x=[int(i) for i in input().split()]
a = [int(i) for i in input().split()]

# print(n, m, x)
# print(a)

A = [0 for i in range(n + 1)]
for i in a:
    A[i] = 1

# print(A)

cnt = 0
for i in range(x, n + 1):
    cnt += A[i]

cnt_ = 0
for i in range(x, -1, -1):
    cnt_ += A[i]
    # print(i, A[i])
# print(cnt_)

if cnt < cnt_:
    print(cnt)
else:
    print(cnt_)

Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

bool isEvenstr(string s) {
	int n = s.length();
	if (n % 2) return false;
	string a = s.substr(0, n / 2), b = s.substr(n / 2);
	return a == b;
}

int main() {
	string s; cin >> s;
	int n = s.length();
	for (int i = 0; i<n; i++) {
		int m = n - i - 1;
		s.pop_back();
		if (isEvenstr(s)) {
			cout << m << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  
  if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0)
    cout << "Possible";
  else
    cout << "Impossible";
  return 0;
}

Measured memory_bytes: 256
B=[]
while True:
    l=input().split()
    n=int(l[0])
    x=int(l[1])
    if n==0 and x==0:
        break
    else:
        a=list(range(1,n+1))
        b=0
        for i in a:
            for p in a:
                for m in a:
                    if i+p+m==x and i!=p and p!=m and m!=i:
                        b+=1
                    else:
                        pass
        B.append(int(b/6))

for c in B:
    print(c)


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int visit[101],d[101],f[101],t;
//
int n,M[101][101];
static const int WHITE=0; //未訪問
static const int GRAY=1; //訪問済み
void dfs(int u){
  visit[u]=GRAY; //訪問した
  d[u]=++t; //発見した時刻
  for(int v=0;v<n;++v){
    if(M[u][v]==0) continue;
    if(visit[v]==WHITE) dfs(v);
  }
  f[u]=++t;
}
int main(){
  int u,v,k,m;
  cin>>n;
   for(int i=0;i<n;++i){
    cin>>u>>k;
    u--; //頂点番号をあわせてる
    for(int j=0;j<k;++j){
      cin>>v;
      v--;
      M[u][v]=1;
    }
   }
  for(int i=0;i<n;++i){
    if(visit[i]==WHITE) dfs(i);
  }
  for(int i=0;i<n;++i){
    cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans=0;
    if(b>n){
        ll tmp = a*n/b - (n/b)*a;
        ans = max(ans, tmp);
    }else{
        ll i = b-1;
        ll tmp = (a*i/b) - (i/b)*a;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}



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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int primes[] = {3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123, 1153, 1163, 1193, 1213, 1223, 1283, 1303};
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("%d ", primes[i]);
  } 
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int main() {
    int a,b,c,x;
    cin >> a;       //500
    cin >> b;       //100
    cin >> c;       //50
    cin >> x;       //もとめる
    
    int a_, b_, c_, i=0;
    /*
    a_ = min(a, x/500);
    b_ = min(b,(x - a_ * 500) / 100);
    c_ = ((x - a_ * 500 - b_ * 100) / 50);
    if(c_ > c) {
        cout << 0 << endl;
        return 0;
    }
    for(; a_ >= 0;){
        int b__ = b_;
        int c__ = (x - a_ * 500 - b__ * 100) / 50;
        for(; b__ >= 0 && c__ <= c; i++){
            b__ -= 1;
            c__ += 2;
        }
        a_ -= 1;
        if(b_ + 5 <= b){
            b_ += 5;
        }else{
            c_ += 10;
        }
    }*/
    for(a_ = 0; a_ <= a; a_++){
        for(b_ = 0; b_ <= b; b_++){
            for(c_ = 0; c_ <= c; c_++){
                if(x==(a_*500+b_*100+c_*50)) i++;
            }
        }
    }
    cout << i << endl;
    return 0;
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> nums(n);
    rep(i, n)
    {
        cin >> nums[i];
    }
    // 正の座標を優先的に取得する
    int mini = INF;
    for (int i = 0; i <= n - k; i++)
    {
        int total = 0;
        if (nums[i] < 0)
        {
            total += abs(nums[i]) * 2;
        }
        else
        {
            total += nums[i];
        }

        if (nums[i + k - 1] < 0)
        {
        }
        else
        {
            total += nums[i + k - 1];
            if (nums[i] > 0)
            {
                total -= nums[i];
            }
        }

        mini = min(mini, total);
    }
    // 負の数を優先的に取得する
    for (int i = 0; i <= n - k; i++)
    {
        int total = 0;

        if (nums[i + k - 1] < 0)
        {
            total += abs(nums[i + k - 1]);
        }
        else
        {
            total += nums[i + k - 1] * 2;
        }
        if (nums[i] > 0)
        {
        }
        else
        {
            total += abs(nums[i]);
            if (nums[i + k - 1] < 0)
            {
                total -= abs(nums[i + k - 1]);
            }
        }
        mini = min(mini, total);
    }
    cout << mini << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
int a=0, b=0,c=0,ans=0;
cin >> a;
cin >> b;
int ball[a];
for (int i=0;i<a;i++){
    cin >> ball[i];
}
for(int j=0; c <= b ; j++){
c += ball[j];
ans ++;
}
cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

int h, w;
ll cb=0, cw=0, res=0;
string s[410];
bool grid[410][410];
int dx[]={1, 0, -1, 0};
int dy[]={0, 1, 0, -1};

void dfs(int x, int y){
    grid[y][x]=true;
    if(s[y][x]=='#')cb++;
    else if(s[y][x]=='.')cw++;

    for (int i = 0; i < 4; i++) {
        int nx=x+dx[i], ny=y+dy[i];
        if(nx>=w||nx<0||ny>=h||ny<0)continue;
        if(grid[ny][nx])continue;
        if(s[y][x]==s[ny][nx])continue;
        dfs(nx, ny);
    }
    return;
}

int main() {
    cin>>h>>w;
    for (int i = 0; i < h; i++) {
        cin>>s[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j]=='#'&&!grid[i][j]){
                cb=0, cw=0;
                dfs(j, i);
                res+=cb*cw;
            }
        }
    }

    cout<<res<<endl;    

    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int price;
	int num[5] = {0};
	int i = 0;

	while (1){
		scanf("%d", &price);

		if (price != 0){
			price = 1000 - price;

			if (price / 500 != 0){
				num[i] += (price / 500);
				price -= (price / 500) * 500;	
			}
			if (price / 100 != 0){
				num[i] += (price / 100);
				price -= (price / 100) * 100;
			}
			if (price / 50 != 0){
				num[i] += (price / 50);
				price -= (price / 50) * 50;
			}
			if (price / 10 != 0){
				num[i] += (price / 10);
				price -= (price / 10) * 10;
			}
			if (price / 5 != 0){
				num[i] += (price / 5);
				price -= (price / 5) * 5;
			}
			if (price / 1 != 0){
				num[i] += price;
			}
		}
		else {
			break;
		}
		i++;
	}

	for (int i = 0; num[i] >= 1; i++){
		printf("%d\n", num[i]);
	}

}

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	char X, Y;
	cin >> X >> Y;
	if (X == Y)cout << "=";
	else if (X > Y)cout << ">";
	else cout << "<";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var s, t string
	fmt.Fscan(read, &s, &t)
	fmt.Fprintln(write, t+s)
}


Measured memory_bytes: 640
from sys import stdin

def calc(N, Y):
    for i in range(N+1):
        for j in range(N+1-i):
            if 10000*i + 5000*j + 1000*(N-i-j) == Y:
                return '%s %s %s' % (i, j, (N-i-j))
    return '-1 -1 -1'

if __name__ == '__main__':
    N, Y = [int(x) for x in stdin.readline().rstrip().split()]
    print(calc(N, Y))


Measured memory_bytes: 3060
n = int(input()) + 1
data = [[0] * 3 for i in range(n)]

for i in range(1, n):
    data[i] = list(map(int, input().split()))

for i in range(1, n):
    dt = data[i][0] - data[i - 1][0]
    dx = data[i][1] - data[i - 1][1]
    dy = data[i][2] - data[i - 1][2]

    for j in range(dt//2 + 1):
        if dt - 2 *j == abs(dx) + abs(dy):
            if i == n - 1:
                print('Yes')
            break
    else:
        if i == n - 1:
            print('No')


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

// 構造体の定義
struct Card{
    char design;
    int value;
};

int N;
Card C1[36];
Card C2[36];

// 配列を出力
void print(Card C[]){
    for(int i = 0; i < N; i++){
        cout << C[i].design << C[i].value << (i != N-1 ? " " : "\n");
    }
}

// バブルソート（後ろの要素から順番に入替）
void bubble_Sort(){
    for(int i = 0; i < N; i++){
        for(int j = N-1; j >= i+1; j--){
            if(C1[j].value < C1[j-1].value){
                swap(C1[j], C1[j-1]);
            }
        }
    }
}

// 選択ソート（頭から最小値を検索して入替）   
void selection_Sort(){
    
    for(int i = 0; i < N; i++){
        int min_Psi = i;
        for(int j = i; j < N; j++){
            if(C2[j].value < C2[min_Psi].value) min_Psi = j;
        }
        swap(C2[i], C2[min_Psi]);
    }
}

// 安定ソートか確認
void check(){
    
    for(int i = 0; i < N; i++){
        if(C1[i].design != C2[i].design) {
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
}

int main(void){
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> C1[i].design >> C1[i].value;
        C2[i] = C1[i];
        
    }
    
    // バブルソート
    bubble_Sort();
    print(C1);
    cout << "Stable" << endl;

    // 選択ソート    
    selection_Sort();
    print(C2);
    check();
    
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int X, Y, Z; cin >> X >> Y >> Z;
    int N = X + Y + Z;
    vec A(N), B(N), C(N);
    int ans = 0;
    pairs p(N);
    REP(i, N){
        cin >> A[i] >> B[i] >> C[i];
        ans += C[i];
        A[i] -= C[i];
        B[i] -= C[i];
        p[i] = Pii(A[i] - B[i], i);
    }
    Sort(p);
    Reverse(p);
    vec a1(N, -INF), a2(N, -INF);

    priority_queue<int, vector<int>, greater<int>> que1;
    int tmp1 = 0;
    REP(i, X){
        tmp1 += A[p[i].s];
        que1.push(A[p[i].s]);
    }
    a1[X - 1] = tmp1;
    FOR(i, X, N){
        if(A[p[i].s] > que1.top()){
            tmp1 += A[p[i].s] - que1.top();
            que1.pop();
            que1.push(A[p[i].s]);
        }
        a1[i] = max(a1[i - 1], tmp1);
    }

    priority_queue<int, vector<int>, greater<int>> que2;
    int tmp2 = 0;
    REP(i, Y){
        tmp2 += B[p[N - 1 - i].s];
        que2.push(B[p[N - 1 - i].s]);
    }
    a2[N - Y] = tmp2;
    FOR(i, Y, N){
        if(B[p[N - 1 - i].s] > que2.top()){
            tmp2 += B[p[N - 1 - i].s] - que2.top();
            que2.pop();
            que2.push(B[p[N - 1 - i].s]);
        }
        a2[N - 1 - i] = max(a2[N - i], tmp2);
    }
    int a = -INF;
    REP(i, N - 1) Max(a, a1[i] + a2[i + 1]);
    ans += a;
    cout << ans << endl;

    return 0;
}


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

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

    int a;
    // 引数の受け取り
    //
    cin >> a ;
    if(a%10 == 9 || a/10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;

    // 出力
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int n,k,w[200000];
int bs(int a)
{
    int i,t = 0,c = 1;
    for(i = 0;i < n;i++)
    {
        if(w[i] > a) return 0;
        if(t+w[i] > a)
        {
            c++;
            t=0;
        }
        t += w[i];
    }
    return c<=k;
}
 
int main()
{
    int i,j,r,m;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&w[i]);
    for(j=0,r=2147483647;j<r;)
    {
        m=(j+r)/2;
        if(bs(m))
            r = m;
        else
            j = m+1;
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 2160
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a;
	cin>>b;
	if(a==1 && b==2)
	cout<<"3"<<endl;
	else if(a==1 && b==3)
	cout<<"2"<<endl;
	else if(a==2 && b==3)
	cout<<"1"<<endl;
	else if(a==2 && b==1)
	cout<<"3"<<endl;
	else if(a==3 && b==1)
	cout<<"2"<<endl;
	else if(a==3 && b==2)
	cout<<"1"<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define int ll

int32_t main(){
    FAST
    int k; cin >> k;
    int sum = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int a = 1; a <= k; a++){
                sum += __gcd(__gcd(i, j), a);
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
S = input()

S_dict = {}

for s in S:
    if not s in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1

x = 1
for k,v in S_dict.items():
    x *= v

print('Yes') if len(S_dict) == 2 and x == 4 else print('No')

Measured memory_bytes: 3060
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

type item struct {
	A, B, C, D int
}

var n, m int

func dfs(seq []int, rst *[][]int) {
	if len(seq) == n {
		*rst = append(*rst, seq)
		return
	}

	var last int
	if len(seq) == 0 {
		last = 1
	} else {
		last = seq[len(seq)-1]
	}
	for i := last; i <= m; i++ {
		dfs(append(seq, i), rst)
	}
}

func calcPoint(seq []int, items []item) int {
	point := 0
	for _, it := range items {
		if seq[it.B]-seq[it.A] == it.C {
			point += it.D
		}
	}
	return point
}

func findMaxPoint(seqs [][]int, items []item) int {
	max := 0
	for _, seq := range seqs {
		if v := calcPoint(seq, items); v > max {
			max = v
		}
	}
	return max
}

func solve(items []item) int {
	seq := make([]int, 0)
	rst := make([][]int, 0)
	dfs(seq, &rst)
	return findMaxPoint(rst, items)
}

func main() {
	n, m = nextInt(), nextInt()
	q := nextInt()
	items := make([]item, q)
	for i := 0; i < q; i++ {
		items[i] = item{nextInt() - 1, nextInt() - 1, nextInt(), nextInt()}
	}
	ans := solve(items)
	fmt.Println(ans)
}


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

bool isvalid(string s,int k) {
    for(int i=0; i<s.length(); ++i) if(s[i] == 'X') s[i] = k+'0';
    string par[3];
    int stat = 0;
    for(int i=0; i<s.length(); ++i) {
        if(s[i] == '+' || s[i] == '=') stat++;
        else{
            par[stat] += string(1, s[i]);
        }
    }

    for(int i=0; i<3; ++i) reverse(par[i].begin(), par[i].end());

    string res = "";
    int carry = 0;
    for(int i=0; i<min(par[0].length(), par[1].length()); ++i) {
        int k = par[0][i] - '0',l = par[1][i] - '0';
        carry += k + l;
        res += string(1, (carry%10)+'0');
        carry /= 10;
    }
    int ll = (par[0].length() < par[1].length());
    for(int i=min(par[0].length(), par[1].length());
        i < max(par[0].length(), par[1].length()); ++i) {
        carry += par[ll][i] - '0';
        res += string(1, (carry%10)+'0');
        carry /= 10;
    }
    if(carry > 0) res += string(1, carry+'0');
    return res == par[2];
}

int main() {
    string s;
    while(cin>>s) {
        for(int i=0; i<=9; ++i) {
            if(isvalid(s,i)) {
                cout<<i<<endl;
                goto NEXT;
            }
        }
        cout<<"NA"<<endl;
    NEXT:;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int d[140][140];
int previous[140][140];
int reached[140][140];

void printpath(int start,int goal){
    for(int cur=goal;cur!=start;cur=previous[start][cur]){
        reached[cur][(previous[start][cur])]=1;
        reached[(previous[start][cur])][cur]=1;
    }
}

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n) rep(j,n) d[i][j]=1000000000;
    rep(i,n) rep(j,n) previous[i][j]=i;
    rep(i,m){
        int src,to,weight;
        cin>>src>>to>>weight;
        --src;--to;
        d[src][to]=weight;
        d[to][src]=weight;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(d[i][j]>d[i][k]+d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                    previous[i][j]=previous[k][j];
                }
            }
        }
    }
    rep(i,n) rep(j,n) printpath(i,j);
    int res=0;
    rep(i,n) rep(j,n){
        if(reached[i][j])++res;
    }
    res/=2;
    cout<<m-res<<endl;
}
    


Measured memory_bytes: 384
#catupper
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()#与えられる配列の小さい値を、大きい値に書き換える

queries = []#書換候補を配列に格納する
for i in range(m):
    b, c = map(int, input().split())#書換数と書換値を入力
    queries.append((c,b))
    #ソートを考慮して、書換値・書換数の順番で配列に入れる

queries.sort(reverse=True)#降順ソート
p = 0#何個、書き替えたか、カウントしておく
for c, b in queries:#逆順で配列に入れているので注意
    while p < len(a) and b > 0:
    #書換られる配列aの長さを書き換えた回数pが超えない、
    #書換値cに書換できるのは書換数b個まで
        if a[p] < c:#書き換えることで値が大きくなれば、書き換え
            a[p] = c
            b -= 1#cに書換可能なbをデクリメント
        p += 1#全体での書換上限pをインクリメント

print(sum(a))#書換後の合計が答

Measured memory_bytes: 20940
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n;
int D[100];
int matrix[100][100];
void bfs(int src)
{
    //cerr<<"bfs root = "<<src<<endl;
    queue<int> q;
    q.push(src);
    D[src]=0;
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        //cerr<<"visiting "<<cur<<' '<<D[cur]<<endl;
        for(int dst=0;dst<n;dst++)
        {
            if(matrix[cur][dst]==1&&D[dst]==-1)
            {
                D[dst]=D[cur]+1;
                q.push(dst);
            }
        }
    }
};

int main()
{
    vector<int> l[101];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int tmp;
            cin>>tmp;
            l[u].push_back(tmp);
        }
    }
    
    for(int i=0;i<100;i++)
    {
        D[i]=-1;
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            matrix[i][j]=0;
        }
    }
    
    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<l[i].size();j++)
        {
            matrix[i-1][l[i][j]-1]=1;
        }
    }
    
    bfs(0);
    
    for(int i=0;i<n;i++)
    {
        cout<<(i+1)<<' '<<D[i]<<endl;
    }
}

Measured memory_bytes: 3164
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num - 1)]
    graph_data = defaultdict(set)
    for i in range(num - 1):
        a, b = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)

    black, white = 0, 0
    b_ind_now, w_ind_now = set(), set()
    b_ind_next, w_ind_next = set(), set()
    # b_ind_pre, w_ind_pre = set(), set()
    pre_ind = set()
    b_ind_now.add(1)
    w_ind_now.add(num)
    # b_ind_pre.add(1)
    # w_ind_pre.add(1)
    pre_ind.add(1)
    pre_ind.add(num)

    while len(b_ind_now) > 0 or len(w_ind_now) > 0:
        for ele_now in b_ind_now:
            for ele_next in graph_data[ele_now]:
                if ele_next in pre_ind:
                    continue
                pre_ind.add(ele_next)
                b_ind_next.add(ele_next)
                black += 1
        b_ind_now = b_ind_next
        b_ind_next = set()


        for ele_now in w_ind_now:
            for ele_next in graph_data[ele_now]:
                if ele_next in pre_ind:
                    continue
                pre_ind.add(ele_next)
                w_ind_next.add(ele_next)
                white += 1
        w_ind_now = w_ind_next
        w_ind_next = set()

        # print(white, black)

    if black > white:
        print('Fennec')
    else:
        print('Snuke')





if __name__ == '__main__':
    main()


Measured memory_bytes: 100572
S = input()

s = 0
t = 0
res = len(S)
stack = [S[0]]
for i in range(1, len(S)):
    if stack != []:
        if stack[-1] == 'S' and S[i] == 'T':
            stack.pop()
        else:
            stack.append(S[i])
    else:
        stack.append(S[i])

print(len(stack))
        

Measured memory_bytes: 4860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N,L;
	cin>>N>>L;
	int a[MAX+1];
	rep1(i,N)cin>>a[i];
	
	int k[MAX];
	int lo=0;
	int un=0;
	rep1(i,N-1){
		k[i]=a[i]+a[i+1];
		if(lo<k[i]){
			lo=k[i];
			un=i;
		}
	}
	if(lo<L)cout<<"Impossible"<<endl;
	else{
		cout<<"Possible"<<endl;
		rep1(i,un-1)cout<<i<<endl;
		for(int i=N-1;i>=un;i--)cout<<i<<endl;
	}
}

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

int main(){

  string s,t;
  cin >> s >> t;

  int s_len=s.length();
  int t_len=t.length();

  vector<vector<int>> dp(s_len+1,vector<int>(t_len+1,0));
  string ans="";

  for(int s_index=0;s_index<s_len;s_index++){
    for(int t_index=0;t_index<t_len;t_index++){
      if(s[s_index]==t[t_index]){
        //dp[s_index+1][t_index+1]=max(dp[s_index+1][t_index+1],dp[s_index][t_index]+1);
        dp[s_index+1][t_index+1]=dp[s_index][t_index]+1;
      }
      dp[s_index+1][t_index+1]=max(dp[s_index+1][t_index+1],dp[s_index+1][t_index]);
      dp[s_index+1][t_index+1]=max(dp[s_index+1][t_index+1],dp[s_index][t_index+1]);
    }
  }

  /*for(int i=1;i<=s_len;i++){
    for(int j=1;j<=t_len;j++){
      cout << dp[i][j];
    }
    cout << endl;
  }*/


  int s_index=s.length();
  int t_index=t.length();
  while(s_index>0 && t_index>0){
    if(dp[s_index-1][t_index]==dp[s_index][t_index]){
      s_index--;
    }else if(dp[s_index][t_index-1]==dp[s_index][t_index]){
      t_index--;
    }else{
      ans = s[s_index-1] + ans;
      s_index--;
      t_index--;
    }
  }

  //cout << dp[s_len][t_len] << endl;
  cout << ans << endl;
}

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

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

int MOD = 1e9 + 7;
int INF = 1e9;
// ll INF = 1e18;

int n, a[105];

int solve(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a, a+n);
	int sum = accumulate(a, a+n, 0);
	if(sum % 10 == 0) for(int i=0;i<n;i++){
		if(a[i] % 10){
			sum -= a[i];
			break;
		}
	}
	if(sum % 10)
		cout << sum << endl;
	else
		cout << 0 << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
let init n f =
  let rec loop i l = if i < n then loop (i + 1) (f i :: l) else l in
  List.rev (loop 0 [])

let n = Scanf.scanf "%d\n" (fun n -> n)
let ps = init n (fun _ -> Scanf.scanf " %c" (fun c -> c = 'T'))
let b = match ps with
    p :: ps -> List.fold_left (fun b p -> not b || p) p ps
  | _ -> raise (Failure "")
let () = if b then
           print_endline "T"
         else
           print_endline "F"



Measured memory_bytes: 8536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2019nic3
{
    class Program
    {
        class TA
        {
            public long A;
            public long B;
            public long AB;
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long A, B;
            List<TA> li = new List<TA>();

            for (int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                A = long.Parse(input[0]);
                B = long.Parse(input[1]);

                TA tmp = new TA();

                tmp.A = A;
                tmp.B = B;
                tmp.AB = A + B;

                li.Add(tmp);
            }

            li.Sort((a, b) => b.AB.CompareTo(a.AB));

            long TAK = 0;
            long AOK = 0;

            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    TAK += li[i].A;
                }
                else
                {
                    AOK += li[i].B;
                }

            }

            Console.WriteLine(TAK - AOK);
        }
    }
}


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

#define INF 900000000
#define LINF 9000000000000000000
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int n, k;

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

	cin >> n >> k;
	k++;

	vector<int> a(n), b(n);
	REP(i,n) cin >> a[i] >> b[i];

	ll r = 0;
	for (int h = 1<<30; h > 0; h >>=1) {
		//cout << k << ' ' << bitset<8>(k) << ' ' << h << ' ' << bitset<8>(h) <<  endl;
		if (k&h) {
			//cout << "yes" << endl;
			//cout << "m " << bitset<8>(k^h) << ' ' << bitset<8>(h-1) << endl;
			int m = ~((k^h)|(h-1));
			ll s = 0;
			REP(i,n) {
				//cout << a[i] << ' ' << bitset<8>(a[i]) << ' ' << m << ' ' << bitset<8>(m);
				if (!(a[i]&m)) s+=b[i]; //cout << " ok";
				//cout << endl;
			}
			//cout << "m,s,r : " << m << ',' << s << ',' << r << endl << endl;
			r = max(r,s);
		}
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N,M; cin >> N >> M;
    vector<int> ans(N,0);
    for(int i=0;i<2*M;i++){
        int m; cin >> m;m--;
        ans[m]++;
    }
    for(int i=0;i<N;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 100000 + 1;
const int inf = (int)1e8 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MAX_INT = (1 << 31) - 1;
const double eps = 1e-6;
const double pi = atan2(0, -1);

/*void print(vector<auto> &a)
{
    for (auto i : a)
        cout << i << " ";
    cout << endl;
}*/

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("calc.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    string s, x = "SW";
    cin >> n >> s;
    int t[n];
    rep(j, 0, 8)
    {
        rep(i, 0, 3)
            t[i] = (j >> i) & 1;
        rep(i, 2, n - 1)
            if (t[i] == 0)
            {
                if (s[i] == 'o')
                    t[i + 1] = t[i - 1];
                else
                    t[i + 1] = 1 - t[i - 1];
            }
            else
            {
                if (s[i] == 'o')
                    t[i + 1] = 1 - t[i - 1];
                else
                    t[i + 1] = t[i - 1];
            }
        bool ok = true;
        rep(i, 0, n)
            if (t[i] == 0)
            {
                if (s[i] == 'o')
                    ok &= (t[(i - 1 + n) % n] == t[(i + 1) % n]);
                else
                    ok &= (t[(i - 1 + n) % n] != t[(i + 1) % n]);
            }
            else
            {
                if (s[i] == 'o')
                    ok &= (t[(i - 1 + n) % n] != t[(i + 1) % n]);
                else
                    ok &= (t[(i - 1 + n) % n] == t[(i + 1) % n]);
            }
        if (ok)
        {
            rep(i, 0, n)
                cout << x[t[i]];
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
#define bs binary_search
//#define d double
bool comp(pi a,pi b){
    return a.se<b.se;
}
int main(){
	FIO;
	int n,k,s;
	cin>>n>>k>>s;
	const int rk=1000000000;
	for(int i=0;i<n;i++){
	    if(i<k) cout<<s<<" ";
	    else cout<<(s+1)%(rk)<<" ";
	}
	    
} 
 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3576
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0,d[10][10]={};
	cin >> n;
	int x[n],y[n];
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	
	/*
	rep(i,n){
		rep(j,n){
			int p=x[j]-x[i],q=y[j]-y[i];
			c=0
			rep(k,n){
				int a=x[k],b=y[k];
				rep(l,n){
					if(x[l]-a==p && y[l]-b==q){
						a = x[l];
						b = y[l];
						//l=0;
						c++;
					}
					//cout << "ak" << endl;
				}
			}
			if(ans<c){
				ans = c;
			}
		}	
	}*/

	rep(i,n){
		rep(j,n){
			if(i==j) break;
			int p=x[j]-x[i],q=y[j]-y[i],c=0;
			rep(k,n){
				rep(l,n){
					if(x[l]-x[k]==p && y[l]-y[k]==q){
						c++;
					}
				}
			}
			if(ans<c){
				ans = c;
			}
		}
	}

	cout << n-ans << endl;
}

Measured memory_bytes: 888