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

int main() {
  int N;
  cin >> N;
  int res = 0;
  for (int i = 0; i < 9; i++) {
    if ((N % (i+1)) == 0) {
      if ((N / (i+1)) < 10) {
        res++;
      }
    }
  }
  if (res != 0) {
    cout << "Yes" << endl;
  }
  else 
    cout << "No" << endl;
}


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

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

    int total = 0;

    if (N >= K) {
        total = X * K + Y * (N - K);
    } else {
        total = X * N;
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
     
    int main() {
        ios_base::sync_with_stdio(false);
     
        string s;
        cin >> s;
      
      	int n = s.size();
     
      	if(n & 1) {
         	cout << "No" << endl;
          	return 0;
        }  
        bool bad = false;
     
        for(int i = 0; i < n; i++) {
            if(i & 1) {
                if(s[i] != 'i') bad = true;
            }
            else {
                if(s[i] != 'h') bad = true;
            }
        }
     
        if(bad) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
}



Measured memory_bytes: 36080
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,d=map(int, input().split())
    x=abs(a-b)
    y=abs(c-b)
    z=abs(c-a)
    if z<=d or (x<=d and y<=d):
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 100005
#define MAXM 200005
int n,a[MAXN];
int main()
{
	read(n);
	for(rei i=1;i<=n;++i) read(a[i]);
	for(rei i=2;i<=n;++i)
	{
		if(a[i]>=a[i-1]) continue;
		if(a[i]+1>=a[i-1]) ++a[i];
		else {puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    char s[6];
    while(scanf("%s",s)!=EOF)
    {
        int flag=0;
        for(int i=0;i<strlen(s)-1;i++)
        {
            if(s[i]=='A'&&s[i+1]=='C')
                {
                    printf("Yes\n");
                    flag=1;
                    break;
                }
        }
        if(!flag)
            puts("No");
    }
    return 0;


}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
def f(x):
    m=0
    while x>0:
        m+=x%10
        x=x//10
    return m
ans=0
for i in range(n):
    
    if a<=f(i+1)<=b:
        ans+=i+1
print(ans)
    


Measured memory_bytes: 9084
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

lcs = 1
for i in range(N):
    lcs = (lcs * A[i]) // gcd(lcs, A[i])
ans = 0
for i in range(N):
    ans += (lcs-1) % A[i]
print(ans)


Measured memory_bytes: 5344
import Control.Monad                                                                                                       
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [h,_] <- map read . words <$> getLine :: IO [Int]                                                                        
  cs <- replicateM h getLine                                                                                               
  putStrLn . unlines . concat $ zipWith (\x -> \y -> x:y:[]) cs cs

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

int main(){
    string s;
    cin >> s;
    if (s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}

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

struct Block {
    int x, y;
};

int main()
{
    int h, w, d;
    long long *sum_table;
    Block *table;
    scanf("%d%d%d", &h, &w, &d);
    table = new Block[w * h];
    sum_table = new long long[w * h];
    for (int i = 0; i < d; i++) sum_table[i] = 0;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            int a;
            scanf("%d", &a);
            table[a - 1].x = j;
            table[a - 1].y = i;
        }
    }
    for (int i = d; i < w * h; i++)
    {
        sum_table[i] = sum_table[i - d] + std::abs(table[i].x - table[i - d].x) + std::abs(table[i].y - table[i - d].y);
    }

    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        int l, r;
        long long count{};
        scanf("%d%d", &l, &r);
        l--;
        r--;
        printf("%lld\n", sum_table[r] - sum_table[l]);
    }

    delete[] table;
    delete[] sum_table;
    return 0;
}

Measured memory_bytes: 2560
// D - Xor Sum 4
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007

int main(){
	int N; cin>>N;
	vector<ll> A(N); rp(i,0,N) cin>>A[i];
	ll ans = 0;
	rp(i, 0, 60){
		ll z=0,o=0; rp(j,0,N) if(A[j]>>i&1) o++; else z++;
		ans = (ans + (z*o % MOD) * ((1LL<<i) % MOD)) % MOD;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 2560
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;
const long double EPS = 1e-7;

long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N >> L >> R;
	vector<pair<int, int>>v(N);
	vector<int>cmin(N, MOD);
	for (int i = 0; i < N; i++) {
		cin >> v[i].first >> v[i].second;
		v[i].first--;
		cmin[v[i].first] = min(cmin[v[i].first], v[i].second);
	}
	vector<long long int>num(N);
	for (int i = 0; i < N; i++) {
		if (v[i].second <= L - cmin[v[i].first]) {
			v[i].second = cmin[v[i].first];
		}
	}
	vector<long long int>by(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	int f = 0, s = 0;
	for (int i = 0; i < N; i++) {
		if (cmin[i] == MOD)continue;
		if (cmin[f] > cmin[i]) {
			s = f;
			f = i;
		}
		else if (cmin[s] > cmin[i]) {
			s = i;
		}
	}
	long long int sum = 0;
	for (int i = 0; i < N; i++) {
		if (v[i].first == f) {
			if (v[i].second <= R - cmin[s]) {
				num[v[i].first]++;
				sum++;
			}
		}
		else {
			if (v[i].second <= R - cmin[f]) {
				num[v[i].first]++;
				sum++;
			}
		}
	}
	long long int ans = by[sum];
	for (int i = 0; i < N; i++) {
		ans *= power(by[num[i]], MOD - 2, MOD);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT {  // [L, R)
    int NV; vector<V> bit; void init(int n) { NV = 1; while (NV < n) NV *= 2; bit.resize(NV); }
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;}
    V get(int L, int R) {assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;}
    void clear() { bit.clear(); }};
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/





int N, Q;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> Q;

    BIT<int> bit;
    bit.init(N);

    rep(q, 0, Q) {
        int a, b, c; cin >> a >> b >> c;
        if (a == 0) bit.add(b - 1, c);
        else {
            int ans = bit.get(b - 1, c);
            printf("%d\n", ans);
        }
    }
}

Measured memory_bytes: 3244
from collections import defaultdict
# import sys
# input = sys.stdin.readline


def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num - 1)]
    graph_data = defaultdict(set)
    for i in range(num - 1):
        a, b = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)

    black, white = 0, 0
    b_ind_now, w_ind_now = set(), set()
    b_ind_next, w_ind_next = set(), set()
    # b_ind_pre, w_ind_pre = set(), set()
    pre_ind = set()
    b_ind_now.add(1)
    w_ind_now.add(num)
    # b_ind_pre.add(1)
    # w_ind_pre.add(1)
    pre_ind.add(1)
    pre_ind.add(num)

    while len(b_ind_now) > 0 or len(w_ind_now) > 0:
        for ele_now in b_ind_now:
            for ele_next in graph_data[ele_now]:
                if ele_next in pre_ind:
                    continue
                pre_ind.add(ele_next)
                b_ind_next.add(ele_next)
                black += 1
        b_ind_now = b_ind_next
        b_ind_next = set()


        for ele_now in w_ind_now:
            for ele_next in graph_data[ele_now]:
                if ele_next in pre_ind:
                    continue
                pre_ind.add(ele_next)
                w_ind_next.add(ele_next)
                white += 1
        w_ind_now = w_ind_next
        w_ind_next = set()

        # print(white, black)

    if black > white:
        print('Fennec')
    else:
        print('Snuke')





