akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int coin[]={500,100,50},number[5];
int dp[10][20007];
int making(int pos,int amount)
{
    if(pos>2){
        if(amount==0) return 1;
        else return 0;
    }
    if(amount==0) return 1;
    if(amount<0) return 0;
    if(dp[pos][amount]!=-1) return dp[pos][amount];
    int ans=0;
    for(int i=0;i<=number[pos];i++){
        ans=ans+making(pos+1,amount-(coin[pos]*i));
    }
    return dp[pos][amount]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    int make;
    cin>>number[0]>>number[1]>>number[2]>>make;
    cout<<making(0,make)<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll a,p;
    cin >> a >> p;
    ll x=a*3+p;
    cout << x/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
	int x,y,z,k;cin>>x>>y>>z>>k;
	vector<ll> a(x),b(y),c(z);
	cinv(x,a);cinv(y,b);cinv(z,c);
	vector<ll> ans;
	sort(a.begin(),a.end());reverse(a.begin(),a.end());
	sort(b.begin(),b.end());reverse(b.begin(),b.end());
	sort(c.begin(),c.end());reverse(c.begin(),c.end());
	rep(i,x){
		rep(j,y){
			if((i+1)*(j+1) > k)break;
			rep(l,z){
				if((i+1)*(j+1)*(l+1) > k)break;
				ans.push_back(a[i]+b[j]+c[l]);
			}
		}
	}
	sort(ans.begin(),ans.end());
	reverse(ans.begin(),ans.end());
	rep(i,k){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1404
(n,m,l) = [int(x) for x in input().split()]
a = []
b = []
c = [[0 for x in range(l)] for y in range(n)]

for nc in range(n):
    a.append([int(i) for i in input().split()])

for mc in range(m):
    b.append([int(i) for i in input().split()])

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]

for r in c:
    print(' '.join([str(d) for d in r]))

Measured memory_bytes: 7764
#include <iostream>
using namespace std;
int main (void) {
    string s;
    int len;

    cin >> s;

    len = s.length();

    while (true) {
        len--;
        if (len % 2 == 1) continue;
        bool even = true;
        for (int i = 0; i < len / 2; i++) {
            if (s[i] != s[len / 2 + i]) even = false;
        }
        if (even) {
            cout << len << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int abs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int n, a, b, c;
	scanf("%d %d %d %d", &n, &a, &b, &c);
	int i, j;
	int l[10];
	for (i = 0; i < n; i++)
		scanf("%d", &l[i]);
	int max = 1;
	for (i = 0; i < n; i++)
		max *= 4;
	int aa, bb, cc;
	int q, ans = 1000000009, count;
	for (i = 0; i < max; i++)
	{
		q = i;
		aa = bb = cc = 0;
		count = 0;
		j = 0;
		while (q > 0)
		{
			if (q % 4 == 1)
			{
				if (aa > 0)
					count += 10;
				aa += l[j];
			}
			if (q % 4 == 2)
			{
				if (bb > 0)
					count += 10;
				bb += l[j];
			}
			if (q % 4 == 3)
			{
				if (cc > 0)
					count += 10;
				cc += l[j];
			}
			j++;
			q /= 4;
		}
		if (aa == 0 || bb == 0 || cc == 0)
			continue;
		count += abs(a - aa) + abs(b - bb) + abs(c - cc);
		if (ans > count)
			ans = count;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
 
  sort(L.begin(), L.end());
  int tmp = 0;
  for (int i = 0; i < N - 1; i++) {
    tmp += L.at(i);
  }
 
  cout << (L.at(N - 1) < tmp ? "Yes" : "No");
}

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

using namespace std;

template<typename T>
struct UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    UnionFind<int>uf(n);
    for(int i=0;i<q;++i){
        int com,x,y;
        cin>>com>>x>>y;
        if(com)uf.same(x,y)?cout<<"1"<<endl:cout<<"0"<<endl;
        else uf.unite(x,y);
    }
    return 0;
}

Measured memory_bytes: 3128
n, c, k = map(int, input().split())
t = sorted(list(int(input()) for _ in range(n)))

ans = 1
now = t[0]
cnt = 0
for i in t:
    cnt += 1
    if i > now + k or cnt > c:
        ans += 1
        cnt = 1
        now = i

print(ans)

Measured memory_bytes: 14024
#include<iostream>


using namespace std;

int main()
{
    int A,B,C;cin >> A >> B >> C;

    if(A==B && A!=C)
    {
        cout << "Yes"<<endl;
        return 0;
    }
    if(B==C && A !=C)
    {
        cout << "Yes"<<endl;
        return 0;
    }
    if(A==C && A !=B)
    {
        cout <<"Yes"<<endl;
        return 0;
    }

    cout << "No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

ll dp[1<<15][15][15];

vector<vector<pii>> es;

int main(){
    int n, m;
    cin >> n >> m;
    es.resize(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        es[a].pb({b, c});
    }
    rep(i, 1<<n) rep(j, n) rep(k, n) dp[i][j][k] = INF;
    rep(i, n) dp[1<<i][i][i] = 0; 
    rep(mask, 1<< n) rep(i, n) rep(j, n) if(dp[mask][i][j] != INF) {
        for(auto&& k: es[j]) if(!(mask&(1<<k.fi))) {
            chmin(dp[mask|(1<<k.fi)][i][k.fi], dp[mask][i][j]+k.se);
        }
    }
    ll ans = INF;
    rep(mask, 1<<n) rep(cur, n) for(auto&& s : es[cur]) chmin(ans, dp[(1<<n)-1][s.fi][cur] + s.se);
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 60708
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val n = readInt()
    val a = readInts()
    var f: Int = a.drop(1).reduce { acc, i -> acc xor i }
    var last = a[0]
    print("$f ")
    println(a.drop(1).map {
        f = f xor last xor it
        last = it
        f.toString()
    }.joinToString(" "))

}


Measured memory_bytes: 84484
#include <bits/stdc++.h>
using namespace std;
#define ll long  long
int main()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n],j,z=0;
    for(i=0;i<n;i++)
    cin>>a[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(i=2;i<n;i++) {
        j=max(z,i-k);
        dp[i] = INT_MAX;
        while(j<i){
             dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
             j++;
        }
    }
    cout<< dp[n-1];
}


Measured memory_bytes: 1792
N, M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
ans = 0
tmp = 1
for i in range(M):
    tmp = 1
    for j in range(N):
        tmp *= int((A[j][1:]).count(i+1)>0)
    ans += tmp
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; ++i){ cin >> x[i]; }
	ll answer = 1;
	for(int i = 0, j = 1; i < n; ++i){
		for(; j < n; ++j){
			if(j - i > (x[j - 1] + 1) / 2){ break; }
		}
		answer = (answer * (j - i)) % MOD;
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();
    LL n, k, s;
    cin >> n >> k >> s;
    LL b = INF;
    if(s == INF) b = 1;
    vector<LL> ans(n, b);
    rep(i, k) ans[i] = s;
    rep(i, n) cout << ans[i] << (i==n-1 ? "\n":" ");

}

Measured memory_bytes: 2176
# F - Three Variables Game

n, a, b, c = map(int, input().split())
s = [input() for i in range(n)]

def decode(c):
    return ord(c) - ord('A')

state = [a, b, c]
choice = []
for i in range(n):
    # 'AC' -> (0, 2)
    j, k = map(decode, s[i])

    # 失敗
    if state[j] == state[k] == 0:
        print('No')
        break

    # state[j] <= state[k] にする
    if state[j] > state[k]:
        j, k = k, j

    # 1手先読み
    if state[j] == state[k] == 1 and i < n - 1:
        xj, xk = map(decode, s[i + 1])
        if state[xj] + state[xk] == 1 and k in {xj, xk}:
            j, k = k, j

    # jを選択
    state[j] += 1
    state[k] -= 1
    choice.append('ABC'[j])
else:
    print('Yes')
    for c in choice:
        print(c)


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

using namespace std;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


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

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ----- end of debug ---------

int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

vector< vector<int> > g;
vector<int> dp_down, dp_up;
vector< vector<int> > presum, sufsum;

void dfs_down(int u, int pa) {
  dp_down[u] = 1;
  for (auto v : g[u]) {
    if (v != pa) {
      dfs_down(v, u);
      dp_down[u] = mul(dp_down[u], dp_down[v]);
    }
  }
  add(dp_down[u], 1); // white
}

void dfs_up(int u, int pa, int id) {
  int child = g[u].size();
  presum[u] = vector<int>(child + 1, 1);
  sufsum[u] = vector<int>(child + 1, 1);
  for (int i = 0; i < child; i++) {
    presum[u][i + 1] = mul(presum[u][i], (g[u][i] == pa) ? 1 : dp_down[g[u][i]]);
    sufsum[u][i + 1] = mul(sufsum[u][i], (g[u][child - i - 1] == pa) ? 1 : dp_down[g[u][child - i - 1]]);
  }

  if (pa == -1) {
    dp_up[u] = 1;
  } else {
    dp_up[u] = dp_up[pa];
    dp_up[u] = mul(dp_up[u], presum[pa][id]);
    dp_up[u] = mul(dp_up[u], sufsum[pa][g[pa].size() - id - 1]);
    add(dp_up[u], 1);
  }

  for (int i = 0; i < child; i++) {
    int v = g[u][i];
    if (v != pa) {
      dfs_up(v, u, i);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n >> md;
  g.resize(n);
  dp_down.resize(n);
  dp_up.resize(n);
  presum.resize(n);
  sufsum.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  dfs_down(0, -1);
  dfs_up(0, -1, 0);

  for (int i = 0; i < n; i++) {
    sub(dp_down[i], 1);
    cout << mul(dp_down[i], dp_up[i]) << '\n';
  }
  debug(dp_down);
  debug(dp_up);
  return 0;
}

Measured memory_bytes: 24960
from itertools import permutations
n = int(input())
p = tuple(i for i in map(int, input().split()))
q = tuple(i for i in map(int, input().split()))
count = 0
for i in permutations([j for j in range(1, n+1)], n):
    if p == i:
        p_c = count
    if q == i:
        q_c = count
    count += 1
print(abs(p_c-q_c))

Measured memory_bytes: 3064
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;
vector<int> g[N], h[N], b1[N], b2[N];
int f[N], c[N], mod, ans[N], par[N];

void go(int x, int p = 0) {
    par[x] = p;
    rep(i, h[x].begin(), h[x].end()) {
        if((*i) == p) {
            continue;
        }
        go(*i, x);
        g[x].emplace_back(*i);
    }
}

int calc1(int x) {
    int cur = 1;
    rep(i, g[x].begin(), g[x].end()) {
        cur = (cur * (ll)calc1(*i)) % mod;
        b1[x].emplace_back(cur);
    }
    f[x] = (1 + cur) % mod;
    pr(x, f[x]);
    return f[x];
}


int calc2(int x) {
    int cur = 1;
    rep(i, g[x].rbegin(), g[x].rend()) {
        cur = (cur * (ll)calc2(*i)) % mod;
        b2[x].emplace_back(cur);
    }
    return (1 + cur) % mod;
}

void calc3(int x) {
    ans[x] = (1 + ans[x] * (ll)ans[par[x]]) % mod;
    rep(i, g[x].begin(), g[x].end()) {
        calc3(*i);
    }
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n >> mod;
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        h[x].emplace_back(y);
        h[y].emplace_back(x);
    }
    go(1, 0);
    calc1(1);
    calc2(1);
    rep(i, 1, n + 1) {
        reverse(b2[i].begin(), b2[i].end());
    }
    rep(i, 1, n + 1) {
        int ind = 0;
        rep(j, g[i].begin(), g[i].end()) {
            int cur = 1;
            if(ind > 0) {
                cur = b1[i][ind - 1];
            }
            if(ind + 1 < sz(b2[i])) {
                cur = (cur * (ll)b2[i][ind + 1]) % mod;
            }
            ans[*j] = cur;
            ind++;
        }
    }
    calc3(1);
    rep(i, 1, n + 1) {
        f[i]--;
        if(f[i] < 0) {
            f[i] += mod;
        }
        ans[i] = (ans[i] * (ll)f[i]) % mod;
        cout << ans[i] << endl;
    }
}

/*

f[x] = prod(1+f[child]) = num ways so that x is black and childs are anything

g[x] = num ways par[x] is anything and leads out = 1+prod(1+f[childs of par[x] without x])*g[par[x]];

ans[x] = f[x]*g[x];

*/

Measured memory_bytes: 27648
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 0
left = 0
for i in range(n):
   tmp = min(a[i], left)
   ans += tmp
   a[i] -= tmp

   if(b[i] > a[i]):
      ans += a[i]
      left = b[i] - a[i]
   else:
      ans += b[i]
      left = 0

ans += min(a[n], left)
print(ans)


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

char a[15][15];
int n, m;

char cu[15];
int co[15];

char ru[15];
int ro[15];

bool row_same(int r1, int r2){
	for(int j=(m&1)+1; j+1<=m; j+=2){
		if(a[r1][co[j]] != a[r2][co[j+1]] || a[r2][co[j]] != a[r1][co[j+1]]){
			return 0;
		}
	}
	if(m&1) return a[r1][co[1]] == a[r2][co[1]];
	return 1;
}

void rdfs(int p){
	if(p > n){
		puts("YES");
		exit(0);
	}
	for(int i=1; i<=n; ++i) if(!ru[i]){
		ro[p] = i;
		if((p&1) == (n&1)) if(!row_same(ro[max(1, p-1)], i)) continue;
		ru[i] = 1;
		rdfs(p+1);
		ru[i] = 0;
		if(p&1) break;
	}
}

void cdfs(int p){
	if(p > m){
		rdfs(1);
		return;
	}
	for(int i=1; i<=m; ++i) if(!cu[i]){
		cu[i] = 1;
		co[p] = i;
		cdfs(p+1);
		cu[i] = 0;
		if((p&1) != (m&1)) break;
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; ++i) scanf("%s", a[i]+1);
	cdfs(1);
	puts("NO");
	return 0;
}


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

int main(){
  int N;
  long long int L[101];
  int i,j,k;
  int a,b,c;
  int count = 0;
  int small1,small2,max1;
  
  cin >> N;
  for(i=0;i<N;i++){
    cin >> L[i];
  }
  for(i=0;i<N-2;i++){
    a = L[i];
    for(j=i+1;j<N-1;j++){
      b = L[j];
      //small2 = max(a,b);
      //small1 = min(a,b);
      for(k=j+1;k<N;k++){
        c = L[k];
        small2 = max(a,b);
        small1 = min(a,b);
        max1 = max(small2,c);
        small2 = min(small2,c);
        
        //printf("**%d %d %d\n",max1, small1,small2);
        if(small1!=small2&&small2!=max1&&max1!=small1){
          if(max1<small1+small2){
            count++; 
            //printf("%d %d %d\n",max1, small1,small2);
          }
        }
        
        
      }
    }
  }
  if(N<=2){
    printf("0");
  }
  else{
  	printf("%d",count);
  }
  
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

str S, T;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> S >> T;
    cout << T << S;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int n = Integer.parseInt(div[0]);
		int m = Integer.parseInt(div[1]);
		if (n > m){
			System.out.println("a > b");
		} else if (n < m){
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 16892
import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline
H, W, M = map(int, input().split())

HH = [0]*H
WW = [0]*W
d = set()
for line in readlines():
    h, w = map(int, line.split())
    h -= 1
    w -= 1
    d.add((h, w))
    HH[h] += 1
    WW[w] += 1

m = -1
argm = []
for i, c in enumerate(HH):
    if c > m:
        m = c
        argm = [i]
    elif c == m:
        argm.append(i)

mH = m
aH = argm

m = -1
argm = []
for i, c in enumerate(WW):
    if c > m:
        m = c
        argm = [i]
    elif c == m:
        argm.append(i)

mW = m
aW = argm

ans = mH + mW
for h in aH:
    for w in aW:
        if (h, w) not in d:
            break
    else:
        continue
    break
else:
    ans -= 1

print(ans)


Measured memory_bytes: 179604
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

//range minimum query
template<typename T>
struct segtree {
    T INF = inf;
    int n;
    vector<T> dat;
 
    void init(int n_) {
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        dat.assign(2 * n - 1, INF);
    }
 
    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
 
    T basequery(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        }
        if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = basequery(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = basequery(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }

    //[l, r)の範囲の最小値を返す
    T query(int l, int r) {
        return basequery(l, r, 0, 0, n);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll L[M], R[M], C[M];
    REP(i, 0, M) {
        cin >> L[i] >> R[i] >> C[i];
    }
    tlglglg data[M];
    REP(i, 0, M) {
        data[i] = tlglglg(L[i] - 1, R[i] - 1, C[i]);
    }
    sort(data, data + M);
    segtree<ll> seg;
    seg.init(N);
    seg.update(0, 0);
    REP(i, 0, M) {
        tlglglg t = data[i];
        ll left = get<0>(t);
        // cout << left << " " << seg.query(left, N) << endl;
        seg.update(left, seg.query(left, N));
        if (seg.query(left, left + 1) < inf) {
            ll right = get<1>(t);
            seg.update(right, min(seg.query(right, right + 1), seg.query(left, left + 1) + get<2>(t)));
        }
    }
    if (seg.query(N - 1, N) == inf) {
        cout << -1 << endl;
    } else {
        cout << seg.query(N - 1, N) << endl;
    }
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, d, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;
map<ll, ll> m;


int main() {
	//Code Line
	cin >> a >> b >> c >> n;

	if (a >= n)cout << n << endl;
	else {
		n -= a; sum += a;
		if (b >= n)cout << sum << endl;
		else {
			n -= b;
			cout << sum - n << endl;


		}


	}


	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		int a = Integer.parseInt(sc.next());
		int current = a;
		int next = 0;
		boolean can = true;
		int sa = 0;
		String result = "Yes";
		while(sc.hasNext()) {
			next = Integer.parseInt(sc.next());
			if(can) current--;
			sa = current - next;
			if(sa>0) {
				result = "No";
			}
			if(current<next) {
				can = true;
			}else {
				can = false;
			}
			current = next;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 46768
#include <stdio.h>

int n;
int a[100001];
int b[100001];
int c[100001];

void quicksort(int left, int right)
{
	int tmp, pivot;
    if (left < right) {
        int i = left, j = right;
		pivot = a[(right-left+1)/2];
        while (1) {
            while (a[i] > pivot) i++;
            while (pivot > a[j]) j--;
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp;
            i++; j--;
        }
        quicksort(left, i - 1);
        quicksort(j + 1, right);
    }
}

int gcd(int b, int a)
{
	if(b<a) { int tmp = b; b = a; a = tmp; }
	int r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int gcd_(int e)
{
	int i = 0;
	int g;
	if(e == 0) i = 1;
	g = a[i];
	for(i=0;i<n-1;i++) {
		if(i+1==e) continue;
		g = gcd(g, a[i+1]);
	}

	return g;
}

int main(void)
{
	int i, tmp;
	int max = 0;
	scanf("%d%*c", &n);
	for(i=0;i<n;i++)
		scanf("%d%*c", &a[i]);

	//quicksort(0, n-1);

	b[0] = a[0];
	for(i=1;i<n;i++)
		b[i] = gcd(b[i-1], a[i]);

	c[n-1] = a[n-1];
	for(i=n-2;i>=0;i--)
		c[i] = gcd(a[i], c[i+1]);

	max = gcd(b[0], c[0]);
	if(max < c[1]) max = c[1];
	for(i=1;i<n-1;i++) {
		tmp = gcd(b[i], c[i]);
		if(max < tmp) max = tmp;
		tmp = gcd(b[i-1], c[i+1]);
		if(max < tmp) max = tmp;
	}
	if(max < b[n-2]) max = b[n-2];
	tmp = gcd(b[n-1], c[n-1]);
	if(max < tmp) max = tmp;

	printf("%d", max);
	
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

string s[410];
int h, w;
bool used[410][410] = {false};
ll black, white;
void dfs(int x, int y){
    // cout << "pos " << x << ", "  << y << endl;
    used[x][y]=true;
    if(s[x][y]=='#')black++;
    else white++;
    if(x+1<h&&s[x+1][y]!=s[x][y]&&!used[x+1][y])dfs(x+1, y);
    if(x>0&&s[x-1][y]!=s[x][y]&&!used[x-1][y])dfs(x-1, y);
    if(y+1<w&&s[x][y+1]!=s[x][y]&&!used[x][y+1])dfs(x, y+1);
    if(y>0&&s[x][y-1]!=s[x][y]&&!used[x][y-1])dfs(x, y-1);
}
 
int main(){
    cin >> h >> w;
    rep(i, h)cin >> s[i];

    ll ans = 0;
    rep(i, h)rep(j, w){
        if(s[i][j]=='#'&&!used[i][j]){
            black = white = 0;
            dfs(i, j);
            ans += black*white;
            // cout << "----done----\n";
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    int s[1000010]{};
    sort(A,A+N);
    if(A[0]==1){
        if(A[1]==1){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
        return 0;
    }
    int ans=0;
    int x=-1;
    rep(i,N){
        if(x==A[i]){
            s[x]++;
            continue;
        }
        x=A[i];
        if(x==1)continue;
        s[x]--;
        while(x<=1000000){
            s[x]+=2;
            x+=A[i];
        }
        x=A[i];

    }
    rep(i,1000010){
        if(s[i]==1)ans++;
    }
    cout << ans << endl;


    



}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> have(n);
    int ans = 0;
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int a; cin >> a;
            a--;
            have[a] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if (!have[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=0;
    bool f;
    while(true)
    {
        if(i%2==0)
        {
            if(c>b)
                c-=b;
            else
            {
                f=true;
                break;
            }
        }
        else
        {
            if(a>d)
                a-=d;
            else
            {
                f=false;
                break;
            }
        }
        i++;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include<utility>
#include<map>
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

using  namespace std;

int main()
{
    ll n,k;
    cin>>n>>k;
    ll w[n]={0},v[n]={0},dp[k+1]={0},i,j,maxi=0;
    for(i=0;i<n;i++)
    {
        std::cin >> w[i]>>v[i];
        for(j=k-w[i];j>=0;j--)
        {
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    for(j=0;j<k+1;j++)
    maxi=max(dp[j],maxi);
    std::cout << maxi << std::endl;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d", $n);
$p = explode(' ', trim(fgets(STDIN)));
$x = 0;
for ($i = 0; $i < $n - 1; $i++) {
	$q = $i + 1;
	if ($p[$i] == $q) {
		list($p[$i], $p[$i+1]) = [$p[$i+1], $p[$i]];
		$x++;
	}
}
if ($p[$n-1] == $n) $x++;
echo $x;

Measured memory_bytes: 12792
#include<stdio.h>
int main(void)
{
	int a[100],b[100],c[100],n,x,y,z,i,j,k,d,e,f;
	d=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		a[i]=0;
		b[i]=0;
		c[i]=0;
	}
	scanf("%d",&x);
	for(i=0;i<x;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&y);
	for(i=0;i<y;i++){
		scanf("%d",&b[i]);
	}
	scanf("%d",&z);
		for(i=0;i<z;i++){
			scanf("%d",&c[i]);
		}
		d=z;
	for(i=0;i<x;i++){
		for(j=0;j<z;j++){
			if(a[i]==c[j]) d=d-1;
			for(k=0;k<y;k++){
				if(c[j]==b[k] && a[i]==c[j]) d=d+1;
			}
		}
	}
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2088
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll dp[200005][2] = {};

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	fill(dp[0], dp[200005], -LINF);
	dp[0][0] = 0;
	dp[1][0] = 0;

	rep(i, n){
		if(i % 2){
			if(i >= 2) chmax(dp[i][0], dp[i - 2][0] + a[i]);
			else chmax(dp[i][0], a[i]);
			if(i >= 3) chmax(dp[i][0], dp[i - 3][0] + a[i]);
			if(i >= 4) chmax(dp[i][0], dp[i - 4][1] + a[i]);
			if(i >= 5) chmax(dp[i][0], dp[i - 5][1] + a[i]);
			if(i >= 2) chmax(dp[i][1], dp[i - 2][1] + a[i]);
			else chmax(dp[i][1], a[i]);
			if(i >= 3) chmax(dp[i][1], dp[i - 3][1] + a[i]);
		}else{
			if(i >= 2) chmax(dp[i][0], dp[i - 2][0] + a[i]);
			else chmax(dp[i][0], a[i]);
			if(i >= 3) chmax(dp[i][0], dp[i - 3][1] + a[i]);
			if(i >= 4) chmax(dp[i][0], dp[i - 4][1] + a[i]);
			if(i >= 2) chmax(dp[i][1], dp[i - 2][1] + a[i]);
			else chmax(dp[i][1], a[i]);
		}
	}

	ll ans = -LINF;
	if(n % 2){
		chmax(ans, dp[n - 1][0]);
		chmax(ans, dp[n - 2][1]);
		chmax(ans, dp[n - 3][1]);
	}else{
		chmax(ans, dp[n - 1][1]);
		chmax(ans, dp[n - 2][1]);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 8000
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    long long int n;
    
    cin >> n;
    
    long long int ans = n - 1;
    long long int wk = 0;
    for(long long int i = 1; i * i <= n; i++){
        if(n % i == 0){
            wk = i - 1;
            wk += (n / i) -1;
            if(wk < ans)ans = wk;
        }
    }
    
    cout << ans << endl;
    
    return 0;
    
}


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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
S = input()

if S == "SUN":
    print("7")
elif S == "SAT":
    print("1")
elif S == "FRI":
    print("2")
elif S == "THU":
    print("3")
elif S == "WED":
    print("4")
elif S == "TUE":
    print("5")
elif S == "MON":
    print("6")


Measured memory_bytes: 2940
#include <stdio.h>

int GCD(int a, int b) {
  if (b == 0) {
    return a;
  }
  return GCD(b, a % b);
}

int main(void) {
  int x, y;
  scanf("%d %d", &x, &y);

  printf("%d\n", GCD(x, y));

  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

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

        String str = scanner.next();

        scanner.close();

        if (str.matches("[A-Z]+")) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }

    }
}


Measured memory_bytes: 35652
def main():
    n = int(input())
    anag = {}
    for i in range(n):
        s = sorted(input())
        if not str(s) in anag.keys():
            anag[str(s)] = 1
        else:
            anag[str(s)] += 1
    s = 0
    for k in anag.keys():
        s += anag[k]*(anag[k]-1)//2
    print(s)


if __name__ == "__main__":
    main()

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



ll gcd(ll a, ll b){
	if(b ==0) return a;

	return gcd(b, a%b);
}

vector<ll> primes(ll x) {
     vector<ll> ret;
     for (ll i = 2; i * i <= x; i++) {
         if (x % i == 0) {
             ret.push_back(i);
             while (x % i == 0) {
                 x /= i;
             }
         }
     }
     if(x != 1) ret.push_back(x);
     return ret;
 }


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


	ll a,b;cin>>a>>b;

	ll n = gcd(a,b);

	writeln(primes(n).size()+1);
}




Measured memory_bytes: 256
n, p = map(int, input().split())

import math
def div(m):
    d = {}
    temp = int(math.sqrt(m))+1
    for i in range(2, temp):
        while m%i== 0:
            m //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[m] = 1
    else:
        if m in d:
            d[m] += 1
        elif m != 1:
            d[m] =1
    return d

d = div(p)
#print(d)
ans = 1
for k, v in d.items():
    if v >= n:
        q = v//n
        ans *= k**q
print(ans)


Measured memory_bytes: 38512
<?php
$a_b = explode(" ", trim(fgets(STDIN)));

if($a_b[1] == 1) {
    echo 0;
} else {
    $count = $a_b[0];
    
    $tap = 1;
    for ($i = 0; $i < 10000; $i++) {
         if($count >= $a_b[1]){
             break;
         }
         $count += $a_b[0] - 1;
         $tap++;
    }
    
    echo $tap;
}

Measured memory_bytes: 4856
#include<iostream>

int main(void){
    int a, b, c, k;
    std::cin >> a >> b >> c >> k;
    int ans;
    while(true){
	if(k <= a){
	    ans = k;
	    break;
	}else{
	    ans = a;
	    k -= a;
	}
	if(k <= b){
	    break;
	}else{
	    k -= b;
	}
	ans -= k;
	break;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  
  ll ans = 0;

  for (ll b = 1; b <= n; b++) {
    ll p = n / b;
    ll r = n % b;
    ans += p * max(0ll, b - k);
    ans += max(0ll, r - k + 1);
  }
  if (k == 0)
    ans -= n;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,C[500],S[500],F[500];
    cin>>n;
    rep(i,n-1) cin>>C[i]>>S[i]>>F[i];
    rep(i,n){
        ll ans=0;
        rep(j,n-1-i){
            if(ans<=S[j+i]) ans=S[j+i]+C[j+i];
            else ans+=(F[j+i]-ans%F[j+i])%F[j+i]+C[j+i];
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 256
S = input()

keyword = "keyence"

if S[0] != 'k':
    if S[-7:] == keyword:
        print("YES")
    else:
        print("NO")
elif S[-1] != 'e':
    if S[:7] == keyword:
        print("YES")
    else:
        print("NO")
else:
    for i in range(1, len(keyword)):
        if S[:i] == keyword[:i] \
            and S[-7+i:] == keyword[-7+i:]:
            print("YES")
            exit(0)
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 100000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define pi atan(1)*4
#define ALL(x) x.begin(),x.end()
#define int ll

int n,k;
pair<int,int>pa[200];
int dp[105][200005];

main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++) cin>>pa[i].F>>pa[i].S;
	sort(pa,pa+n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(i==0)
			{
				if(j>=pa[i].F) dp[i][j]=pa[i].S;
				else dp[i][j]=0;
				continue;
			}
			dp[i][j]=0;
			if(j>=pa[i].F){
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-pa[i].F]+pa[i].S);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n-1][k]<<endl;
}

Measured memory_bytes: 155136
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define in insert
#define bs binary_search   

ll opc(ll arr[],int n,ll dp[],int k)
{
    ll a=10000000000;
    if(n<=0)
        return 0;
    else if(dp[n]!=-1)
        return dp[n];
    else
    {
        for(int i=1;i<=k;i++)
        {
            if(n-i>=0)
            a=min(a,opc(arr,n-i,dp,k)+abs(arr[n]-arr[n-i]));
            else
            break;
        }
        dp[n]=a;
        return dp[n];
    }
}
int main()
{
    int n,k;
    cin>>n>>k;
    ll arr[n];
    ll dp[n];
    for(int i=n-1;i>=0;i--)
    {
        cin>>arr[i];
        dp[i]=-1;
    }
    cout<<opc(arr,n-1,dp,k);
    return 0;
}

Measured memory_bytes: 11136
# -*- coding utf-8 -*-

N = int(input())

rest = {}
cities = []
for i in range(N):
    k, s = input().split()
    if k not in rest:
        rest[k] = []
        cities.append(k)
    rest[k].append([int(s), i + 1])

cities.sort()
for k in cities:
    rest[k].sort(reverse=True)
    for r in rest[k]:
        print(r[1])


Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    

    int m,d;
    cin >> m >> d;

   

    ll ans = 0;
    rep(i,1,m+1){
	rep(j,1,d+1){
	    int d1 = j%10,d10 = j/10;
	    if(d1 >= 2 && d10 >= 2 && d1*d10 == i)ans++;
	}
    }
    P(ans);
    
    return  0;
}


Measured memory_bytes: 256