akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int A = in.nextInt();
			int B = in.nextInt();
			out.println(Math.min(A * N, B));
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, S; cin >> N >> S;
  ll A[N]; rep(i,N) cin >> A[i];
  ll dp[N+1][S+1] = {}; dp[0][0] = 1;
  rep(i,N) rep(j,S+1) {
    if (A[i]>S) dp[i+1][j] = dp[i][j];
    else if (A[i]==S) {
      if (j==S) dp[i+1][j] = ( dp[i][j] + dp[i][0]*(i+1)*(N-i) ) % MOD;
      else dp[i+1][j] = dp[i][j];
    }
    else {
      if (j==A[i]) dp[i+1][j] = ( dp[i][j] + dp[i][0] * (i+1) ) % MOD;
      else if (j==S) dp[i+1][j] = ( dp[i][j] + dp[i][j-A[i]] * (N-i) ) %MOD;
      else if (j<A[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = ( dp[i][j] + dp[i][j-A[i]] ) % MOD;
    }
  }
  // rep(i,N+1) debug(dp[i], dp[i]+(S+1));
  ll result = dp[N][S];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 70656
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

struct Trie{
	int n;
	bool b;

	Trie *next[26];
	
	Trie(){
		fill(next , next + 26 , (Trie*)0);
		n = 0;
		b = 0;
	}
	
	~Trie(){
		for(int i = 0 ; i < 26 ; ++i){
			if(next[i] != (Trie*)0) delete next[i];
		}
	}
	
	void insert(char *s){
		++n;
		if((*s) == 0){
			b = 1;
			return;
		}
		if(this -> next[(*s) - 'a'] == (Trie*)0){
			this -> next[(*s) - 'a'] = new Trie;
		}
		this -> next[(*s) - 'a'] -> insert(s + 1);
	}
	
	int find(char *s){
		if((*s) == 0) return n;
		if(this -> next[(*s) - 'a'] == (Trie*)0) return 0;
		return this -> next[(*s) - 'a'] -> find(s + 1);
	}
	
	int pre(char *s){
		if((*s) == 0) return 0;
		return (b ? 1 : 0) + this -> next[(*s) - 'a'] -> pre(s + 1);
	}
};

int N , Q;
string S[100010];
char a[400010];
char c[30];
int r[100010][26][26];
Trie *T = new Trie;

void search(char *s , Trie *p , int &z){
	if((*s) == 0) return;
	int x = (*s) - 'a';
	repp(i,0,26){
		if(x == i) continue;
		if(p -> next[i] == (Trie*)0) continue;
		r[z][i][x] += (p -> next[i] -> n);
	}
	search(s + 1 , p -> next[x] , z);
}

int ans(int x){
	int z = r[x][0][0];
	repp(i,0,26){
		repp(j,i+1,26){
			z += r[x][c[i] - 'a'][c[j] - 'a'];
		}
	}
	return z + 1;
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N+1){
		scanf(" %s" , a);
		S[i] = a;
		T -> insert(a);
	}
	repp(k,1,N+1){
		search((char*)S[k].c_str() , T , k);
		r[k][0][0] = T -> pre((char *)S[k].c_str());
	}
	scanf("%d" , &Q);
	repp(i,0,Q){
		int x;
		scanf("%d %s" , &x , c);
		printf("%d\n" , ans(x));
	}
	delete T;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,suma=0,sumb=0;
	cin >> n;
	vll a(n),b(n);
	rep(i,n){
		cin >> a[i];
		suma+=a[i];
	}
	rep(i,n){
		cin >> b[i];
		sumb+=b[i];
	}
	if(suma<sumb){
		cout << -1 << endl;
		return 0;
	}
	bool bb=true;
	ll sum=0,cnt=0;
	vll tmp;
	rep(i,n){
		if(a[i]<b[i]){
			sum+=b[i]-a[i];
			cnt++;
			bb=false;
		}
		else tmp.pb(a[i]-b[i]);
	}
	if(bb){
		cout << 0 << endl;
		return 0;
	}
	sort(rall(tmp));
	ll cnt1=0,cnt2=0;
	while(cnt1<sum){
		cnt1+=tmp[cnt2];
		cnt2++;
	}
	cout << cnt+cnt2 << endl;
	return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}


int main(){

   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   /// 1 2 3 4  ....
   ll n,w;
   cin>>n>>w;
   vector<pair<ll,ll> >vp;
   rep(i , 0 , n){
       ll w1,v1;
       cin>>w1>>v1;
        vp.push_back({w1 , v1 });
   }
   ll dp[n+1][w+1];
   memset(dp , 0 , sizeof(dp));



   for(int i = 1; i <=n;i++){
        for(int j = 1;j<=w;j++){

                if(j-vp[i-1].first>=0)
                    dp[i][j] = max(dp[i-1][j] , dp[i-1][j-vp[i-1].first ]+vp[i-1].second);
                else
                    dp[i][j] = dp[i-1][j];

        }
   }
   cout<<dp[n][w];









}


Measured memory_bytes: 79232
#ifdef ABACABA

#include "stdc++.h"

#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define int long long

typedef long double ld;

#define all(a) a.begin(), a.end()

#define pii pair<int, int>

#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mkt make_tuple
#define ff first
#define ss second

#define in(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 1000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());


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

    int n;
    cin >> n;

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

    set<int> id;

    id.insert(-1);
    id.insert(n);

    int sum = 0;

    for (int j = 1; j <= n; ++j) {
        int x = b[j];

        int l = *prev(id.ub(x), 1);
        int r = *(id.ub(x));

        ++l;
        --r;

        sum += (x - l + 1) * (r - x + 1) * j;

        id.insert(x);
    }

    cout << sum;
    // 0 1[2 3]4 5 6 7 8
    // 7 - 8 3 - 9 4 6 5
}

