akhauriyash/Code-Regression huggingface dataset:
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討

#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3 * 1e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL<<60;
const long double EPS = 1e-7;
const int X = 1;
const int Y = 0;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE], B[SIZE];

LL solve() {
	LL N,P;
	cin >> N >> P;
	LL ans = 1;
	if (N > 50) return 1;
	if (N == 1) return P;
	EFOR(i,2, P) {
		if (N*log(i-1) > log(P)) return ans;
		LL now = 1;
		REP(j, N) {
			if (P%i == 0) P /= i;
			else break;
			if (j == N - 1) {
				ans *= i;
				i--;
			}
		}
	}
	return ans;
}
signed main() {
	cout << solve() << endl;
	
	cin >> N;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 8192
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

vector<int>adj[9];
int last;
int cnt=0;
void rec(int u,int msk)
{
    if(msk==last)
    {
        cnt++;
        return;
    }
    for(auto v:adj[u])
    {
        if(!(msk>>v & 1))
        {
            rec(v,msk|(1LL<<v));
        }
    }
}
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    last=(1LL<<n)-1;
    rec(0,1);
    cout<<cnt<<endl;
    return 0;

}






































Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s=std::move(buf);

  if (s[0] == '0' || s.back() == '1') return !printf("-1\n");

  if (s == std::string(s.length()-1, '1') + "0") {
    for (size_t i=1; i<s.length(); ++i)
      printf("%zu %zu\n", i, i+1);
    return 0;
  }

  size_t n=s.length();
  for (size_t i=0; i+1<n; ++i) {
    if (s[i] != s[n-i-2]) {
      fprintf(stderr, "%zu [%c:%c]\n", i, s[i], s[n-i-1]);
      return !printf("-1\n");
    }
  }

  size_t last=1;
  for (size_t i=1; i<n; ++i) {
    printf("%zu %zu\n", last, i+1);
    if (s[i-1] == '1') {
      last = i+1;
    }
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  char x, y;
  cin >> x >> y;

  if (x < y) {
    cout << "<";
  } else if (x > y) {
    cout << ">";
  } else {
    cout << "=";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
s = input()

ans = 0

cand = defaultdict(int)
for bit in range(1 << n):
    red = []
    blue = []
    for i in range(n):
        if (bit >> i) & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    red = ''.join(red[::-1])
    blue = ''.join(blue[::-1])
    cand[(red, blue)] += 1

for bit in range(1 << n):
    red = []
    blue = []
    for i in range(n):
        if (bit >> i) & 1:
            red.append(s[n + i])
        else:
            blue.append(s[n + i])

    red = ''.join(red)
    blue = ''.join(blue)
    ans += cand[(red, blue)]

print(ans)


Measured memory_bytes: 169212
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XL):
    s = []
    for x, l in XL:
        lp, rp = x-l, x+l
        s.append((lp, rp))

    s.sort(key=lambda x: x[1])
    # s.sort(key=lambda x: x[0])

    ans = 0
    t = -INF
    for l, r in s:
        if t <= l:
            ans += 1
            t = r

    return ans

def main():
    N = read_int()
    XL = [read_int_n() for _ in range(N)]
    print(slv(N, XL))


if __name__ == '__main__':
    main()


Measured memory_bytes: 86872
#include<stdio.h>
#define LEN1 100000
#define LEN2 500

int main(){
  int i, j, count=0;
  int n, q, S[LEN1], T[LEN2];

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++)
    scanf("%d", &T[i]);

  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(T[i] == S[j]){
        count++;
        break;
      }
    }
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 2700
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	string s[n];
	unordered_map<char,int> map[n];
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<s[i].size();j++){
			map[i][s[i][j]]++;
		}
	}
	int mini;
	char ans;
	for(int az=0;az<26;az++){
		mini=INF;
		ans = char(az+'a');
		for(int i=0;i<n;i++){
			mini = min(mini,map[i][ans]);
		}
		for(int i=0;i<mini;i++) cout << ans;
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    char c;
    cin >> c;
    
    if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include<set>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    set<int> s1, s2, s;
    for (int i = 0; i < n ;i++) {
        int t;cin >> t;
        s1.insert(t);
    }
    cin >> n;
    for (int i = 0;i < n; i++) {
        int t;cin >> t;
        s2.insert(t);
    }
    set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(s, s.begin()));
    for(auto it : s) {
        cout << it << endl;
    }
    return 0;
}