if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

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

    string S;
    cin >> S;

    map<char, int> X;
    map<char, int> Y;

    int ans = 0;
    REP (i, N)
    {
        Y.clear();

        X[S[i]]++;

        FOR (j, i + 1, N)
        {
            Y[S[j]]++;
        }

        int a = 0;
        for (auto &x : X)
        {
            for (auto &y : Y)
            {
                if (x.first == y.first) a++;
            }
        }
        ans = max(ans, a);
    }

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


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

int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int H, W;
vector<string> mp;

void solve(int i, int j, int c){
  if(i<0 || H<=i || j<0 || W<=j || mp[i][j]!=c)return;
  mp[i][j]='a';
  for(int k=0; k<4; k++){
    solve(i+dir[k][0], j+dir[k][1], c);
  }
}

int main(){
  while(true){
    cin >> H >> W;
    if(H==0 && W==0)break;
    mp.clear();
    for(int i=0; i<H; i++){
      string tmp;
      cin >> tmp;
      mp.push_back(tmp);
    }
    int cn=0;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(mp[i][j]!='a'){
          cn++;
          solve(i, j, mp[i][j]);
        }
      }
    }
    cout << cn << endl;
  }
  return 0;
}

Measured memory_bytes: 1856
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    ll sum2 = 0;
    rep(i, N) {
        sum += A[i];
        sum %= mod;
        sum2 += A[i] * A[i];
        sum2 %= mod;
    }
    ll ans = sum * sum % mod;
    ans -= sum2;
    (ans += mod) %= mod;
    (ans *= inv_mod(2, mod)) %= mod;
    output(ans);
    
    
    
    return 0;
}


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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = INT_MAX;

