akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << X << endl
#define vec vector
#define pb push_back
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;
inline string YesNo(bool cond) { return cond ? "Yes" : "No"; }
inline string YESNO(bool cond) { return cond ? "YES" : "NO"; }
template <class T>
string join(const vector<T>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}
//---------------------------------------------------------------------------
int main(void)
{
  ll N,M;
  map<string, ll> sc;
  string s;
  cin >> N;
  rep(i,N){
    cin >> s;
    //debug2(i,s);
    sc[s] += 1;
  }
  cin >> M;
  rep(i,M){
    cin >> s;
    //debug2(i,s);
    sc[s] -= 1;
  }
  vec<ll> sv(1,0);
  for (auto t: sc) {
    sv.pb(t.second);
  }
  print(*max_element(all(sv)));
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long M, std::vector<long long> P, std::vector<long long> Y){
    vector< tuple<ll, ll, ll> > ans(M);
    rep(i, M){
        get<0>(ans[i]) = P[i];
        get<1>(ans[i]) = Y[i];
        get<2>(ans[i]) = i;
    }
    sort(ans.begin(), ans.end());
    map<ll, pll> a;
    ll cnt = 1;
    rep(i, M){
        
        if(i==0){
            a[get<2>(ans[i])] = make_pair(get<0>(ans[i]), cnt);
            cnt ++;
        }
        else{
            if(get<0>(ans[i]) != get<0>(ans[i-1])){
                cnt = 1;
                a[get<2>(ans[i])] = make_pair(get<0>(ans[i]), cnt);
                cnt++;
            }
            else{
                a[get<2>(ans[i])] = make_pair(get<0>(ans[i]), cnt);
                cnt++;
            }
        }
    }
    for(auto x:a){
        cout << setfill('0') << setw(6) << x.second.first;
        cout << setfill('0') << setw(6) << x.second.second << endl;
    }

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> Y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, M, std::move(P), std::move(Y));
    return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
const int N=1005;
int f[N],a[N],dp[N][5005],sum[N],n;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++) scanf("%d",&f[i]);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) dp[i][0]=1;
	for (int i=n;i>=1;i--){
		int mini=-1;
		for (int j=a[i];j>=0;j--)
			if (dp[i][j]){
				mini=a[i]-j;
				break;
			}
		sum[i]+=mini;
		if (mini==-1){
			puts("IMPOSSIBLE");
			return 0;
		}
		if (f[i]){
			int fa=f[i];
			for (int j=a[fa];j>=0;j--){
				int t=0;
				if (j>=a[i]) t|=dp[fa][j-a[i]];
				if (j>=sum[i]-a[i]) t|=dp[fa][j-(sum[i]-a[i])];
				dp[fa][j]=t;
			}
			sum[fa]+=sum[i];
		} 
	}
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 18048
fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!.toCharArray()
    val D = IntArray(N + 1)
    for (i in 2..N) {
        D[i] = D[i - 1]
        if (S[i - 2] == 'A' && S[i - 1] == 'C') D[i]++
    }
    repeat(Q) {
        val (l, r) = readLine()!!.split(" ").map(String::toInt)
        println(D[r] - D[l])
    }
}

Measured memory_bytes: 62696
#include <stdio.h>

int main(void)
{
	int N, i, n, min;
	int P[200001];
	
	scanf("%d", &N);
	
	n=0; min=9999999;
	for(i=0; i<N; i++){
		scanf("%d", &P[i]);
		if(P[i]<=min){
			min = P[i];
			n++;
		}
	}
	
	printf("%d", n);
	
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

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

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3732
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	h, w, h2, w2 := getInt(), getInt(), getInt(), getInt()

	a := h2 * w
	b := w2 * h
	c := h2 * w2
	d := h * w

	fmt.Println(d - (a + b) + c)

}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

const int dif = 'A' - 'a';

