akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

vector<int>v[2*maxn];

int32_t main(){
	fastio();
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		v[x].push_back(i);
	}
	for(int i=1;i<=n;i++){
		cout<<v[i].size()<<"\n";
	}
}

Measured memory_bytes: 14488
#define INT_MAX 2147483647
#include<bits/stdc++.h>
using namespace std;
 
const int MAX_N=10000000;
  
int n;
int dat[MAX_N*2-1];
  
void init(){
    int i=n;
    n=2;
 
    while (n<i)n*=2;
     
    fill(dat,dat+n*2,0);
}
  
void update(int i,int x){
    i+=n-1;
    while(i>0){
        dat[i]+=x;
        i=(i-1)/2;
    }
    dat[0]+=x;
}
 
long long int query(int a,int b,int k,int l,int r){
    if(r<a||b<l)return 0;
    if(a<=l&&r<=b) return dat[k];
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2+1,r);
        return vl+vr;
    }
}
 
int main(){
    int q,a,b,c;
    cin>>n>>q;
     
    init();
     
    while(q--){
        cin>>a>>b>>c;
        if(a)cout<<query(b-1,c-1,0,0,n-1)<<endl;
        else update(b-1,c);
         
        /*for(int i=0;i<n*2;i++){
            cout<<dat[i]<<" ";
        }
        cout<<endl;*/
    }
     
}

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

using namespace std;

string S, T;

bool Match(const int i) {
  if (S.length() - i < T.length()) return false;
  for (int ti = 0; ti < T.length(); ti++) {
    int si = i + ti;
    if (S[si] == '?') continue;
    if (S[si] == T[ti]) continue;
    return false;
  }

  return true;
}

void Replace(int i) {
  for (int ti = 0; ti < T.length(); ti++) {
    int si = i + ti;
    S[si] = T[ti];
  }
  for (int si = 0; si < S.length(); si++) {
    if (S[si] == '?') S[si] = 'a';
  }
}

int main() {
  cin >> S >> T;
  for (int i = S.length() - 1; i >= 0; i--) {
    if (Match(i)) {
      Replace(i);
      printf("%s\n", S.c_str());
      return 0;
    }
  }

  printf("UNRESTORABLE\n");

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
ll gcd(ll a, ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
int main(void) {
	int N, i;
	scanf("%d\n", &N);
	ll T,ans=1;
	for (i = 0; i < N; i++) {
		scanf("%lld\n", &T);
		ans=lcm(ans, T);
	}
	printf("%lld", ans);

	return 0;
}

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

int n, m, u, v, p[100000];
vector<int> a[100000];

int main() {
    scanf("%d%d", &n, &m);
    while (m--) {
        scanf("%d%d", &u, &v);
        u--; v--;
        a[u].push_back(v);
        a[v].push_back(u);
    }

    memset(p, -1, sizeof(p));
    queue<int> q;
    q.push(0);
    p[0] = 0;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : a[u]) {
            if (p[v] == -1) {
                q.push(v);
                p[v] = u;
            }
        }
    }

    bool ok = true;
    for (int i=0;i<n;++i)
        if (p[i] == -1) ok = false;

    if (ok) {
        puts("Yes");
        for (int i=1;i<n;++i) printf("%d\n", p[i]+1);
    }
    else puts("No");
}


Measured memory_bytes: 10596
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
q = gets.chomp.to_i
bc = []
q.times do
  bc << gets.chomp.split(' ').map(&:to_i)
end
sum = a.sum
memo = {}
a.each do |num|
  memo[num] ? memo[num] += 1 : memo[num] = 1
end

bc.each do |arr|
  b = arr[0]
  c = arr[1]
  if (memo[b])
    nanko = memo[b]
    tasu = c - b
    sum += tasu * nanko
    memo[b] = 0
    memo[c] ? memo[c] += nanko : memo[c] = nanko
    puts sum
  else
    puts sum
  end
end