ll power(int a, int n, int mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
int gcd(int a,int b){ return __gcd(a,b);}
int lcm(int a,int b){return a*b/__gcd(a,b);}
vector<vector<int>> adj;
bool visited[mxn];


void solve(ll test){


    ll h,w,m;
    cin >> h >> w >> m;

    map<ll,ll> row;
    map<ll,ll> col;
    map<pp,ll> target;

    for(int i=0 ; i<m ; i++) {
        ll x,y;
        cin >> x >> y;
        target[{x,y}]++;
        row[x]++;
        col[y]++;
    }

    vpp r;
    vpp c;
    for(auto i : row) {
        r.pb({i.se,i.fi});
    }
    for(auto i : col) {
        c.pb({i.se,i.fi});
    }

    sort(all(r),greater<pp>());
    sort(all(c),greater<pp>());


    ll index1 = 0;
    while(r[index1].fi == r[index1+1].fi && index1+1 < r.size()) {
        index1++;
    }

    ll index2 = 0;
    while(c[index2].fi == c[index2+1].fi && index2+1 < c.size()) {
        index2++;
    }

    // deg(index1);
    // deg(index2);
    ll ans = -inf;
    for(ll i=0 ; i<=index1 ; i++) {
        bool ok = 0;
        for(ll j=0 ; j<=index2 ; j++) {
            if(target[{r[i].se,c[j].se}]) {
                ll temp = (r[i].fi+c[j].fi)-1;
                ans = max(temp,ans);
            }
            else{
                ll temp = (r[i].fi+c[j].fi);
                ans = max(ans,temp);
                ok = 1;
                break;
            }
        }
        if(ok)break;
    }

    cout << ans;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 67844
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    long long x;
    cin >> x;
    long long sen = x / 500;
    long long go = (x - 500 * (x / 500)) / 5;
    cout << 1000 * sen + 5 * go << endl;
}

Measured memory_bytes: 256
a = input()
x = ['2','4','5','7','9']
y = ['0','1','6','8']
z = ['3']
if len(a) == 1:
    if a in x:
        print('hon')
        exit()
    elif a in y:
        print('pon')
        exit()
    elif a in z:
        print('bon')
        exit()

a = a[::-1]
if a[0] in x:
        print('hon')
elif a[0] in y:
        print('pon')
elif a[0] in z:
        print('bon')

Measured memory_bytes: 9148
class Pizza:
  def __init__(self, price, count = 0):
    self.price = price
    self.count = count
    
  def count_pay(self):
  	return self.price * self.count
  
  def add_count(self,n):
    self.count += n
    if self.count <= 0:
      self.count = 0
      
A, B, C, X, Y = map(int, input().split())
P_A = Pizza(A,X)
P_B = Pizza(B,Y)
P_AB = Pizza(C)

i = 0
pay_list = []
while i <= max(X, Y):
  pay = P_A.count_pay() + P_B.count_pay() + P_AB.count_pay()
  pay_list.append(pay)
  P_A.add_count(-1)
  P_B.add_count(-1)
  P_AB.add_count(2)
  i += 1

print(min(pay_list))

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

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    int h[N];

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

    sort(h,h+N);

    int ans = 1000000001;

    for(int i = 0;i < N -K+1; i++){
        int minp = h[K-1+i] - h[i];
        if(ans > minp){
            ans = minp;
        }
    }
    
    cout << ans << endl;
    return 0;
}

    