Measured memory_bytes: 31204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double

main(){
	int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n){
    ans=ans+a[i]-1;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  map<ll,bool> paper;
  
  ll n; cin >> n; ll cnt = 0;
  
  rep(i,n){
    ll x; cin >> x;
    if(paper[x]){
      paper[x] = false;
    }
    else paper[x] = true;
    
  }
  
  for(auto p : paper){
    bool flag = p.second;
    
    if(flag) cnt++;
    
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 6528
import java.io.*;
  public class Main{
    public static void main(String[] args)throws IOException{
      BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String str;
        while((str=mBufferedReader.readLine())!=null){
        String[] arr=str.split(" ");
        int a=Integer.parseInt(arr[0]);
        String op=arr[1];
        int b=Integer.parseInt(arr[2]);
        if(op.equals("+")){
          System.out.println(a+b);
        }else if(op.equals("-")){
          System.out.println(a-b);
        }else if(op.equals("*")){
          System.out.println(a*b);
        }else if(op.equals("/")){
          System.out.println(a/b);
        }else{
          break;
        }
      }
      mBufferedReader.close();
  }
}


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

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

using namespace std;
using lint=long long;

const lint MOD=1000000007;

int main(){
	int n,m; cin>>n>>m;
	vector<int> s(n),t(m);
	rep(i,n) cin>>s[i];
	rep(i,m) cin>>t[i];

	vector<vector<lint>> dp(n+1,vector<lint>(m+1));
	dp[0][0]=1;
	rep(i,n) dp[i+1][0]=1;
	rep(j,m) dp[0][j+1]=1;
	rep(i,n) rep(j,m) {
		dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j]-dp[i][j]+MOD)%MOD;
		if(s[i]==t[j]) dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%MOD;
	}
	cout<<dp[n][m]<<endl;

	return 0;
}


Measured memory_bytes: 31616
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t pos[200000];
std::pair<int32_t, int32_t> v[200000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		in >> v[i].first;
		v[i].second = i;
	}
	std::sort(v, v + N);
	for (int32_t i = 0; i < N; i++)
	{
		pos[v[i].second] = i;
	}
	for (int32_t i = 0; i < N; i++)
	{
		if (pos[i] < N / 2) {
			out << v[N / 2].first<<endl;
		}
		else {
			out << v[N / 2-1].first << endl;
		}
	}

	return 0;
}
#endif


Measured memory_bytes: 4608
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    # s = input()
    # a, b = map(int, input().split())
    p = list(map(int, input().split()))
    # a = [int(input()) for i in range(N)]

    count = 0
    for i in range(N):
        if i+1 != p[i]:
            count += 1
    if count == 2 or count == 0:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll, ll> mp;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  ll ans = 0;
  for (auto& x : mp) {
    ll a = x.first, b = x.second;
    if (b >= m) {
      ans += a * m;
      break;
    }
    m -= b;
    ans += a * b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,n,qq;
priority_queue<ll>q;
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>qq;
    for(ll i=1,a;i<=n;++i)
		cin>>a,q.push(a);
	for(ll i=1;i<=qq;++i)
	{
		ll num=q.top();q.pop();
		q.push(num/2);
	}
	while(!q.empty())ans+=q.top(),q.pop();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
/* main code starts from line 130. */

/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;
template <typename T>
using PQ = priority_queue<T>;

using ll = long long;
using str = string;

#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end

#define SORT(v) sort(ALL(v))
#define GSORT(v) sort(ALL(v), greater<decltype((v).front())>())

/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n-1 to 0)
// Natural REP runs from 1 to n (R: n to 1)

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

