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

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<ll,ll>
#define endl              "\n"
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define repe(i,a,b)       for(ll i=a;i<=b;i++)
#define bac(i,a,b)        for(ll i=a;i>b;i--)
#define bace(i,a,b)       for(ll i=a;i>=b;i--)
#define fast              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll                long long int
#define ld                long double
#define mod1              (ll)(1e9 + (ll)7)
#define mod2              (ll)998244353
#define pi                (float)3.14159265358979323846
#define inf               LLONG_MAX
#define ninf              LLONG_MIN

#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define RSORT(v)          sort(all(v),greater<ll>())
#define REVERSE(v)        reverse(all(v))

#define pow(i,n)          (ll)pow((ll)i,n)
#define pow2(n)           ((ll)1<<n)
#define sz(x)             (ll)x.size()

typedef std::priority_queue<ll, std::vector<ll>, std::greater<ll> > min_pq;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

inline string inttos(ll a){std::stringstream soso; soso<<a; return soso.str();}
inline ll stoint(const std::string &s) {std::stringstream soso; soso << s; long long x; soso >> x; return x;}
inline std::string inttobin(ll x) {return std::bitset<7>(x).to_string();}
inline void swp(ll &a, ll &b){auto temp=a;a=b;b=temp;}

//pri - 1000000009
//ba  - 937,991,1013,1409,1741,4391

void solve(){
    ll k,a,b;
    cin>>k>>a>>b;
    repe(i,a,b){
        if(i%k==0){
            cout<<"OK"<<endl;
            return;
        }
    }
    cout<<"NG"<<endl;

}


signed main(){
    fast
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    #endif
    ll t=1;
    //cin>>t;
    rep(i,0,t){
       solve();
    }

}


Measured memory_bytes: 3652
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    string s;
    cin>>s;
    if(s=="RRR"){
        cout<<3<<endl;
    }else if(s=="RRS" || s=="SRR"){
        cout<<2<<endl;
    }else if(s=="RSS" || s=="RSR" || s=="SRS" || s=="SSR"){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_N = 110;
const ll MAX_K = 1e5 + 10;
ll dp[MAX_K];


void init() {
	for (ll i = 0; i < MAX_K; i++) {
		dp[i] = -1;
	}
}

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

int main() {
	ll i, j;
	ll N, K;
	cin >> N >> K;
	vll A(N);
	for (auto& e : A)cin >> e;
	init();

	dp[0] = 0;
	for (i = 1; i <= K; i++) {
		ll win = 0;
		for (auto a : A) {
			if (a > i)continue;
			if (dp[i - a] == 0) {
				win = 1;
				break;
			}
		}
		dp[i] = win;
	}
	string ans = (dp[K] == 1) ? "First" : "Second";
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int h, w, kk, res = 0;
	cin >> h >> w >> kk;
	vector<vector<int> > v(h, vector<int> (w, 0));
	for (int i = 0; i < h; i++){
		string s;
		cin >> s;
		for (int j = 0; j < w; j++)
			if (s[j] == '#') v[i][j] = 1;
	}
	for (int i = 0; i < 1<<h; i++)
		for (int j = 0; j < 1<<w; j++){
			int ans = 0;
			for (int k = 0; k < h; k++)
				for (int m = 0; m < w; m++)
					if (((i>>k)&1) == 0 && ((j>>m)&1) == 0 && v[k][m] == 1)
						ans += 1;
			if (ans == kk) res += 1; 
		}
	cout << res << '\n';
}


Measured memory_bytes: 3608
n,m,k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)

i = 0
sum = 0
while sum <= k && i < n
  sum += a[i]
  i += 1
end
if sum > k
  i -= 1
  sum -= a[i]
end
j = 0
while sum <= k && j < m
  sum += b[j]
  j += 1
end
if sum > k
  j -= 1
  sum -= b[j]
end
max = i+j

while i > 0
  i -= 1
  sum -= a[i]
  while sum <= k && j < m
    sum += b[j]
    j += 1
  end
  if sum > k
    j -= 1
    sum -= b[j]
  end
  max = [max,i+j].max
end
puts max

Measured memory_bytes: 46020
import java.awt.geom.Point2D;
import java.util.*;