int main(){
	string num;
	int sum;
	while(cin >> num){
		if(num.size() == 1 && num[0] == '0') return 0;
		sum = 0;
		for(int i = 0; i < static_cast<int>(num.size()); i++){
			sum += num[i] - '0';
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3216
#include<stdio.h>
int main()
{
	int n,i,a[100],l,m,r,x,c;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)scanf("%d",&a[i]);
		scanf("%d",&x);
		for(c=l=0,r=n-1;l<=r;)
		{
			++c;
			m=(l+r)/2;
			if(a[m]==x)break;
			else if(a[m]<x) l=m+1;
			else r=m-1;
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){
  vector<int> vec(5);
  for(int i=0; i<5; i++){
    cin >> vec.at(i);
  }
  int k;
  cin >> k;
  
  sort(vec.begin(), vec.end());
  
  if(vec.at(4) - vec.at(0) <= k){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF=2147483645;
int n,m,x;
int c[20],a[20][20];
int ans=INF;
int und[20];
bool chk(){
	for(int i=1;i<=m;++i){
		if(und[i]<x) return false;
	}
	return true;
}
void dfs(int cur,int cost){
	if(cur==n+1){
		if(chk()){
			ans=min(ans,cost);
		}
		return;
	}
	for(int i=1;i<=m;++i){
		und[i]+=a[cur][i];
	}
	dfs(cur+1,cost+c[cur]);
	for(int i=1;i<=m;++i){
		und[i]-=a[cur][i];
	}
	dfs(cur+1,cost);
}
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=n;++i){
		scanf("%d",&c[i]);
		for(int j=1;j<=m;++j){
			scanf("%d",&a[i][j]);
		}
	}
	dfs(1,0);
	if(ans==INF){
		puts("-1");
	}
	else{
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,x,y,k,c=0;
    cin>>n>>k;

    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        x=abs(x);
        y=abs(y);
       long double m=sqrt(x*x+y*y);
       if(m<=k)c++;
    }
    cout<<c;

}



Measured memory_bytes: 3676
import math
n,m=map(int,input().split())
data = []
ans = 0
for i in range(n):data.append(list(map(int,input().split())))

for i in range(n):
  for j in range(n):
    if(i>=j):continue
    t = 0
    for k in range(m):
      
      t += (data[i][k] - data[j][k])**2
    
    res = math.sqrt(t)
    if(res == int(res)):ans+=1
print(ans)

Measured memory_bytes: 62424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] c = new int[n];
		int[] colors = new int[h*w];
		
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}
		
		int pos = 1;
		int row = 0;
		int[][] res = new int[h][w];
		
		while (row < h) {
			int col = (row % 2 == 0) ? 0 : w - 1;
			
			if (row % 2 == 0) {
				while (col < w) {
					int color = pos;
					c[pos-1]--;
					if (c[pos-1] == 0) { pos++; }
					res[row][col] = color;
					col++;
				}
			} else {
				while (col >= 0) {
					int color = pos;
					c[pos-1]--;
					if (c[pos-1] == 0) { pos++; }
					res[row][col] = color;
					col--;
				}
			}

			row++;
		}

		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(res[i][j] + " ");
			}
			System.out.println("");
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22868
//Fence
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
#define ll long long
//#define d double
//#define int long long
#define F first
#define S second
#define FastIO ios_base::sync_with_stdio(false),cin.tie(0)
#define fix std::fixed<<setprecision(10)
#define M 100000000
#define f(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define cl(n,m) (ceil(double(n)/double(m)))
#define T() int t; cin>>t; while(t--)

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long n,k;
    cin>>n>>k;
    long arr[n];
    f(n)cin>>arr[i];
    long long dp[n];
    if(n>=1)
    dp[0]=0;
    /*if(n>=2)
    dp[1]=abs(arr[2]-arr[1]);*/

    for(long i=1;i<n;i++)
    {dp[i]=1000000000;
        for(int j=1;j<=min(k,i);j++)
        {
        dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout<<dp[n-1];

}


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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

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

    int r;
    cin >> r;
    cout << 3*r*r << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  ll n,k;
  cin >>n >> k;
  ll sum1=0;
  for(ll i=k; i<=n+1;i++){
	sum1+=i*(n-i+1)+1;
    sum1%=MM;
  }  
   cout << sum1 << endl;     
}

Measured memory_bytes: 3676
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;
char ch;
int main()
{
	cin>>ch;
	if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')cout<<"vowel";
	else cout<<"consonant";
    return 0;
}