Measured memory_bytes: 12800
#!/usr/bin/env python

a, b, c = map(int, input().split())

if a%2 == 0 and a == b == c:
    print(-1)
    exit()

ans = 0 
while True:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        print(ans)
        exit()
    ta = a 
    tb = b 
    tc = c 
    a = (tb+tc)//2
    b = (tc+ta)//2
    c = (ta+tb)//2
    ans += 1


Measured memory_bytes: 9176
N, A, B = list( map(int, input().split()) )
s = input()

count = 0
abroad = 0
for i in range(len(s)):
    if s[i] == 'a' and (A+B) > count:
        count += 1
        print('Yes')
    elif s[i] == 'b':
        abroad += 1
        if (A+B)  > count and B >= abroad:
            count += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4040
#include "bits/stdc++.h"
#include <random>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;
template<class T>
T gcd(T a,T b){
  if(a==0){
    return b;

  }else if(b==0){
    return a;
  }
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  int mode=1;
  if(mode==0){
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      tmp*=a;
      return (tmp)%d9_7;
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      return (tmp)%d9_7;
    }
  }else{
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp*=tmp;
      tmp*=a;
      return (tmp);
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp*=tmp;
      return (tmp);
    }
  }
  return 0;
  
}
template<class T>
void Printvector(std::vector<T> &a){
  int size = a.size();
  rep(i,size){
    cout<<a[i]<<" ";
  }
  cout<<endl;
}
template<class T>
void Printvector(std::vector<std::vector<T>> &a){
  int size = a.size();
  rep(i,size){
    int size2=a[i].size();
    rep(j,size2){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}
int main(void){
  double x,y,b,c,m;
  string s,t;
  int n;
  cin>>n>>m;
  vector<double> a(n);
  rep(i,n)cin>>a[i];
  int sum=0;
  rep(i,n)sum+=a[i];
  double ans=0;
  rep(i,n){
    if(a[i]>=sum/(4*m)){
      ans+=1;
    }
  }
  if(ans>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

//<<std::setprecision(30)

//重複削除
 /* std::sort(vec.begin(), vec.end());
 
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/

  //ペアの全探索
  /*do{
		int s=0;
		for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2];
		r=max(s,r);
		reverse(v.begin()+n/2,v.end());
	}while(next_permutation(v.begin(),v.end()));*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef unsigned long long ull;
bool gr(double a,double b){
	return a>b;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double tot=0;
	int m,n;
	cin>>n>>m;
	vector<double> ar(n);
	for(int a=0;a<n;a++){
		cin>>ar[a];
		tot += ar[a];
	}
	sort(ar.begin(),ar.end(),gr);
	double lea = tot/(4*m);
	if(lea<= ar[m-1]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int n,vis[101][101];

struct point{int x,y;};
struct point grid[101][101];

int dfs(int x,int y,int fg){
  
  vis[y][x]=fg;
  struct point nx=grid[y][x];
  int res=vis[nx.y][nx.x];
  
  if(vis[nx.y][nx.x]==0)res=dfs(nx.x,nx.y,fg);
  
  return vis[y][x]=res;
}

int main(void){
  
  struct point p;
  int i,j,cnt;  

  while(scanf("%d",&n),n){
    memset(vis,0,sizeof(vis));
    
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d %d",&p.x,&p.y);
	grid[i][j]=p;
      }
    }
    
    for(i=0,cnt=1;i<n;i++)
      for(j=0;j<n;j++)
	if(!vis[i][j] && dfs(j,i,cnt)==cnt)cnt++;  

    printf("%d\n",cnt-1);
  }
  
  return 0;
}

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


int main()
{
	int a, b, i;
	while (cin >> a >> b) {
		i = 0;
		int j = a + b;
			while (j > 0) {
			i++;
			j = j / 10;
		}
			cout << i << endl;
	}
    return 0;
}


Measured memory_bytes: 3100
import itertools
n, k = map(int, input().split())
d = set(list(map(int, input().split())))
inzero = False
if 0 in d:
    inzero = True
    d -= set([0])
can_use = set([0,1,2,3,4,5,6,7,8,9]) - d
can_use = list(can_use)
#全探索
ans = 10**6
def check(i):
    global ans
    x = int("".join(list(map(str, i))))
    if inzero:
       pp = list(str(x))
       if '0' in pp:
           return
    if x >= n:
        ans = min(ans, x)
def dfs(Sequence):
    if len(Sequence) == len(str(n)) + 1:
        check(Sequence)
    else:
        for i in can_use:
            dfs(Sequence + [i])
dfs([])
print(ans)



Measured memory_bytes: 50268
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, ans = 0;

int main() {
	cin >> n;
	vector<pair<ll, int>>res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	rep(i, sz(res)) {
		ll cnt = 0;
		for (int j = 1;; j++) {
			cnt += j;
			if (cnt > res[i].second) {
				ans += j - 1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	p := intScanner()
	ps := PrimeFactors(p)
	ds := make(map[int]int)
	for i := 0; i < len(ps); i++ {
		ds[ps[i]]++
	}
	ans := 1
	for k, v := range ds {
		for v >= n {
			ans *= k
			v -= n
		}
	}
	fmt.Println(ans)
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
constexpr ll llMIN=-9223372036854775808LL;
ll n,k,x,y;
 
int main(){
  
  ll ans=llMIN;
  cin >> n >> k;
  
  vi p(n),c(n);
  REP(i,n){
    cin>>p[i];
    p[i]--;
    }
  REP(i,n) cin>>c[i];
 
  vvi data(n, vi(n));  // N * M の2次元配列
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      data[i][j]=llMIN;
    }
  }
 
  ll nowmasu=-1;
  ll score=0;
  for(ll i=0;i<n;i++){//最初に選ぶマス
    nowmasu=i;
    score=0;
    //data[i][i]=0;//score
    ll cnt=0;
    for(ll j=0;j<min(k,n);j++){
      if (data[i][p[nowmasu]]!=llMIN)break;
      nowmasu=p[nowmasu];
      score+=c[nowmasu];
      cnt++;
      data[i][nowmasu]=score;
      ans=max(ans,score);
    }
    //今のnowmasuは必ず最初の地点
    if (k!=cnt){
      ll nnum=(k-cnt)/cnt;
      score*=nnum;
      if (nnum!=0)ans=max(ans,score);
      ll kk=k-nnum*cnt;
      
      for(ll j=0;j<kk;j++){
        nowmasu=p[nowmasu];
        score+=c[nowmasu];
        ans=max(ans,score);
      }
    }
 
    
 
  }
 
 
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	vector<int> edg[n];
	for(int i=0; i<n-1; i++)
	{
	    int a,b;
	    cin>>a>>b;
	    a--, b--;
	    edg[a].push_back(b);
	    edg[b].push_back(a);
	}
	
	vector<int> distf(n, -1), dists(n, -1);
	
	queue<int> quef;
	distf[0] = 0;
	quef.push(0);
	while(!quef.empty())
	{
	    int v = quef.front();
	    quef.pop();
	    for(int nv : edg[v])
	    {
	        if(distf[nv] != -1) continue;
	        distf[nv] = distf[v] + 1;
	        quef.push(nv);
	    }
	}
	
	queue<int> ques;
	dists[n-1] = 0;
	ques.push(n-1);
	while(!ques.empty())
	{
	    int v = ques.front();
	    ques.pop();
	    for(int nv: edg[v])
	    {
	        if(dists[nv]!=-1) continue;
	        dists[nv] = dists[v] + 1;
	        ques.push(nv);
	    }
	}
	int cntf = 0, cnts = 0;
	for(int i=0; i<n; i++)
	{
	    if(distf[i] <= dists[i])
	        cntf++;
	    else
	        cnts++;
	}
	
	if(cntf > cnts) cout<<"Fennec";
	else cout<<"Snuke";
	
	return 0;
}


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

int main(){
  long long n,a,b,i,ans,co;
  cin >> n >> a >> b;
  ans=0;
  co=0;
  if(abs(a-b)%2==0){
    ans=abs(a-b)/2;
  }else{
    co=min(a-1,n-b);
    ans=co;
    ans++;
    if(abs(a-1)<abs(n-b)){
      ans=ans+(b-co-1-1)/2;
    }else{
      ans=ans+(n-(a+co+1))/2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// var line = input.split("\n");
	var strN = input.split("\n")[0];
	var divider = 0;
	for(var i = 0; i < strN.length; i++){
		divider += Number(strN[i]);
	}
	var ans = Number(strN)%divider === 0 ? "Yes" : "No";
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#ifdef INPUT
#include <sstream>
stringstream input(R"(
2
80 70
)");
#define cin input
#endif

#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

    ll c = 0;
    ll s = 0;
    map<ll, int> r;
    REP(i, n)
    {
        int a;
        cin >> a;
        ++r[s];
        s += a;
        if (r.count(s))
            c += r[s];
    }

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

LL n,m,mod=1000000007,x[100100],y[100100],L,area,h,w;

int main() {
	scanf("%lld %lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
	sort(x+1, x+n+1);
	for(int i=1;i<=m;i++) scanf("%lld",&y[i]);
	sort(y+1, y+m+1);
	for(int i=2;i<=n;i++){
		LL temp = ((n-1-(i-1)+1)*(i-1))%mod;
		temp = (temp * (x[i]-x[i-1]))%mod;
		w = (w+temp)%mod;
	}
	
	for(int i=2;i<=m;i++){
		LL temp = ((m-1-(i-1)+1)*(i-1))%mod;
		temp = (temp * (y[i]-y[i-1]))%mod;
		h = temp;
		L = (h*w)%mod;
		area = (area+L)%mod;
	}
	cout<<area<<endl;
	return 0;
}

Measured memory_bytes: 1792
/*
 *
 * Author: r3gz3n
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define fil(a,b) memset((a),(b),sizeof(a))
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;
using namespace __gnu_pbds;

template <class T = int> using order_statistics = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T = int> inline T gcd(T a, T b)
{
    while (b) b ^= a ^= b ^= a %= b;
    return a;
}
template <class T = int> inline T mod(T x)
{
    if (x < 0) return -x;
    else return x;
}
typedef pair<int, int> PII;
typedef vector<int> VII;
typedef vector<PII> VPII;
const int MAX = 1e3 + 5;
const int MOD = 1e9 + 7;
string s[MAX];
ll dp[MAX][MAX];
int main(int argc, char* argv[])
{
    if (argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if (argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) cin >> s[i];
    dp[0][0] = 1;
    for (int i = 1; i < n; ++i)
    {
        if (s[i][0] == '.') dp[i][0] = dp[i - 1][0];
        else dp[i][0] = 0;
    }
    for (int i = 1; i < m; ++i)
    {
        if (s[0][i] == '.') dp[0][i] = dp[0][i - 1];
        else dp[0][i] = 0;
    }
    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j < m; ++j)
        {
            if (s[i][j] == '.') dp[i][j] = ( dp[i - 1][j] + dp[i][j - 1] ) % MOD;
            else dp[i][j] = 0;
        }
    }
    cout << dp[n - 1][m - 1] << endl;
    return 0;
}


Measured memory_bytes: 9216
function main(input){
  const y=input.split("/")[0];
  const m=input.split("/")[1];
  const d=input.split("/")[2];
  var aaa =y+m+d;
  aaa=parseInt(aaa,10);
  if(aaa<20190500){
    console.log("Heisei");
  }else{
    console.log("TBD");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

const long long MOD = 1000000007;

const int MAX = 1000001;

vector<long long> fac(MAX), finv(MAX), inv(MAX);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k || n < 0 || k < 0) {
        return 0;
    }
    
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int X, Y;
    cin >> X >> Y;

    int j;
    long long answer = 0;

    COMinit();

    for(int i = 0; i < 500001; i++) {
        j = X - 2*i;
        if(3*i == 2*X - Y && 3*j == 2*Y - X) {
            answer = COM(i+j, i);
            break;
        }
    }
    
    cout << answer << endl;
	return 0;
}

Measured memory_bytes: 26612
#include "bits/stdc++.h"
using namespace std;

int main() {
    string S;
    cin >> S;

    vector<char> S1(S.size());
    vector<char> S2(S.size());
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            S1[i] = '0';
            S2[i] = '1'; 
        }
        else {
            S1[i] = '1';
            S2[i] = '0'; 
        }
    }

    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S1[i] != S[i]) cnt1++;
        if (S2[i] != S[i]) cnt2++;
    }

    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 512
s=input()
n=len(s)
a=[0]*(n+1)
for i in range(n):
    if s[i]=="<":
        a[i+1]=a[i]+1
for i in range(n)[::-1]:
    if s[i]==">":
        a[i]=max(a[i+1]+1,a[i])
print(sum(a))

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

using namespace std;

int main() {
    int n, d;
    scanf("%d%d", &n, &d);

    int res = 0;

    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);

        if (1LL * x * x + 1LL * y * y <= 1LL * d * d) res++;
    }

    printf("%d\n", res);
}


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

using namespace std;

using p = pair<long long, long long>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<p> vec;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        vec.push_back({a, 1});
    }
    for(int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        vec.push_back({c, b});
    }
    sort(vec.begin(), vec.end(), greater<p>());

    long long cnt = 0, ans = 0;
    for(auto p : vec) {
        if(cnt + p.second <= n) {
            ans += p.first * p.second;
            cnt += p.second;
        } else {
            ans += p.first * (n - cnt);
            cnt = n;
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 56000;

vl Prime(60000, 1);  // Prime[i] : iが素数のとき1、iが素数でないとき0

void Eratosthenes(ll n) {  // n未満の素数を求める
    
    Prime[0] = Prime[1] = 0;
    for(ll i = 2; i*i < n; i++) {
        if(Prime[i]) {
            for(ll j = 2; i*j < n; j++) {
                Prime[i*j] = 0;
            }
        }
    }
    
}

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

    Eratosthenes(MAX_N);

    ll cnt = 0;
    exrep(i, 11, MAX_N) {
        if(Prime[i] && i%5 == 1) {
            cout << i << " ";
            cnt++;
        }
        if(cnt == n) {
            re0;
        }
    }
    
    re0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n; cin >> n;
    string S; cin >> S;
    vec<int> r(n), l(n);
    loop (n - 1, i) {
        r[i + 1] = r[i] + (S[i] != 'E');
        l[n - 1 - (i + 1)] = l[n - 1 - i] + (S[n - 1 - i] != 'W');
    }
    int ans = 1<<29;
    loop (n, i) {
        ans = min(ans, r[i] + l[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < m; i++) {
        cin >> a.at(i);
    }

    int sum = accumulate(a.begin(), a.end(), 0);
    if (sum <= n) {
        cout << n - sum << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 7216
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;

int n,k;
double maxv=0.00,a[200005],pre[200005]={0};

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=(a[i]+1.00)/2;
		pre[i]=pre[i-1]*1.00+a[i];
	}
	for (int i=1;i<=n-k+1;i++)  maxv=max(maxv,pre[i+k-1]-pre[i-1]);
	cout<<fixed<<setprecision(8)<<maxv<<endl;
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend() 
#define pb(x) push_back(x)

using namespace std;
using ll=long long;

long mod=1e9+7;

int main() {
  int n;cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));

  ll ans=0;
  rep(i,n){
    ll bx=b[i];
    auto iter1 = lower_bound(ALL(a),bx);
    auto iter2 = upper_bound(ALL(c),bx);
    ll p=iter1-a.begin();
    ll q=c.end()-iter2;
    ans+=p*q;
  }
  cout<<ans;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 100005
int head,tail,n;
typedef struct PP
{
    char name[100];
    int time;
}P;

P Q[LEN];
void enqueue(P p)
{

    Q[tail] = p;
    tail = (tail+1) % LEN;
    return;
}
P dequeue()
{
    P p;
    p = Q[head];
    head = (head+1) % LEN;
    return p;
}
int min(int a, int b) { return a>b ? b:a;}
int main()
{
    int n,q;
    P u;
    int elapse = 0;
    int c = 0;
    scanf("%d %d",&n,&q);
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d",Q[i].name, &Q[i].time); 
    } 
    head = 0, tail = n;
    while (head!=tail)
    { 
        u = dequeue();
        c = min(q, u.time);
        u.time -= c;
        elapse += c;
        if(u.time > 0) enqueue(u);
        else
        { 
            printf("%s %d\n",u.name,elapse); 
        } 
    } 
    return 0;
}

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

int main(void){
  int a[5], k;
  for(int i = 0; i < 5; i++)
    cin >> a[i];
  cin >> k;
  
  string str = "Yay!";
  for(int i = 0; i < 4; i++){
    if((a[i + 1] - a[0]) > k)
      str = ":(";
    else
      str = "Yay!";
    
  }
  cout << str << endl;
}

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

int main() {
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int n; cin >> n;
    if( n >= 30 )
        pri("Yes");
    else
        pri("No");
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

string shuffle(string s,  int h) {
    string ret = "";
    for (int i = h; i < s.size(); i++){
        ret += s[i];
    }
    for(int i = 0; i < h; i++){
        ret += s[i];
    }
    return ret;
}

int main() {
    while(1){
        string s;
        int m;
        cin >> s;
        if (s == "-") break;
        cin >> m; 
        for (int i = 0; i < m; i++){
            int h;
            cin >> h;
            s = shuffle(s,h);
        }
        cout << s << endl; 
    }
}


Measured memory_bytes: 3180
X,n= list(map(int, input().split())) 

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

res=(Base_10_to_n(X,n))
print(len(res))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  char b; cin >> b;
  char ans;
  if (b == 'A') {
    ans = 'T';
  } else if (b == 'T') {
    ans = 'A';
  } else if (b == 'C') {
    ans = 'G';
  } else if (b == 'G') {
    ans = 'C';
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
	    string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int K = int.Parse(input[1]);
		
		string[] array = new string[N];
		
		int sum =0;
		
		//すぬけくん配列
		for(int m =0; m<N; m++ )
		{
		    array[m] = (m+1).ToString();
		}
		
		for(int i = 0; i< K; i++)
		{
    		int num = int.Parse(Console.ReadLine());
    		string [] retsu = Console.ReadLine().Split(' ');
    		
    		
    		
    		for(int j =0; j<num; j++)
    		{
    		    for(int k = 0; k<N; k++)
    		    {
    		       // Console.WriteLine(retsu[k]);
    		        if(retsu[j] == array[k])
    		        {
    		            array[k] = "0";
    		        }
    		    }
    		}
		}
		
		for(int l=0; l<N; l++)
		{
		if(array[l] != "0")
		{
		    sum++;
		}
		}
		//出力

        Console.WriteLine(sum);
    
        
		
	}
}

Measured memory_bytes: 18292
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 161 -B
int main(void) {
	int i,n,m,a[101],t=0;

	scanf("%d %d", &n,&m);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		t += a[i];
	}
	t = t / (4 * m) + (t % (4 * m) ? 1 : 0);
	int c = 0;
	for(i=0;i<n;i++)
		if (a[i] >= t) c++;
	
	if(c>=m) printf("Yes\n");
	else     printf("No\n");
	return 0;
}

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

typedef long long ll;

const int MN = 200010;

int N;
vector<int> adj[MN];
char S[MN];
int dist[MN], par[MN], x;
ll ans;

void dfs0(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dist[v] = dist[u] + 1;
        par[v] = u;
        dfs0(v, u);
    }
}

int dp[MN];

int dfs1(int u, int p) {
    int ret = 0;
    int mn = 1e9;
    dp[u] = S[u] == '1'? 1 : 0;
    if(dp[u]) mn = 0;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        int t = dfs1(v, u);
        ret = max(ret, t + 1);
        if(dp[v]) mn = min(mn, t + 1);
        dp[u] |= dp[v];
    }
    if(dp[u]) {
        //cout << u << ' ' << ret << ' ' << dist[x] << ' ' << ret << ' ' << mn << endl;

        if(ret >= dist[x] / 2) ans += ret + 1 - mn;
        else ans += ret + 2 - mn;
    }
    return ret;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    scanf("\n");
    for(int i = 0; i < N; i++) {
        scanf("%c", &S[i]);
    }

    dfs0(0, -1);
    int p = 0;
    for(int i = 0; i < N; i++) if(dist[p] < dist[i]) p = i;
    dist[p] = 0;
    dfs0(p, -1);
    for(int i = 0; i < N; i++) if(dist[x] < dist[i]) x = i;

    int root = x;
    while(dist[root] > dist[x] / 2) {
        root = par[root];
    }
    dfs1(root, -1);
    printf("%lld", ans);
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c; cin>>a>>b>>c;
    int m=min(a,min(b,c)),M=max(a,max(b,c));
    cout<<m<<" "<<(a+b+c-m-M)<<" "<<M<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(){
  int  flag[31] = {0}, i, input;

  for(i = 1; i < 29;i++){
    scanf("%d", &input);
    flag[input] = 1;
  }

  for(i = 1; i < 31;i++){
    if(flag[i] != 1){
      printf("%d\n", i);
    }
  }
 return 0;
}

Measured memory_bytes: 596
N, M = map(int,input().split())
x,y = [],[]
for _ in range(M):
	tx,ty = map(int, input().split())
	x.append(tx)
	y.append(ty)

flg = [0] * (N+1)
flg[1] = 1
cnt = [1] * (N+1)
#フラグが１が経っているところからは、移動することで赤を移せる。
for i in range(M):
	cp,np = x[i],y[i]

	if flg[cp] == 1:
		if cnt[cp] == 1:
			flg[cp] = 0
		cnt[cp] -= 1
		cnt[np] += 1
		flg[np] = 1
	else:
		cnt[cp] -= 1
		cnt[np] += 1

print(sum(flg))


Measured memory_bytes: 12528
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
const double PI = acos(-1.0);
int dx[] = { 1,-1,0,0 };
int dy[] = { 0,0,1,-1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);  
#endif
}
bool check_prime(ll a)
{
	bool flag = true;
	if (a <= 1)
		return false;
	else
	{
		for (ll i = 2; i <= sqrt(a); i++)
		{
			if (a % i == 0)
			{
				flag = false;
				break;
			}
		}
	}
	if (flag)
		return true;
	else
	{
		return false;
	}
}

int main()
{
	//file();
	Fast;
	ll n;
	cin >> n;
	cout << (n * (n + 1)) / 2;
}

Measured memory_bytes: 256
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string v;
  cin >> v;
  deque<string> s;
  s.push_back(v);
  int mojicount=v.size();
//  cout << s.at(0) << endl;
  int q;
  cin >> q;
  vector<int>a(q);
  vector<int>f(q);
  vector<string>c(q);
  rep(i,q){
    cin >> a.at(i);
    if(a.at(i)==2){
      cin >> f.at(i);
      cin >> c.at(i);
      mojicount += c.at(i).size();
    }
  }
/*//入力できているかテスト
  rep(i,q) cout<<a.at(i);
  cout << endl;
  rep(i,q) cout<<f.at(i);
  cout << endl;
  rep(i,q) cout<<c.at(i);
*/
  int revcount=0;
  rep(i,q){
    if(a.at(i) ==1){
      revcount++;
//	reverse(s.begin(), s.end());//bという配列をリターン
    }
    else{
      if(f.at(i)==1){
        //先頭に追加
        if(revcount%2==0){
          s.push_front(c.at(i));
//        s.insert(0,c.at(i) );
        }
        else{
          reverse(c.at(i).begin(), c.at(i).end());
          s.push_back( c.at(i) );
          reverse(c.at(i).begin(), c.at(i).end());
//         s = s + c.at(i);
        }
      }
      else{
        //末尾に追加
        if(revcount%2==0){
          s.push_back(c.at(i));
//        s = s + c.at(i);
        }
        else{
          reverse(c.at(i).begin(), c.at(i).end());
          s.push_front(c.at(i));         
          reverse(c.at(i).begin(), c.at(i).end());
//        s.insert(0,c.at(i) );
        }       
      }
    }
//   rep(i,s.size()) cout << s.at(i); 
//   cout << endl;
  }
  string tests;
  if(revcount%2!=0){
//    reverse(s.begin(), s.end());//bという配列をリターン
//	  for(int i=s.size()-1;i>=0;i--){
  rep(i,s.size()){
      tests += s.at(i); 
	  }
//  	  cout << tests;
//	  for(int i=s.size()-1;i>=0;i--){
	  for(int i=mojicount-1;i>=0;i--){
        cout << tests.at(i);
      }
    cout << endl;
  }
  else{
  rep(i,s.size()) cout << s.at(i); 
  cout << endl;
  }
//  cout << mojicount ;
}

Measured memory_bytes: 18344