public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0107();
	}
	class AOJ0107{
		int tate,yoko,height;
		boolean hantei(int r){
			int x = tate,y = yoko;
			if(new Point2D.Double(x,y).distance(0,0)<2*r)return true;
			x=tate;y=height;
			if(new Point2D.Double(x,y).distance(0,0)<2*r)return true;
			x=yoko;y=height;
			if(new Point2D.Double(x,y).distance(0,0)<2*r)return true;
			return false;
		}
		public AOJ0107() {
			while(true){
				tate = in.nextInt();
				yoko = in.nextInt();
				height = in.nextInt();
				if(tate+yoko+height==0)break;
				int n = in.nextInt();
				for(int s=0;s<n;s++){
					int r = in.nextInt();
					if(hantei(r))System.out.println("OK");
					else System.out.println("NA");
				}
			}
			
		}
	}
}

Measured memory_bytes: 17212
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if ((a + b + c) == 17) {
    if ((a + b) ==12 || (b + c) == 12) {
      printf("YES");
    } else {
      printf("NO");
    }
  } else {
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[] B = new int[M];
		int[] A = new int[N];

		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}

		int check = C;
		int result = 0;
		for (int j = 0; j < N; j++) {
			check = C;
			for (int i = 0; i < M; i++) {
				check += sc.nextInt() * B[i];
			}
			if (check > 0) {
				result++;
			}
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 22868
import itertools
n=int(input())
p=tuple(map(int, input().split()))
q=tuple(map(int, input().split()))

for i, v in enumerate(itertools.permutations(range(1,n+1))):
    if p==v:
        s=i
    if q==v:
        t=i
print(abs(s-t))

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

int main(int argc, char const *argv[])
{
	char a,b;
	scanf("%c",&a);
	getchar();
	scanf("%c",&b);
	if(a>b){
		printf(">\n");
	}else if(a==b){
		printf("=\n");
	}else{
		printf("<\n");
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();

        if(X < A){
            System.out.println(0);
        } else {
            System.out.println(10);
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int Mod=1e9+7;
const int N=405;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int n,m,A[N],B[N],f[N][N],g[N][N];
int mod(int x){return x>=Mod?x-Mod:x;}
int Pow(int x,int y){int ans=1;while(y){if(y&1)ans=1ll*ans*x%Mod;x=1ll*x*x%Mod;y>>=1;}return ans;}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();m=read();
	for(int i=1;i<=n;i++)A[i]=read();
	for(int i=1;i<=n;i++)B[i]=read();
	for(int j=0;j<=400;j++)for(int i=1;i<=400;i++)g[i][j]=mod(g[i-1][j]+Pow(i,j));
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=m;j++){
			for(int k=0;k<=j;k++){
				f[i][j]=mod(f[i][j]+1ll*f[i-1][j-k]*mod(g[B[i]][k]-g[A[i]-1][k]+Mod)%Mod);
			}
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 5004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >> n;
    vector<P> res;
    rep(i,n){
        int x,l;cin >> x >> l;
        res.emplace_back(x-l,x+l);

    }
    int ans = n;
    sort(res.begin(),res.end());
    vector<int> hidari;
    for(int i = n-1;i >= 0 ;i--){
        if(hidari.size()&&res[i].second > hidari.back()){
            ans--;
            continue;
        }
        hidari.emplace_back(res[i].first);



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

Measured memory_bytes: 3568
#include <stdio.h>
int main(void)
{
  int n,m,i,sum=0;
  scanf("%d",&n);
  scanf("%d",&m);
  int a[n],b=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  for(i=0;i<n;i++)
    if(a[i]*4*m>=sum)
      b++;
  if(b>=m)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

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

using namespace std;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif

int main() {
    int n;
    cin >> n;
    vector<int> first, second;
    for (int i = 0; i < n + 1; ++i) {
        int q;
        cin >> q;
        first.push_back(q);
    }
    for (int i = 0; i < n; ++i) {
        int q;
        cin >> q;
        second.push_back(q);
    }
    long long  summ = 0;
    for (int j = 0; j < first.size() - 1; ++j) {
        if (!j) {
            if (first[j] <= second[j]) {
                summ += first[j];
                second[j] -= first[j];
                first[j] = 0;
            } else {
                summ += second[j];
                first[j] -= second[j];
                second[j] = 0;
            }
        } else {
            if (first[j] <= second[j - 1]) {
                //  cout<<first[j]<<"a "<<second[j-1]<<endl;
                summ += first[j];
                second[j - 1] -= first[j];
                first[j] = 0;
            } else if (first[j] > second[j - 1]) {
                summ += second[j - 1];
                first[j] -= second[j - 1];
                second[j - 1] = 0;
                if (first[j] <= second[j]) {
                    summ += first[j];
                    second[j] -= first[j];
                    first[j] = 0;
                } else {
                    summ += second[j];
                    first[j] -= second[j];
                    second[j] = 0;
                }
            }
        }
        //   cout<<summ<<endl;
    }
    if (first[first.size() - 1] <= second[second.size() - 1]) {
        summ += first[first.size() - 1];
    } else {
        summ += second[second.size() - 1];
    }
    cout << summ << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N, P;
    cin>>N>>P;
    int A[101];
    rep(i, N){
        cin>>A[i];
        A[i]%=2;
    }
    ll gu=0, ki=0;
    rep(i, N){
        if(A[i]==0) gu++;
        else ki++;
    }
    ll count=1;
    rep(i, gu) count*=2;
    rep(i, ki-1) count*=2;
    if(ki==0 && P==1) count=0;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string n = ReadLine();
	string s = "";

	for (int i = 0; i < n.Length; i++)
	{
	    char c = n[i];
	    if (c == '1')
	    {
		s += '9';
	    }
	    else if (c == '9')
	    {
		s += '1';
	    }
	    else
	    {
		s += n[i];
	    }
	}

	WriteLine(s);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>n>>s;
    int cnt=0;
  //  n=s.size();
    for(i=0,j=n-1;i<n && i<j ;i++,j-- ){
        while(s[i]=='R' && i<j) i++;
        while(s[j]=='W' && i<j) j--;
        if(i<j) cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3756
n = int(input())
s = [[0, 0, 0]]
for i in range(n):
    s.append(list(input().split()))

for i in range(1, len(s)):
    dt = int(s[i][0])-int(s[i-1][0])
    dx = abs(int(s[i][1])-int(s[i-1][1]))
    dy = abs(int(s[i][2])-int(s[i-1][2]))

    if dx+dy > dt:
        print("No")
        exit()
    elif (dx+dy) % 2 != dt % 2:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 71640
#include <stdio.h>

void Comb(int,int);

int n,A[20];
int Cart[100000000];

int main(){
  int i;

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


  Comb(0,0);

  int q,m;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(Cart[m]==1){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

}

void Comb(int x, int sum){
  if(x==n){
    Cart[sum]=1;
    return;
  }
  Comb(x+1,sum);
  Comb(x+1,sum+A[x]);
}



Measured memory_bytes: 2052
D = int(input())
c = list(map(int, input().split()))
s = []
for d in range(D):
	s.append(list(map(int, input().split())))
last = [0 for i in range(26)]
v = 0
for d in range(1, D+1):
  A = []
  for i in range(1, 27):
    a = s[d-1][i-1]
    for k in range(26):
      if k != i-1:
        a -= c[k] * (d - last[k])
    A.append(a)
  ind = A.index(max(A))
  last[ind-1] = d
  v += A[ind]
  print(ind+1)

Measured memory_bytes: 69336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >>N;
    vector<string> W(N);
    REP(i,N) cin >> W[i];
    bool f = true;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(W[i]==W[j]) f=false;
        }
    }
    if(f){
        for(int i=1;i<N;i++){
            if(W[i-1][W[i-1].length()-1]!=W[i][0]){
                f=false;
                break;
            }
        }
    }
    if(f){
        cout <<"Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<limits.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll INF=LLONG_MAX/2;

int n;
vector<ll> x,y;
vector<int> dx,dy;

ll solve(ll t)
{
    ll xmin=INF;
    ll ymin=INF;
    ll xmax=-INF;
    ll ymax=-INF;
    rep(i,n)
    {
        ll x2=x[i]+dx[i]*t;
        ll y2=y[i]+dy[i]*t;
        xmin=min(xmin,x2);
        xmax=max(xmax,x2);
        ymin=min(ymin,y2);
        ymax=max(ymax,y2);
    }
    return (xmax-xmin)*(ymax-ymin);
}
main()
{
    cin>>n;
    x.assign(n,0);
    y.assign(n,0);
    dx.assign(n,0);
    dy.assign(n,0);
    rep(i,n)
    {
        char d;
        cin>>x[i]>>y[i]>>d;
        x[i]*=2;
        y[i]*=2;
        if(d=='R')dx[i]++;
        else if(d=='L')dx[i]--;
        else if(d=='U')dy[i]++;
        else if(d=='D')dy[i]--;

    }
    ll left=0;
    ll right=400000000;
    while(right-left>3)
    {
        ll mid1=(left*2+right)/3;
        ll mid2=(left+right*2)/3;
        if(solve(mid1)<solve(mid2))right=mid2;
        else left=mid1;

    }
    ll ans=INF;
    for(ll i=left;i<=right;i++)ans=min(ans,solve(i));
    printf("%.10f\n",ans/4.0);
}

Measured memory_bytes: 2560
sub z3 [] = []
sub z3 l@(x:xs) =
  let y' = dropWhile (\y -> (x + y) > z3) l
      r  = sub z3 xs
  in
    if y' == []
    then r
    else (z3 - x - (y'!!0)):r

ans z =
  let z3 = z*z*z
      ls = map (\ x -> x*x*x) $ reverse $ [1..(z-1)]
  in
    minimum $ sub z3 ls

main = do
  c <- getContents
  let i = takeWhile (/= 0) $ map read $ lines c :: [Integer]
      o = map ans i
  mapM_ print o
  



Measured memory_bytes: 5484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=2e5+5;
const ll MOD=1e9+7;
const ll MOD1=13;
ll n,a[MAXN],sum[MAXN],ans[MAXN],now[MAXN];
vector<ll>fac[MAXN];
vector<ll>out;
void solve()
{
    for(ll i=n;i>=1;i--)
    {
        for(ll j=i;j<=n;j+=i)
        {
            fac[j].push_back(i);
        }
        sum[i]=a[i];
    }

    for(ll i=n;i>=1;i--)
    {
        ans[i]=(sum[i]-now[i]+2)%2;
        if(ans[i])
        {
            out.push_back(i);
        }
        for(ll j=0;j<fac[i].size();j++)
        {
            ll v=fac[i][j];
            now[v]+=ans[i];
            now[v]%=2;
        }
    }

    printf("%d\n",out.size());
    for(ll i=0;i<out.size();i++)
    {
        printf("%lld\n",out[i]);
    }

}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    solve();
}


Measured memory_bytes: 40696
/*
Author:Fuad Ashraful Mehmet
University of Asia Pacific
AtCoder Beginner Contest 155
Date:16 Feb 2020
*/
#include<bits/stdc++.h>
using namespace std;


int n,m,q,len;
const int N=1e6+5;


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    
    cin>>n;
    int mx=0;
    string s;
    map<string,int>mp;
    for(int i=1;i<=n;++i)
    {
        cin>>s;
        mp[s]+=1;
        if(mp[s]>mx)
        {
            mx=mp[s];
        }
    }

    for(auto it:mp)
    {
        if(it.second==mx)
        cout<<it.first<<endl;
    }
    return 0;
}

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

int main() {
    int n, T; cin >> n >> T;
    int ans =  1001;
    rep (i, n) {
        int c, t; cin >> c >> t;
        if (t > T) continue;
        ans = min(ans, c);
    }
    if (ans == 1001) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000
int G[MAX+1][MAX+1],d[MAX+1];
int col[MAX+1],que[MAX+1];
int head,tail;
int n;

void enque(int i){
  que[tail] = i;
  tail = (tail + 1)%n;
}

int deque(){
  int v;
  v = que[head];
  head = (head + 1)%n;
  return v;
}

void bfs(int u){
  int v,i;
  for(i=0; i<=n; i++){
    d[i]=INF;
  }
  enque(u);
  d[u] = 0;
  while(head != tail){
    v = deque();
    for(i=0; i<=n; i++){
      if(G[v][i] == 0)continue;
      if(d[i] != INF)continue;
      d[i] = d[v] + 1;
      enque(i);
    }
  }

  for(i=0; i<n; i++){
    printf("%d ",i+1);
    if(d[i] == INF){
      printf("%d\n",-1);
    }
    else {
      printf("%d\n",d[i]);
    }
  }
  
}

int main(){
  int i,j,l,len,num,k;

  for(i=0; i<MAX+1; i++){
    for(j=0; j<MAX+1; j++){
      G[i][j]=0;
    }
  }
  //表に入れる  
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d %d",&len,&num);
    len--;
    for(l=0; l<num; l++){
      scanf("%d",&k);
      k--;
      for(j=1; j<=n; j++)G[len][k]=1;
    }
  }
  
  bfs(0);
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a, n) priority_queue<int>a(n)
#define PQmin(a, n) priority_queue< int, std::vector<int>, std::greater<int> >a(n)

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<pair<pair<string, int>, int> > sp(n);
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin>>s>>p;
        sp[i] = make_pair(make_pair(s, -p), i+1);
    }
    sort(sp.begin(),sp.end());
    for(int i=0;i<n;i++){
        cout<<sp[i].second<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
import heapq
q = []
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    heapq.heappush(q, -A[i])

MAX1 = -heapq.heappop(q)
MAX2 = -heapq.heappop(q)
for i in range(N):
    if A[i] == MAX1:
        print(MAX2)
    else:
        print(MAX1)

Measured memory_bytes: 71640
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"


int main()
{
    IOS;

    ll i, a, b, num1=1, num2=1, value;
    vector<tuple<int, int, int>> fibo;

    cin>>a>>b;
    ll dif= b-a;

    while(num2 <=999){
        ll sum = 0;

        for(i=1; i<=num2; i++){
            sum = sum + i;
        }

        fibo.pb(make_tuple( num1, sum, num2));
        num2++;
        num1 = sum;
    }



    cout<<(get<1>(fibo[dif-1]) - b);



}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(){
	using namespace std;
	int A_num, b_num, A_count, b_count, data,row=0, col=0;
	cin >> A_num >> b_num;
	A_count = A_num*b_num;
	b_count = b_num;
	vector<vector<int>> A(A_num,vector<int>(b_num));
	vector<int> b(b_num);
	while (A_count > 0)
	{
		cin >> data;
		A[row][col] = data;
		col++;
		if (col == b_num)
		{
			row++;
			col = 0;
		}
		A_count--;
	}
	col = 0;
	while (b_count > 0)
	{
		cin >> data;
		b[col] = data;
		col++;
		b_count--;
	}
	for (int i = 0; i < A_num; i++)
	{
		int sum = 0;
		for (int j = 0; j < b_num; j++)
		{
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
a_list = []
b_list = []
op_list = []
count = 0
while True:
  a, op, b = (str(i) for i in input().split())
  if op != '?':
    a_list.append(int(a))
    b_list.append(int(b))
    op_list.append(op)
    count += 1
  else :
    break
for i in range(0,count):
  if op_list[i] == '+':
    print(a_list[i] + b_list[i])
  elif op_list[i] == '-':
    print(a_list[i] - b_list[i])
  elif op_list[i] == '*':
    print(a_list[i] * b_list[i])
  elif op_list[i] == '/':
    print(a_list[i] // b_list[i])

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

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

Measured memory_bytes: 1188
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;
vector<pair<int,int> > V;

void solve(void) {
    for(int i = 2;i <= N;i++) {
        V.push_back({1,i});
    }

    int rest = (N-1)*(N-2)/2 - K;
   
    for(int i = 2;i < N;i++) {
        for(int j = i+1;j <= N;j++) {
            if(rest > 0) {
                rest--;
                V.push_back({i,j});
            }
        }
    }

    cout<<V.size()<<endl;

    for(auto u: V) {
        cout<<u.first<<" "<<u.second<<endl;
    }
    

    return;
}

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

    if(K > ((N-1)*(N-2))/2) {
        cout<<-1<<endl;

        return 0;
    }

    solve();

    return 0;
}


Measured memory_bytes: 384
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
B=Int[]
if N%2==0
	for i=N:-2:2
		push!(B,A[i])
	end
	for i=1:2:N-1
		push!(B,A[i])
	end
else
	for i=N:-2:1
		push!(B,A[i])
	end
	for i=2:2:N-1
		push!(B,A[i])
	end
end
println(join(B," "))


Measured memory_bytes: 161148
#include <stdio.h>
#include <math.h>
#include <string.h>

#define MAX 1001

int N = 1000;

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

void allzero(int A[],int m){

  int i;
  for(i=0;i<=m;i++) A[i]=0;
}

void lcs(char X[], char Y[]) {

  int c[N + 1] [N + 1];
  
  int m= strlen(X);
  int n = strlen(Y);
  
  int maxl = 0;
  int i,j,k;

  for(i=0;i<=m;i++) c[i][0]=0;

  for(j=1;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i][j-1],c[i-1][j]);
      maxl=max(maxl,c[i][j]);
    }
  }

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


int main() {

  char s1[MAX], s2[MAX];
  int n,i;
  
  scanf("%d",&n);
  
  for ( i = 0; i < n; i++ ) {
    scanf("%s",s1);
    scanf("%s",s2);
    lcs(s1, s2);
  }
  return 0;
}



Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void reverse(char arr[], char arr2[], int len){
	strncpy(arr2+1, arr, len-1);
	arr2[len-1]='\0';
	arr2[0]=arr[len-2];
}

int equals(char s[], char t[], int len){
	for(;len>0;len--){
		if(s[len-1]!=t[len-1]) return 0;
	}
	
	return 1;
}


int main(){
	char s[2][101], t[101];
	int len, i;
	scanf("%s", s[0]);
	scanf("%s", t);
	len=strlen(s[0])+1;
	strcpy(s[1], s[0]);
	
	for(i=0;i<len;i++){
		if(equals((i%2?s[1]:s[0]), t, len)){
			printf("Yes");
			return 0;
		}
		reverse((i%2?s[0]:s[1]),(i%2?s[1]:s[0]), len);
	}
	
	printf("No");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	long long x1,y1,x2,y2,s1,s2,w1,w2;
	cin>>x1>>y1>>x2>>y2;
	s1=x1;
	w1=y1;
	s2=x2;
	w2=y2;
	while(y1<y2)
	{
		cout<<'U';
		y1++;
	}
	y1=w1;
	while(x1<x2)
	{
		cout<<'R';
		x1++;
	}
	x1=s1;
	while(y2>y1)
	{
		cout<<'D';
		y2--;
	}
	while(x2>x1)
	{
		cout<<'L';
		x2--;
	}
	cout<<'L';
	x1=s1;
	y1=w1;
	x2=s2;
	y2=w2;
	while(y1<=y2)
	{
		cout<<'U';
		y1++;
	}
	y1=w1;
	while(x1<=x2)
	{
		cout<<'R';
		x1++;
	}
	cout<<'D';
	cout<<'R';
	x1=s1;
	while(y2>=y1)
	{
		cout<<'D';
		y2--;
	}
	while(x2>=x1)
	{
		cout<<'L';
		x2--;
	}
	cout<<'U';
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    long long d;
    cin >> n >> d;

    int ret = 0;
    for (int i=0; i<n; i++) {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d)
            ret++;
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int row, col;
	while (cin >> row >> col) {
		if (row == 0 && col == 0)
			break;
		rep(_, row) cout << string(col, '#') << "\n";
		cout << endl;
	}
}


Measured memory_bytes: 3208
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);

$answer = PHP_INT_MAX;

$max9 = floor($N / 9);
for ($i = $max9; $i >= 0; $i--) {
    $newN = $N;
    $newN -= 9 * $i;
    $ret9 = getLog($i * 9, 9);
    $num6 = floor($newN / 6);
    $ret6 = getLog($num6 * 6, 6);
    $newN -= 6 * $num6;
    $ret1 = $newN;
    $sum = $ret9 + $ret6 + $ret1;
    $answer = min($sum, $answer);
    if (DEBUG) printf("9:%d 6:%d 1:%d sum:%d answer:%d\n", $ret9, $ret6, $ret1, $sum, $answer);
}
echo $answer . PHP_EOL;

function getLog($n, $base) {
    if (DEBUG) echo "{$n} {$base}\n";
    $l = log($n, $base);
    $tmp = intval((string)$l);

    $ret = 0;
    for ($i = $tmp; $i >= 1; $i--) {
        $num = floor($n / pow($base, $i));
        $n -= $num * pow($base, $i);
        if (DEBUG) printf("base:%d number:%d proc:%d rest:%d\n", $base, pow($base, $i), $num, $n);
        $ret += $num;
    }
    return $ret;
}


Measured memory_bytes: 4728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long res = 0;
        int[,] cnts = new int[30, 30];
        for (int _ = 0; _ < n; _++)
        {
            var s = Console.ReadLine();
            long a, b;
            var ind = s.IndexOf('.');
            if (ind != -1)
            {
                a = int.Parse(s.Substring(0, ind));
                b = int.Parse(s.Substring(ind + 1).PadRight(9, '0'));
            }
            else
            {
                a = int.Parse(s);
                b = 0;
            }
            var val = a * 1000000000 + b;
            var (cnta, cntb) = GetCnt(val);
            cnts[Min(cnta, 18), Min(cntb, 18)]++;
            //Console.WriteLine($"{Min(cnta, 18)} {Min(cntb, 18)}");
            if (18 <= cnta + cnta && 18 <= cntb + cntb) res--;
        }
        //Console.WriteLine(res);
        for (int i = 0; i <= 18; i++)
        {
            for (int j = 0; j <= 18; j++)
            {
                long curres = 0;
                for (int k = 18 - i; k <= 18; k++)
                {
                    for (int l = 18 - j; l <= 18; l++)
                    {
                        curres += cnts[k, l];
                    }
                }
                res += curres * cnts[i, j];
            }
        }
        //Console.WriteLine(res);
        res /= 2;
        Console.WriteLine(res);
    }

    static (int, int) GetCnt(long n)
    {
        int cnt2 = 0;
        int cnt5 = 0;
        while ((n & 1) == 0)
        {
            n >>= 1;
            cnt2++;
        }
        while (n % 5 == 0)
        {
            n /= 5;
            cnt5++;
        }
        return (cnt2, cnt5);
    }

    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}


Measured memory_bytes: 40532
//B - Digital Gifts
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	cin>>N;
	long double total=0.0;
	while(N--)
	{
		long double v;string s;
		cin>>v>>s;
		if(s=="BTC")
			v*=380000.0;
		total+=v;
	}
	cout<<fixed<<total;
	return 0;
}

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    if(a>=k)ans=k;
    else{
        ans=a;
        k-=a+b;
        if(k>0)ans-=k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(0,c-a+b);
    return 0;
}

Measured memory_bytes: 764
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]);
    double x = Math.Log(n, k);
    int i;
    for (i=0; i<=x; i++);
    Console.WriteLine(i);
  }
}

Measured memory_bytes: 11092
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n]
    }

    let mut dp = vec_md![0i64;n+1;k+1];
    dp[0][k] = 1;
    for i in 0..n {
        let cum = Cum::new(&dp[i]);
        for j in 0..k+1 {
            dp[i+1][j] = cum.sum(j, std::cmp::min(j+a[i], k) + 1);
        }
    }
    println!("{}", dp[n][0]);
}

