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

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

   int Nketa;
   Nketa = to_string(N).size();
   if (Nketa == 1)
      cout << N << endl;
   else if (Nketa == 2)
      cout << 9 << endl;
   else if (Nketa == 3)
      cout << 9 + (N-100+1) << endl;
   else if (Nketa == 4)
      cout << 909 << endl;
   else if (Nketa == 5)
      cout << 909 + (N-10000+1) << endl;
   else
      cout << 90909 << endl;

}



Measured memory_bytes: 256
l=int(input())
if l <= 1000:
  print(1000-l)
elif l <= 2000:
  print(2000-l)
elif l <= 3000:
  print(3000-l)
elif l <= 4000:
  print(4000-l)
elif l <= 5000:
  print(5000-l)
elif l <= 6000:
  print(6000-l)
elif l <= 7000:
  print(7000-l)
elif l <= 8000:
  print(8000-l)
elif l <= 9000:
  print(9000-l)
else:
  print(10000-l)

Measured memory_bytes: 9192
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(int i = 0; i < n; i++)
#define INF 100
#define DEBUG
using namespace std;


int main(){
	int n;
	while(cin>>n, n){
		int flag[n][30];
		rep(i, n){
			rep(j, 30){
				flag[i][j] = 0;
			}
		}
		rep(i, n){
			int m;
			cin>>m;
			rep(j, m){
				int d;
				cin>>d;
				flag[i][d-1] = 1;
			}
		}
		int days[n][n];//day[from][to]
		rep(i, n){
			rep(j, n){
				days[i][j] = (i == j)?0:INF;
			}
		}
		rep(day, 30){
			//¯¶úÉÉÈlª¢½çjÐªs«néÅáúª¨Ý¢ÉXV
			rep(i, n){
				for(int j = i+1; j < n; j++){
					if(flag[i][day] && flag[j][day]){
						//SÄÌkÉÂ¢ÄAk©çÌjÐÍi©jªàÁÄêÎAÅá¡úÈ~ÅiÆjÉ¢­
						rep(k, n){
							if(days[k][i] == INF && days[k][j] == INF)continue;
							days[k][i] = min(days[k][i], day);
							days[k][j] = min(days[k][j], day);
						}
					}
				}
			}
		}
		int day;
		bool goal = false;
		for(day = 0; day < 30 && !goal; day++){
			rep(i, n){
				bool flag = true;
				rep(j, n){
					flag = flag &(days[j][i] <= day);
				}
				if(flag){
					goal = true;
					break;
				}
			}
		}
		if(!goal)day = -1;
		cout<<day<<endl;
	}
	return 0;
}

Measured memory_bytes: 876
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
string s;