Measured memory_bytes: 32540
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
ll a[100000];
vector<int>g[100000];
bool flag;
void NO(){
    cout << "NO" << endl;
    exit(0);
}
ll dfs(int s, int p){
    if(g[s].size()==1 and g[s][0]==p)return a[s];
    vector<ll> d;
    ll sum = 0;
    ll mx = 0;
    for(int x:g[s]){
        if(x==p)continue;
        ll temp = dfs(x, s);
        if(temp<0){
            NO();
        }
        mx = max(mx, temp);
        sum += temp;
    }
    if(mx > a[s])NO();
    if(2 * a[s] - sum > sum)NO();
    return 2 * a[s] - sum;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n)cin >> a[i];
    if(n==2){
        if(a[0]==a[1])cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }
    rep(i,n-1){
        int v,u;
        cin >> v >> u;
        v--;u--;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    ll res = -1;
    rep(i,n)if(g[i].size()>1){
        flag = true;
        res = dfs(i,-1);
        break;
    }
    if(flag and res==0)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 13184
import java.util.Scanner;
import java.util.Arrays;
import java.util.PriorityQueue;

public class Main{
  static final long INF = Long.MAX_VALUE / 2;
  static int x, y, z;
  static int[] a, b, c;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    x = sc.nextInt();
    y = sc.nextInt();
    z = sc.nextInt();
    int n = x + y + z;
    a = new int[n];
    b = new int[n];
    c = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }

    long sumA = 0;
    for(int i = 0; i < n; i++){
      sumA += a[i];
      b[i] = b[i] - a[i];
      c[i] = c[i] - a[i];
    }

    Block[] blocks = new Block[n];
    for(int i = 0; i < n; i++){
      blocks[i] = new Block(b[i], c[i]);
    }

    Arrays.sort(blocks);

    long[] max1 = new long[n + 1];
    long sum1 = 0;
    PriorityQueue< Integer > pq1 = new PriorityQueue< >();
    for(int i = 0; i < n; i++){
      sum1 += blocks[i].c;
      pq1.offer(blocks[i].c);
      if(pq1.size() > z){
        sum1 -= pq1.poll();
      }
      max1[i] = sum1;
    }

    long[] max2 = new long[n];
    long sum2 = 0;
    PriorityQueue< Integer > pq2 = new PriorityQueue< >();
    for(int i = n - 1; i >= 0; i--){
      sum2 += blocks[i].b;
      pq2.offer(blocks[i].b);
      if(pq2.size() > y){
        sum2 -= pq2.poll();
      }
      max2[i] = sum2;
    }

    long max = -INF;
    for(int i = z - 1; i + y - 1 < n; i++){
      if(i + 1 < n){
        max = Math.max(max, max1[i] + max2[i + 1]);
      }
    }

    System.out.println(sumA + max);
  }

  static class Block implements Comparable< Block >{
    int b, c;

    Block(int b, int c){
      this.b = b;
      this.c = c;
    }

    @Override
      public int compareTo(Block block){
        return (b - c) - (block.b - block.c);
      }
  }
}


Measured memory_bytes: 93720
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <iomanip>

#include <string>
#include <numeric>