Measured memory_bytes: 256
def f(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1
s = int(input())
a=[0]*1000001
get_ans = False
ans = 0
for i in range(2,1000001):
    #aiを保存しながら進む&見つかったら進まなくてよい
    if i==2:
        a[1] = s
        a[2] = f(s)
        if a[1]==a[2]:
            ans = 2
            break
    else:
        a[i]=f(a[i-1])
        for j in range(1,i):
            if a[i]==a[j]:
                ans = i
                get_ans = True
                break
    if get_ans:
        break
print(ans)

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, k;
	cin >> n >> k;
	map<int, int> mop;
	for (int i = 0, x; i < n; i++)
		cin >> x, mop[x]++;
	vector<int> v;
	for (auto i : mop)
		v.pb(i.S);
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i + k < (int)v.size(); i++)
		ans += v[i];
	cout << ans;
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, y;
    cin >> n >> y;
    bool ok = false;
    rep(i, n + 1){
        rep(j, n + 1 - i) {
            int sum = 10000 * i + 5000 * j + 1000 * (n - i - j);
            if (sum == y) {
                cout << i << " " << j << " " << (n - i - j) << endl;
                ok = true;
                break;
            }
        }
        if (ok) break;
    }
    if (!ok) cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
ok = p-1
ng = n
def solve(x):
    if a[x] + m < a[p-1]:
        return False
    now = 0
    for i in range(n):
        if i >= x:
            now += m
        elif i < p-1:
            now += m
        else:
            now += a[x] + m - a[i]
    if now >= m*v:
        return True
    else:
        return False

while ng - ok > 1:
    mid = (ng + ok)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok+1)