#define fcout cout << fixed << setprecision(10)

/* ----------- debug ---------- */

template <typename T, typename U>
void testP2(T a, U b) {
    cout << "(" << a << ", " << b << ")" << endl;
    return;
}

template <typename T>
void testV(T v) {
    cout << "[";
    for (auto i : v) {
        cout << i << ", ";
    }
    cout << "\b\b]" << endl;
    return;
}

template <typename T>
void testV2(T v) {
    for (auto sv : v) {
        testV(sv);
    }
    cout << endl;
    return;
}

#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p)                      \
    cout << GET_VAR_NAME(p) << " = "; \
    testP2(p.fst, p.snd);

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

/* ---------- Type Definition ----------- */


/* ---------- Global Variance ----------- */


/* ------------- Functions -------------- */


/* ----------- Main Function ------------ */

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

    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define pll pair<ll,ll>
#define vll vector<long long>
#define f first
#define s second
long long mod = 1e9+7;
typedef vector<map<char,int>> vmci;

// int diry[] = {-1,-1,-1,0,0,1,1,1};
// int dirx[] = {-1,0,1,-1,1,-1,0,1};

ll pow(ll x, ll y, ll p) {
    ll res = 1;
    x %= p;
    if(x == 0) {
        return 0;
    }
    while(y > 0) {
        if(y & 1) {
            res = (res * x) % p;
        }
        y >>= 1;
        x = (x * x) % p;
    }
    return res;
}

// ll factorial(ll n) 
// { 
//     int res = 1, i; 
//     for (i = 2; i <= n; i++) 
//         res *= i; 
//     return res; 
// }

void seg_sieve(ll max,ll arr[]){
    ll i,j;
    for(i=2;i*i<=max;i++){
        if(arr[i]==0){
            for(j=i*i;j<=max;j+=i)
                arr[j]=1;
        }
    }
}


bool check(ll n,set<ll> &a){
    
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(n/i==i){
                if(a.count(i)) return true;
                a.insert(i);
            }
            else{
                if(a.count(i)) return true;
                a.insert(i);
                if(a.count(n/i)) return true;
                a.insert(n/i);
            }            
        }
    }
    return false;
}

int lte(vector<ll> array, int start_idx, int end_idx, ll search_val) {

   if( start_idx == end_idx )
      return array[start_idx] <= search_val ? start_idx : -1;

   int mid_idx = start_idx + (end_idx - start_idx) / 2;

   if( search_val < array[mid_idx] )
      return lte( array, start_idx, mid_idx, search_val );

   int ret = lte( array, mid_idx+1, end_idx, search_val );
   return ret == -1 ? mid_idx : ret;
}

bool noob(const pii &a,const pii &b){
    if(a.second == 0 ) return true;
    return a.first*1.0/a.second > b.first*1.0/b.second;
}

unordered_map<bitset<1000>,int> dp;