using namespace std;


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {

		string str; in >> str;

		int n = str.size();

		bool is_t = false;
		bool is_s = false;

		int s = 0;


		int ans = 0;

		for (int i = 0; i < n; i++) {
			if (str[i] == 'S')
			{
				s++;
			}
			else if (str[i] == 'T')
			{
				if (s > 0) {
					s--;
					ans++;
				}
			}
		}

		out << n - ans*2;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n, a, b;
    cin >> n;
    long long int ans=0;
    vector<long long int > A(n);
    vector<long long int > B(n);
    vector<long long int > C(n);
    for(long long int  i=0;i<n;i++) cin >> A[i];
    for(long long int  i=0;i<n;i++) cin >> B[i];
    for(long long int  i=0;i<n;i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    for(long long int  i=0;i<n;i++) {
        a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        b = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += a*b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int N, L;
    cin >> N >> L;
    vector<int> sum(N+1);
    for(int i =1; i <= N; i++){
        sum[i] = L+i-1;
    }
    int mm=1000000;
    int ans =0;
    int save = 0;
    for(int i=1; i <= N ;i++){
        if(mm>abs(sum[i])){
            save = i;
            mm = abs(sum[i]);
        }
    }
    for(int i = 1; i <= N; i++){
        if(i!=save){
            ans+=sum[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
signed main(){
	if(n<m)	swap(n,m);
	if(m==1)	return puts("1"),0;
	cout<<(n*m+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)) System.out.print("Yes");
		else System.out.println("No");
	}
	
}

Measured memory_bytes: 21588
#include<stdio.h>
#include<string.h>
int main(void)
{
	int k,len,i;
	char s[1000],e[3];
	scanf("%d",&k);
	scanf("%s",s);
	len=0;
	len=strlen(s);
	if(len<=k){
		for(i=0;i<len;i++){
			printf("%c",s[i]);
		}
	}
	else{
		for(i=0;i<k;i++){
			printf("%c",s[i]);
		}
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 1628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

bool bingo=false;
ll n,a[3][3];

void init(){
	rep(i,3)rep(j,3)cin>>a[i][j];
	cin>>n;
}

int main(void){
	init();
	rep(i,n){
		int b;
		cin>>b;
		rep(i,3)rep(j,3)if(b==a[i][j])a[i][j]=-1;
	}
	rep(i,3){
		bool ok=true;
		rep(j,3)if(a[i][j]!=-1)ok=false;
		if(ok)bingo=true;
	}
	rep(i,3){
		bool ok=true;
		rep(j,3)if(a[j][i]!=-1)ok=false;
		if(ok)bingo=true;
	}
	bool ok=true;
	rep(i,3)if(a[i][i]!=-1)ok=false;
	if(ok)bingo=true;

	ok=true;
	rep(i,3)if(a[2-i][i]!=-1)ok=false;
	if(ok)bingo=true;
	cout<<(bingo?"Yes":"No")<<endl;
	// rep(i,3){
	// 	rep(j,3)cerr<<a[i][j]<<" ";
	// 	cerr<<endl;
	// }
	return 0;
}

Measured memory_bytes: 256
a, v = [int(i)  for i in input().split()]
b, w = [int(i)  for i in input().split()]
t = int(input())

if w >= v:
  print("NO")
  exit()
#print((b-a) / (v-w))

if b > a:
  if a + v*t >= b + w*t:
    print("YES")
  else:
    print("NO")
else :
  if a - v*t <= b - w*t:
    print("YES")
  else:
    print("NO")


Measured memory_bytes: 9188
n = int(input())
word = []
for i in range(n):
  a = int(input())
  l = [list(map(int,input().split())) for _ in range(a)]
  word.append(l)

ans = 0
for i in range(2**n):
  flag = 0
  count = 0
  for j in range(n):
    if ((i>>j)&1)==1 and flag==0:
      for k,l in word[j]:
        if ((i>>(k-1))&1) != l:
          flag = 1 ## tell a lie
          break
  if flag==0:
    count = bin(i).count('1')
    ans = max(ans,count)
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		final int X = 0;
		final int Y = 1;
		final int SIZE = 2;
		int countAxis = 0;
		int maxThickness = 0;

		// 真っ白(全てが0である)座標を作成
		int[][] axis = new int[10][10];
		for (int countX = 0; countX < 10; countX++) {
			for (int countY = 0; countY < 10; countY++) {
				axis[countX][countY] = 0;
			}
		}
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		// 無限ループ
		while (true) {

			String inputData = input.readLine();
			// 入力データがnullもしくは空文字の時、ループを抜ける
			if (inputData == null || inputData.equals("")) {
				break;
			}
			// 入力データをカンマで区切り配列に格納(0→X軸、１→Y軸、２→インクのサイズ)
			String[] data = inputData.split(",");
			// 入力データのインクのサイズに合わせてそれぞれのメソッドを実行
			if (Integer.parseInt(data[SIZE]) == 1) {
				makeSmallArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));
			}

			if (Integer.parseInt(data[SIZE]) == 2) {
				makeMiddleArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));

			}

			if (Integer.parseInt(data[SIZE]) == 3) {
				makeBigArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));

			}

		}
		// 色がついていない部分(値が0である部分)の数をカウントする
		countAxis = 0;
		for (int countX = 0; countX < 10; countX++) {
			for (int countY = 0; countY < 10; countY++) {
				if (axis[countX][countY] == 0) {
					countAxis++;
				}
				// 一番高い濃度を記録する
				if (axis[countX][countY] > maxThickness) {
					maxThickness = axis[countX][countY];
				}

			}
		}
		// 出力
		System.out.println(countAxis);
		System.out.println(maxThickness);
	}

	// インクサイズが小の場合のメソッド、枠からはみ出した部分を無視するif文を記載
	static void makeSmallArea(int[][] axis, int xAxis, int yAxis) {
		if (xAxis >= 1) {
			axis[xAxis - 1][yAxis]++;
		}
		if (xAxis <= 8) {
			axis[xAxis + 1][yAxis]++;
		}
		if (yAxis >= 1) {
			axis[xAxis][yAxis - 1]++;
		}
		if (yAxis <= 8) {
			axis[xAxis][yAxis + 1]++;
		}
		axis[xAxis][yAxis]++;
	}

	// インクサイズが中の場合のメソッド、枠からはみ出した部分を無視するif文を記載
	static void makeMiddleArea(int[][] axis, int xAxis, int yAxis) {
		makeSmallArea(axis, xAxis, yAxis);
		if (xAxis >= 1 && yAxis >= 1) {
			axis[xAxis - 1][yAxis - 1]++;

		}
		if (xAxis >= 1 && yAxis <= 8) {
			axis[xAxis - 1][yAxis + 1]++;

		}
		if (xAxis <= 8 && yAxis >= 1) {
			axis[xAxis + 1][yAxis - 1]++;
		}
		if (xAxis <= 8 && yAxis <= 8) {
			axis[xAxis + 1][yAxis + 1]++;

		}
	}

	// インクサイズが大の場合のメソッド、枠からはみ出した部分を無視するif文を記載
	static void makeBigArea(int[][] axis, int xAxis, int yAxis) {
		makeMiddleArea(axis, xAxis, yAxis);
		if (xAxis >= 2) {
			axis[xAxis - 2][yAxis]++;
		}
		if (xAxis <= 7) {
			axis[xAxis + 2][yAxis]++;
		}
		if (yAxis >= 2) {
			axis[xAxis][yAxis - 2]++;
		}
		if (yAxis <= 7) {
			axis[xAxis][yAxis + 2]++;
		}
	}
}