Measured memory_bytes: 62576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(P == 1){
			Console.WriteLine(1);
			return;
		}
		
		var di = PrimDec(P);
		long ret = 1;
		foreach(var k in di.Keys){
			long c = di[k] / N;
			for(int i=0;i<c;i++) ret *= k;
		}
		Console.WriteLine(ret);
		
		
	}
	long N,P;
	public Sol(){
		var d = rla();
		N = d[0]; P = d[1];
	}
	Dictionary<long,long> PrimDec(long A){
	 	Dictionary<long,long> D=new Dictionary<long,long>();
	 	if(A==1)return null;
	 	long rem=A;
	 	for(long i=2;i*i<=A;i++){
	 		if(rem%i==0){
	 			long cnt=0;
	 			while(rem%i==0){cnt++;rem/=i;}
	 			D.Add(i,cnt);
	 		}
	 		if(rem==1)break;
	 	}
	 	if(rem!=1)D.Add(rem,1);
	 	return D;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
    long N;
    cin >> N;
    long A[N], B[N];
    for(long i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    sort(A, A + N);
    sort(B, B + N);
    if(N & 1){
        cout << B[N / 2] - A[N / 2] + 1;
    }else{
        cout << B[N / 2] + B[(N / 2) - 1] - A[N / 2] - A[(N / 2) - 1] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s;
  string t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    s.push_back(t);
  }

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

  cout << cnt*n << endl;

  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:14:43 2020

@author: masat
"""
import fractions

N = int(input())

A_list = list(map(int, input().split()))

GCD = A_list[0]
LCM = A_list[0]
for i in A_list:
    GCD = fractions.gcd(LCM,i)
    LCM = (LCM*i)//GCD
    #print("{},{}".format(GCD, LCM))

answer = 0

for i in A_list:
    answer += LCM//i

print(answer%(10**9 + 7))


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

int main(){
	int n, k;
  	cin >> n >> k;
  	vector<int> p(n);
  	rep(i, n) cin >> p[i];
  	
  	sort(p.begin(), p.end());
  	
  	int ans = 0;
  	rep(i, k) ans += p[i];
  
  	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
string a,b;
int x,y;
int main(){
	cin>>x>>y;
	for(int i=1;i<=x;i++)a+=char(y+'0');
	for(int i=1;i<=y;i++)b+=char(x+'0');
	cout<<min(a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    map<ll,ll> M;
    vl A;
    rep(i,n){
        cin>>x;
        A.push_back(x);
        M[x]++;
    }

    for(auto ite=M.begin();ite!=M.end();ite++){
        ans+=(*ite).second*((*ite).second-1)/2;
    }

    rep(i,n){
        cout<<ans-(M[A[i]]-1)<<endl;
    }
}

Measured memory_bytes: 11120
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    n,p=MI()
    c=Counter(prime_factorize(p))
    ans=1
    for x in c.keys():
        ans*=x**(c[x]//n)
    print(ans)
        
    

        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 66704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,sum,t,a[100005];
    while(cin>>sum>>n)
    {
        int s=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
        if(s>=sum)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 640
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
  vector<int> times(n,0);
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> times[i];
    sum += times[i];
  }
  int m;
  cin >> m;
  int tmp;
  vector<vector<int>> vv(m,vector<int>());
  for (int i = 0; i < m; i++)
  {
    cin >> tmp;
    vv[i].push_back(tmp);
    cin >> tmp;
    vv[i].push_back(tmp);
  }

  for (vector<int> i : vv)
  {
    cout << sum - times[(i[0]-1)] + i[1]  << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 10000
#define NIL -1

typedef struct {
  int p,l,r;
}Node;

Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main()
{
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL) root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

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

int main(){
  int y, m, d;
  char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
  cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f(ll b,ll n)
{
    if(n<b)return n;
    return f(b,n/b)+n%b;
}
int main()
{
    ll n,s;
    cin>>n>>s;
    if(n<s){cout<<"-1"<<endl;return 0;}
    if(n==s){cout<<n+1<<endl;return 0;}
    ll m=(ll)sqrt(n)+1;
    for(ll i=2;i<=m;i++)
    {
        if(f(i,n)==s)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    n-=s;
    ll r=1e11;
    for(ll p=1;p*p<=n;p++)
    {
        if(n%p==0)
        {
            ll b=n/p+1;
            ll a0=s-p;
            ll a1=p;
        if(b>=2&&a0>=0&&a0<b&&a1<b)
        {
            r=min(r,b);
        }
        }
    }
    if(r==1e11)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<r<<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	map<int, int> a, b;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		i & 1 ? a[x]++ : b[x]++;
	}
	int s = 0, t = 0, p = 0, q = 0;
	int m1 = 0, m2 = 0;
	for(int i = 0; i < 100005; i++) {
		if(b[i] >= s) {
			t = s;
			s = b[i];
			m1 = i;
		}
		if(a[100005 - i] >= p) {
			q = p;
			p = a[100005 - i];
			m2 = 100005 - i;
		}
	}
	cout << (m1 != m2 ? n - s - p : min(n - s - q, n - t - p)) << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

const int MAX_N = 16;
int a[MAX_N][MAX_N];

ll dp[(1<<MAX_N)+10];

int main(){
    int n;
    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    rep(mask, 1<<n) {
        ll tmp = 0LL;
        rep(i, n) if(mask&(1<<i)) {
            rep(j, n) if(mask&(1<<j)) tmp += a[i][j];
        }
        dp[mask] = tmp;
    }
    using bs = bitset<17>;
    rep(mask, 1<<n) {
        int A = mask;
        while(1) {
            int B = (mask - A);
            // cout << bs(mask) << " " << bs(A) << " " << bs(B) << endl;
            // assert((mask&A) == mask);
            assert((A&B) == 0); 
            chmax(dp[mask], dp[A]+dp[B]);
            A--;
            if(A <= 0) break;
            A &= mask;
        }
    }
    cout << dp[(1<<n)-1]/2 << endl;
    return 0;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

n = int(input())
S = input()
x = S[int(input())-1]
ans = ''
for c in S:
    if c != x:
        ans += '*'
    else:
        ans += x
print(ans)


Measured memory_bytes: 64364
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int[] init = new int[] { a, b, c };

		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}

		List<String> result = new ArrayList<>();
		dfs(result, s, 0, n, init);

		if (result.size() == n) {
			System.out.println("Yes");
			for (int i = result.size() - 1; i >= 0; i--) {
				System.out.println(result.get(i));
			}
		} else {
			System.out.println("No");

		}

	}

	private static boolean dfs(List<String> result, String[] s, int i, int n, int[] init) {
		if (i == n)
			return true;

		int l = s[i].charAt(0) - 'A';
		int r = s[i].charAt(1) - 'A';

		if (init[l] == 0 && init[r] == 0) {
			return false;
		}

		if (init[r] > 0) {
			int[] next = Arrays.copyOf(init, init.length);
			next[r]--;
			next[l]++;
			if( dfs(result, s, i + 1, n, next) ) {
				result.add(s[i].substring(0, 1));
				return true;
			}
		}

		if (init[l] > 0) {
			int[] next = Arrays.copyOf(init, init.length);
			next[l]--;
			next[r]++;
			if( dfs(result, s, i + 1, n, next) ) {
				result.add(s[i].substring(1, 2));
				return true;
			}
		}


		return false;
	}

}


Measured memory_bytes: 95520
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]

mindist = 1e5
ans = -1

for i in range(N):
	curdist = abs(T - H[i] * 0.006 - A)
	if mindist > curdist:
		mindist = curdist
		ans = i

print(ans + 1)


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

int main()
{
    long a, b; cin>>a>>b;
    if (a>b) swap(a, b);
    cout<<(b-a>1 ? "Alice" : "Brown")<<endl;
}

#if 0
int memo[1024][1024];

int func(long a, long b)
{
    if (a>b) swap(a, b);
    if (b<2) return 0;

    int& res=memo[a][b];
    if (~res) return res;

    res=0;
    for(auto i=2; i<=a; i+=2) res|=!func(a-i, b+i/2);
    for(auto i=2; i<=b; i+=2) res|=!func(a+i/2, b-i);
    return res;
}

int main()
{
    memset(memo, -1, sizeof(memo));
    int n=300;
    for(int i=0; i<n; ++i) {
        for(int j=i; j<n; ++j) {
            cout<<i<<", "<<j<<": "<<func(i, j)<<endl;
        }
    }
}
#endif



Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
ans = 1

if 0 in a_list:
    print(0)
    exit()

for i in range(n):
    ans *= a_list[i]
    if len(str(ans)) > 19 or ans > 10 ** 18:
        print(-1)
        exit()

print(ans)


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int r,d,x2000; cin >> r >> d >> x2000;

  int x = x2000;
  rep(i,10){
    x = r*x-d;
    cout << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3644
--バブルソート

import Data.Array
import Data.Array.ST
import Data.STRef
import Control.Monad.ST
import Control.Monad

--アレイ境界、アレイ、ソート済み先頭インデックス、アクション
bubble::(Int,Int)->STArray s Int Int -> Int -> ST s ()
bubble (s,e) ar idx = if idx >= (e-1) then return () else  do
  forM_ [((-j),(-j)+1)|j<-[(-(e-1))..(-(idx+1))]] (\(i,j)-> do
                                                  v_i<-readArray ar i
                                                  v_j<-readArray ar j
                                                  if v_i <= v_j then return ()
                                                                else do
                                                                  writeArray ar j v_i
                                                                  writeArray ar i v_j)

bubble_c::(Int,Int)->STArray s Int Int -> Int -> ST s Int
bubble_c (s,e) ar idx = if idx >= (e-1) then return 0 else  do
  counter<-newSTRef 0
  forM_ [((-j),(-j)+1)|j<-[(-(e-1))..(-(idx+1))]] (\(i,j)-> do
                                                  v_i<-readArray ar i
                                                  v_j<-readArray ar j
                                                  if v_i <= v_j then return ()
                                                                else do
                                                                  writeArray ar j v_i
                                                                  writeArray ar i v_j
                                                                  v<-readSTRef counter
                                                                  writeSTRef counter (v+1))
  c<-readSTRef counter
  return c

bubble_sort::(Int,Int)->STArray s Int Int -> ST s()
bubble_sort (s,e) ar = do
  forM_ [s-1..e-1] (bubble (s,e) ar)

bubble_sort_with_c::(Int,Int)->STArray s Int Int -> ST s Int
bubble_sort_with_c (s,e) ar = do
  ct <- forM [s-1..e-1] (bubble_c (s,e) ar)
  return (sum ct)

b_sort_with_c::Array Int Int -> (Int,Array Int Int)
b_sort_with_c ar = runST $ do
   let (s,e) = bounds ar
   mar<-thaw ar
   c<-bubble_sort_with_c (s,e) mar
   iar<-freeze mar
   return (c,iar)


main::IO()
main=do
  nc<-getLine
  let n = read nc
  d<-getLine
  let ar = listArray (1,n) (map read (words d))
  let (c,out)=b_sort_with_c ar
  putStr ((ls_show (elems out))++"\n")
  print c

ls_show::[Int]->String
ls_show [] = []
ls_show (x:xs) = (show x)++(if xs == [] then (ls_show xs) else ' ':(ls_show xs))


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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 main() {
    int a, b;

    cin >> a >> b;
    
    if (a*b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll p = (a1-b1)*t1, q = (a2-b2)*t2;

  if(p > 0) {
    p *= -1;
    q *= -1;
  }

  if(p+q == 0) {
    cout << "infinity" << endl;
    return 0;
  }

  if(p+q < 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = -p / (p+q);
  ans *= 2;
  ans += 1;
  if((-p)%(p+q) == 0) --ans;

  cout << ans << endl;
}


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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
typedef vector<int> vi;

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int main() {
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

main(){
 int i,j,m;
 int H,W;

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

 if(H==0 && W==0){
 break;}

 for(i=1;i<=H;i++){

  for(j=1;j<=W;j++){
  m = (i + j) % 2;
  
  if(m == 0){
  printf("#");
  }
  
  else{
  printf(".");
  }
 }  
  printf("\n");
 }

 printf("\n");
}

return 0;
}


Measured memory_bytes: 2052
// Problem : A - Next Alphabet
// Contest : AtCoder - AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3540
#include <stdio.h>
int main()
{
  double r;
  double Pi=3.14159265359;
  double S=0.0, W=0.0;
  scanf("%lf" ,&r);

  if (0<r && r<10000) {
    S=r*r*Pi;
    W=2*Pi*r;
  }
  printf("%f %f\n" ,S ,W);

  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	vector<int> a(m);
	for(int i = 0; i < m; i++) cin >> a[i];
	vector<int> ans;
	auto add = [&](int x){
		if(x) ans.push_back(x);
	};
	if(m == 1){
		cout << a[0] << endl;
		add(n - 1);
		add(1);
	} else if(m == 2){
		cout << a[0] << " " << a[1] << endl;
		add(a[0] - 1);
		add(a[1] + 1);
	} else {
		int cnt = 0;
		for(int i = 0; i < m; i++) cnt += a[i] % 2;
		if(cnt > 2) return cout << "Impossible" << endl, 0;
		for(int i = 0; i < m; i++) if(a[i] % 2) swap(a[i], a[0]);
		for(int i = 1; i < m; i++) if(a[i] % 2) swap(a[i], a[m - 1]);
		add(a[0] - 1);
		for(int i = 1; i < m - 1; i++) add(a[i]);
		add(a[m - 1] + 1);
		for(int i = 0; i < m; i++) cout << a[i] << " "; cout << endl;
	}
	cout << ans.size() << endl;
	for(int v : ans) cout << v << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int k = 0;
    int n, tmp;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp != i + 1) k++;
    }
    if (k <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

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

  sort(d.begin(), d.end(), greater<int>());

  int count = 1;
  for(int j=0;j<n-1;j++){
    if(d[j] > d[j+1]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double[] dp = new double[N + 1];
		dp[0] = 1;
		for(int i=0;i<N;i++){
			double p = P[i];
			var ndp = new double[N + 1];
			for(int j=0;j<N;j++){
				ndp[j] += (1 - p) * dp[j];
				ndp[j + 1] += p * dp[j];
			}
			dp = ndp;
		}
		
		double ans = 0;
		for(int i=0;i<=N;i++){
			int omote = i;
			int ura = N - i;
			if(omote > ura){
				ans += dp[i];
			}
		}
		Console.WriteLine(ans);
	}
	int N;
	double[] P;
	public Sol(){
		N = ri();
		P = rda();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 29904
#include<stdio.h>

int main(){

  int data[10000];
  int search[500];

  int i,j,sumdata,sumsearch,count;

  count = 0;

  scanf("%d",&sumdata);

  for(i = 0; i < sumdata; i++){

    scanf("%d",&data[i]);

  }

  scanf("%d",&sumsearch);

  for(i = 0; i < sumsearch; i++){

    scanf("%d",&search[i]);

  }


  for(i = 0; i < sumsearch; i++){

    for(j = 0; j < sumdata; j++){

      if(data[j] == search[i]){

	count = count + 1;
	break;

      }

    }

  }

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

  return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(double n,int k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2);
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1);
  }
}

int main(){

  int n,k;cin>>n>>k;

  double ans;
  double coin = 0.5;

int count = 0;
  for(int i=n;i>0;i--){
    while(1){
      if(i * pow(2,count)>=k)break;
      count++;
    }
    //cout<<count<<endl;
    ans += pow(coin,count);
  }

  ans /= n;

  cout<<setprecision(18)<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define      fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define      debug       printf("\n<<CameHere>>\n")
#define      mem(x,y)    memset(x, y, sizeof(x))
#define      all(qz)     qz.begin(),qz.end()
#define      rall(qz)    qz.rbegin(),qz.rend()
#define      inf         1000000000000000000
#define      mod         1000000007
#define      Sqr(x)      ((x)*(x))
#define      ll          long long
#define      mk          make_pair
#define      pb          push_back
#define      pi          acos(-1.0)
#define      cos(a)      cos(a*pi/180)
#define      sin(a)      sin(a*pi/180)
#define      tan(a)      tan(a*pi/180)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    fastt

    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    sort(all(v));
    ll cnt=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(v[i]+v[j]>v[k]&&(v[i]!=v[j]&&v[j]!=v[k])) cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}
























Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n,k;
vector<ll> w;
int check(ll p)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        ll sum=0;
        while(sum+w[i]<=p)
        {
            sum+=w[i];
            i++;
            if(i==n)return n;
        }
        
    }
    return i;
}
ll solve()
{
    ll left=0;
    ll right = 1000000000;
    ll mid;
    while(right-left>1)
    {
        mid=(right+left)/2;
        ll v=check(mid);
        if(v>=n)right=mid;
        else left=mid;
    }
    return right;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        w.push_back(a);
    }
    ll ans = solve();
    cout<<ans<<endl;
    return 0;
    
}



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

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

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


const int S=100100;
ll n,m;
ll x[S+5],y[S+5];

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    int l,r,d;
    while(~sf("%d %d %d",&l,&r,&d))
    {
        int cnt=0;
        for(int i=l;i<=r;i++)
        {
            if(i%d==0)cnt++;
        }
        pf("%d\n",cnt);
    }
    return 0;
}
 






































Measured memory_bytes: 3756
whether=str(input())
if whether[0]==whether[1]==whether[2]=="R":
    print ("3")
elif whether[0]==whether[1]==whether[2]=="S":
    print ("0")
elif whether[0]==whether[1]=="R" or whether[1]==whether[2]=="R":
    print ("2")
else:
    print ("1")


Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll n,k,A[200001],F[200001];
ll ok,ng,mid;
ll solve(ll x){
    ll ans=0;
    rep(i,n) if(A[i]>x/F[i]) ans+=A[i]-x/F[i];
    if(ans<=k) return 1;
    return 0;
}
int search(){
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(solve(mid)) ok=mid;
        else ng=mid;
    }
}
int main(){
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    rep(i,n) cin>>F[i];
    sort(A,A+n);
    sort(F,F+n,greater<ll>());
    ok=1e18;ng=-1;
    search();
    cout<<ok;
}

Measured memory_bytes: 3328
import math
n=int(input())
a=list(map(int,input().split()))

a.sort()
g=a[0]

for i in range(1,n):
  g=math.gcd(g,a[i])

d=[set(),set()]
for i in range(2):
  b=a[i]//g
  f=1
  while f*f<b+1:
    if b%f==0:
      d[i].add(f)
      d[i].add(b//f)
    f+=1

an=d[0]&d[1]
xo=d[0]^d[1]

for i in range(2,n):
  e1=set()
  e2=set()
  for m in xo:
    if a[i]%m!=0:
      e1.add(m)
  for m in an:
    if a[i]%m!=0:
      e2.add(m)
      xo.add(m)
  for m in e1:
    xo.remove(m)
  for m in e2:
    an.remove(m)
an.add(0)
xo.add(0)
print(max(max(xo),max(an))*g)
    

Measured memory_bytes: 20696
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  char S[N];
  cin>>S;
  int j=0;
  for(int i=2;i<N;i++){
  if(S[i-2]=='A'&S[i-1]=='B'&S[i]=='C'){j++;}
  }
  cout<<j;
}

Measured memory_bytes: 256