void dfs(vector<set<int>> &adj,vector<bool> &vis,int x,int &lmax){
    vis[x]=1;
    lmax++;
    for(auto i:adj[x]){
        if(!vis[i]){
            dfs(adj,vis,i,lmax);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;    
    // cin>>t;        
    while(t--){    
        int n;
        cin>>n;
        vll arr(n);
        set<ll> in;
        for(int i=0;i<n;i++){
            cin>>arr[i];            
        }
        ll gcd=arr[0];
        for(int i=1;i<n;i++){
            gcd = __gcd(gcd,arr[i]);
        }
        if(gcd!=1){
            cout<<"not coprime";
            break;
        }
        int flag=1;
        for(int i=0;i<n;i++){
            if(in.count(arr[i]) or check(arr[i],in)){                
                // for(auto j:in) cout<<j<<'a';                
                flag=0; break;
            }        
            in.insert(arr[i]);
            in.erase(1);    
        }
        if(flag==1) cout<<"pairwise coprime";
        else cout<<"setwise coprime";
        
    }
    
}

Measured memory_bytes: 11052
#include<iostream>
#include<vector>
#include<map>
using namespace std;


int main(){
  int N;
  cin>>N;
  string s;
  map<string,int> m;
  
  for(int i=0;i<N;i++){
    cin>>s;
    if(m[s]==0){
      m[s]=1;
    }else{
      m.at(s)++;
    }
  }
  cout<<m.size();
}

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

int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  for(int i = 0;i < n;i++){
   if(s.at(k-1) == s.at(i)){
     continue;
   }else{
     s.at(i) = '*';
   }
  }
    cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
h, w = map(int,input().split())
a = [input() for _ in range(h)]
for i in range(h):
    l =""
    for j in range(w):
        if a[i][j] == "#":
            l += "#"
        else:
            l+=str(sum([s[max(0,j-1):min(w,j+2)].count("#") for s in a[max(0,i-1):min(h,i+2)]]))
    print(l)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int A;
    //りんごの数
    int P;
    //りんごの欠片の数
    cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
    //頭の中ではわかっているけど言葉にできない処理
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
	int N;
	cin>>N;
	vector<string> S(N);
	FOR(i,N)cin>>S[i];
	vector<string> S1(S);
	FOR(i,N){
		for(char& c:S1[i])if(c=='?')c='z';
	}
	string T;
	cin>>T;
	sort(ALL(S1));
	int h=lower_bound(ALL(S1),T)-S1.begin();
	vector<string> S2(S);
	FOR(i,N){
		for(char& c:S2[i])if(c=='?')c='a';
	}
	sort(ALL(S2));
	int t=upper_bound(ALL(S2),T)-S2.begin();
	for(int i=h;i<=t;++i)cout<<i+1<<(i<t?" ":"\n");
  return 0;
}

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

using namespace std;
const int INF = 1000000000;

int popcount[1 << 16];
int dp[2][16][1 << 16];
vector<int> patterns[17];

int main(){
	int R, C;
	cin >> R >> C;
	vector<string> words(R + 2);
	for(int i = 1; i <= R; ++i){ cin >> words[i + 1]; }
	for(int i = 0; i < (1 << C); ++i){ popcount[i] = __builtin_popcount(i); }
	for(int i = 0; i < 2; ++i){
		for(int j = 0; j < C; ++j){
			for(int k = 0; k < (1 << C); ++k){ dp[i][j][k] = -INF; }
		}
	}
	dp[1][C - 1][0] = 0;
	const int all_mask = (1 << C) - 1;
	for(int i = 1; i < R + 2; ++i){
		int crow = i & 1, nrow = 1 - crow;
		for(int j = 0; j < C; ++j){
			for(int k = 0; k < (1 << C); ++k){
				int dp_cur = dp[crow][j][k];
				dp[crow][j][k] = -INF;
				int cur = k & ((1 << j) - 1), prev = k >> j;
				int pcc = popcount[cur], pcp = popcount[prev];
				if(j == 0 && pcp != words[i - 1].size()){ continue; }
				if(pcc > words[i].size() || pcp > words[i - 1].size()){ continue; }
				int nr = (j == C - 1 ? nrow : crow), nc  = (j + 1) % C, nk = (k << 1) & all_mask;
				dp[nr][nc][nk] = max(dp[nr][nc][nk], dp_cur);
				if(pcc < words[i].size()){
					int s = dp_cur;
					char c = words[i][pcc];
					if((k & 1) && words[i][pcc - 1] == c){ s += 2; }
					if((k & (1 << (C - 1))) && words[i - 1][words[i - 1].size() - pcp] == c){ s += 2; }
					dp[nr][nc][nk | 1] = max(dp[nr][nc][nk | 1], s);
				}
			}
		}
	}
	int answer = -INF;
	for(int i = 0; i < (1 << C); ++i){
		if(popcount[i] != words.back().size()){ continue; }
		answer = max(answer, dp[R & 1][0][i]);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 9668
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  string s,t="keyence";
    cin>>s;

    for(int i=0;i<=7;i++){
      string a=t.substr(0,i),b=t.substr(i,7-i);
      if(a==s.substr(0,i)&&b==s.substr(s.length()-(7-i),7-i)){
        cout<<"YES"<<endl;
        return 0;
         }
    }

    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    deque<char> dq;
    ll i, j, k;
    char a[100005], c;
    cin >> a;
    ll q, t, f, st = 0;
    cin >> q;
    ll h = strlen(a);
    //end-=1;
    for (i = 0; i < h; i++)
    {
        dq.pb(a[i]);
    }
    for (i = 0; i < q; i++)
    {
        cin >> t;
        if (t == 2)
        {
            cin >> f;
            getchar();
            cin >> c;
            if (f == 1)
            {
                if (st == 0)
                {
                    dq.push_front(c);
                }
                else if (st == 1)
                {
                    dq.pb(c);
                }
            }
            if (f == 2)
            {
                if (st == 1)
                {
                    dq.push_front(c);
                }
                else if (st == 0)
                {
                    dq.pb(c);
                }
            }
        }
        else
        {
            st = !st;
        }
    }
    if (st == 0)
    {
        while (dq.empty() != 1)
        {
            cout << dq.front();
            dq.pop_front();
        }
    }
    else
    {
        while (dq.empty() != 1)
        {
            cout << dq.back();
            dq.pop_back();
        }
    }

    return 0;
}

Measured memory_bytes: 896
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    int n,m,x;
    cin >> n >> m >> x;
    int a[n+1]={0};
    for(int i=1;i<=m;i++){
      int x;
      cin >> x;
      a[x]=1;
    }
    int sum = 0;
    for(int i=1;i<=x;i++){
      sum+=a[i];
    }
    cout << min(sum,m-sum) << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

char tmp[305][305];

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

    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }

    int res = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            for(int k = 0; k < n; ++k){
                tmp[j][k] = s[j][(k+i)%n];
            }
        }

        bool flag = true;
        for(int j = 0; j < n-1; ++j){
            for(int k = j+1; k < n; ++k){
                if(tmp[j][k] != tmp[k][j]){
                    flag = false;
                    break;
                }
            }

            if(!flag)   break;
        }

        if(flag)    res += n;
    }

    cout << res << endl;
}

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