Measured memory_bytes: 16920
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef struct{
	ll pf;
	ll times;
}Node;
ll n,p;
vector<Node> v;
int main(){
	scanf("%lld%lld",&n,&p);
	Node temp;
	ll p2 = p;
	for(ll i = 2;i * i <= p;i++){
		if(p % i == 0){
			temp.pf = i;
			temp.times = 0;
			while(p % i == 0){
				temp.times++;
				p/=i;
			}
			v.push_back(temp);
		}
	}
	if(p > 1){
		temp.pf = p;
		temp.times = 1;
		v.push_back(temp);
	}
	ll res = 1;
	
	
	for(int i = 0;i < v.size();i++){
		if(v[i].times >= n){
			res = res * pow(v[i].pf,(v[i].times/n));
		}
	}
	
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
ans = 10**11
for d in make_divisors(N):
    keta = max(len(str(d)), len(str(N//d)))
    ans = min(keta, ans)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
string s;
int main() {
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using uint = unsigned int;

int main() {

    uint N; cin >> N;
    vector<int> B(N-1, 0);
    vector<int> A(N, 0);
    for (auto &b: B) cin >> b;
    A[0] = B[0];
    for (size_t i = 1; i < N - 1; i++) {
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];
    int sum = 0;
    for (auto &a: A) sum += a;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#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>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

 long long ret[210000];
int main(){
	long long a,v,b,w,t;
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	long long d=ABS(a-b);
	long long e=t*(v-w);
	if(d<=e)printf("YES\n");else printf("NO\n");
}

Measured memory_bytes: 1660
s = raw_input()
k = input()

if len(set(s)) == 1:
    print len(s) * k / 2
else:
    n = len(s)
    a = [1]
    for i in xrange(1, n):
        if s[i] == s[i - 1]:
            a[-1] += 1
        else:
            a.append(1)
    ans = 0
    if s[0] == s[-1]:
        ans += a[0] / 2 + a[-1] / 2 + (a[0] + a[-1]) / 2 * (k - 1)
        a = a[1:-1]
    ans += sum(x / 2 for x in a) * k
    print ans


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

int main() {
  vector<int>ans(101,0);
  for(int i = 0;i<10;i++){
    for(int j = 0;j<10;j++){
      ans.at(i*j)= 1;
    }
  }
  int a;
  cin >> a;
  if(ans.at(a))cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,old,gene[7];
    while(cin>>n&&n!=0){
        for(int i=0;i<7;i++)gene[i]=0;
        for(int i=0;i<n;i++){
            cin>>old;
            for(int j=1;j<7;j++){
                if(old-j*10<0){
                        gene[j-1]++;
                        break;
                }
                else if(j==6)gene[6]++;
            }
        }
        for(int i=0;i<7;i++)cout<<gene[i]<<endl;
    }
}

Measured memory_bytes: 1156
// 2014/09/11 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int y;
		cin >> y;

		double g_max = 0.0;
		int b_max = 0;

		for(int i=0; i<n; i++){
			int b, r, t;
			cin >> b >> r >> t;

			double g;
			if(t==1){
				g = 1.0+(double)y*(double)r/100.0;
			}
			else{
				g = 1.0;
				for(int j=0; j<y; j++){
					g *= (1.0+(double)r/100.0);
				}
			}

			if(g>g_max){
				g_max = g;
				b_max = b;
			}
		}

		cout << b_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1e9;
int const MAX_N = 105;

using P = pair<int,int>;
vector<P> G[MAX_N];

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> dist(n,vector<int>(n,INF));
    rep(i,n) dist[i][i] = 0;
    rep(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
        G[a].emplace_back(b,c);
        G[b].emplace_back(a,c);
    }

    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int res = 0;
    rep(i,n) {
        for(auto e : G[i]) {
            int j = e.first;
            int d = e.second;
            bool ok = false;
            for(int x = 0; x < n; ++x) {
                for(int y = x+1; y < n; ++y) {
                    if(dist[x][y] == dist[x][i] + d + dist[j][y] 
                    || dist[x][y] == dist[x][j] + d + dist[i][y]) {
                        ok = true;
                    }
                }
            }
            if(!ok) res++;
        }
    }
    cout << res/2 << endl;
    return 0;
}


Measured memory_bytes: 3632
/* DICE1*/
#include <stdio.h>

typedef struct DICE{
        int num1;
        int num2;
        int num3;
        int num4;
        int num5;
        int num6;
    }DICE;

int main(void)
{
    DICE Dice1;
    scanf("%d %d %d %d %d %d", &Dice1.num1, &Dice1.num2, &Dice1.num3, &Dice1.num4, &Dice1.num5, &Dice1.num6);
    int i, tmp = 0;
    char str[256];
    scanf("%s", str);
    for(i = 0; str[i] != '\0'; i++){
        if(str[i] == 'N'){
            tmp = Dice1.num6;
            Dice1.num6 = Dice1.num5;
            Dice1.num5 = Dice1.num1;
            Dice1.num1 = Dice1.num2;
            Dice1.num2 = tmp;
        }else if(str[i] == 'E'){
            tmp = Dice1.num6;
            Dice1.num6 = Dice1.num3;
            Dice1.num3 = Dice1.num1;
            Dice1.num1 = Dice1.num4;
            Dice1.num4 = tmp;
        }else if(str[i] == 'W'){
            tmp = Dice1.num6;
            Dice1.num6 = Dice1.num4;
            Dice1.num4 = Dice1.num1;
            Dice1.num1 = Dice1.num3;
            Dice1.num3 = tmp;
        }else{
            tmp = Dice1.num6;
            Dice1.num6 = Dice1.num2;
            Dice1.num2 = Dice1.num1;
            Dice1.num1 = Dice1.num5;
            Dice1.num5 = tmp;
        }
    }
    printf("%d\n", Dice1.num1);
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int X[N], Y[N];
  for(int i = 0; i < N; i++){
    cin >> X[i];
    Y[i] = X[i];
  }

  sort(Y, Y + N);

  for(int i = 0; i < N; i++){
    if(Y[N / 2] <= X[i]) cout << Y[N / 2 - 1];
    else cout << Y[N / 2];

    if(i != N - 1) cout << endl;
  }
}


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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	vector<char> s = {'a', 'e', 'i', 'o', 'u'};
	char c; cin >> c;
	if(find(s.begin(), s.end(), c) != s.end()) cout << "vowel\n";
	else cout << "consonant\n";
}


Measured memory_bytes: 3544
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, x;
ll a[100010];

ll solve() {
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > x) {
            res += a[i] - x;
            a[i] = x;
        }
    }
    for (int i = 0; i < n-1; i++) {
        if (a[i] + a[i+1] > x) {
            int d = a[i] + a[i+1] - x; 
            res += d;
            a[i+1] = max(0LL, a[i+1]-d);
        }
    }
    return res;
}

void input() {
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}

Measured memory_bytes: 1152
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for(int i = 0; i <= 7; ++i){
    string t = s.substr(0, i) + s.substr(int (s.size())-7+i, 7-i);
    if(t == "keyence"){
    cout << "YES" << endl;
    return 0;
    }
  }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;

string a;

int main() {
    cin >> a;

    map<int, int> table;
    
    for (int i = 0; i < a.size(); i++)
        table[a[i] - 'a']++;

    long long count = 1;

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++) {
            if (i < j && table.count(i) > 0 && table.count(j) > 0) {
                count += static_cast<long long>(table[i]) * table[j];
            }
        }
    }

    cout << count << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const int MAX_N = 200010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    create_table(200000);
    ll n,m,k;
    cin >> n >> m >> k;
    vector<int> sumx(n+1,0),sumy(m+1,0);
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        (ans += m*m%mod*combi(n*m-2,k-2)%mod*(n-i)%mod*(n-i-1)%mod*pow_mod(2,-1)) %= mod;
    }
    for (int i = 0;i < m;++i) {
        (ans += n*n%mod*combi(n*m-2,k-2)%mod*(m-i)%mod*(m-i-1)%mod*pow_mod(2,-1)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  ll n;
  scanf("%lld",&n);
  int m = 1;
  vi s;
  deque<int> a;
  while (n) {
    if (n&1) {
      s.pb(0);
      n >>= 1;
    } else {
      s.pb(1);
      n -= 1;
    }
  }
  drep(i,sz(s)) {
    if (s[i]) a.push_front(m++);
    else a.pb(m++);
  }
  rrep(i,m-1) a.pb(i);
  vi ans;
  rep(i,sz(a)) ans.pb(a[i]);
  cout<<sz(ans)<<endl;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 06.03.2020 16:45:33
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

template <class T>
inline bool chmax(T &a, T b) {
  return a < b && (a = b, true);
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b && (a = b, true);
}

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

void solve() {}

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

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, 0, n) { cin >> a[i] >> b[i]; }
  sort(all(a));
  sort(all(b));
  if (n % 2 == 1) {
    cout << (b[n / 2] - a[n / 2] + 1) << endl;
  } else {
    cout << (b[n / 2] - a[n / 2] + b[n / 2 - 1] - a[n / 2 - 1] + 1) << endl;
  }
}