signed main(){
	cin >> s;
	int flag = true;
	if(s[0] != 'A') flag = false;
	
	int cnt = 0;
	for(int i=2; i<s.size()-1; i++){
		if(s[i] == 'C') cnt++;
	}
	if(cnt != 1) flag = false;

	int lower_cnt = 0;
	for(auto c: s){
		if(islower(c)) lower_cnt++;
	}
	if(lower_cnt != s.size() - 2) flag = false;
	 
	if(flag) cout << "AC" << endl;
	else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
a=[int(i) for i in input().split()]
ans=100000
for i in range(3):
    for j in range(3):
        for k in range(3):
            if i==j or i==k or j==k: continue
            ans=min(ans,abs(a[i]-a[j])+abs(a[j]-a[k]))
print(ans)

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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

typedef pair<lint, lint> P;

int main(){
    int N;
    lint W;
    cin >> N >> W;
    vector<lint> v1(N/2), v2(N-N/2), w1(N/2), w2(N-N/2);
    rep(i, N/2){
        cin >> v1[i] >> w1[i];
    }
    rep(i, N-N/2){
        cin >> v2[i] >> w2[i];
    }
    vector<P> s1, s2;
    for(int i = 0 ; i < (1 << N/2) ; i++){
        lint v = 0, w = 0;
        for(int j = 0 ; j < N/2 ; j++){
            if(i >> j & 1){
                v += v1[j];
                w += w1[j];
            }
        }
        s1.push_back(make_pair(w, v));
    }
    for(int i = 0 ; i < (1 << N-N/2) ; i++){
        lint v = 0, w = 0;
        for(int j = 0 ; j < N-N/2 ; j++){
            if(i >> j & 1){
                v += v2[j];
                w += w2[j];
            }
        }
        s2.push_back(make_pair(w, v));
    }
    s2.push_back(make_pair(LLINF, 0));
    SORT(s2);
    rep(i, s2.size()-1){
        s2[i+1].second = max(s2[i+1].second, s2[i].second);
    }
    repr(i, s2.size()-1){
        if(s2[i].first == s2[i+1].first){
            s2[i].second = max(s2[i].second, s2[i+1].second);
        }
    }
    lint ans = 0;
    rep(i, s1.size()){
        lint tmpw = W - s1[i].first, tmpv = s1[i].second;
        int left = 0, right = s2.size() - 1, mid;
        while(left < right){
            mid = (left + right) / 2;
            if(s2[mid].first <= tmpw && tmpw < s2[mid+1].first){
                ans = max(ans, tmpv + s2[mid].second);
                break;
            }else if(tmpw < s2[mid].first){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 52224
#include <vector>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;



int main(void){

  vector<int> a,b;

  int A,B,C;
  
  int ans;
  
  cin >> A >> B >> C ;

 if(A> (B + C)){
   ans = 0;
 }else{
   ans = B + C - A;
 }
 

  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    vector<ll> vec(n);

    rep(i, n)
    {
        cin >> vec[i];
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int cnt=0;

    ll sum=vec[0];
int i=1;
    for(;i<n/2; i++)
    {
        sum+=vec[i]*2;
    }

    if(n%2==1) sum+=vec[i]; 


    cout << sum << endl;








    return 0;

}


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

int f(int n) {
    if (n % 2) return n * 3 + 1;
    return n / 2;
}

int main() {
    vector<bool> ap(1000006);
    int n;
    cin >> n;
    for (int i = 1; i <= 1000006; i++) {
        if (ap[n]) {
            cout << i << endl;
            return 0;
        }
        ap[n] = true;
        n = f(n);
    }
}

Measured memory_bytes: 384
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_059_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(32).
    01 s1     PIC X(10).
    01 s2     PIC X(10).
    01 s3     PIC X(10).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO s1 s2 s3.

    MOVE FUNCTION UPPER-CASE(s1) TO s1.
    MOVE FUNCTION UPPER-CASE(s2) TO s2.
    MOVE FUNCTION UPPER-CASE(s3) TO s3.

    DISPLAY s1(1:1) s2(1:1) s3(1:1).

    STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e2+5;
int n;
string s;
vector<int> acc[3];
int solve(int d, int st, char c)
{
	int ret = 0;

	if (c == 'R') ret = acc[0][n-1] - acc[0][st];
	if (c == 'G') ret = acc[1][n-1] - acc[1][st];
	if (c == 'B') ret = acc[2][n-1] - acc[2][st];

	if (st + d < (int)s.size() && s[st + d] == c) ret--;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> s;
	for (auto i : s)
	{
		acc[0].pb((i == 'R') + (acc[0].size() ? acc[0].back() : 0));
		acc[1].pb((i == 'G') + (acc[1].size() ? acc[1].back() : 0));
		acc[2].pb((i == 'B') + (acc[2].size() ? acc[2].back() : 0));
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (s[i] == s[j]) continue;

			if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R'))
				ans += solve(j - i, j, 'B');

			if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R'))
				ans += solve(j - i, j, 'G');

			if ((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B'))
				ans += solve(j - i, j, 'R');
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

long long MOD = 1000000007;
int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
A = list(map(int,input().split()))
b,g,r = sorted(A[0:3])
n = A[3]
count = 0
rr = 0
gg = 0
while n - r*rr >= 0:
  N = n - r*rr
  while True:
    if N - g*gg < 0:
      break
    elif (N - g*gg) % b == 0:
      count+=1
      gg+=1
    else:
      gg+=1
  rr+=1
  gg=0
print(count)

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, long long D, std::vector<long long> X,
           std::vector<long long> Y) {
    int cnt = 0;
    rep(i, N) {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D) cnt++;
    }
    cout << cnt << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long D;
    scanf("%lld", &D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6428
#include <stdio.h>
int main(){
 int N,judge=1;
 scanf("%d",&N);
 int A[N];
 for(int i=0;i<N;i++){
  scanf("%d",&A[i]);
  if(A[i]%2==0){
  if(A[i]%3==0||A[i]%5==0);
   else judge=0;
   }
 }
 if(judge==1)printf("APPROVED");
   else printf("DENIED");
 return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

signed main(){
 int N;
 cin >> N;
 vector<vector<ll> > f(N);
 vector<vector<ll> > p(N,vector<ll>(11));
 for(int i=0;i<N;i++){
   for(int j=0;j<10;j++){
     ll a;
     cin >> a;
     f[i].push_back(a);
   }
 }
 for(int i=0;i<N;i++){
   for(int j=0;j<11;j++){
     cin >> p[i][j];
   }
 }
 ll ans = LLONG_MIN;
 vector<ll> a(N+1);
 for(ll key=1;key<(1<<10);key++){
   ll sum = 0;
   for(ll i=0;i<10;i++){
     if(key&(1<<i)){
       for(ll j=0;j<N;j++){
         if(f[j][i]) a[j]++;
       }
     }
   }
   for(ll i=0;i<N;i++){
     sum += p[i][a[i]];
   }
   if(ans<sum){
     ans = sum;
   }
   for(ll i=0;i<N;i++) a[i]=0;
 }
 cout << ans << endl;
}

Measured memory_bytes: 256
def Qa():
    n = input()
    if n[-1] in ['2', '4', '5', '7', '9']:
        print('hon')
    elif n[-1] in ['0', '1', '6', '8']:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    Qa()


Measured memory_bytes: 8964
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,d,x;
  cin >>n >> d >> x;
  
  int eat = 0;
  
  vector<int> p(n);
  rep(i,n){
  cin >>p[i];
  eat+=(d-1)/p[i]+1;
  }
    
  cout << eat+x << endl;  
  
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int k = log10(i);
        if(k % 2 == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> fld(n);
  FOR(s,fld) {
    cin >> s;
  }
  int count = 0;
  REP(k,0,n) {
    bool ok = true;
    REP(i,0,n) {
      REP(j,0,n) {
        if(fld[(i+k) % n][j] != fld[(j+k) % n][i]) {
          ok = false;
        }
      }
    }
    if(ok) {
      count++;
    }
  }
  cout << count * n << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    int main() {
        int n;
        cin >> n;
        if(n==1){
            cout<<"Hello World"<<endl;
        }else{
            int a,b;
            cin >> a>>b;
            cout<<a+b<<endl;
        }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << (b / 2) << endl;
    else cout << 0 << endl;
    return 0;
}


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

#define ll long long
#define y1 caibictq
#define P pair<int, int>
#define fi first
#define se second

using namespace std;

const int MAXN = 200010;
const int MAXM = 100010;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int n, m, k;
int tot, cnt, ans;

int read() {
	int f = 1, s = 0;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 1) + (s << 3) + ((int)ch ^ 48); ch = getchar();}
	return s * f;
}

int a[MAXN], b[MAXN];

string s;

int main() {
	int T;
	cin >> s;
	s = 'S' + s;
//	int tot = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] == 'S' && s[i] == 'R') {
			tot = 1;
		}
		else if (s[i - 1] == 'R' && s[i] == 'R') {
			++tot;
		}
		ans = max(ans, tot);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3724
#include <stdio.h>
int main(void)
{
  int h[3][2],m[3][2],s[3][2],ans[3][3];
  int i,a,b,c;
  for(i=0;i<3;i++){
    scanf("%d %d %d %d %d %d",
	  &h[i][0],&m[i][0],&s[i][0],&h[i][1],&m[i][1],&s[i][1]);
    a=h[i][0]*3600+m[i][0]*60+s[i][0];
    b=h[i][1]*3600+m[i][1]*60+s[i][1];
    c=b-a;
    ans[i][0]=c/3600;
    c%=3600;
    ans[i][1]=c/60;
    c%=60;
    ans[i][2]=c;
  }
  for(i=0;i<3;i++)
    printf("%d %d %d\n",ans[i][0],ans[i][1],ans[i][2]);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	int n;
	int h, w;
	cin >> n >> h >> w;

	cout << (n - h + 1) * (n - w + 1) << endl;
} 
 

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int a[n], b[n];

    ll sA = 0, sB = 0;

    repi(i, n, 0)
    {
        cin >> a[i];
        sA += a[i];
    }
    repi(i, n, 0)
    {
        cin >> b[i];
        sB += b[i];
    }

    ll m = sB - sA;
    if (m < 0)
    {
        //絶対終わらない
        cout << "No" << endl;
    }
    else
    {
        //絶対終わる
        ll c1 = 0, c2 = 0;
        repi(i, n, 0)
        {
            if (a[i] > b[i])
            {
                c1 += a[i] - b[i]; //絶対終わるやつ
            }
            else
            {
                c2 += (b[i] - a[i]) / 2; //終わるかどうか怪しいやつ
            }
        }
        // cout << c1 << " " << c2 << endl;
        if (c2 < c1)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

unsigned long long int a = 0, b = 0, c =1, d = 0, e = 9999, n = 0,x=0,y=0,z=0, maxy = 0, mini = 9999, counter = 0, sur = 0,kuso=0,kuso2=0,ans=0;
std::vector<unsigned long long int> vec{}, vecsec{};
std::vector<std::string>str{};
std::vector<std::string>str2{};

int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, input,nyahhoi;
int kakunou[50][50] = { 53 };

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {
	
		c = i % j;
		i = j;
		if (c != 0) {
		
			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> a>>b>>c;
	for (int i = 0; i < a; i++) {
		cin >> kuso;
		vec.push_back(kuso);
	}
	std::sort(vec.begin(), vec.end());
	
	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] <= b) {
			x++;
	}
		if (vec[i] > b&&vec[i] <= c) {
			y++;
		}
		if(vec[i]>c) {
			z++;
		}
	}

	cout << std::min(x, std::min(y, z));
}






Measured memory_bytes: 256
import math
import fractions
A, B, C, D = map(int, input().split())
gcd = fractions.gcd(C, D)
# gcd = math.gcd(C, D)
Bans = B - B // C - B // D + B // ((C*D) // gcd)
Am1 = A-1
Aans = Am1 - Am1 // C - Am1 // D + Am1 // ((C*D) // gcd)
print(Bans-Aans)


Measured memory_bytes: 5048
A, B, K = map(int,input().split())
if(A > B):
    A,B = B,A
d = 1;
l = []
while(d*d <= A):
    if(A%d != 0):
        d += 1
        continue
    if(not (B%d)):
        l.append(d)
    if(A//d != d and not (B%(A//d))):
        l.append(A//d)
    d += 1
l.sort(reverse=True)
print(l[K-1])


Measured memory_bytes: 3064
fs = require('fs');
token = fs.readFileSync('/dev/stdin').toString().split(/\s/, 2).map(Number);
res = function(sign) {
	if (sign < 0) return "a < b";
	else if (sign > 0) return "a > b";
	else return "a == b";
} (token[0] - token[1]);
console.log(res);

Measured memory_bytes: 15544
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9L+7;
int n;
vector<int> inp;
vector<vector<ll>> dp;

ll candp (int k,int i=0)
{
    //cout<<i<<" "<<j<<" "<<c<<" "<<sum<<'\n';
    if(k==0) return 1;
    if(i == n) return 0;
    if(dp[i][k] != -1) return dp[i][k];

    ll ans = 0;
    for(int a=0;a<=inp[i];a++)
    {
        if(k-a>=0)
        {
            ans += candp(k-a,i+1);
            ans%=mod;
        }
        else break;
    }
    return dp[i][k]=ans;
}

ll cf_solver(int k)
{
    vector<vector<ll>> cf_dp(k+1,vector<ll> (n+1,1));

    for(int a=1;a<=k;a++)
    {
        for(int i=1;i<=n;i++)
        {
            ll ans=0;
            int sub = min(a,inp[i]);
            sub++;
            if(a-sub == -1) ans = cf_dp[a][i-1] ;
            else ans = cf_dp[a][i-1] - cf_dp[a-sub][i-1];
            if(ans < 0) ans += mod;
            ans += cf_dp[a-1][i];
            ans %= mod;

            cf_dp[a][i] = ans;
        }
    }

    ll ret_val = cf_dp[k][n];
    if(k>0) ret_val -=  cf_dp[k-1][n];
    if(ret_val < 0) ret_val += mod;
    ret_val %= mod;
    return ret_val;
}

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

    int k;
    cin>>n>>k;
    inp.resize(n+1);
    dp.assign(n+1,vector<ll> (k+1,-1));

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

    //cout<<candp(k)<<'\n';
    cout<<cf_solver(k)<<'\n';

}


Measured memory_bytes: 164204
#include <cstdio>
#include <cstring>
#include <iostream>
#include <utility>
using namespace std;

typedef struct{
	int num;
	int u;
	int ac;
	long p;
}team;


int main(){
	while(1){
		int n;
		team t[300];
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i) scanf(" %d %d %d %ld", &t[i].num, &t[i].u, &t[i].ac, &t[i].p);
		
		//sort
		for(int i=0; i<n; ++i){
			for(int j=i+1; j<n; ++j){
				
				if(t[i].ac<t[j].ac) swap(t[i],t[j]);
				else if(t[i].ac==t[j].ac){
					if(t[i].p>t[j].p) swap(t[i],t[j]);
					else if(t[i].p==t[j].p){
						if(t[i].num>t[j].num) swap(t[i],t[j]);
					}
				}
				
			}
		}
		
		//for(int i=0; i<n; ++i) printf(" %d %d %d %ld\n", t[i].num, t[i].u, t[i].ac, t[i].p);
		
		int now=0;
		int bel[1001]; //????±????????????°?????????????????°	
		bool sel[1001]; //?????°??????????????????
		
		memset(bel, 0, sizeof(bel));
		for(int i=0; i<=1000; ++i) sel[i]=false;
		
		for(int i=0; i<n; ++i){
			if(sel[t[i].num]) continue;
			
			if(bel[t[i].u]<3){
				printf("%d\n", t[i].num);
				sel[t[i].num]=true;
				bel[t[i].u]++;
				now++;
			}
			
			if(now==10) break;
		}
	
		for(int i=0; i<n; ++i){
			if(sel[t[i].num]) continue;
			
			if(bel[t[i].u]<2){
				printf("%d\n", t[i].num);
				sel[t[i].num]=true;	
				bel[t[i].u]++;
				now++;
			}
			
			if(now==20) break;
		}
	
		for(int i=0; i<n; ++i){
			if(sel[t[i].num]) continue;
			
			if(bel[t[i].u]<1){
				printf("%d\n", t[i].num);
				sel[t[i].num]=true;	
				bel[t[i].u]++;
				now++;
			}
			
			if(now==26) break;
		}
	

	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+7; bool fl[N];
int n,w[N],len[N]; vector<int>v[N];
inline void find(int u,int fa){
	fl[u]=0;
	for(int i=0;i<len[u];i++){
		int x=v[u][i]; if(x==fa) continue;
		find(x,u); if(w[u]>w[x]&&!fl[x]) fl[u]=1;
	}
}
int main(){
	scanf("%d",&n); int u,t;
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	for(int i=1;i<n;i++) scanf("%d%d",&u,&t),v[u].push_back(t),v[t].push_back(u),len[u]++,len[t]++;
	for(int i=1;i<=n;i++){
		find(i,0); if(fl[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

int main() {
  cout << fixed << setprecision(8);

  string s, t;
  cin >> s >> t;

  ll n = sz(s);
  ll m = sz(t);
  
  vvl dp(n+1, vl(m+1));

  FOR(i,1,n+1) {
    FOR(j,1,m+1) {
      if(s[i-1] == t[j-1]) {
	dp[i][j] = dp[i-1][j-1] + 1;
      } else {
	dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  string res(dp[n][m], ' ');
  ll i = n, j = m;
  ll x = dp[n][m];
  while(i > 0 && j > 0) {
    if(s[i - 1] == t[j - 1]) {
      --x;
      res[x] = s[i - 1];
      --i; --j;
    } else if(dp[i-1][j] > dp[i][j-1]) {
      --i;
    } else {
      --j;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int ans = -INF;
   int i = 1;
   while(1){
      if(i*i > n){break;}
      ans = max(ans, i*i);
      i++;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
int main() {
	
	int N;
	cin >> N;
	vector<int> A;
	vector<int> B;
	vector<int> all;
	for(int i=0; i<N; i++) {
		int a;
		cin >> a;
		if(i%2==0) A.push_back(a);
		else B.push_back(a);
		all.push_back(a);
	}
	vector<int> original = all;
	sort(all.begin(), all.end());
	int sum = 0;
	for(int i=0; i<N; i++) {
		int p = upper_bound(all.begin(), all.end(), original[i]) - all.begin();
		if((abs(p-i))%2 == 0)
			sum++;
	}
	cout << sum / 2 << endl;
	return 0;
}



Measured memory_bytes: 1652
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

const inf = 1001001001

var dp []int

func rec(n int, a []int) int {
	if dp[n] != inf {
		return dp[n]
	}
	ret := inf
	for _, v := range a {
		if n == v {
			return 1
		}
		if n < v {
			continue
		}
		ret = min(ret, rec(n-v, a))
	}
	ret++
	dp[n] = ret
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)

	a := make([]int, 0)
	n := 1
	for n < 100000 {
		n *= 6
		a = append(a, n)
	}
	n = 1
	for n < 100000 {
		n *= 9
		a = append(a, n)
	}
	a = append(a, 1)
	sort.Ints(a)

	N := getInt()

	dp = make([]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = inf
	}
	out(rec(N, a))
}


Measured memory_bytes: 30976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){

  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  ll tmp = 0;
  rep(i,N)tmp += A[i];
  if(tmp==0){cout << "Yes" << endl; return 0;}
  if(N%3!=0){cout << "No" << endl; return 0;}
  sort(A.begin(), A.end());
  ll x=A[0], y=A[N/3], z=A[N*2/3];
  if((x^y)!=z) {cout << "No" << endl;return 0;}
  rep(i,N/3){
    if(A[i]!=x || A[i+N/3]!=y || A[i+N*2/3]!=z) {cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
	int n;
	cin >> n;
    vector<int> h(n);
    vector<bool> flg(n, 0);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }

    if(n==1){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i=0; i<n-1; i++){
        if(h[i]>h[i+1]){
            h[i]--;
            flg[i]=1;
            for(int j=i; j>=0; j--){
                if(h[j]>h[j+1]){
                    if(flg[j]){
                        cout << "No" << endl;
                        return 0;
                    }
                    h[j]--;
                    flg[j]=1;
                }
            }
        }
    }
	cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstring>
using namespace std;
#define MAXN 100
int n;
int G,T[MAXN+5],c[MAXN+5];
int cnt,vis[MAXN+5],ans=1000000000;
void dfs(int x,int G,int step)
{
    for(int i=1;i<=n;i++)
    if(!vis[i])
    {
        int M=T[i]*100*i+c[i];
        if(G>M)vis[i]=1,dfs(x+1,G-M,step+T[i]),vis[i]=0;
        else
        {
            int p=(G+i*100-1)/(i*100);
            ans=min(ans,step+min(p,T[i]));
        }
    }
}
int main()
{
    scanf("%d%d",&n,&G);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&T[i],&c[i]);
    }
    dfs(1,G,0);
    printf("%d",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int F[10005] = { 0 }, C[105], W[105];
using namespace std;
int main() {
    int n, w;
    scanf("%d%d", &n, &w);
    for (int i = 0; i < n; i++)
        scanf("%d%d", &C[i], &W[i]);
    for (int i = 0; i < n; i++)
        for (int v = w; v >= W[i]; v--)
            F[v] = max(F[v], F[v - W[i]] + C[i]);
    printf("%d\n", F[w]);
    return 0;
}


Measured memory_bytes: 2756
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};    
        
        
    int k;
    cin>>k;
    k--;

    cout<<arr[k];











    return 0;
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int a[125252], b[125252], c[125252];

bool solve(int n, int k){
    if(!(n >= 2*k-1))return false;

    REP(i,n)c[i] = 2*n+i;
    int m = (n+1)/2;
    REP(i,n)b[(m+i)%n] = (2*n-1-i);
    REP(i,m)a[i] = 2*i;
    REP(i,n-m)a[m+i] = 2*i+1;
    REP(i,n)if(a[i]+b[i] > c[i]-k)return false;
    return true;
}

int main(){
    // {
    //     FOR(n,1,50){
    //         FOR(k,1,n+1){
    //             printf("%d",solve(n,k));
    //         }
    //         puts("");
    //     }
    //     return 0;
    // }
    int n,k;
    scanf("%d%d",&n,&k);
    if(!solve(n,k)){
        puts("-1");
    }else{
        REP(i,n)printf("%d %d %d\n",a[i]+k,b[i]+k,c[i]+k);
    }
    return 0;
}


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

char dir[4][2] = { 1, 0, 0, 1, -1, 0, 0, -1 };
int h, w, it, xc, yc, xd, yd;
char s[1010][1010], vis[1000010];
int a[1010][1010];
vector <int> gl[1000010];
int q1[1000010], q2[1000010];
inline char legal(const int &x, const int &y);

int main() {
	scanf("%d%d%d%d%d%d", &h, &w, &xc, &yc, &xd, &yd);
	--xc, --yc, --xd, --yd;
	memset(a, -1, sizeof(a));
	for (int i = 0; i < h; ++i)
		scanf("%s", s[i]);
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (s[i][j] == '.' && a[i][j] == -1) {
				a[i][j] = it++;
				q1[0] = i, q2[0] = j;
				int h = 0, t = 1;
				while (h < t) {
					for (int k = 0; k < 4; ++k) {
						int x1 = q1[h] + dir[k][0], y1 = q2[h] + dir[k][1];
						if (legal(x1, y1) && a[x1][y1] == -1)
							q1[t] = x1, q2[t++] = y1,
								a[x1][y1] = a[i][j];
					}
					++h;
				}
			}
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (s[i][j] == '.')
				for (int i1 = -2; i1 <= 2; ++i1)
					for (int j1 = -2; j1 <= 2; ++j1) {
						int x = i + i1, y = j + j1;
						if (legal(x, y) && a[x][y] != a[i][j]) {
							int &u = a[i][j], &v = a[x][y];
							gl[u].push_back(v);
							gl[v].push_back(u);
						}
					}
	int h = 0, t = 1;
	q1[0] = a[xc][yc], q2[0] = 0, vis[a[xc][yc]] = 1;
	while (h < t) {
		if (q1[h] == a[xd][yd]) {
			printf("%d\n", q2[h]);
			return 0;
		}
		int &u = q1[h];
		for (int i = 0; i < gl[u].size(); ++i) {
			int &v = gl[u][i];
			if (!vis[v])
				vis[v] = 1, q1[t] = v, q2[t++] = q2[h] + 1;
		}
		++h;
	}
	puts("-1");
	return 0;
}

inline char legal(const int &x, const int &y) {
	return x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.';
}



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

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<int> prev;
  vector<vector<Edge>> g;
  Dijkstra(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vector<T> build(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  Dijkstra<ll> sg(n), tg(n);
  for (size_t i = 0; i < m; i++) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    sg.addEdge(u, v, a);
    tg.addEdge(u, v, b);
  }
  auto sd = sg.build(s);
  auto td = tg.build(t);
  vector<ll> ans(n, sd[n - 1] + td[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    ans[i] = min(ans[i + 1], sd[i] + td[i]);
  }
  for (size_t i = 0; i < n; i++) {
    cout << (ll)1e15 - ans[i] << endl;
  }
}


Measured memory_bytes: 19780
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL A,B,i,ans=0;
  scanf("%lld%lld",&A,&B);

	printf("%lld",LCM(A,B));
	return 0;
}


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

#define ll long long
#define ld long double
#define debug(x) \
//    (cout << #x << ": " << (x) << endl)
#define eb emplace_back

using namespace std;

const ll inf = 9e18;

ll n, a, b, c, d;
unordered_map<ll, ll> ans;

ll f(ll n) {
	if (!n) {
		return 0;
	}
	if (n == 1) {
		return d;
	}
	if (ans.count(n)) {
		return ans[n];
	}
	ll res = inf;
	if (n < res / d) {
		res = n * d;
	}
	ll l2 =  (n / 2) * 2, r2 = ((n + 1) / 2) * 2;
	ll l3 =  (n / 3) * 3, r3 = ((n + 2) / 3) * 3;
	ll l5 =  (n / 5) * 5, r5 = ((n + 4) / 5) * 5;
	res = min(res, (n - l2) * d + a + f(l2 / 2));
	res = min(res, (n - l3) * d + b + f(l3 / 3));
	res = min(res, (n - l5) * d + c + f(l5 / 5));
	res = min(res, (r2 - n) * d + a + f(r2 / 2));
	res = min(res, (r3 - n) * d + b + f(r3 / 3));
	res = min(res, (r5 - n) * d + c + f(r5 / 5));
	return ans[n] = res;
}

void solve() {
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	ans.clear();
	printf("%lld\n", f(n));
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t;
	scanf("%d", &t);
	while (t--) {
		solve();
	}
#ifdef LOCAL
	printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
#endif
}



Measured memory_bytes: 4320
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }

  // val a = new Array[Int](N)
  for (i <- 1 to D) {
    pw.println(i % 26 + 1)
  }

  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

const ll MX = 1e18;

int main(){
    int N;
    cin >> N;
    ll A[N];
    int zero = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i] == 0){
            zero++;
        }
    }

    if(zero>0){
        printf("0\n");
        return 0;
    }

    ll prod = 1;
    for(int i=0; i<N; i++){
        if(A[i] <= MX/prod){
            prod *= A[i];
        } else{
            printf("-1\n");
            return 0;
        }
    }

    cout << prod << endl;
    return 0;
}

Measured memory_bytes: 4380
from collections import defaultdict

N = input().strip()
K = int(input().strip())
lenN = len(N)

memo = defaultdict(lambda :defaultdict(lambda :defaultdict(int)))
def f(keta, flag, k):
    if keta == lenN-1:
        if k == K:
            return 1
        else:
            return 0
    if keta in memo and flag in memo[keta] and k in memo[keta][flag]:
        return memo[keta][flag][k]
    nketa = keta + 1
    maxi = int(N[nketa]) if flag else 9
    res = 0
    for i in range(maxi+1):
        nflag = flag and (int(N[nketa]) == i)
        nk = k if i == 0 else k + 1
        if nk > K:
            continue
        res += f(nketa, nflag, nk)
    memo[keta][flag][k] = res
    return res

print(f(-1, True, 0))


Measured memory_bytes: 3436
N = int(input())

S = []
for i in range(N):
    S.append(input())
ac = S.count("AC")
wa = S.count("WA")
tle = S.count("TLE")
re = S.count("RE")

print("AC", "x", ac, "\n"
      "WA", "x", wa, "\n"
      "TLE", "x", tle, "\n"
      "RE", "x", re)

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

int main(){
    char s[]="";
    scanf("%s",s);
    
    if(strlen(&s)==2){
        printf("%s\n",s);
    }else if(strlen(&s)==3){
        int i;
        for(i=0;i<3;++i){
            printf("%c",s[2-i]);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 101

int main() {
  vector<int> arr(MAX,0);
  int num;
  while(cin >> num) {
    arr[num]++;
  }
  int mode_max = 0;
  for(int i=0;i<MAX;i++) {
    mode_max = max(mode_max,arr[i]);
  }
  for(int i=0;i<MAX;i++) {
    if(arr[i] == mode_max) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

	static class Node<E> {
		public E value;
		public Node<E> next;		
		public Node(E value) {
			this.value = value;
			this.next = null;
		}
	}

	static class SimpleQueue<E> {
		
		private Node<E> head;
		private Node<E> tail;
		int size;
		
		public SimpleQueue() {
			size = 0;
			head = null;
			tail = null;
		}
		
		public int getSize() {
			return size;
		}
		
		public boolean isEmpty() {
			return size == 0;
		}
		
		public void enqueue(E element) {
			Node<E> node = new Node<E>(element);
			if (head == null && tail == null) {
				head = tail = node;
			} else {
				tail.next = node;
				tail = node;
			}
			size++;
		}
		
		public E dequeue() {			
			if (isEmpty()) {
				return null;
			}
			E element = head.value;
			head = head.next;
			if (head == null) {
				tail = null;
			}
			size--;
			return element;			
		}
		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("[");
			Node<E> current = head;
			while (current != null) {
				sb.append(current.value);
				current = current.next;
				if (current != null) {
					sb.append(", ");
				}
			}			
			sb.append("](");
			if (tail != null) {
				sb.append(tail.value);
			}
			sb.append(")");
			return sb.toString();
		}		
	}
	
	static class Process {		
		public String name;
		public int time;		
		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}		
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		SimpleQueue<Process> queue = new SimpleQueue<Process>();
		for (int i = 0; i < n; i++) {
			String name = sc.next();
			int time = sc.nextInt();
			queue.enqueue(new Process(name, time));
		}
		sc.close();

		int total = 0;
		while (!queue.isEmpty()) {
			
			Process process = queue.dequeue();
			if (process.time > q) {
				process.time = process.time - q;
				total += q;
				queue.enqueue(process);
			} else {
				total += process.time;
				System.out.println(process.name + " " + total);
			}			
		}
	}
}




Measured memory_bytes: 74052
#include<iostream>
#include<vector>
using namespace std;
void dfs(bool* visited,vector<int> *adj,int v,int *dp)
{
      visited[v]=true;
      for(int i=0;i<adj[v].size();i++){
      	  if(!visited[adj[v][i]])
      	  	dfs(visited,adj,adj[v][i],dp);
      	  dp[v]=max(dp[v],1+dp[adj[v][i]]);
      	}
}
int main()
{
	int n,m,a,b;
	cin>>n>>m;
    vector<int> *adj;
    adj=new vector<int>[n+1];
    for(int i=0;i<m;i++)
    {
    	cin>>a>>b;
    	adj[a].push_back(b);
    }
    bool visited[n+1];
    int dp[n+1];
    for(int i=0;i<=n;i++)
    	{visited[i]=false;dp[i]=0;}
    for(int i=1;i<=n;i++)
    	if(!visited[i])
    		dfs(visited,adj,i,dp);
    int mx=0;
    for (int i = 0; i < n+1; ++i)
    {mx=max(mx,dp[i]);
    	/* code */
    }
    cout<<mx;
}

Measured memory_bytes: 9600