int main(){
    
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        v[i] = d;
    }
    sort(v.begin(),v.end());
    ans = v[n/2] - v[(n/2)-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
n=io.read("*n","*l")
m={}
combination=0
for i=1,n do
    a=io.read("*n")
    if not m[i+a] then
        m[i+a]=0
    end
    if m[i-a] then
        combination=combination+m[i-a]
    end
    m[i+a]=m[i+a]+1
end
print(combination)

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

int main(){
	int H, W;
	cin >> H >> W;
	string list[H];
	string text = "";
	for(int i = 0; i < H; i++){
		cin >> list[i];
	}
 	for(int i = 0; i < W + 2; i++){
 		text.push_back('#');
 	}
 	cout << text << endl;
	for(int i = 0; i < H; i++){
		cout << "#" << list[i] << "#" << endl;
	}
 	cout << text << endl;
}

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

int main(){

    int N, M;
    cin >> N >> M;

    vector<int> ans(N);
    int s, c, i;
    int c1=0, c2=0, c3=0;
    int count1=0, count2=0, count3=0;
    int flg=0;

    for (i=0; i<M; i++){
        cin >> s >> c;

        if ((s == 1) && (c != c1) && (count1 > 0)){
            flg = 1;
        }
        if ((s == 2) && (c != c2) && (count2 > 0)){
            flg = 1;
        }
        if ((s == 3) && (c != c3) && (count3 > 0)){
            flg = 1;
        }

        if ( (s == 1) && (count1 == 0)){
            c1 = c;
            ans.at(s-1) = c1; 
            count1++;
        }
        if ( (s == 2) && (count2 == 0)){
            c2 = c;
            ans.at(s-1) = c2;
            count2++;
        }
        if ( (s == 3) && (count3 == 0)){
            c3 = c;
            ans.at(s-1) = c3;
            count3++;
        }
    }

    if (N>1){
        if (count1 == 0){
            ans.at(0) = 1;
        }
    }

    if ( ( (N>1) && (ans.at(0) == 0) && (M != 0) ) || (flg != 0) ){
        cout << -1 << endl;
    }
    else if (M == 0){
        if (N == 1){
            cout << 0 << endl;
        }
        if (N == 2){
            cout << 10 << endl;
        }
        if (N == 3){
            cout << 100 << endl;
        }
    }
    else{
        for (i=0; i<N; i++){
            cout << ans.at(i);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }

int main() {
	ll X;
	cin >> X;

	ll cost = 0;
	while (X >= 5) {
		if (X >= 500) {
			X -= 500;
			cost += 1000;
			continue;
		}

		X -= 5;
		cost += 5;
	}

	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.Point;
class Main {
    static Queue<Point> q;
    static int[][] count;
    static char[][] maze;
    static int H,W;
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	H = sc.nextInt();
	W = sc.nextInt();
	maze = new char[H][W];
	count = new int[H][W];
	int white = 0;
	for(int i = 0; i<H; i++) {
	    for(int j = 0; j<W; j++) {
		count[i][j] = 100000;
	    }
	}
	for(int i = 0; i<H; i++) {
	    String line = sc.next();
	    for(int j = 0; j<W; j++) {
		maze[i][j] = line.charAt(j);
		if(maze[i][j] == '.') white++;
	    }
	}

	count[0][0] = 1;
	q = new ArrayDeque<Point>();
	q.add(new Point(0,0));
	while(q.peek() != null) {
	    Point p = q.poll();
	    if(p.getX() == H-1 && p.getY() == W-1) break;
	    addPQ(p);
	}
	int result = count[H-1][W-1];
	if(result < 100000) {
	    System.out.println(white - count[H-1][W-1]);
	}else {
	    System.out.println(-1);
	}
    }
    public static void addPQ(Point p) {
	int x = (int)(p.getX());
	int y = (int)(p.getY());
	//System.out.println("x : y" + x +" , "+ y);
	if(maze[x][y] =='#') return;
	maze[x][y] = '#';
	if(x+1<H && maze[x+1][y] == '.') {
	    q.add(new Point(x+1,y));
	    count[x+1][y] = count[x][y] + 1;
	}
	if(x-1>=0 && maze[x-1][y] == '.') {
	    q.add(new Point(x-1,y));
	    count[x-1][y] = count[x][y]+ 1;
	}
	if(y+1<W && maze[x][y+1] == '.') {
	    q.add(new Point(x, y+1));
	    count[x][y+1] = count[x][y]+ 1;
	}
	if(y-1>=0 && maze[x][y-1] == '.') {
            q.add(new Point(x,y-1));
	    count[x][y-1] = count[x][y]+ 1;
	}
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x[5];
for(int i=0;i<5;i++)
{
	cin>>x[i];
	if(x[i]==0)
	{
		cout<<i+1<<endl;
		return 0;
	}
}

return 0;
}
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	int n, p[111],dai,kazu;
	cin >> n;
		dai = -1;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; i++) {
		kazu = 0;
		for (int z = 1; z <= n; z++) {
			if (p[z] >= i) {
				kazu++;
			}
		}
		if (kazu >= i) {
			if (dai < i) {
				dai = i;
			}
		}
	}
	cout << dai << endl;
}


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

int main()
{
    int n;
    cin>>n;
    int ar[n+1];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n);
    int mn=1e9;
    for(int i=ar[0];i<=ar[n-1];i++)
    {
        int cal=0;
        for(int j=0;j<n;j++)
            cal+=pow(ar[j]-i,2);
        mn=min(mn,cal);
    }
    cout<<mn<<endl;
    return 0;
}


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

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}

