akhauriyash/Code-Regression huggingface dataset:
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

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=I()
u=prime_factorize(n)
c=Counter(u)
ans=0
lis=[0 for i in range(15)]
for i in range(14):
    lis[i+1]=lis[i]+i+1
#print(lis)
mans=[]
for x in c.keys():
    y=c[x]
    man=-1
    for i in range(15):
        if y>=lis[i]:
            man+=1
    mans.append(man)
print(sum(mans))
            
            

    
    
        


Measured memory_bytes: 9500
#include <iostream>
#include <cstdio>
#include <limits>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	double h;
	double highest = 0;
	double lowest = numeric_limits<double>::max();
	while(cin >> h) {
		if(highest < h) highest = h;
		if(lowest > h) lowest = h;
	}
	cout << highest - lowest << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int n,T;
	cin>>n>>T;
	int c,t,id=-1;
	int c1=1005;
	for(int i=1;i<=n;i++)
    {
        cin>>c>>t;
        if(t<=T)
        {
            c1=min(c1,c);
        }
    }
	if(c1==1005)
        cout<<"TLE"<<endl;
    else
        cout<<c1<<endl;





    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();
        int[] s = new int[M];
        int[] c = new int[M];
        for (int i = 0; i < M; i++) {
            s[i] = in.i();
            c[i] = in.i();
        }
        int[] d = {0, 0, 10, 100, 1000};
        int[] e = {1, 10, 100};
        int ans = -1;
        loop:for (int i = d[N]; i < d[N + 1]; i++) {
            for (int j = 0; j < M; j++) {
                if (i / e[N - s[j]] % 10 != c[j]) {
                    continue loop;
                }
            }
            ans = i;
            break;
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

using namespace std;

// sが与えられる
int fn2(int s) {
  int ans = 0;
  while (s != 0) {
    auto bs = bitset<32>(s);
    int cnt = bs.count();
    s = s % cnt;
    ans++;
  }

  return ans;
}

using ll = long long;
int main(int argc, const char *argv[]) {
  int n;
  string x;
  cin >> n >> x;

  int cnt = count_if(x.begin(), x.end(), [](char c) { return c == '1'; });
  int md1 = cnt - 1, md2 = cnt + 1;

  vector<int> pow2_1(x.size() + 1, 1), pow2_2(x.size() + 1, 1);
  for (int i = 1; i < pow2_1.size(); ++i) {
    if (md1 > 0) {
      pow2_1[i] = pow2_1[i - 1] * 2 % md1;
    }

    pow2_2[i] = pow2_2[i - 1] * 2 % md2;
  }

  int x_md1 = 0, x_md2 = 0;
  for (int i = 0; i < x.size(); ++i) {
    char ch = *(x.rbegin() + i);
    if (ch == '1') {
      if (md1 > 0) {
        x_md1 = (x_md1 + pow2_1[i]) % md1;
      }

      x_md2 = (x_md2 + pow2_2[i]) % md2;
    }
  }

  // md1 : cnt-1
  // md2 : cnt+1
  vector<int> ans(x.size());
  for (int i = 0; i < x.size(); ++i) {
    int d = x[i] - '0';
    if (d) {
      // popcountは一つ減る
      if (md1 == 0) {
        ans[i] = 0;
      } else {
        int dd = x_md1 - pow2_1[x.size() - i - 1];
        if (dd < 0) {
          dd += md1;
        }

        ans[i] = fn2(dd % md1) + 1;
      }
    } else {
      // popcountは一つ増える
      ans[i] = fn2((x_md2 + pow2_2[x.size() - i - 1]) % md2) + 1;
    }
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 6032
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  rrep(i,n-1) {
    if(a[i]>a[i+1]) a[i]--;
    if(a[i]>a[i+1]) {
      pr("No");
      return;
    }
  }
  pr("Yes");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

long double dp[3100][6100];

int main()
{
    int n;
    cin>>n;
    dp[0][3000] = 1;
    for(int i = 0; i < n; i++)
    {
        long double t;
        cin>>t;
        for(int j = 1; j <= 6001; j++)
        {
            if(j == 3000)
                j = 3000;
            dp[i+1][j+1] += dp[i][j]*t;
            dp[i+1][j-1] += dp[i][j]*(1.0 - t);
        }
    }
    long double ans = 0;
    for(int j = 3001; j <= 6001; j++)
        ans += dp[n][j];
    cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 286848
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+1;

template<class T> bool chkmax(T &x,const T &y){return y>x?x=y,1:0;}
template<class T> bool chkmin(T &x,const T &y){return y<x?x=y,1:0;}

char S[maxn];
int val[maxn],n,k,cnt;
int s[maxn];

int Solve(int k,int op){
	int res=0;
	for (int i=1;i<=cnt;++i){
		int pre=((i&1)==op)?(max(0,i-2*k)):(max(0,i-2*k-1));
		chkmax(res,s[i]-s[pre]);
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&k);
	scanf("%s",S+1);
	if (S[1]=='0') cnt=1;
	int pos=1;
	for (int i=1;i<=n+1;++i){
		if (S[i]!=S[pos])
		val[++cnt]=i-pos,pos=i;
	}
	for (int i=1;i<=cnt;++i)
	s[i]=val[i]+s[i-1];
	printf("%d\n",max(Solve(k,0),Solve(k-1,1)));
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>

using namespace std;
int main() {
	int n, m, nn, mm;
	int i[49];
	cin >> n >> m;
	for (int x = 0; x < n; ++x)i[x] = 0;
	for (int x = 0; x < m; ++x) {
		cin >> nn >> mm;
		for (int y = 0; y < n; ++y) {
			if (nn == (y+1))i[y] = i[y] + 1;
			if (mm == (y+1))i[y] = i[y] + 1;
		}
	}
	for (int x = 0; x < n; ++x)cout << i[x] << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [0]*n
x = [[0] *n for i in range(n)]
y = [[0] *n for i in range(n)]
ans = 0
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        x[i][j],y[i][j] = map(int,input().split())
        x[i][j]-=1
def honest(i,j):
    return (i>>j)%2 ==1
def check(m):
    for i in range(n):
        if not honest(m,i) :continue
        for j in range(a[i]):
            if y[i][j] == 1 and honest(m,x[i][j]) == 0:
                return False
            if y[i][j] == 0 and honest(m,x[i][j]) == 1:
                return False
    return True
def count(c):
    cnt = 0
    for i in range(n):
        cnt+= honest(c,i)
    return cnt      

for i in range(2**n):
    if check(i):
        ans = max(ans,count(i))
    
        
        
        
print(ans)
        

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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define int long long
#define ld long double
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mod 1000000007

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int32_t main(){
  int n,k;  cin>>n>>k;
  vector<int> A(n); fr(i,0,n) cin>>A[i];
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  dp[1] = abs(A[0]-A[1]);
  fr(i,2,n){
    for(int j=i-1;j>=i-k and j>=0;j--)
    dp[i] = min(dp[i],dp[j]+abs(A[i]-A[j]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int h, w, p, x, y, ans = 0;
char map[1234][1234];
int mapi[1234][1234];
int f1(int i, int j, int cost, char ch) {
	if (map[i][j] == ch) {
		x = i; y = j;
		return cost;
	}
	if (mapi[i][j] <= cost)return mod;
	mapi[i][j] = cost;
	int r = mod;
	if (i > 1 && map[i - 1][j] != 'X')r = min(r, f1(i - 1, j, cost + 1, ch));
	if (i < h && map[i + 1][j] != 'X')r = min(r, f1(i + 1, j, cost + 1, ch));
	if (j > 1 && map[i][j - 1] != 'X')r = min(r, f1(i, j - 1, cost + 1, ch));
	if (j < w && map[i][j + 1] != 'X')r = min(r, f1(i, j + 1, cost + 1, ch));
	return r;
}
int f(int i) {
	for1(i, h) for1(j, w) mapi[i][j] = mod;
	return f1(x, y, 0, (char)('0' + i));
}
signed main() {
	cin >> h >> w >> p;
	for1(i, h) {
		for1(j, w) {
			cin >> map[i][j];
			if (map[i][j] == 'S') { x = i; y = j; }
		}
	}
	for1(i, p)ans += f(i);
	cout << ans << endl;
}


Measured memory_bytes: 19680
def z_is_exist(X, Y, x, y):
    cand = []
    for i in range(X + 1, Y + 1):
        if max(x) < i and min(y) >= i:
            return True
    return False
    

def main():
    N, M, X, Y = map(int, input().split())
    *x, = map(int, input().split())
    *y, = map(int, input().split())
    if z_is_exist(X, Y, x, y):
        print("No War")
    else:
        print("War")


main()

Measured memory_bytes: 3060
def gcd(a, b):
  if (b == 0):
    return a
  return gcd(b, a % b)

def gcd_xyz(x, y, z):
  xy = gcd(x, y)
  xyz = gcd(xy, z)
  return xyz

def past(p):
  if(p == 2):
    return 1
  else:
    return past(p-1)+(p-2)*4+6

K = int(input())
sum=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd_xyz(i,j,k)
print(sum)

Measured memory_bytes: 77780
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
      	int b = in.nextInt();
      	int c = in.nextInt();
      
      int now = a-b;
      int ans = c-now;
      
      if(ans<0){ans=0;}
      System.out.print(ans);
      
	}
}


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

using namespace std;


int main()
{
	unsigned long long  a, b, c;
	cin >> a >> b >> c;
	unsigned long long  left = 4 * a * b;
	if (c < a + b) {
		cout << "No" << endl;
		return 0;
	}
	long long right = (c - a - b) * (c - a - b);
	if (left < right) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
hoge = {}
for i in range(1000):
    hoge[i] = i**5
for i in range(1000):
    hoge[-i] = -i**5
x = int(input())
for i in hoge.items():
    for j in hoge.items():
        if i[1] - j[1] == x:
            print(i[0], j[0])
            break
    else:
        continue
    break


Measured memory_bytes: 67636
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>

using namespace std;

#define ll long long unsigned int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[50][2500];
ll dp2[50][2500];

int main()
{
    std::cout << std::noshowbase;
    Fill(dp, 0);
    Fill(dp2, 0);
    
    int n, a;
    cin >> n >> a;
    vector<int> v;
    vector<int> v2;
    int aCount = 0;
    for(int i = 0;i < n;i++)
    {
        int e;
        cin >> e;
        if(e == a)
        {
            aCount++;
        }
        else if(e > a)
        {
            v.push_back(e-a);
        }
        else
        {
            v2.push_back(a-e);
        }
    }
    if(v.empty() || v2.empty())
    {
        if(aCount > 0)
        {
            ll s =pow(2, aCount) - 1;
            cout << s << endl;
            return 0;
        }
        cout << 0 << endl;
        return 0;
    }
    dp[0][v[0]]++;
    for(int i = 1;i < v.size();i++)
    {
        for(int k = 0;k < 2500;k++)
        {
            if(dp[i-1][k] > 0)
            {
                dp[i][k] += dp[i-1][k];
                dp[i][k + v[i]] += dp[i-1][k];
            }
        }
        dp[i][v[i]]++;
    }
    dp2[0][v2[0]]++;
    for(int i = 1;i < v2.size();i++)
    {
        for(int k = 0;k < 2500;k++)
        {
            if(dp2[i-1][k] > 0)
            {
                dp2[i][k] += dp2[i-1][k];
                dp2[i][k + v2[i]] += dp2[i-1][k];
            }
        }
        dp2[i][v2[i]]++;
    }
    ll sum = 0;
    for(int i = 0;i < 2500;i++)
    {
        sum += dp[v.size()-1][i] * dp2[v2.size() - 1][i];
    }
    if(aCount > 0)
    {
        ll p = pow(2, aCount);
        ll r = sum * p + p - 1LL;
        cout << r << endl;
        return 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2176
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N=0;
    ll M=0;
    cin >>N>>M;

    cout<<N+M/2<<endl;
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  rep(i,n) cin >> data[i];
  vector<int>ans(n);
  ans = data;
  sort(data.begin(),data.end());
  int bf = data[n/2-1],bb = data[n/2];
  rep(i,n){
    if(ans[i] <= bf) cout << bb << endl;
    else cout << bf << endl;
  }
}

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

int main(){
    ll x;
    cin >> x;
    ll y=100;
    ll ans = 0;
    while (y <x){
        y *= 1.01;
        ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
 
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    Map<String, Integer> blue = new HashMap<>();
    Map<String, Integer> red = new HashMap<>();
    
    int N = sc.nextInt();
    for(int i = 0; i < N; i++) {
      String s = sc.next();
      if(blue.get(s) == null) {  //値が存在しない場合
        blue.put(s, 1);
      }else {                    //値がすでに存在する場合
        blue.put(s, blue.get(s)+1);
      }
    }
    
    int M = sc.nextInt();
    for(int i=0;i<M;i++) {
      String s=sc.next();
      if(red.get(s) == null) {
        red.put(s, 1);
      }else {
        red.put(s, red.get(s)+1);
      }
    }
    
    int max = 0;
    for(String key : blue.keySet()) {
      int now;
      if(red.containsKey(key)) {
        now = blue.get(key) - red.get(key);
      }else {
        now = blue.get(key);
      }
      if(max < now) {
        max = now;
      }
    }
    System.out.println(max>0?max:0);
  }
}
    

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

const int maxn=500005;
const int mo=998244353;

int n,m,N,M;
int fac[maxn],ifac[maxn],pw1[maxn],pw2[maxn];

inline int pow(int a,int b,int p){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1)ans=1ll*ans*a%p;
	return ans;
}

inline int C(int n,int m){
	if(n<m||m<0)return 0;
	return 1ll*fac[n]*ifac[m]%mo*ifac[n-m]%mo;
}

int main(){
	cin>>n>>m;
	N=min(n,m),M=max(n,m);
	fac[0]=ifac[0]=pw1[0]=pw2[0]=1;
	for(int i=1;i<=n;i++)pw1[i]=1ll*pw1[i-1]*(m+1)%mo;
	for(int i=1;i<=m;i++)pw2[i]=1ll*pw2[i-1]*(n+1)%mo;
	for(int i=1;i<=M;i++)fac[i]=1ll*fac[i-1]*i%mo;
	ifac[M]=pow(fac[M],mo-2,mo);
	for(int i=M-1;i;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mo;
	long long ans=0,w=1;
	for(int i=0;i<=N;i++,w=-w)
		ans+=w*C(n,i)*C(m,i)%mo*fac[i]%mo*pw1[n-i]%mo*pw2[m-i]%mo;
	cout<<(ans%mo+mo)%mo<<'\n';
	return 0;
}

Measured memory_bytes: 11400
#include <stdio.h>

int main(void)
{
	int temp_num;
	char temp_bload[3];
	int a = 0, b = 0, o = 0, ab = 0;
	
	while (scanf("%d,%s", &temp_num, temp_bload) != EOF){
		if ((temp_bload[0] == 'A') && (temp_bload[1] == 'B')){
			ab++;
		}
		else if (temp_bload[0] == 'A'){
			a++;
		}
		if (temp_bload[0] == 'B'){
			b++;
		}
		if (temp_bload[0] == 'O'){
			o++;
		}
		temp_bload[1] = '\0';
	}
	
	printf("%d\n", a);
	printf("%d\n", b);
	printf("%d\n", ab);
	printf("%d\n", o);
	
	return (0);
}

Measured memory_bytes: 0
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    
    int n,m;
    ll s=0;
    cin>>n>>m;
    int a[n];
    for0(i,n)cin>>a[i];
    sort(a,a+n);
    for0(i,m){
        s+=a[i];
    }
    cout<<s;

End;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  int sum = 0;
  if(L>0){
    for(int i=0;i<N-1;i++){
      sum += L+i+1;
    }
    cout << sum <<endl;
  }
  else if(L<=0 && L + N >= 1){
    for(int i=0;i<N;i++){
      sum += L+i;
    }
    cout << sum <<endl;
  }
  else{
     for(int i=0;i<N-1;i++){
       sum += L+i;
     }
    cout << sum <<endl;
  }    
}

Measured memory_bytes: 256
#define M 26
P[M],A[M],B[M];
int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
	for(k=0;k<M;k++)A[k]=B[k]=0,P[k]=k;
	for(k=0;k<l;k++)scanf("%s",s),A[x=*s-97]++,B[y=s[strlen(s)-1]-97]++,P[R(x)]=R(y);
	for(k=0;k<M;k++)if(A[k]-B[k]||(A[k]&&R(*s-97)!=R(k)))break;
}exit(0);}

Measured memory_bytes: 584
#include<stdio.h>

int main() {
	char s[1001];
	int loop;
	int flag;
	int n = 0, w = 0, S = 0, e = 0;

	scanf("%s", &s);

	for (loop = 0; s[loop] != '\0'; loop++) {
		if (s[loop] == 'N')
			n++;
		else if (s[loop] == 'W')
			w++;
		else if (s[loop] == 'S')
			S++;
		else if (s[loop] == 'E')
			e++;
	}

	if (n != 0 && S == 0) printf("No");
	else if (n == 0 && S != 0) printf("No");
	else if (e == 0 && w != 0)printf("No");
	else if (e != 0 && w == 0) printf("No");
	else printf("Yes");

	return 0;
}


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

using namespace std;

int main(){
  int n,q,s[10000],t,ans = 0;

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

  cin >> q;
  for(int i = 0 ; i < q ; i++){
    cin >> t;
    for(int j = 0 ; j < n ; j++){
      if(t == s[j]){
	ans++;
	break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL gcd(LL m,LL n){
    if(m<n) swap(m,n);
    while(true){
        if(n==0) break;
        LL t = n;
        n = m%n;
        m = t;
    }
    return m;
}
LL lcm(LL a,LL b){
    return (a*b)/gcd(a,b);
}

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

    LL a,b;
    cin>>a>>b;
    PUTS(lcm(a,b));
}

Measured memory_bytes: 256
/*
 　　　　　／＞　 フ
 　　　　　| 　_　 _|
 　 　　　／`ミ _x 彡
 　　 　 /　　　 　 |
 　　　 /　  ヽ　　 ?
 　／￣|　　 |　|　|
 　| (￣ヽ＿_ヽ_)_)
 　＼二つ
  */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

#include<cmath>
const double pi = acos(-1);
const int N = 3050;
int n, L, t[N];
double ansx, ansy;
int main() {
    read(n), read(L);
    for (int i = 1;i <= n; i++) read(t[i]);
    for (int i = 1;i <= n; i++) {
        for (int j = i + 1;j <= n; j++) {
            ll nd = n - (j - i - 1) * 2 - 2;
            double delta = pi * (t[j] + t[i]) / L;
            ansx += cos(delta) * nd, ansy += sin(delta) * nd;
        }
    }
    ansx *= 6, ansx /= n, ansx /= (n - 1), ansx /= (n - 2);
    ansy *= 6, ansy /= n, ansy /= (n - 1), ansy /= (n - 2);
    printf ("%.12lf %.12lf\n", ansx, ansy);
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n, k;
  string s;
  vector<int> vec;
  cin >> n >> k;
  cin >> s;
  int cnt = 0;
  if(s[0] == '0') vec.push_back(0);
  for(int i = 1; i <= int(s.size()); i++){
    if(s[i-1] != s[i]){
      vec.push_back(cnt+1);
      cnt = 0;
      continue;
    }
    cnt++;
  }
  int t = 0;
  int si = vec.size();
  for(int i = 0;i < 2 * k + 1;i++){
    if(i == si-1){
      cout << n << endl;
      return 0;
    }
    t+=vec[i];
  }
  int ans = t;
  for(int i = 0; i < si - 2*k-2;i+=2){
    t = t - vec[i] - vec[i+1] + vec[i+2*k+1] + vec[i+2*k+2];
    ans = max(t, ans);
  }
  ans = max(ans, t + vec[si-1] - vec[si-1-2*k-1]-vec[si-1-2*k]);
  cout << ans <<endl; 
}

Measured memory_bytes: 4072
import numpy as np

N,L = [int(i) for i in input().split()]
L = np.arange(L,L+N)


if 0 in L:
  print(sum(L))
else:
  if min(L) > 0:
    print(sum(L)-min(L))
  else:
    print(sum(L)-max(L))


Measured memory_bytes: 21136
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string S,ans;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0)ans += S[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    num = int(input())
    data = list(map(int, input().split()))
    count = Counter(data)

    ans = 0
    for i in range(2 ** 11):
        bin_list = bin(i)[2:]
        bin_list = bin_list.zfill(11)
        bin_list = list(map(int, list(bin_list)))
        now_data = [0, 24]

        if count[12] >= 2:
            print(0)
            sys.exit()
        elif count[12] == 1:
            now_data.append(12)

        if count[0] >= 1:
            print(0)
            sys.exit()


        for j in range(1, 12):
            if count[j] == 0:
                continue
            elif count[j] >= 3:
                print(0)
                sys.exit()
            elif count[j] == 2:
                now_data.append(j)
                now_data.append(24 - j)
            elif bin_list[j - 1]:
                now_data.append(j)
            else:
                now_data.append(24 - j)
        now_data.sort()

        kari = 12
        # print(now_data)
        for j in range(len(now_data) - 1):
            kari = min(kari, now_data[j + 1] - now_data[j])
        ans = max(ans, kari)

    print(ans)




if __name__ == '__main__':
    main()
    # test()



Measured memory_bytes: 44780
n, m = gets.chomp.split.map(&:to_i)
arr = []
n.times{
    line = gets.chomp
    w = line.count("W")
    b = line.count("B")
    r = line.count("R")
    arr << [m - w, m - b, m - r]
}
min = nil
for i in 0..n-3
    for j in i+1..n-2
        sum = 0
        for k in 1..n-2
            if k <= i
                sum += arr[k][0]
            elsif k <= j
                sum += arr[k][1]
            else
                sum += arr[k][2]
            end
        end
        min = sum if min.nil? || min > sum
    end
end
puts arr[0][0] + min + arr[n-1][2]


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

using namespace std;
using ll = long long;
using ld = long double;

#define int long long
signed main(){
//int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int n,a;
    cin >> n >> a;
    int x[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int dp[n+5][n+5][2505];
    memset(dp,0,sizeof(dp));
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            for(int k = 0; k <= 2500; k++) {
                if(i==0 && j==0 && k==0) dp[i][j][k]=1;
                else if(i>=1 && k<x[i-1])dp[i][j][k]=dp[i-1][j][k];
                else if(i>=1 && j>=1 && k>=x[i-1]) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
                else dp[i][j][k]=0;
            }
        }
    }



    int ans=0;
    for(int i = 1; i <= n; i++) {
        int tmp=dp[n][i][i*a];
        ans+=tmp;
//        cout << i << " " << tmp << "\n";
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 62808
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	vector<int> a(3);
	int b = 0, c = 0, d = 0;
	while (true) {
		for (int& i : a) cin >> i;
		sort(a.begin(), a.end());
		if (a[0] + a[1] <= a[2]) break;
		if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2]) ++b;
		else if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) ++c;
		else ++d;
	}
	cout << b + c + d << ' ' << c << ' ' << d << ' ' << b << endl;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
#define INF 1LL<<32
typedef long long ll;
ll A[100][100];
int V,E,s,t;
ll d;
ll D[100][100];

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

void floyd(){
    for(int i=0;i<V;++i){
        for(int j=0;j<V;++j){
            if(A[j][i]==INF) continue;
            for(int k=0;k<V;++k){
                if(A[i][k]==INF) continue;
                A[j][k]=(A[j][k]>A[j][i]+A[i][k]?A[j][i]+A[i][k]:A[j][k]);
            }
        }
    }
}

int main(){
    cin>>V>>E;
    Fill(A,INF);
    for(int i=0;i<V;++i){
        A[i][i]=0;
    }
    for(int i=0;i<E;++i){
        cin>>s>>t>>d;
        A[s][t]=d;
    }

    floyd();

    bool negative=false;
    for(int i=0;i<V;++i){
        if(A[i][i]<0) negative=true;
    }

    if(negative){
        cout<<"NEGATIVE CYCLE\n";
    }
    else{
        for(int i=0;i<V;++i){
            for(int j=0;j<V;++j){
                if(A[i][j]==INF) cout<<"INF";
                else cout<<A[i][j];
                if(j==V-1) cout<<"\n";
                else cout<<" ";
            }
        }
    }
}


Measured memory_bytes: 3196
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        boolean han = true;
        
        for(int i = 0; i < N; i++) {
            int s = sc.nextInt();
            if(map.containsKey(s)) {
                han = false;
                break;
            }else {
                map.put(s, 1);
            }
        }
        
        if(han) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
}


Measured memory_bytes: 98436
import collections
N = int(input())
A = list(map(int, input().split()))
A_C = collections.Counter(A)
#{[3:4, 5:4]}

ans = 0
for i in A_C.keys():#3,5
  if i > A_C[i]:
    ans += A_C[i]
  else:
    ans += A_C[i] - i
    
print(ans)

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

int main(){
    int n, m;

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

    vector<pair<string,int>> blue;
    sort(s.begin(), s.end());
    int b = 0;
    int i = 0;
    while(i<=n-1){
        int num = 1;
        while(i+1 <= n-1 && s[i+1] == s[i]){
            num += 1;
            i += 1;
        }
        blue.push_back({s[i],num});
        b += 1;
        i += 1;
    }

    vector<pair<string,int>> red;
    sort(t.begin(), t.end());
    int r = 0;
    int j = 0;
    while(j<=m-1){
        int num = 1;
        while(j+1 <= m-1 && t[j+1] == t[j]){
            num += 1;
            j += 1;
        }
        red.push_back({t[j],num});
        r += 1;
        j += 1;
    }

    /*
    cout << "b = " << b << ", r = " << r << endl;
    for(int i=0; i<b; i++){
        cout << blue[i].first << " " << blue[i].second << endl;
    }
    cout << endl;
    for(int i=0; i<r; i++){
        cout << red[i].first << " " << red[i].second << endl;
    }
    */

    int ans = 0;
    for(int i=0; i<b; i++){
        int diff = blue[i].second;
        for(int j=0; j<r; j++){
            if(blue[i].first == red[j].first){
                diff -= red[j].second;
                break; 
            }
        }
        if(ans < diff) ans = diff;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int c = sc.nextInt();

        if (n == k) {
            if (n != c) {
                System.out.println("Yes");
                return;
            }
        } else if (k == c) {
            if (n != c) {
                System.out.println("Yes");
                return;
            }
        } else if (n == c) {
            if (k != c) {
                System.out.println("Yes");
                return;
            }

        } else {

        }
        System.out.println("No");
    }
}


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

const int MAX = 200000;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	
	int64_t sum = 0, ans = 0;
	for (int l = 0, r = 0;l < N;r = l > r ? l : r) {
		if (r < N && (sum ^ A[r]) == sum + A[r]) { // lからrまでの範囲で条件を満たす
			ans += r - l + 1;
			sum += A[r];
			r ++;
		} else {
			sum -= A[l]; // 次はl+1からrまでを満たすか調べる
			l ++;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

A_iからA_jが条件を満たすならA_iからA_(j-1)も条件を満たす
また、A_iからA_jが条件を満たさないならどの部分集合も条件を満たさない
ということで、尺取り法
*/

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static long w;
	static long h;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		w = Long.parseLong(strArr[0]);
		h = Long.parseLong(strArr[1]);
		long x = Long.parseLong(strArr[2]);
		long y = Long.parseLong(strArr[3]);
		long r = Long.parseLong(strArr[4]);
		boolean isIn = isIn(x, y - r) && isIn(x, y + r) && isIn(x - r, y) && isIn(x + r, y);
		System.out.println(isIn ? "Yes" : "No");
	}
	
	private static boolean isIn(long x, long y){
		boolean xIsIn = 0 <= x && x <= w;
		boolean yIsIn = 0 <= y && y <= h;
		return xIsIn && yIsIn;
	}
}

Measured memory_bytes: 17056
#include<cstdio>

int main(){
    int H,W;
    for(int i = 0;; i++){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j = 1; j <= W; j++){
            printf("#");
        }
        printf("\n");
        for(int j = 2; j < H; j++){
            printf("#");
            for(int k = 2; k < W; k++){
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for(int j = 1; j <= W; j++){
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}


Measured memory_bytes: 2584
#!/usr/bin/env python3
#ABC97 D

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def union(x,y):
    x = root(x)
    y = root(y)

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
n,m = LI()
p = LI()
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for _ in range(m):
    x,y = LI()
    if root(x-1) != root(y-1):
        union(x-1,y-1)

ans = 0
for i in range(n):
    if root(p[i]-1) == root(i):
        ans += 1
print(ans)


Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<int, int>;

void solver(int N, vector<int> &a, int &ans){

    map<int, int> dict;

    for(auto iter = a.begin(); iter != a.end(); ++iter){
        auto buf = iter;
        ++dict[*buf+1];
        ++dict[*buf];
        ++dict[*buf-1];
    }

    for(auto p: dict){
        auto num = p.second;
        ans = max(num, ans);
    }

    return;
}

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    for(auto iter = a.begin(); iter != a.end(); ++iter) cin >> *iter;

    int ans{};
    solver(N, a, ans);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7988
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*WA=freopen("water.in","r",stdin);
	FILE*TER=freopen("water.out","w",stdout);
#endif
}

const int MAXN=2e5+7;

static ll n,p;

inline void init()
{
	read(n),read(p);
}

static ll ans=1;

inline void solve()
{
	int lim=sqrt(p)+1;
	Rep(i,2,lim)if(p%i==0)
	{
		int cnt=0;
		while(p%i==0)
		{
			++cnt,p/=i;
			if(cnt>=n)ans*=i,cnt-=n;
		}
	}
	if(p>1&&n==1)ans*=p;
	cout<<ans<<endl;
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int A, B, C;

  cin >> A >> B >> C;

  if ((A < C && C < B) || (B < C && C < A)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (((A == B)&&(B == C)) || ((A != B) && (B != C) && (A != C))) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22740
n=int(input())
arr=list(map(int,input().split(' ')))

arr.sort()
c=0
for i in range(len(arr)-2):
    for j in range(i+1,len(arr)-1):
        if(arr[i]!=arr[j]):
            for k in range(j+1,len(arr)):
                if(arr[i]!=arr[k] and arr[j]!=arr[k] and arr[i]+arr[j]>arr[k]):
                    c=c+1
                    # print(str(i)+str(j)+str(k))
print(c)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	vi v(n);
	for(int i = 0; i < n; i++)cin>>v[i];
	sort(all(v));
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			for(int k = j+1; k < n; k++){
				if(v[i]<v[j]+v[k]&&v[k]<v[i]+v[j]&&v[j]<v[i]+v[k])cnt++;
			}
		}
	}	
	cout<<cnt;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n; cin >> n;
    map<int,int,greater<int>> map;
    vint a(n);
    rep(i,n){
        cin >> a[i];
        map[a[i]]++;
    }
    vint squ,rec;
    for(auto m:map){
        if(m.S>=2) rec.pb(m.F);
        if(m.S>=4) squ.pb(m.F);
    }
    sort(all(squ),greater<int>());
    sort(all(rec),greater<int>());
    int res=0;
    if(squ.size()>0) res=squ[0]*squ[0];
    if(rec.size()>1) chmax(res,rec[0]*rec[1]);
    cout<<res<<endl;


}

Measured memory_bytes: 10272
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

constexpr double E = 1e-8;

int main() {
    int n;
    std::vector<std::pair<int, int>> v;
    std::pair<int, int> upperLeft(0, 0), bottomRight(0, 0);
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y; std::cin >> x >> y;
        v.push_back(std::make_pair(x, y));


        upperLeft.first = std::min(upperLeft.first, x);
        upperLeft.second = std::max(upperLeft.second, y);
        bottomRight.first = std::max(bottomRight.first, x);
        bottomRight.second = std::min(bottomRight.second, y);
    }

    if (n % 2) {
        std::cout << "NA" << std::endl;
        return 0;
    }

    // 重心計算
    std::pair<double, double> center((upperLeft.first + bottomRight.first) / 2.0, (upperLeft.second + bottomRight.second) / 2.0);

    // 平行移動
    for (auto& x : v) {
        x.first -= center.first;
        x.second -= center.second;
    }

    // 点対称か調べる
    bool isOk = true;
    for (int i = 0; i < v.size(); i++) {
        const auto& base = v[i];
        bool isThereCompatiblePoint = false;
        for (int j = 0; j < v.size(); j++) {
            if (i != j && std::abs(v[j].first + base.first) < E && std::abs(v[j].second + base.second) < E) {
                isThereCompatiblePoint = true;
                break;
            }
        }
        isOk &= isThereCompatiblePoint;
    }

    if (!isOk) {
        std::cout << "NA" << std::endl;
    }
    else {
        std::cout << std::fixed << std::setprecision(8) << center.first << " " << center.second << std::endl;
    }

    return 0;
}


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

int main()
{
		string a, b;
		cin >> a >> b;
		int n = a.length(), m = b.length();
		
		vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
		
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				if(a[i - 1] == b[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
				else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		
		int x = n, y = m;
		string ans = "";
		while(x > 0 and y > 0)
		{
			if(a[x - 1] == b[y - 1])
			{
				ans.push_back(a[x - 1]);
				x--;
				y--;
			}
			else
			{
				if(dp[x - 1][y] > dp[x][y - 1]) x--;
				else y--;
			}
		}
		
		reverse(ans.begin(), ans.end());
		
		cout << ans << endl;
		
		return 0;
}


Measured memory_bytes: 38572