Measured memory_bytes: 640
/* 	   Dsingh_24 	 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define N  1000005
ll a[1000006];
ll sieve(){
	ll i,j;
	for(i=2;i<=N;i++){
		for(j=2*i;j<=N;j+=i)
			a[j]=1;
	}
}
signed main()
{
	ios
	ll n,i,j,p,pp;
	cin>>n>>p;pp=p;
	map<ll,ll>m;
	if(n==1){cout<<p;return 0;}
	for(i=2;i*i<=p;i++){
		if(a[j]==0){
			ll cnt=0;
			while(pp%i==0){
				pp/=i;cnt++;
			}
			m[i]=cnt;
		}
	}
	ll ans=1;
	for(auto i:m){
		if(i.S>=n){
			while(i.S>=n){
				ans*=i.F;
				i.S-=n;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
struct node{
	long long times, num;
};
long long a[100001];
node b[100001];
int cmp(node x, node y){
	return x.num>y.num;
}
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	for (int i=1;i<=m;i++)
		cin >> b[i].times >> b[i].num;
	sort (a+1,a+n+1);
	sort (b+1,b+m+1,cmp);
	long long j=1;
	long long cnt=0;
	for (int i=1;i<=n;i++){
		if (cnt==b[j].times){
			j++;
			cnt=0;
		}
		if (j>m||b[j].num<=a[i]) break;
		cnt++;
		a[i]=b[j].num; 
	}
	long long ans=0;
	for (int i=1;i<=n;i++) 
		ans+=a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: String,
        _t: String,
        a: u32,
        b: u32,
        u: String
    }
    let mut a = a;
    let mut b = b;
    if u == s {
        a -= 1;
    } else {
        b -= 1;
    }
    println!("{} {}", a, b);
}
/* vim:set foldmethod=marker: */


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

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

  if(N >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3628
n, m = map(int, input().split())
cakes = []
ans = 0
for i in range(n): cakes.append(list(map(int, input().split())))
for x in [1, -1]:
    for y in [1, -1]:
        for z in [1, -1]:
            tmp = []
            tmpans = 0
            for cake in cakes: tmp.append(x * cake[0] + y * cake[1] + z * cake[2])
            tmp.sort(reverse = True)
            for i in range(m): tmpans += tmp[i]
            ans = max(ans, tmpans)
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;
typedef long double ld;
static const ld PI = 3.14159265358979323846264338327950;
int main()
{
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld theta = h / (ld)6 * PI+m/(ld)360*PI;
    ld phi = m / (ld)30 * PI;
    ld psi = theta - phi;
    ld ans = a * a + b * b - 2 * a * b * cosl(psi);
    ans = sqrtl(ans);
    cout <<fixed<<setprecision(15)<< ans << endl;
    return 0;
}

Measured memory_bytes: 4116
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String arg[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int H = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());
        boolean visited[][] = new boolean[H][W];
        Queue<Point> q = new LinkedList<>();
        for(int i=0;i<H;i++){
            st = new StringTokenizer(br.readLine());
            String value = st.nextToken();
            for(int j=0;j<W;j++) {
                char c = value.charAt(j);
                if (c == '#') {
                    q.add(new Point(i,j));
                    visited[i][j] = true;
                }
            }
        }
        q.add(new Point(-1,-1));
        int op = 0;
        boolean trigger = false;
        while(!q.isEmpty()){
            Point p = q.poll();
            if(p.H==-1&&p.W==-1){
                if(trigger) {
                    op++;
                    q.add(new Point(-1, -1));
                    trigger = false;
                }
                continue;
            }
            int dr[] = {-1, 0, 0, 1};
            int dc[] = { 0,-1, 1, 0};
            for(int i=0;i<4;i++){
                int nH = p.H+dr[i];
                int nW = p.W+dc[i];
                if(nH<0||nH>=H){
                    continue;
                }
                if(nW<0||nW>=W){
                    continue;
                }
                if(visited[nH][nW]){
                    continue;
                }
                visited[nH][nW] = true;
                q.add(new Point(nH,nW));
                trigger = true;
            }
        }
        System.out.println(op);
    }
}