int main(){
    string s;
    while(cin >> s, s != "#"){
        int pos = s.length()-1;
        int child = 0, mother = 1<<20;

        for(int i = 0; pos >= 0; i++){
            if(s[pos] == 'h'){
                if(i)   child -= 90 * (1<<(20-i));
                pos -= 5;
            }else if(s[pos] == 't'){
                child += 90 * (1<<(20-i));
                pos -= 4;
            }
        }

        int g = gcd(child, mother);
        child /= g, mother /= g;

        if(mother == 1){
            cout << child << endl;
        }else{
            cout << child << "/" << mother << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3216
n = int(input())
s = [int(x) for x in input().split()]

for i in range(n):
    s[i] = s[i] - i - 1

s.sort()
a = s[(n+1)//2 - 1]

res = 0
for ss in s:
    res += abs(ss - a)
print(res)


Measured memory_bytes: 25196
(N, M, T), *XYs = $<.map{|l| l.split.map &:to_i }

puts(
  if T == 1
    A = N.times.map{|i| 1 << i }
    XYs.reverse_each do |x, y|
      A[x-1] = A[y-1] |= A[x-1]
    end
    all = A.reduce :&
    if all == 0
      -1
    else
      goal = N.times.find{|i| all[i] == 1 }
      ok = N.times.map{|i| i == goal }
      ans = XYs.reverse.map do |x, y|
        if ok[x-1]
          ok[y-1] = true
          ?^
        else
          ok[x-1] ||= ok[y-1]
          ?v
        end
      end
      ans.reverse.join
    end
  else
    if N == 2
      -1
    else
      to = [1, 2, 3]
      ans = XYs.reverse.map do |x, y|
        if y > 3
          ?^
        elsif to[x] == to[6 - x - y]
          to[x] = to[y]
          ?v
        else
          to[y] = to[x]
          ?^
        end
      end
      ans.reverse.join
    end
  end
)


Measured memory_bytes: 493164
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int m = fs.nextInt();
        int[][] range = new int[m][2];
        for(int i=0;i<m;i++){
            range[i][0] = fs.nextInt();
            range[i][1] = fs.nextInt();
        }

        Arrays.sort(range,new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[1] - o2[1];
			}
        });
        int f = 0,ans = 0;
        for(int i=0;i<m;i++){
            if(range[i][0]>=f){
                ans++;
                f = range[i][1];
            }
        }
        System.out.print(ans);
        System.out.flush();
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <=0){
                return false;
            }
        }
        return true;
    }

    private int readByte(){
        if(hasNextByte())return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}

