akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, fastout};

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    if n==1 {
        println!("Hello World");
    } else {
        input!{
            a: usize,
            b: usize,
        }
        println!("{}", a+b);
    }

}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include<array>
using namespace std;
using UL = unsigned;
using LL = long long;
using ULL = unsigned long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)
void Solve() {
	UL an[100000] = {};
	UL an2[100000] = {};
	UL n; cin >> n;
	ULL ans = 1;
	UL col = 0;
	rep(i, n) {
		UL a; cin >> a;
		an[a]++;
		an2[a]++; if (an2[a] == 4) { cout << 0 << endl; return; }
		if (a != 0) {
			ans = ans * an[a - 1] % 1000000007;
			an[a - 1]--;
		}
		else col++;
	}
	UL mul = 1;
	if (col == 1) mul = 3;
	if (col == 2) mul = 6;
	if (col == 3) mul = 6;
	cout << ans * mul % 1000000007 << endl;
}
int main() { Solve(); return 0; }


Measured memory_bytes: 1024
#include <cstdint>
#include <iostream>

using namespace std;

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

    int count_k = 0;
    int count_half = 0;

    for (int i = 1; i <= n; i += 1) {
        if (i % k == 0) {
            count_k += 1;
        } else if (i % k == k / 2) {
            count_half += 1;
        }
    }

    int64_t res = 1LL * count_k * count_k * count_k;
    if (k % 2 == 0) {
        res += 1LL * count_half * count_half * count_half;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  if(N == 0) {
    cout << 0 << endl;
    return 0;
  }
  string ans = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
  ll two[40];
  CLR(two);
  two[0] = 1;
  FOR(i,1,40) two[i] = two[i-1] * 2;
  vector<P> v;
  // +
  FOR(i,0,1<<16) {
    ll num = 0;
    FOR(j,0,16) {
      if(i & (1 << j)) {
        num += two[j * 2];
      }
    }
    v.push_back(P(num, i));
  }
  sort(v.begin(), v.end());
  // -
  FOR(i,0,1<<16) {
    ll num = 0;
    FOR(j,0,16) {
      if(i & (1 << j)) {
        num -= two[j * 2 + 1];
      }
    }
    int k = lower_bound(v.begin(), v.end(), P(N - num, -2e9)) - v.begin();
    if(v[k].first + num == N) {
      FOR(j,0,16) {
        if(v[k].second & (1 << j)) {
          ans[j*2] = '1';
        }
      }
      FOR(j,0,16) {
        if(i & (1 << j)) {
          ans[j*2+1] = '1';
        }
      }
      break;
    }
  }
  reverse(ans.begin(), ans.end());
  bool f = false;
  FOR(i,0,ans.length()) {
    if(f) {
      cout << ans[i];
    } else {
      if(ans[i] == '1') {
        cout << ans[i];
        f = true;
      }
    }
  }
  cout << endl;
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    int64_t K, A[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t opt_same = 0, opt_less = -1e18;

    for(int d=40; d>=0; d--){
        int64_t D = 1LL<<d;
        
        int num1 = 0;
        for(int i=0; i<N; i++) if(nth_bit(A[i], d)) num1++;
        int num0 = N - num1;

        opt_less += D * max(num0, num1);

        if(nth_bit(K, d)){
            opt_less = max(opt_less, opt_same + D * num1);
            opt_same += D * num0;
        }else{
            opt_same += D * num1;
        }
    }

    cout << max(opt_same, opt_less) << endl;
    return 0;
}

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

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	long long x = 1LL * n * m / __gcd(n, m);
	for(int i = 0, j = 0; i < n && j < m; i += x / m, j += x / n) {
		if(s[i] != t[j]) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << x << '\n';

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

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

using namespace std;

const int N = 1e5 + 27;

vector<int> g[N];
int col[N];

bool dfs(int v, int c)
{
	//cout << v << " " << c << endl;
	col[v] = c;

	for (int u : g[v])
	{
		if (col[u] != -1 && col[u] != (1 - c))
			return 0;
		if (col[u] == -1 && !dfs(u, 1 - c))
			return 0;
	}

	return 1;
}

int main()
{
	long long n, m;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		
		g[a].push_back(b);
		g[b].push_back(a);	
	}

	for (int i = 1; i <= n; i++)
		col[i] = -1;	

	if(dfs(1, 0))
	{
		long long b = 0, w = 0;

		for (int i = 1; i <= n; i++)
		{
			//cout << i << " " << col[i] << endl;
			if (col[i])
				b++;
			else
				w++;
		}

		cout << (b * w) - m;
	}	
	else
		cout << (1LL * n * (n - 1) / 2 - m);
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> que;
    vector<int> seen(n, -1);

    int ans = -1;

    rep(i,n){
        if(seen[i] != -1) continue;
        ans++;
        seen[i] = ans;
        que.push(i);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int nv : g[v]){
                if(seen[nv] != -1) continue;
                que.push(nv);
                seen[nv] = ans;
            }
        }
    }
    cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        int n;
        long[][] dp;
        long[] a;

        private void fill(int left, int right) {
            if (dp[left][right] != Long.MAX_VALUE) return;
            for (int i = 0; left + i < right; i++) {
                fill(left, left + i);
                fill(left + i + 1, right);

                long combine = sum(left, left + i) + sum(left + i + 1, right);
                dp[left][right] = Math.min(dp[left][right], dp[left][left+i] + dp[left+i+1][right] + combine);
            }
        }

        long[] sum;
        private long sum(int left, int right) {
            if (left == 0) return sum[right];
            return sum[right] - sum[left-1];
        }

        private void solve(InputReader inp, PrintWriter out) {
            n = inp.nextInt();
            dp = new long[n][n];

            a = new long[n];
            for (int i = 0; i < n; i++) a[i] = inp.nextInt();

            sum = new long[n];
            sum[0] = a[0];
            for (int i = 1; i < n; i++) sum[i] = sum[i-1] + a[i];

            for (long[] array: dp) Arrays.fill(array, Long.MAX_VALUE);
            for (int i = 0; i < n; i++) dp[i][i] = 0;

            fill(0, n - 1);

            out.print(dp[0][n-1]);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 26736
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, q, k, red[N], white[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
int a[N], b[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> q;
	fill (white, white + n, 1);
	white[0] = 0;
	red[0] = 1;
	while (q--) {
		int i, j;
		cin >> i >> j;
		i--; j--;
		if (red[i]) {
			red[i]--;
			red[j]++;
			red[j] += white[j];
			white[j] = 0;
		} else {
			white[i]--;
			if (red[j])
				red[j]++;
			else
				white[j]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += (red[i] > 0);
	cout << ans << endl;
}

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

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
  array<array<int,3>,3>a;
  
  REP(i,3){
    REP(j,3){
      cin >> a[i][j];
    }
  }
  
  array<int,3>y;
  array<int,3>x; x[0] = 0;
  REP(i,3)y[i]=a[0][i]-x[0];
  REP(i,3)x[i]=a[i][0]-y[0];
  bool good = true;
  
  REP(i,3){
    REP(j,3){
      if(x[i]+y[j] != a[i][j])good = false;
    }
  }
  
  if(good == true)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}




  /*
  int a1{},a2{},a3{},b1{},b2{},b3{};
  
  int c11 = a1+b1,  c21 = a2+b1,  c31 = a3+b1,
      c12 = a1+b2,  c22 = a2+b2,  c32 = a3+b2,
      c13 = a1+b3,  c23 = a2+b3,  c31 = a3+b3;
  
  if()*/
  

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc065/tasks/arc076_b

#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e18;

struct pos {
    ll x;
    ll y;
};
struct edge {
    ll to;
    ll cost;
};
using Graph = vector<vector<edge>>;
// <最短距離, 頂点の番号>
using P = pair<ll, ll>;

vector<ll> dist; // 最短距離
// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(const Graph &G, int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<ll>(n, INFTY);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n*2; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < G[v].size(); k++) {
        edge e = G[v][k];
        // cout << v << endl;;
        if (dist[v] != INFTY && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (e.to == n-1 && i == 2 * n-1) return true; // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}


int main() {

    ll N, M;    cin >> N >> M;
    Graph G(N);
    REP(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--; c *= -1;
       G[a].push_back({b, c});
    }

    bool ans = bellman_ford(G, N, 0);

    if(ans == false){
        cout << -dist[N-1] << endl;
    } else{
        cout << "inf" << endl;
    }
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 555;
int n, m;
char s[N][N];

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

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf(" %s ", s[i]);
	for (int i = 0; i < n; i++)
	{
		printf("#");
		for (int j = 1; j < m - 1; j++)
		{
			if (i % 2 == 0 || s[i][j] == '#')
				printf("#");
			else
				printf(".");
		}
		printf(".\n");
	}
	printf("\n");
	for (int i = 0; i < n; i++)
	{
		printf(".");
		for (int j = 1; j < m - 1; j++)
		{
			if (i % 2 == 1 || s[i][j] == '#')
				printf("#");
			else
				printf(".");
		}
		printf("#\n");
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct node{
	int number;
	int pos;
}s[100005];
bool cmp(node a,node b){
	return a.pos<b.pos;
}
int main(){
	int n,k;
	cin >>n;
	
	for(int i=1;i<=n;i++){
		
		scanf("%d",&s[i].pos);
		s[i].number=i;
		
		
	}
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(i==1)printf("%d",s[i].number);
		else printf(" %d",s[i].number);
	}
	return 0;
}

Measured memory_bytes: 1536
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100,W=10000;
int n,m,dp[W+1]={0},v[N],w[N];
void solve(){
	for(int i=0;i<n;i++) 
		for(int j=m;j>=w[i];j--) 
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
} 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d%d",&v[i],&w[i]);
	solve();printf("%d\n",dp[m]);
}	


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> heights(N+1, 0);

    for(int i=1; i<N+1; i++){
        cin >> heights.at(i);
    }

    vector<int> reachableHeightMax(N+1, 0);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        reachableHeightMax.at(a) = max(reachableHeightMax.at(a), heights.at(b));
        reachableHeightMax.at(b) = max(reachableHeightMax.at(b), heights.at(a));
    }

    int res = 0;
    for(int i=1; i<N+1; i++){
        if(heights.at(i) > reachableHeightMax.at(i))res++;
    }

    cout << res;
}

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

#define FOR(i,a,b) for(long long int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

set<long long int> st;

int main()
{
    long long int A, B, K;
    cin >> A >> B >> K;

    FOR(i, A, A + K)
    {
        if (B < i) break;
        st.insert(i);
        cout << i << endl;
    }

    FOR(i, B - K + 1, B + 1)
    {
        if (i <= A) break;
        set<long long int>::iterator itr = st.find(i);
        if (itr == st.end())
        {
            cout << i << endl;
        }
    }

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i], A[i]--;
	int ret=0;
	FOR(i,N) if(A[i]>i && A[A[i]]==i) ret++;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	cout << N * N * N << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
#include <fstream>
#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  ll A, B;
  std::cin >> A >> B;

  ll res1 = 0LL;
  ll res2 = 0LL;
  for (ll i = B; (i) % 4 != 3 && i >= 0; i--) {
    res1 ^= i;
  }
  for (ll i = A-1; (i) % 4 != 3 && i >= 0; i--) {
    res2 ^= i;
  }
  ll ans = res1 ^ res2;

  print(ans);
}


Measured memory_bytes: 256
from sys import exit
from math import ceil
N,H = [int(n) for n in input().split()]
ab = [(0,0)]*N
maxa = 0#振る最大値
ans = 0
for i in range(N):
    ab[i] = tuple(int(n) for n in input().split())
    maxa = max(maxa, ab[i][0])
ab = sorted(ab,key= lambda x:-x[1])
for katana in ab:
    if katana[1] > maxa:
        H-=katana[1]
        ans+=1
        if(H<=0): break
    else:
        break

if(H<=0):
    print(ans)
else:
    print(ans + ceil(H/maxa))

Measured memory_bytes: 21992
#include<bits/stdc++.h>
using namespace std;
//datatypes
	#define int long long
	#define vi vector<int>
	#define si set<int>
	#define vii vector<ii>
	#define ii pair<int,int>
	#define mii map<int,int>
	#define M 1000000007
	#define pi 3.141592653589793
	#define in(x) int x; cin>>x;
	#define sz(x) (int)x.size()
	#define fr first
	#define sc second
	#define pb push_back
	#define mkp make_pair
	#define inputFile \
	    freopen("input.txt", "r", stdin); 
	#define outputFile \
	    freopen("output.txt", "w", stdout)
	#define rep(i,a,b) for(int i=a; i<b; i++)
	#define trav(a) for(auto &x:a)
	#define test cout<<"hello\n";
	#define all(x) (x).begin(),(x).end()
	#define mem0(x) memset(x, 0, sizeof(x))
	#define mem1(x) memset(x, -1, sizeof(x))
	#define sa(x) std::sort(all(x))
	#define sd(x) std::sort(all(x),greater<int>())
	#define pf push_front

signed solve()
{
	string a,b;
	cin>>a>>b;
	int m=sz(a);
	int n=sz(b);
	//cout<<a<<b<<m<<n<<endl;
	int dp[m+1][n+1];
	mem0(dp);

	rep(i,1,m+1)
	{
		rep(j,1,n+1)
		{
			if(a[i-1]==b[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout<<dp[m][n];
	/*rep(i,0,m+1)
	{
		rep(j,0,n+1)
		cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	vector<char> an;
	an.clear();

	int i=m, j=n;
	while(i&&j)
	{
		if(a[i-1]==b[j-1])
		{
			an.pb(a[i-1]);
			i--;
			j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else j--;
		}
	}
	//cout<<sz(an);
	/*trav(an)
	cout<<x;*/
	//std::reverse(std::begin(an), std::end(an));
	//cout<<an;
	if(an.size()==0)
		cout<<"";
	else for(auto it=--an.end(); it>=an.begin(); it--)
		cout<<*it;
	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	//cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 70656
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
a, b = m.times.map{gets.split.map(&:to_i)}.transpose

vw = Array.new(n+1, 1)
for i in 0..(m-1)
  if h[a[i]-1] == h[b[i]-1]
    vw[a[i]] = 0
    vw[b[i]] = 0
  elsif h[a[i]-1] > h[b[i]-1]
    vw[b[i]] = 0
  elsif h[a[i]-1] < h[b[i]-1]
    vw[a[i]] = 0
  end
end
cnt = 0
for i in 1..n
  cnt += vw[i]
end
puts cnt

Measured memory_bytes: 24724
#include<iostream>
#include<map>
#include<vector>

using namespace std;

typedef long long ll;

struct cum_sum_lm {
	vector<int> sum;
	int N;
	cum_sum_lm() = default;
	cum_sum_lm(int _N) {
		N = _N;
		sum.resize(N + 1);
	}

	void setup(vector<int>& _ar) {
		sum.resize(_ar.size() + 1);
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + _ar[i];
		}
	}
	ll getval(int l, int r) {
		//[l, r)
		ll ret = sum[r] - sum[l];
		return ret;
	}
};

int N;
map<int, int> A;
vector<int> B(300000 + 10);
cum_sum_lm sum;

int main() {
	cin >> N;
	ll X = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}

	X = N;
	ll s = X;
	for (auto it = A.begin(); it != A.end(); it++) {
		B[(*it).second]++;
	}
	sum.setup(B);
	
	cout << X << endl;
	ll cnt = 0;
	for (int k = 2; k <= N; k++) {
		while (X > 0) {
			//cout << k << " " << X << " " << s << endl;
			//X*K<=取れるもの ならば今のXでOK
			if (X * k <= s + cnt * X) {
				break;
			}
			else {
				//sをX-1としたときに減る分を高速計算しておく
				s -= B[X] * X;
				cnt += B[X];
				//cout << X << "   " << X + 1 << " " << B[X] << endl;
				X--;
			}
		}
		cout << X << endl;
	}
	return 0;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int Par[100000],Rank[100000] = {},Weight[100000] = {};
void init(int n){
  for(int i=0;i<n;i++) Par[i] = i;
}
int find(int x){
  if(Par[x]==x) return x;
  int r = find(Par[x]);
  Weight[x] += Weight[Par[x]];
  return Par[x] = r;
}
int weight(int x){
  find(x);
  return Weight[x];
}
int diff(int x,int y){
  return weight(y)-weight(x);
}
void merge(int x,int y,int w){
  w = w+weight(x)-weight(y);
  x = find(x);y = find(y);
  x = find(x);y = find(y);
  if(x==y) return;
  if(Rank[x]<Rank[y]){
    swap(x,y);w = -w;
  }
  if(Rank[x]==Rank[y]) Rank[x]++;
  Par[y] = x;Weight[y] = w;
}
bool same(int x,int y){
  return find(x)==find(y);
}
int main(){
  int n,m,i,l,r,d;scanf("%d%d",&n,&m);
  init(n);
  for(i=0;i<m;i++){
    scanf("%d%d%d",&l,&r,&d);l--;r--;
    if(same(l,r)){
      if(d!=diff(l,r)){
        printf("No\n");return 0;
      }
    } else merge(l,r,d);
  }
  printf("Yes\n");
}

Measured memory_bytes: 1408
s=input()
q=int(input())
check=0
query=["","",""]
tfel=""
right=""
for i in range(q):
    query=list(map(str,input().split()))
    if (query[0]=="1"):
        check+=1
    else:
        if (query[1]=="1"):
            if (check%2==0):
                tfel+=query[2]
            else:
                right+=query[2]
        else:
            if (check%2==0):
                right+=query[2]
            else:
                tfel+=query[2]
            
s=tfel[::-1]+s+right
print(s if check%2==0 else s[::-1])

Measured memory_bytes: 4596
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    ll ans=1;
    ll c[n+1];
    fill(c,c+n+1,0);
    rep(i,0,n){
       // cout<<ans<<endl;
        if(a[i]==0){
            ans*=(3-c[0]);
            c[0]++;
            ans%=mod;
            continue;
        }
        ll t=c[a[i]-1];
        ll s=c[a[i]];
        if(t<=s){
            ans=0;
            continue;
        }
        ans*=(t-s);
        ans%=mod;
        c[a[i]]++;
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ab = reads!string;
    auto s = ab[0] ~ ab[1];

    int n = s.to!int;
    int x = cast(int)sqrt(1.0 * n);
    writeln(n == x * x ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
	int a,b,c;
	int i,n,flag;
	long long sum;
	while(~scanf("%d %d %d",&a,&b,&c))
	{
		flag=0;
		n = c % b;
		for(i = 0;i < 1000;i++)
		{
			sum = (i + 1) * a;
			if(sum % b == n)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			printf("YES\n");
		if(flag==0)
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define P pair<int, int>
int px[] = { 0, 2, 0, -2 };
int dx[] = { 0, 1, 0, -1 };
int py[] = { 2, 0 ,-2, 0 };
int dy[] = { 1, 0 ,-1, 0 };

int main() {
	int w, h;
	while (cin >> w >> h) {
		if (w == 0 && h == 0)return 0;
		int d[60][60];
		bool m[60][60] = {};
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w - 1; j++) {
				cin >> m[i * 2][2 * j + 1];
			}
			if (i != h - 1) {
				for (int j = 0; j < w; j++) {
					cin >> m[i * 2 + 1][2 * j];
				}
			}
		}

		for (int i = 0; i < 2 * h; i++) {
			for (int j = 0; j < 2 * w; j++) {
				d[i][j] = 1 << 30;
			}
		}
		queue<P> q;
		q.push({ 0,0 });
		d[0][0] = 1;
		while (!q.empty()) {
			P p = q.front();
			q.pop();
			int a = p.first, b = p.second;
			for (int i = 0; i < 4; i++) {
				int rx = a + px[i];
				int tx = a + dx[i];
				int ry = b + py[i];
				int ty = b + dy[i];
				if (0 <= rx && rx < 2 * h && 0 <= ry && ry < 2 * w) {
					if (d[rx][ry] > d[a][b] + 1 && !m[tx][ty]) {
						d[rx][ry] = d[a][b] + 1;
						q.push({ rx, ry });
					}
				}
			}
		}
		cout << (d[2 * h - 2][2 * w - 2] == 1 << 30 ? 0 : d[2 * h - 2][2 * w - 2]) << endl;
	}
	return 0;
}


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

int main() {
  int a, b, r=0;
  cin >> a >> b;
  
  if (a-b <= a+b && a*b <= a+b) r = a+b;
  if (a+b <= a-b && a*b <= a-b) r = a-b;
  if (a+b <= a*b && a-b <= a*b) r = a*b;
  cout << r << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
      if(s.length()==6 && s.charAt(2)==s.charAt(3) && s.charAt(4) == s.charAt(5)){
        System.out.println("Yes");
      }else{
      System.out.println("No");
      }
    }
}

Measured memory_bytes: 22612
s=int(input())

n = s - 5

dp = [0] * 2001

dp[1]=2
dp[2]=3
dp[3]=4

for i in range(4, 2001):
    dp[i] = dp[i-1] + dp[i-3]

if s < 3:
    print(0)
elif s == 3:
    print(1)
elif s == 4:
    print(1)
elif s == 5:
    print(1)
else:
    print(dp[n]%(10**9+7))

Measured memory_bytes: 9336
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
/*
 * ex.  s = "aaabaaaab"
 * -> z[i]= "*21034210"
 */
vector<int> Z_algorithm(const string &s){
    int sz=s.length();
    vector<int> z(sz,0);
    int i = 1, j = 0;
    while(i < sz) {
        while(i+j<sz && s[j]==s[i+j]) j++;
        z[i] = j;
        if(j==0){ i++; continue; }
        int k = 1;
        while(i+k<sz && k+z[k]<j){ z[i+k] = z[k]; k++; }
        i += k; j -= k;
    }
    return z;
}

vector<int> Z_algorithm2(const string &s){
    int sz = s.length();
    vector<int> z(sz);
    int l=0, r=0;
    for(int i=1;i<sz;i++){
        if(i>r){
            l = r = i;
            while(r<sz && s[r-l]==s[r]) r++;
            z[i]=r-l; r--;
        } else{
            int k=i-l;
            if(z[k]<r-i+1) z[i]=z[k];
            else{
                l=i;
                while(r<sz && s[r-l]==s[r]) r++;
                z[i]=r-l; r--;
            }
        }
    }
    return z;
}

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

    string s,p; cin>>s>>p;
    int slen = s.length(),plen=p.length();
    string t = p + "$" + s;
    vector<int> z = Z_algorithm(t);
    for(int i=plen+1;i<plen+slen+1;i++){
        int idx=i-plen-1;
        if(z[i]==plen) cout<<idx<<endl;
    }
    /*
    string rs="";
    for(int i=0;i<sz;i++) rs += s[sz-i-1];
    vector<int> z = Z_algorithm2(s), rz = Z_algorithm2(rs);
    ll res=0;
    for(int i=sz/2+1;i<sz;i++){
        int a = min(sz-i-1,z[i]), c = min(sz-i-1,rz[sz-i]);
        res += max(0, a+c-(sz-i)+1);
    }
    cout<<res<<endl;
    */
}


Measured memory_bytes: 8952
n=int(input())
a=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for q in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v
for b in range(4):
    for f in a[b]:
        print(" "+" ".join(map(str,f)))
    if (not b==3):
        print("####################")


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

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

Measured memory_bytes: 256
#include<iostream>
#include <algorithm> 
using namespace std;
long long a[1000000];
int main()
{
	long long minn=999999999999999999;
	long long m,n;
	cin>>m>>n;
	for(int i=0;i<m;i++)
	cin>>a[i];
	sort(a,a+m);
	for(int i=0;i<=m-n;i++)
	{
		long long ans=a[i+n-1]-a[i];
		minn=min(minn,ans);
	}
	cout<<minn;
}

Measured memory_bytes: 1024
N, M = (int(x) for x in input().split())
H = list(map(int, input().split()))

result = [1] * N

for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] < H[b-1]:
    result[a-1] = 0
  elif H[a-1] == H[b-1]:
    result[a-1] = 0
    result[b-1] = 0
  elif H[a-1] > H[b-1]:
    result[b-1] = 0
print(sum(result))

Measured memory_bytes: 20104
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(k, a, b);
	if (a % k) a += k - (a%k);
	
	if (a <= b) cout << "OK";
	else cout << "NG";
	
}










Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int sx,sy,tx,ty;
int main(void){
  cin >> sx >> sy >> tx >> ty;
  for(int i = 0; i < ty-sy; i++) cout << 'U';
  for(int i = 0; i < tx-sx; i++) cout << 'R';
  for(int i = 0; i < ty-sy; i++) cout << 'D';
  for(int i = 0; i < tx-sx; i++) cout << 'L';
  
  cout  << 'L';
  for(int i = 0; i <= ty-sy; i++) cout << 'U';
  for(int i = 0; i <= tx-sx; i++) cout << 'R';
  cout  << 'D';

  cout  << 'R';
  for(int i = 0; i <= ty-sy; i++) cout << 'D';
  for(int i = 0; i <= tx-sx; i++) cout << 'L';
  cout  << 'U';

  cout << endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main() {
  int A, B, K;

  cin >> A >> B >> K;

  for (int i = 0; i < K; i++) {
    A = A / 2 * 2;
    B += A / 2;
    A -= A / 2;

    swap(A, B);
  }

  if (K % 2) swap(A, B);

  cout << A << " " << B << endl;

  return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int height = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if (height <= h[i]) {
            height = h[i];
            ans++;
        }
    }
    cout << ans << '\n';

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun read() = readLine()!!
    fun readInt() = read().toInt()
    fun readInts() = read().split(" ").map { it.toInt() }
    fun readLongs() = read().split(" ").map { it.toLong() }
    var (a, b) = readLongs()
    var ans = 1L
    for(i in 2..1e6.toInt()) {
        if(a % i == 0L && b % i == 0L) {
            ans++
        }
        while(a % i == 0L) a /= i
        while(b % i == 0L) b /= i
    }
    if(a > 1 && b > 1) {
        if(a % b == 0L || b % a == 0L) ans++
    }
    println(ans)
}

Measured memory_bytes: 38028
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















vector<vector<ll>> g;

bool dfs(ll now, ll par){
    bool f = true;
    for(auto &child : g[now]){
        if(child == par) continue;
        bool b = dfs(child, now);
        if(b){
            if(f) f = false;
            else {
                cout << "First" << endl;
                exit(0);
            }
        }
    }
    return f;
}


int main(){
    ll n;
    cin >> n;
    g.resize(n);
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool b = dfs(0, -1);
    cout << (b? "First" : "Second") << endl;
}

Measured memory_bytes: 6400
#include <iostream>
 
using namespace std;
 
int main() {
  int ac = 0; int wa = 0; int tle = 0; int re = 0;
  int n;
  
  cin >> n;
  
  for(int i = 0; i < n; i++) {
    string curr;
    cin >> curr;
    if(curr == "AC") ac++;
    else if(curr == "WA") wa++;
    else if(curr == "TLE") tle++;
    else if(curr == "RE") re++;
  }
  
  cout << "AC x " << to_string(ac) << endl;
  cout << "WA x " << to_string(wa) << endl;
  cout << "TLE x " << to_string(tle) << endl;
  cout << "RE x " << to_string(re) << endl;
  
  return 0;
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

void solve()
{
  int n;
  cin >> n;
  n%=10;
  if(n == 3)
  {
    cout << "bon";
  }
  else if(n == 0 || n == 1 || n == 6 || n == 8)
  {
    cout << "pon";
  }
  else
  {
    cout << "hon";
  }
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FOR(a,b,n) for(int a=b;a<=b;a++)
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("d",&a,&b)
#define sccc(a,b,c) scanf("d%d",&a,&b,&c)
#define sccs(s) scanf("%s",s)
#define pccs(s) printf("%s",s)
#define debug printf("---debug---");
#define pcc(a,b) printf("d",a,b)
#define pccc(a,b,c) printf("d%d",a,b,c)
#define pb push_back
typedef long long ll;
const int MAXN_1e5=1e7+500;
const int MAXN_2e5=2e5+5;
const int MAXN_3e5=3e5+5;
const int MAXN_4e5=4e5+5;
const int MAXN_5e5=5e5+5;
const int INF_INT=0x3f3f3f3f;
const long long INT_LL=2e18;
ll prime[MAXN_1e5];
ll visit[MAXN_1e5];
void Prime(){
    for (ll i = 2;i <MAXN_1e5; i++) {
        if (!visit[i]) {
            prime[++prime[0]] = i;      //记录素数， 这个prime[0] 相当于 cnt，用来计数
        }
        for (ll j = 1; j <=prime[0] && i*prime[j] <MAXN_1e5; j++) {
            visit[i*prime[j]] = 1;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
}
int main()
{
    ll a,b;
    Prime();
    while(cin>>a>>b)
    {
        ll g=__gcd(a,b);
        ll cnt=1;
        for(int i=1;i<=prime[0]&&prime[i]<=g;i++)
        {
            if(g%prime[i]==0)
            {
                cnt++;
                while(g%prime[i]==0)g/=prime[i];
            }
        }
        if(g!=1)cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}


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

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> Graph(n, vector<int>(0));
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  vector<int> per(0);
  int res = 0;
  rep(i,n) per.push_back(i);
  do {
    if(per[0] != 0) continue;
    bool flag = true;
    rep(i,n-1) {
      int cnt = count(Graph[per[i]].begin(), Graph[per[i]].end(), per[i+1]);
      if(cnt == 0) flag = false;
    }
    if(flag) res++;
  } while(next_permutation(per.begin(), per.end()));

  cout << res << endl;
  return 0;
}

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

vector<int> z_algorithm(string S) {
    int n = S.size();
    vector<int> Z(n);
    Z[0] = n;
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && S[R - L] == S[R]) R++;
            Z[i] = R - L;
            R--;
        } else {
            if (Z[i - L] <= R - i) {
                Z[i] = Z[i - L];
            } else {
                L = i;
                while (R < n && S[R - L] == S[R]) R++;
                Z[i] = R - L;
                R--;
            }
        }
    }
    return Z;
}

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int ret = 0;
    for (int i = 0; i < N; i++) {
        vector<int> Z = z_algorithm(S.substr(i, N - i));
        for (int j = 0; j < Z.size(); j++) {
            ret = max(ret, min(Z[j], j));
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n - 1):
    xi, yi = xy[i]
    for j in range(i + 1, n):
        xj, yj = xy[j]
        cost = 0
        for x, y in xy:
            cost += 1 if [x - xj + xi, y - yj + yi] in xy else 0
    cnt = max(cnt, cost)
print(n - cnt)

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

#define INF 1LL<<60

int main() {
    int h, n;
    cin >> h >> n;
    int a[1010], b[1010];
    vector<long long> dp(h + 1, INF);

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

    // dp[h] = 0;
    // for (int i = h; i >= 0; i--) {
    //     for (int j = 0; j < n; j++) {
    //         int next = max(0, i - a[j]);
    //         dp[next] = min(dp[next], dp[i] + b[j]);
    //     }
    // }
    // cout << dp[0] << endl;

    dp[0] = 0;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            int next = min(h, i + a[j]);
            dp[next] = min(dp[next], dp[i] + b[j]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}


Measured memory_bytes: 384
#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 <cstring>
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define REP(i, s, e) for ( int i = s; i <= e; i++ )  
#define fi first
#define se second
int dp[1024][1024];
struct Item{
	int l,r,S1,S2;
};
vector<Item> item;
bool operator < (const Item &a,const Item &b){
	if( a.l != b.l ) return a.l < b.l;
	return a.r < b.r;
}

int nextNode[1024];
int n;
int dfs(int x,int y){
	if( dp[x][y] != -1) return dp[x][y];
	int ans = 0;
	int xNext = nextNode[x];
	int yNext = nextNode[y];
	if( x == n && y == n ) return 0;
	else if( x == n ){
		return dp[x][y] = max( dfs(x,y+1) , dfs(x,yNext)+item[y].S2 );
	}else if( y == n){
		return dp[x][y] = max( dfs(x+1,y) , dfs(xNext,y)+item[x].S1 );
	}
	if( y < x ){
		ans = max( ans , dfs(x,y+1) );
		ans = max( ans , dfs(x,yNext) + item[y].S2 );
	}else if( x == y ){
		ans = max( ans , dfs(x+1,y+1) );
		ans = max( ans , dfs(xNext,y+1) + item[x].S1);
		ans = max( ans , dfs(x+1,yNext) + item[y].S2);
	}else{
		ans = max( ans , dfs(x+1,y) );
		ans = max( ans , dfs(xNext,y) + item[x].S1 );
	}
	return dp[x][y] = ans;
}


int conv(string t){
	t[2] = ' ';
	stringstream ss(t);
	int h,m;
	ss >> h >> m;
	
	return h * 60 + m;
}

int main(){
	while(cin >> n && n){
		memset(dp,-1,sizeof(dp));
		item.clear();
		for(int i = 0 ; i < n ; i++){
			string nm;
			string a,b;
			cin >> nm >> a >> b;
			int r1,r2;
			cin >> r1 >> r2;
			item.push_back({conv(a),conv(b),r1,r2});
			//cout << a << " " << b << endl;
		}
		sort(item.begin(),item.end());
		for(int i = 0 ; i < n ; i++){
			nextNode[i] = n;
			for(int j = i+1 ; j < n ; j++)
				if( item[i].r <= item[j].l ){
					nextNode[i] = j;
					break;
				}
		}
		cout << dfs(0,0) << endl;
	}
	
	
}

Measured memory_bytes: 5456
n,k=map(int,input().split())
s=input()

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

happy=0
cnt=0
for i in range(n-1):
  if s[i]==s[i+1]:
    happy+=1
  else:
    cnt+=1

print(min(n-1,happy+min(cnt,k)*2))

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

int compare(const void*a,const void*b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int N, A[200000], i = 0;
	scanf("%d", &N);
	while (i < N) {
		scanf("%d", &A[i]);
		i++;
	}
	qsort(A,N,sizeof(int),compare);
	for (int i = 0; i < N - 1;i++) {
		if (A[i]==A[i+1]) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1788
import math as mt
#import numpy as np

def ro(n):
  return mt.floor(mt.sqrt(n))
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


a,b=map(int,input().split())
#lis=list(map(int,input().split()))
#n=int(input())
#s=input()

if b%2:
  na()
elif b>a*4:
  na()
elif a*2>b:
  na()
else:
  ya()

Measured memory_bytes: 9168
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[30];
char c[30];
int p[26];
int main(){
	scanf("%s",in);
	for(int i=0;in[i];i++)p[in[i]-'a']=1;
	if(strlen(in)!=26){
		printf("%s",in);
		for(int i=0;i<26;i++){
			if(!p[i]){
				printf("%c\n",i+'a');
				break;
			}
		}
	}else{
		for(int i=0;i<26;i++)c[i]=in[i];
		int t=next_permutation(c,c+26);
		if(t==0){
			printf("-1\n");
		}else{
			for(int i=0;i<26;i++){
				printf("%c",c[i]);
				if(in[i]!=c[i])break;
			}printf("\n");
		}
	}
}

Measured memory_bytes: 256