class Point{
    int H;
    int W;
    Point(int H,int W){
        this.H = H;
        this.W = W;
    }
}


Measured memory_bytes: 119492
a = input()
ans = 0
for i in range(1, len(a)):
  df = a[:i]
  sm = a[i:]
  if sm[0] == "0":continue
  df = int(df)
  sm = int(sm)
  if (df + sm) % 2 == 0 and sm >= df and (sm - df) % 2 == 0:
    ans += 1
if int(a) % 2 == 0:ans += 1
print(ans)


Measured memory_bytes: 5596
N = int(input())
t_x_y = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]
flag = True
for i in range(1, N + 1):
    d = t_x_y[i][0] - t_x_y[i-1][0] - abs(t_x_y[i][1] - t_x_y[i-1][1]) - abs(t_x_y[i][2] - t_x_y[i-1][2])
    if d < 0 or d % 2:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62040
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
long long MIN(long long x, long long y) { return x < y ? x : y; }
long long MAX(long long x, long long y) { return x > y ? x : y; }
#define lowbit(x) ((x) & (-(x)))
typedef long long ll;
const int MAXN = 57;
using namespace std;

int N , X , T;

int main() {
    scanf ("%d %d %d" , &N , &X , &T);
    printf ("%d\n" , (N / X + (N % X != 0)) * T);
    return 0;
}


Measured memory_bytes: 3824
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int a = scan.nextInt();
			a += scan.nextInt();
			
			int count = 1;
			while (a >= 10) {
				//System.out.println(a);
				count++;
				a /= 10;
			}
			System.out.println(count);
		}
	}

}

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

int msb (int i) {
  while (i >= 10) i /= 10;
  return i;
}

int main() {
  int n;
  cin >> n;
  int cnt[10][10] = {};
  for (int i = 1; i <= n; ++i) {
    cnt[msb(i)][i%10]++;
  }
  long long ans = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      ans += 1ll * cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
}

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