Measured memory_bytes: 4772
import sys
sys.stdin.readline()


for i, line in enumerate(sys.stdin.readlines()):
    for j, s in enumerate(line.split()):
        if s == 'snuke':
            #print(str(i+1)+chr(ord('A')+j))
            print(chr(ord('A')+j)+str(i+1))
            sys.exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

ll h;

ll rec(ll h){
    if(h <= 1) return 1;
    else{
        return (2*(rec(h/2))+1);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>h;
    ll ans = rec(h);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int H,N;cin >> H >> N;
    vector<int> A(N);
    rep(i,0,N)cin >> A[i];
    cout << (accumulate(range(A),0)>=H ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int cost,saving;
	vector< vector<int> > money(12,vector<int>(2));
	while(1){
		cin >> cost;
		if(cost==0) break;
		saving=0;
		for(int i=0;i<12;i++){
			cin >> money[i][0] >> money[i][1];
		}
		for(int i=0;i<12;i++){
			saving+=(money[i][0]-money[i][1]);
			if(cost<=saving){
				cout << i+1 << endl;
				break;
			}
		}
		if(saving<cost) cout << "NA" << endl;
		money.clear();
	}
	return 0;
}

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

const ll MOD = 1e9+7;

ll kaijou(ll a, ll b)
{
    ll kai = 1;
    for(ll i=a; i < b+1; i++)
    {
        kai *= i;
        kai %= MOD;
    }
    return kai;
}

ll modinv(ll a)
{
    ll b = MOD;
    ll u = 1;
    ll v = 0;

    while(b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
    {
        u += MOD;
    }

    return u;
}

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

    if ((2*y - x) % 3 != 0 ||(2*x - y) % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    ll n = (2*y - x) / 3;
    ll m = (2*x - y) / 3;

    if (n < 0 || m < 0)
    {
        cout << 0 << endl;
        return 0;
    }

    if (n == 0 || m == 0)
    {
        cout << 1 << endl;
        return 0;
    }

    cout << (kaijou(n+1, m+n) * modinv(kaijou(1, m))) % MOD << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void L_judge(double);
void R_judge(double);

volatile int R_rank[4] = {};
volatile int L_rank[4] = {};

int main(void)
{
	int i;
	double L_sight, R_sight;
	
	while(scanf("%lf %lf", &L_sight, &R_sight) != EOF){
		L_judge(L_sight);
		R_judge(R_sight);
	}
	for(i = 0;i < 4;i++){
		printf("%d %d\n", L_rank[i], R_rank[i]);
	}
	
	return 0;
}
	
void L_judge(double a)
{
	if(a >= 1.1){
		L_rank[0] += 1;
	}
	else if(a >= 0.6){
		L_rank[1] += 1;
	}
	else if(a >= 0.2){
		L_rank[2] += 1;
	}
	else{
		L_rank[3] += 1;
	}
}
void R_judge(double b)
{
	if(b >= 1.1){
		R_rank[0] += 1;
	}
	else if(b >= 0.6){
		R_rank[1] += 1;
	}
	else if(b >= 0.2){
		R_rank[2] += 1;
	}
	else{
		R_rank[3] += 1;
	}
}

Measured memory_bytes: 628
#include<stdio.h>
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int arr[a];
		for(int i=0; i<a; i++)
			scanf("%d",&arr[i]);
		int temp;
		long long sum = 0;
		for(int i=0; i<a; i++)
		{
			scanf("%d",&temp);
			if(arr[i] - temp > 0)
			{
				sum += (long long) arr[i] - temp;
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 128
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()
ans = 0

for x in range(1, n):
    ans += (n-1) // x

print(ans)


Measured memory_bytes: 67896
from time import time
import random


def main():
    random.seed(0)

    now = time()

    MAX = 26

    # 入力
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]

    # 初期解を貪欲法で求める
    t = []
    prev = [0] * MAX
    for day, row in enumerate(s, 1):
        mxi = 1
        mx = 0
        for i, (es, ec) in enumerate(zip(row, c), 1):
            point = es + ec * (day - prev[i - 1])
            if point > mx:
                mx = point
                mxi = i

        prev[mxi - 1] = day
        t.append(mxi)

    # 初期解に対する満足度を計算
    last = [0] * MAX
    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    # 変更を検討する日にちの選ばれやすさ
    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    # 各日にちにおいて変更を検討するコンテストの選ばれやすさ
    sc = []
    for day, row in enumerate(s, 1):
        app = []
        for i, (es, ec) in enumerate(zip(row, c), 1):
            ln = max(1, (es + ec * (d ** 2 // 4 - (day - d // 2) ** 2)) // 200)
            app += [i] * ln
        sc.append(app)

    # 時間の許す限り更新を検討する
    while time() - now <= 1.85:
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, len(sc[ed-1]) - 1)
        eq = sc[ed-1][qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            t[ed-1] = q_old
            score = prev_score

    print(*t, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 788940
import math

def is_prime(n):
    if n == 2:
        return 1
    elif n % 2 == 0:
        return 0
    for x in range(3, math.ceil(math.sqrt(n)) + 1, 2):
        if n % x == 0:
            return 0
    return 1


N = int(input())
print(sum(is_prime(int(input())) for _ in range(N)))



Measured memory_bytes: 5684
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
i64 n, y;
vector<i64> x, s;
int main() {
    cin >> n >> y;
    x.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    s.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
        s[i] += s[i - 1] + x[i - 1];
    }
    i64 ans = 1ll << 62;
    for (int k = 1; k <= n; ++k) {
        i64 scr = (n + k) * y;
        bool f = true;
        for (int i = n, j = 1; i > 0; i -= k, ++j) {
            i64 a = j == 1 ? 5 : 2 * j + 1;
            scr += a * (s[i] - s[max(i - k, 0)]);
            if (scr >= (1ll << 61)) f = false;
        }
        if (f) ans = min(ans, scr);
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

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

  // 0: wolf
  rep (i, 2) rep (j, 2) {
    vector<int> vi(n);
    vi[0] = i;
    vi[1] = j;
    rep (l, n) {
      int c = (l + 1) % n;
      int r = (l + 2) % n;
      if (s[c] == 'o') {
        if (vi[c] == 0) {
          vi[r] = 1 - vi[l];
        } else {
          vi[r] = vi[l];
        }
      } else {
        if (vi[c] == 0) {
          vi[r] = vi[l];
        } else {
          vi[r] = 1 - vi[l];
        }
      }
    }
    if (vi[0] == i && vi[1] == j) {
      rep (k, n) {
        cout << "WS"[vi[k]];
      }
      cout << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 1024