#[allow(dead_code)]
pub const M: i64 = 1_000_000_007;

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i] % M;
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> i64 {
        let mut ret = (self.s[r] - self.s[l]) % M;
        if ret < 0 {
            ret += M;
        }
        ret
    }
}

Measured memory_bytes: 108924
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
 
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,d;
	cin>>n>>d;
	int a[n][d];
	for(int x=0;x<n;x++){
		for(int y=0;y<d;y++){
			cin>>a[x][y];
		}
	}
	int o=0;
	for(int x=0;x<n;x++){
		for(int i=x+1;i<n;i++){
			int ans=0;
			for(int y=0;y<d;y++){
				ans+=pow(a[i][y]-a[x][y],2);
			}
			int z=sqrt(ans);
			if(z*z==ans){
				o++;
			}
		}
	}
	cout<<o;
	







	
	
return 0;	
}


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

int main() {
  int N;
  cin >> N;
  set<int> st;
  for (int i = 0; i < N; ++i) {
    int d;
    cin >> d;
    st.insert(d);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

void make_prime_factors(ll num, vector<ll>& prime_factors)
{
	ll base = num;
	ll j = 2;
	while (j*j <= base)
	{
		if (base%j == 0)
		{
			base /= j;
			prime_factors.push_back((ll)j);
		}
		else
		{
			j++;
		}
	}
	if (base >= 2)
	{
		prime_factors.push_back((ll)base);
	}
}


int main() 
{
	ll N, P;
	cin >> N >> P;

	vector <ll> factors;
	make_prime_factors(P, factors);
	sort(factors.begin(), factors.end());

	map <ll, int> mp;
	for (auto a : factors)
	{
		mp[a]++;
	}

	ll ans = 1;
	for (auto m : mp)
	{
		ll k = m.second / N;
		for (int i=0;i<k;++i)
		{
			ans *= m.first;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    double ans=0.0;
    for(int i=0;i<n;i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end(),greater<int>());
    for(int i=1;i<n;i++){
        ans += v.at(i-1) / pow(2,i);
    }
    ans += v.at(n-1) /pow(2,n-1);

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>

#define lo long long
using namespace std;

const lo inf = 1e18;
lo k,tab[100100];
bool cek(lo nil,lo key)
{
	for (int i=0;i<k;i++)
	{
		nil/=tab[i];
		nil*=tab[i];
	}
	
	return nil>=key;
}
int main()
{
	cin>>k;
	for (int i=0;i<k;i++) cin>>tab[i];
	
	lo bawah=0, atas=inf;
	
	lo mid;
	lo key =2;
	
	while(atas-bawah>1)
	{
		mid = bawah+ (atas-bawah)/2;
		if (cek(mid,key))
		{
			atas=mid;
		}
		else bawah=mid;
	}
	mid = bawah+ (atas-bawah)/2;
	if (cek(mid,key))
	{
		atas=mid;
	}
	else bawah=mid;
	
	lo ans1=bawah;
	
	key =3;
	bawah=0, atas=inf;
	while(atas-bawah>1)
	{
		mid = bawah+ (atas-bawah)/2;
		if (cek(mid,key))
		{
			atas=mid;
		}
		else bawah=mid;
	}
	
	mid = bawah+ (atas-bawah)/2;
		if (cek(mid,key))
		{
			atas=mid;
		}
		else bawah=mid;
		
	lo ans2=bawah;
	
	if (ans1>=ans2) cout<<-1<<endl;
	else cout<<ans1+1<<" "<<ans2<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
 
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

ll lcm(ll a,ll b){
    return (a * b) / __gcd(a,b);
}

const ll INF = 10010001010;
const int inf = 1000034000;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    ll ans = 0;
    ll div = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        ans += A[i] - 1;
    }
    
    cout << ans << endl;
} 

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

typedef long long ll;

int main() {
    vector<int> a(4);
    rep(i, 4) cin >> a[i];
    sort(a.begin(), a.end());
    cout << abs(a[0] - a[1] - a[2] + a[3]) << "\n";
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0 && W==0){
        break;
      }
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          if(i%2==1){
            if(j%2==1) System.out.print("#");
            else System.out.print(".");
          }else{
            if(j%2==0) System.out.print("#");
            else System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 32832
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, m, ans=0;
    cin >> n >> m;
    vector<vector<ll>> s(m);
    rep(i,m){
        ll k;
        cin >> k;
        rep(j,k){
            ll a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<ll> p(m);
    rep(i,m) cin >> p[i];
    rep(bit,(1<<n)){
        bool ok = true;
        rep(i,m){
            ll cnt = 0;
            for(auto on:s[i]){
                if(bit & (1<<on)) cnt++;
            }
            if(cnt%2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
///At Coder  : Vacation
///Approach  : Iterative Dp
///Complexity: O(n)

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

int dp[100005][4];
int arr[100005][4];

int main(){

    ios_base::sync_with_stdio(false);cout.tie(false);cin.tie(false);

    int n,i,j,a;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>arr[i][1];
        cin>>arr[i][2];
        cin>>arr[i][3];
    }
    for(i=1; i<=n; i++){
       dp[i][1]=arr[i][1]+max(dp[i-1][2],dp[i-1][3]);
       dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][3]);
       dp[i][3]=arr[i][3]+max(dp[i-1][1],dp[i-1][2]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;

    return 0;
}



Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

  
int main(){
	int i,n;
	char str[21];
	scanf("%s",str);
	n=strlen(str);
	for(i=n-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 524
# coding=utf-8
import bisect


if __name__ == '__main__':
    N, Q = map(int, input().split())
    Que = [[] for i in range(N)]

    for j in range(Q):
        query = list(map(int, input().split()))
        if query[0] == 0:
            bisect.insort_left(Que[query[1]], query[2])
        elif query[0] == 1:
            if Que[query[1]]:
                print(Que[query[1]][-1])
        elif query[0] == 2:
            if Que[query[1]]:
                Que[query[1]].pop()



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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	int ans = n;
	for (int i = 0; i <= n; i++) {
		int count = 0;
		int t = i;
		while (t > 0) {
			count += t % 6;
			t /= 6;
		}

		t = n - i;
		while (t > 0) {
			count += t % 9;
			t /= 9;
		}

		ans = min(ans, count);
	}

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


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
count = 0
new_list = []
while count < K:
    min = P[0]
    for i in P:
        if min > i:
            min = i
    new_list.append(min)
    P.remove(min)
    count += 1
print(sum(new_list))

Measured memory_bytes: 9252