inline int readInt(){
  int ret = 0;
  char c;
  while((c=getchar()) && isdigit(c)){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

void outint(int a){
  if (a == 0)return;
  outint(a/10);
  putchar('0' + a%10);
}

main(){
  int n,s;
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    int r[101]={0};
    int sum[101];
    for(int i=0;i<n;i++){
      int tmp;tmp=readInt();r[tmp]++;
    }
    sum[0] = 0;
    for(int i=0;i<101;i++){
      sum[i] = sum[i-1] + r[i];
    }
    int ans = 0;
    for(int i=1;i != 101;i++){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      for(int j=i+1;j<101;j++){
	//if (i+j>s)ans += r[i]*r[j];
	if (i+j > s){
	  ans += r[i] * (sum[100] - sum[j-1]);
	  break;
	}
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a + b == c || b + c == a || c + a == b) System.out.println("Yes");
		else System.out.println("No");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <double> v(N);
  for (int i = 0; i < N; i++) {
	  cin >> v[i];
	}
  sort(v.begin(), v.end());
  for (int i = 0; i < N - 1; i++) {
	  v[i + 1] = (v[i + 1] + v[i]) / 2.0;
	}
  cout <<  v[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;


int main(){

	string s;
    cin >> s;
    bool ans = true;
    for (int i = 0; i < s.length(); i++)
    {
       if(s[i] == 'L' && i%2 == 0){
           ans = false;
       }
       if(s[i] == 'R' && i%2 == 1){
           ans = false;
       }
    }
    
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

	return 0;
}


Measured memory_bytes: 256
object Main {
    def queens(n: Int, fix: List[(Int, Int)]): List[List[(Int, Int)]] = {
        def placeQueens(k: Int): List[List[(Int, Int)]] = {
            if(k == -1) List(List())
            else
                for {
                    queens <- placeQueens(k - 1)
                    col <- 0 to n - 1
                    queen = (k, col)
                    if isSafe(queen, queens)
                } yield queen :: queens
        }
         placeQueens(n - 1).filter(qs => check(fix, qs))
    }

    def isSafe(queen: (Int, Int), queens: List[(Int, Int)]) = {
        queens.forall(q => !inCheck(queen, q))
    }

    def inCheck(q1: (Int, Int), q2: (Int, Int)) = {
        q1._1 == q2._1 ||
        q1._2 == q2._2 ||
        (q1._1 - q2._1).abs == (q1._2 - q2._2).abs
    }

    def check(fix: List[(Int, Int)], queens: List[(Int, Int)]) =
        fix.forall(q => queens.contains(q))

    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        val fix = List.fill(n)(sc.nextInt, sc.nextInt)
        for(qs <- queens(8, fix)) {
            for(y <- 0 to 7) {
                for(x <- 0 to 7) {
                    print(if(qs.contains((y, x))) "Q" else ".")
                }
                println
            }
        }
    }
}

Measured memory_bytes: 50856
#include <iostream>

using namespace std;

int main(){
    int i,n,l,k;
    cin >> n >> l;;
    int a[n+1];
    for(i=1;i<=n;i++){
        cin >> a[i];
    }
    for(i=1;i<n;i++){
        if(a[i]+a[i+1]>=l){
            k = i;
            break;
        }
        if(i==n-1){
            cout <<"Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    for(i=1;i<k;i++){
        cout << i << endl;
    }
    for(i=n-1;i>k;i--){
        cout << i << endl;
    }
    cout << k << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll bunbo = 10;
    ll sum = 0;
    cin >> N;
    if(N % 2 == 0) {
        while(bunbo <= N) {
            sum += N / bunbo;
            bunbo *= 5;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

ull factorial(ull n) {
  ull result = 1;
  for (ull i=1; i <= n; ++i) {
    result *= i;
  }
  return result;
}

ull ncr(ull n, ull r) {
  return factorial(n) / factorial(r) * factorial(n-r);
}

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<string> s;
  each(i, n) {
    string tmp;
    cin >> tmp;
    std::sort(tmp.begin(), tmp.end());
    s.push(tmp);
  }

  unordered_map<string, ull> res = {};
  ull result = 0;
  each(i, n) {
    if (res.count(s[i]) > 0) {
      const auto current = res[s[i]];
      result += current;
      res[s[i]] = (current + 1);
    } else {
      res[s[i]] = 1;
    }
  }

  /*
  ull result = 0;
  for (const auto& v : res) {
    if (v.second == 1) {
    //} else if (v.second == 2) {
    } else {
      result += ncr(v.second, 2);
    }
  }
  */

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 11380
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int a , b , c;
	cin >> a >> b >> c;
	int ans = 0;
	ans += min(c , a);
	c -= min(c , a);
	ans += 2 * min(c , b);
	int tmp =  min(c , b);
	c -= tmp;
	b -= tmp;
	ans += b;
	ans += (c >= 1);
	cout << ans;	
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	
	if(b<a){
		x=a;
		a=b;
		b=x;
	
	}	
		if(c<a){
			x=a;
			a=c;
			c=x;
		
		}
	if(c<b){
		x=b;
		b=c;
		c=x;
	
	}	
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int f(float x)
{
	int ans = int(x);
	if (x - ans > 0)
		return ans;
	else
		return x;
}
int main()
{
	int a, b;
	cin >> a >> b;
	for (int i = a * 10; i <= b * 20; i++)
	{
		//cout << f(i * 0.08) << " " << f(i * 0.1)<<"  "<<i << endl;
		if (f(i * 0.08) == a && f(i * 0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

/* see https://github.com/pllk/cphb/ */
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;

typedef unsigned int uint;
typedef long long ll;
//typedef __int128 lll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> d(n);
    fori(n)
        cin>>d[i];
    sort(d.begin(), d.end());

    if(n&1) {
        cout<<0<<endl;
        return 0;
    }

    int ans=0;
    //if(d[n/2]!=d[n/2-1])
        ans=d[n/2]-d[n/2-1];
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

#define rep(i,n) for(int i=0; i<int(n); i++)

namespace std {
    template<typename T>
    T lcm(T a,T b){
        return a/__gcd(a,b)*b;
    }
}
 
int main(){
    long long cyc[3], a[3], m[3];

#define in(i) ,&a[i],&m[i]
#define o(i) |a[i]|m[i]
    
    while(scanf("%lld%lld%lld%lld%lld%lld" in(0)in(1)in(2)), 0 o(0)o(1)o(2)){
        rep(i,3){
            cyc[i]=0;
            int cnt=1,k=1;
            while(1){
                k*=a[i];
                k%=m[i];
                if(k==1){
                    cyc[i]=cnt; break;
                }
                cnt++;
            }
        }
        cout << lcm(lcm(cyc[0],cyc[1]),cyc[2]) << endl;
    }
}

Measured memory_bytes: 1192
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    s = input()
    k = int(input())

    substrs = set()
    for i in range(1, 5 + 1):
        for j in range(len(s) - i + 1):
            substrs.add(s[j:j + i])
    # print(substrs)
    print(sorted(list(substrs))[k - 1])


if __name__ == '__main__':
    main()

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

#ifdef _WIN32
#define scanfll(x) scanf("%I64d", x)
#define printfll(x) printf("%I64d", x)
#else
#define scanfll(x) scanf("%lld", x)
#define printfll(x) printf("%lld", x)
#endif
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>;
using ld = long double;  using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
string bits_to_string(ll mask, ll n) { string s; rep(i, n) s += '0' + !!(mask & (1ll << i)); return s; }
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll m = abs(a - c);
    ll n = abs(b - d);
    cout << m + n - __gcd(m, n) << endl;
    return 0;
}


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

int ind[202020];

int main(){
  int N; cin>>N;
  rep(i,N){
    int p; cin>>p; p--;
    ind[p]=i;
  }
  int ans=1,l=0;
  for(int r=1;r<N;r++){
    if(ind[r]>ind[r-1]) ans=max(ans,r+1-l);
    else l=r;
  }
  cout<<N-ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <queue>
using namespace std;
long long gcd(long long a, long long b){
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
long long lcm(long long a, long long b){
	if (b > a) swap(a, b);
	return a / gcd(a, b) * b;
}



int main(){
	int n;
	cin>>n;
	long long T[n];
	for(int i=0;i<n;i++){
		cin>>T[i];
	}
	if(n==1){
		cout<<T[0]<<endl;
		return 0;
	}
	long long ans = lcm(T[0],T[1]);
	for(int i=0;i<n-2;i++){
		ans = lcm(ans,T[2+i]);
	}
	cout<<ans<<endl;
		
	return 0;
}


Measured memory_bytes: 256