Measured memory_bytes: 26984
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())

c = collections.Counter(prime_factorize(N))

output = 0
for k, v in c.items():
    num = 1
    cnt = 0
    while num <= v:
        cnt += 1
        v -= num
        num += 1
    output += cnt
    
print(output)

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

int main() {
  long long X;
  cin >> X;
  long long Y = 100;
  int count = 0;
  long long risoku;
  
  while (Y < X){
    risoku = Y/100;
    Y += risoku;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    char c[105];
    int k;
    scanf("%d%s",&k,c);
    int maxn=0;
    for (int i=0;i<k-1;i++)
    {
        int flag1[26],flag2[26];
        memset(flag1,0,sizeof(flag1));
        memset(flag2,0,sizeof(flag2));
        for (int j=0;j<=i;j++) flag1[c[j]-'a']++;
        for (int j=i+1;j<k;j++) flag2[c[j]-'a']++;
        int ans=0;
        for (int j=0;j<26;j++)
            if (flag1[j]!=0&&flag2[j]!=0) ans++;
        maxn=max(maxn,ans);
    }
    printf("%d\n",maxn);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int max(int a,int b){return (a<b?b:a);};
typedef struct {
  int p,s,deg,dep,h,left,right;
} Node;

Node t[100000];
int n;

void setdepth(int x){
  if(t[x].p==-1){
    t[x].dep=0;
    return;
  }
  if(t[x].dep==-1){
    setdepth(t[x].p);
    t[x].dep=t[t[x].p].dep+1;
  }
}

void setheight(int x){

  int l=t[x].left;
  int r=t[x].right;
  if(t[x].deg==0){
    t[x].h=0;
    return;
  }
  if(t[x].h==-1){
    if(l!=-1){
      setheight(l);
      t[x].h=max(t[x].h,t[l].h+1);
    }
    if(r!=-1){
      setheight(r);
      t[x].h=max(t[x].h,t[r].h+1);
    }
  }
}

void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i].p=t[i].s=t[i].deg=t[i].dep=t[i].h=t[i].left=t[i].right=-1;
  }
}

int main(){
  init();
  int i,id,a,b;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&a,&b);
    if(a!=-1){
      t[id].left=a;
      t[a].p=id;
    }
    if(b!=-1){
      t[id].right=b;
      t[b].p=id;
    }
    if(a!=-1&&b!=-1){
      t[a].s=b;
      t[b].s=a;
    }
    t[id].deg=(a!=-1)+(b!=-1);
   
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,t[i].p,t[i].s,t[i].deg);
    setdepth(i);
    setheight(i);
    printf("depth = %d, height = %d, ",t[i].dep,t[i].h);
    
    if(t[i].p==-1)printf("root\n");
    else if(t[i].deg!=0)printf("internal node\n");
    else printf("leaf\n");
    
  }
  return 0;
}

Measured memory_bytes: 3344
N = int(input())
*A, = map(int,input().split())

if N%2==0:
    INF = 2* 10**9
    dp = [[-INF]*N for _ in [0]*2]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    for i in range(2,N,2):
        a = A[i]
        dp[0][i] = dp[0][i-2] + a
    for i in range(3,N):
        a = A[i]
        dp[1][i] = max(dp[1][i-2],dp[0][i-3]) + a
    print(max(dp[1][-1],dp[0][-2]))
else:
    INF = 2* 10**9
    dp = [[-INF]*N for _ in [0]*3]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(2,N,2):
        a = A[i]
        dp[0][i] = dp[0][i-2] + a
    for i in range(3,N):
        a = A[i]
        dp[1][i] = max(dp[1][i-2],dp[0][i-3]) + a
    for i in range(4,N,2):
        a = A[i]
        dp[2][i] = max(dp[2][i-2],dp[1][i-3],dp[0][i-4]) + a
    print(max(dp[2][-1],dp[1][-2],dp[0][-3]))

Measured memory_bytes: 41036
#include<cstdio>

int main(){
	int sen[10000],bit[1024],num[1024][11],s,i,j,r,c,cc;
	for(int r=1;r<11;r++){
		for(i=0;i<2<<r;i++){
			for(num[i][r]=0,s=i;s>0;s >>= 1)num[i][r]+=s&1;
			if(num[i][r]<r/2) num[i][r] = r-num[i][r];
		}
	}

  while(1){
		scanf("%d %d",&r,&c);
		if (!r)break;
		for(i=0;i<c;i++) sen[i] = 0;
		for(j=0;j<r;j++){
			for(i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		for(i=0;i<1024;i++) bit[i] = 0;
		for(i=0;i<c;i++) bit[sen[i]]++;

		int n,sum = 0,smax = 0,k=1;
		k <<= r-1;
		for(i=0;i<k;i++){
			sum = 0;
			for(j=0;j<k<<1;j++){
				s = j^i;
				sum += num[s][r] * bit[j];
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

Measured memory_bytes: 852