akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.array,std.string;

void main()
{
    string[] input=readln.split;
    
    int a=input[0].to!int,b=input[1].to!int;
    
    if((a*b)%2==0){
        writeln("Even");
    }else{
        writeln("Odd");
    }
}

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

#define int long long 
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define lbound lower_bound 
#define ubound upper_bound
#define pqueue priority_queue
#define umap unordered_map
#define uset unordered_set
#define len(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std ;

using vi   = vector<int> ;
using vvi  = vector<vi> ;
using pii  = pair<int,int> ;
using vpii = vector<pii>  ;
using mii  = map<int, int>;
using umii = umap<int, int>; 

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

int32_t main(){
    ios::sync_with_stdio(false); 
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("D:/Coding/in.txt", "r", stdin);
    freopen("D:/Coding/out.txt", "w", stdout);
#endif
    
    int n ;
    cin >> n;
    vi a(n), ans(n);
    for (int i = 0;i < n; ++i){
         cin >> a[i];
         ans[a[i] -1 ] = i + 1;
    }
    for(int i :  ans){
         cout << i << ' ';
    }

#ifndef ONLINE_JUDGE  
    cerr << "\n\nTime elapsed: " << 1.0 * clock() /CLOCKS_PER_SEC<< " s.\n";
#endif
    return 0;
}

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

int main() {

    int n;
    cin >> n;
    int mx = 0;
    int count = 0;
    for (int i=0; i<n; i++) {
        int curr;
        cin >> curr;
        if (curr >= mx) count++;
        mx = max(mx, curr);
    }
    cout << count;

}

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

//データの最大個数
#define MAX_COUNT 100000
//名前の最高文字数
#define NAME_LENGTH 10

int main(void)
{
	int i, n, q;
	/*
	first_pointはキューの先頭ポインタを、end_pointはキューの後尾ポインタを表す
	time_countはプロセスの処理時間の合計を表す
	*/
	int first_point, end_point, loop_end, time_count, end_process;
	char name[MAX_COUNT][NAME_LENGTH];
	int time[MAX_COUNT];

	//データの個数とクオンタムを入力
	scanf("%d %d", &n, &q);

	//名前と必要処理時間を入力
	for(i = 0; i < n; i++){
		scanf("%s %d", name[i], &time[i]);
	}

	time_count = end_process = 0;
	end_point = n - 1;
	loop_end = n;

	//全てのプロセスが終了したらループから抜ける
	while(n > 0){
		end_process = 0;

		//ループの最後のポイントまで繰り返す
		for(first_point = 0; first_point < loop_end; first_point++){
			time[first_point] -= q;
			time_count += q;

			//処理が終了した場合
			if(time[first_point] <= 0){
				//残った時間を加算する
				time_count += time[first_point];
				end_process++;
				//プロセスを1つ減らす
				n--;

				//名前と処理時間を出力
				printf("%s %d\n", name[first_point], time_count);
			}
			//処理が残った場合
			else{
				//キューの最後尾をずらす
				end_point++;
				if(end_point >= n){
					end_point = 0;
				}

				//先頭のデータを最後尾に移動する
				time[end_point] = time[first_point];
				strcpy(name[end_point], name[first_point]);
			}
		}

		//ループの最後のポイントを変動する
		loop_end -= end_process;
	}

	return 0;
}


Measured memory_bytes: 2380
a = input()
b = input()
na = len(a)
nb = len(b)

dp = [[0]*(nb+1) for _ in range(na+1)]

for i in range(na):
    for j in range(nb):
        if a[i] == b[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
ans = []
num = dp[na][nb]
x = na
y = nb
while num:
    if dp[x][y] == dp[x-1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y-1]:
        y -= 1
    else:
        ans.append(a[x-1])
        x -= 1
        y -= 1
        num -= 1

print("".join(ans[::-1]))


Measured memory_bytes: 144632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] c = new int[7];
			while(n--!=0){
				int x = sc.nextInt();
				int k = 0;
				while(k<6&&x>=(k+1)*10)k++;
				c[k]++;
			}
			for(int a:c)System.out.println(a);
		}
	}
}

Measured memory_bytes: 208420
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

#define REP( i, n )	for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( x )	(x).begin(), (x).end()

bool isRightAngle( int a, int b, int c );

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

	REP( i, n ) {
		int a, b, c; cin >> a >> b >> c;

		if( isRightAngle( a, b, c ) == true ) cout << "YES" <<endl;
		else								  cout << "NO" << endl;
	}

}

bool isRightAngle( int a, int b, int c ) {
	if( a > b && a > c ) {
		if( a * a == b * b + c * c ) return true;
		else						 return false;
	}
	if( b > a && b > c ) {
		if( b * b == a * a + c * c ) return true;
		else						 return false;
	}
	if( c > a && c > a ) {
		if( c * c == a * a + b * b ) return true;
		else						 return false;
	}
	return false;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int>  P;
vector<vector<ll> >v;
const int maxn = 2e6;
ll val[maxn];
ll n,m;
int main() {
    int a[20];
    while(cin >> a[0] >> a[1] >> a[2]) {
        sort(a,a + 3);
        int cha1 = a[1] - a[0];
        int cha2 = a[2] - a[1];
        int num = 0;
        if(cha1 % 2) num = 1;
        int ans = cha2;
        if((a[2] - (cha2 + a[0]))% 2) ans += 2;
        ans += (a[2] - (cha2 + a[0])) / 2;
        cout <<  ans  << endl;
    }
    return 0;
}














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

#define int long long 
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define show(e) cerr<<#e<<" = "<<e<<endl

using namespace std;
using vi=vector<int>;
using pint=pair<int,int>;

int h,w;
vi d[10];
int n;

void warshall_floyd(int v){
    rep(k,v){
        rep(i,v){
            rep(j,v){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

signed main(){
    cin>>h>>w;
    rep(i,10){
        rep(j,10){
            cin>>n;
            d[i].pb(n);
        }
    }

    warshall_floyd(10);

    vi vec(10);
    rep(i,h){
        rep(j,w){
            cin>>n;
            if(n!=-1){
                vec[n]++;
            }
        }
    }
    int ans=0;
    rep(i,10){
        ans+=vec[i]*d[i][1];
    }
    cout<<ans<<endl;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint a,b,c; cin>>a>>b>>c;
	cout<<min({a*b*(c%2),a*c*(b%2),b*c*(a%2)})<<'\n';
	return 0;
}


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

int main(){
  long long N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  long long LCM;
  long long GCM;
  GCM = min(N, M);
  long long temp;
  temp =max(N, M);
  long long r=temp%GCM;
  while(r!=0){
    temp = GCM;
    GCM = r;
    r = temp % GCM;
  }
  LCM = N * M / GCM;
  long long  ans=LCM;
  if(GCM!=1){
    for(long long i=0; i<GCM; i++){
      if(S.at(i*S.size()/GCM)!=T.at(i*T.size()/GCM)) ans=-1;
    }
  }
  else if(S.at(0)!=T.at(0)) ans=-1;
  cout << ans << endl;
}

Measured memory_bytes: 512
/*ILTH      ILTH            ILTHILTHILTH    ILTH        ILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTH                ILTH        ILTHILTHILTHILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTHILTHILTH        ILTH        ILTH        ILTH

  */
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN=300009;
pii a[maxN];
int n,m,bt[maxN];
bool comp(pii a, pii b){
    return a.se-a.fi<b.se-b.fi;
}
void up(int x, int y){
    for (;x<=m; x+=x&-x) bt[x]+=y;
}
int get(int x){
    int res=0;
    for (;x;x-=x&-x) res+=bt[x];
    return res;
}
int main()
{
    cin >> n >> m;
    for (int i=1; i<=n; ++i){
        int l,r;
        cin >> l >> r;
        a[i]={l,r};
    }
    sort(a+1, a+n+1, comp);

    int j=1;
    for (int i=1; i<=m; ++i){
        int res=0;
        while (a[j].se-a[j].fi+1<i && j<=n){
            up(a[j].fi,1);
            up(a[j].se+1,-1);
            ++j;
        }
        res+=n-j+1;
        for (int k=1; k*i<=m; ++k) res+=get(k*i);
        cout << res << "\n";
    }

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

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

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

	auto maxH = H[0];
	auto count = 1;

	for (auto i = 1; i < N; ++i)
	{
		if (H[i] >= maxH)
		{
			++count;
		}

		maxH = max(maxH, H[i]);
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	long l, r;
	long res;
	scanf("%ld %ld", &l, &r);
	if(r - l >= 2019 || l % 2019 > r % 2019 || l % 2019 == 0)
		res = 0;
	else{
		res = 2019;
		int end = r % 2019;
		for(int i = l % 2019; i < end; i++){
			for(int j = i + 1; j <= end; j++)
				if(i * j % 2019 < res)res = i * j % 2019;
		}
	}
	printf("%ld\n", res);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ifstream cin (".in");
	//ofstream cout (".out")
	
	ll n;
	cin >> n;
	ll ans=0;
	
	for(ll i=2; n>1 && i*i<=n; ++i) {
		int temp=0;
		while(n%i==0) ++temp, n/=i;
		for(int j=1; ; ++j) {
			if(temp>=j) ++ans, temp-=j;
			else break;
		}
	}
	
	if(n>1) ++ans;
	
	cout << ans << '\n';
	return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  int ans = 1;
  while (N--) {
    if (ans >= K) {
      ans += K;
    } else {
      ans *= 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
struct edge{int to,cap,rev;};
vector< edge > G[210]; // 0~h-1, 100~100+(w-1), 200 st, 201 goal
bool used[210];
void addedge(int from,int to, int cap){
	G[from].pb( (edge){to,cap,G[to].size()} );
	G[to].pb( (edge){from,0,G[from].size()-1} );
}
int dfs(int v,int t, int f){
	if(v==t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		memset(used, 0, sizeof(used));
		int f = dfs(s,t,inf);
		if(f==0)return flow;
		flow += f;
	}
}
signed main(){
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		string str;
		cin>>str;
		for(int j=0;j<w;j++){
			if(str[j]=='o'){
				addedge(i,100+j,1);
				addedge(100+j,i,1);
			}
			else if(str[j]=='S'){
				addedge(200,i,inf);
				addedge(200,100+j,inf);
			}
			else if(str[j]=='T'){
				addedge(i,201,inf);
				addedge(100+j,201,inf);
			}
		}
	}
	int ans = max_flow(200,201);
	if(ans>=inf)ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

int main(){

  int N = 0;
  cin >> N;

  string S = "";
  string T = "";

  cin >> S >> T;

  for (int i = 0; i < N; i++) {
    cout << S[i] << T[i];
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
//#include <vector>
#include <string>
#include <algorithm>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int k;
    int ans = 0;
    int boundary = 0;
    int update;
    string s;
    cin >> n >> k;
    cin >> s;

    for(int i=0; i<n-1; i++){
        if(s[i]==s[i+1]){
            ans++;
        }else{
            boundary++;
        }
    }
    if(k*2>boundary){
        update = boundary;
    }else{
        update = k*2;
    }
    ans += update;
    cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> result(n);
	int count = 0, forward = 1;
	for (int i = 0; i < n; i++) {
		if (forward) {
			if (s[i] == 'R')
				count++;
			else {
				result.at(i - 1) += (count + 1) / 2;
				result.at(i) += count / 2;

				forward = 0;
				count = 1;
			}
		} else {
			if (s[i] == 'L')
				count++;
			else {
				result.at(i - count - 1) += count / 2;
				result.at(i - count) += (count + 1) / 2;

				forward = 1;
				count = 1;
			}
		}
	}
	result.at(n - count - 1) += count / 2;
	result.at(n - count) += (count + 1) / 2;

	for (int i = 0; i < n; i++) {
		cout << result[i] << (i < n - 1 ? " " : "\n");
	}
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);
    if(a > b) swap(a,b);
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

double dot(P a,P b){
  return real(b*conj(a));
}

double cross(P a,P b){
  return imag(b*conj(a));
}

P init(P a){
  return a/max(0.0001,abs(a));
}

int ax,ay,bx,by,cx,cy;

P A,B,C;
double sinA,cosA,sinB,cosB,sinC,cosC;

double funcC(double ra){
  double L=0,R=10000,M;
  for(int i=0;i<100;i++){
    M=(L+R)/2.0;
    if( M/sinC*cosC + ra/sinA*cosA + sqrt( 4.0*ra*M ) < abs(A-C) ) L=M;
    else R=M;
  }
  return L;
}

double funcB(double ra){
  double L=0,R=10000,M;
  for(int i=0;i<100;i++){
    M=(L+R)/2.0;
    if( M/sinB*cosB + ra/sinA*cosA + sqrt( 4.0*ra*M ) < abs(A-B) ) L=M;
    else R=M;
  }
  return L;
}

bool check(double ra){
  double rb=funcB(ra);
  double rc=funcC(ra);

  if( rb/sinB*cosB + rc/sinC*cosC + sqrt( 4.0*rb*rc ) < abs(C-B) ){
    return true;
  }else{
    return false;
  }
}

int main(){
  while(1){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    if(ax==0&&ay==0&&bx==0&&by==0&&cx==0&&cy==0)break;
    A=P(ax,ay),B=P(bx,by),C=P(cx,cy);
    P AB=init(B-A),AC=init(C-A);
    AB=(AB+AC)*0.5;
    sinA = abs(cross(AB,AC))/abs(AB);
    cosA = dot(AB,AC)/abs(AB);
    
    P BA=init(A-B),BC=init(C-B);
    BA=(BA+BC)*0.5;
    sinB = abs(cross(BA,BC))/abs(BA);
    cosB = dot(BA,BC)/abs(BA);

    P CA=init(A-C),CB=init(B-C);
    CA=(CA+CB)*0.5;
    sinC = abs(cross(CA,CB))/abs(CA);
    cosC = dot(CA,CB)/abs(CA);

    double L=0,R=10000,M;
    for(int i=0;i<100;i++){
      M=(L+R)/2.0;
      if(check(M))R=M;
      else L=M;
    }

    printf("%.10f %.10f %.10f\n",L,funcB(L),funcC(L));
  }
  return 0;
}

Measured memory_bytes: 1220
let max x y =
    let add = x + y
    let sub = x - y
    let mul = x * y
    if add <= sub && mul <= sub then sub
    else if sub <= add && mul <= add then add
    else mul

stdin.ReadLine().Split(' ')
|> Array.map (int)
|> (fun xs -> (xs.[0], xs.[1]))
||> max
|> printfn "%d"

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)

bool lunlun(int n) {
	int last = n % 10;
	n /= 10;
	while (n) {
		int x = n % 10;
		if (abs(x - last) > 1) {
			return false;
		}
		last = x;
		n /= 10;
	}
	return true;
}

vector<string> H = {
	"99",
	"999",
	"9999",
	"99999",
	"999999",
	"9999999",
	"99999999",
	"999999999",
	"9999999999",
	"99999999999",
};

void next(string &curr) {
	if (find(H.begin(), H.end(), curr) != H.end()) {
		int x = curr.length();
		curr = "1";
		for (int i = 0; i < x; i++) {
			curr.push_back('0');
		}
		return;
	}

	int x = curr.length();
	int loc = x - 1;
	while (loc > 0) {
		if (curr[loc] > curr[loc - 1]) {
			loc--;
		} else {
			if (curr[loc] == '9') {
				loc--;
				continue;
			}
			curr[loc]++;
			loc++;
			while (loc < x) {

				curr[loc] = max((int) '0', curr[loc - 1] - 1LL);
				loc++;
			}
			return;			
		}
	}
	curr[loc]++;
	loc++;
	while (loc < x) {

		curr[loc] = max((int) '0', curr[loc - 1] - 1LL);
		loc++;
	}
}

int32_t main() { fastio;
    int k; cin >> k;
    // int count = 0;
    // for (int i = 1; i; i++) {
    // 	if (lunlun(i)) {
    // 		count++;
    // 		cout << i << endl;
    // 	}
    // 	if (count == 200) {
    // 		break;
    // 	}
    // }

    // k = 200;

    if (k > 12) {
    	string curr = "21";
    	int loc = 13;
    	while (loc < k) {
    		// deb(loc);
    		// deb(curr);
    		next(curr);
    		loc++;
    	}
    	cout << curr << endl;
    } else {
    	cout << k << endl;
    }
    // string curr = "899";
    // next(curr);
    // deb(curr);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b;

	std::cin >> a;

	if (a % 2 != 0) {
		b = a + 1;
	}
	else { b = a; }

	double c = (double)b / 2.0 / (double)a;
	std::cout << c << std::endl;

	return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1

def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):   
        if A[bi] - A[ai] == ci:               
            tmp += di                        
    return tmp                               
    # for i in range(q):
    #     if A[b[i]]-A[a[i]] == c[i]:
    #         tmp += d[i]
    # return tmp

def dfs(A):
    if len(A) == n:
        return score(A)   
    res = 0
    if len(A) > 0:                # prev_last = A[-1] if len(A) > 0 else 0
        prev_last = A[-1] 
    else:
        prev_last = 0
    for i in range(prev_last, m):
        A.append(i)
        res = max(res, dfs(A))    # 再起を呼び出しながら、最大値の更新
        A.pop()
    return res

print(dfs([]))

Measured memory_bytes: 9212
import java.util.*;
import java.lang.*;
import java.io.*;
import java.awt.Point;

class Main{

    public static class Pox{
	public int id,time,difficulty;
	Pox(){
	    id = time = difficulty = 0;
	}

	Pox(int a,int b,int c){
	    id = a;
	    time = b;
	    difficulty = c;
	}

    }

    public static void main(String args[])throws IOException{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  
	while(true)
	      {
		  int n,m;
		  String line = in.readLine();
		
		  List<Integer> list = new ArrayList<Integer>();
		  List<Integer> list2 = new ArrayList<Integer>();

		  n = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		  m = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		  
		  if(n == 0 && m == 0)
		      break;		  

		  String[] elements = in.readLine().split(" ");    

		  for(int i=0;i<elements.length;i++)
		      {
			  list.add(Integer.parseInt(elements[i]));
		      }

		  int pre = m;
		  List<Pox> list3 = new ArrayList<Pox>();

		  for(int i=0;i<list.size();i++)
		      {
			
			  if(pre >= m/list.get(i)*list.get(i))
			      {
				  list2.add(m/list.get(i)*list.get(i));
				  pre = m/list.get(i)*list.get(i);
				  list3.add(new Pox(i,pre,list.get(i)));
			      }
			  else
			      {
				  int val = list.get(i);
				  int cnt = val;
				  while(val*cnt < pre)
				      {
					  cnt++;
				      }
			
				  list2.add(val*cnt);
				  pre = val*cnt;
				  list3.add(new Pox(i,pre,val));
			      }
			 
		      }

		  Collections.sort(list3,new Comparator<Pox>(){

			  @Override
			      public int compare(Pox a,Pox b){
			      if(a.time != b.time)
				  {
				      if(a.time > b.time)
					  return 1;
				      else 
					  return -1;
				  }
			      if(a.difficulty != b.difficulty)
				  {
				      if(a.difficulty > b.difficulty)
					  return 1;
				      else
					  return -1;
				  }
			      return -1;
			  }
		      });

		  if(list3.get(0).time != list3.get(1).time)
		      {
			  System.out.println(list3.get(0).id+1);
		      }
		  else if(list3.get(0).difficulty != list3.get(1).difficulty)
		      {
			  System.out.println(list3.get(0).id+1);
		      }
		  else
		      {
			  System.out.println(n);
		      }


	      }
      }

}

Measured memory_bytes: 11000
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var res = 0;
            var c = 0;
            for(var i = 0; i < a.Length; i++)
            {
                if('A' != a[i] && 'C' != a[i] && 'G' != a[i] && 'T' != a[i])
                {
                    c = 0;
                    continue;
                }
                c++;
                if (res < c) res = c;
            }
            Console.WriteLine(res);
        }
    }

    public class Scanner
    {
        public static string[] scan => Console.ReadLine().Split(' ');
        public static int[] scanint => Array.ConvertAll(scan, int.Parse);
        public static long[] scanlong => Array.ConvertAll(scan, long.Parse);
        public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => scan).ToArray();
        public static int[][] rescanint(int n) => Enumerable.Repeat(0, n).Select(_ => scanint).ToArray();
        public static long[][] rescanlong(int n) => Enumerable.Repeat(0, n).Select(_ => scanlong).ToArray();

    }

    public class Ex
    {
        public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


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

int main(){
    string w,t;
    getline(cin,w);
    int i;
    for(i=0;i<w.size();i++){
        if(w[i]>='A'&&w[i]<='Z')w[i]+='a'-'A';
    }
    int count=0;
    cin>>t;
    while(true){
        if(t=="END_OF_TEXT")break;
        for(i=0;i<t.size();i++){
            if(t[i]>='A'&&t[i]<='Z')t[i]+='a'-'A';
        }
        if(w==t)count++;
        cin>>t;
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int M = 1e5+5;
const int MD= 1e9+7;

ll dp[M];
ll MOD(ll x,ll n){
	ll ans=1;
	while(n>0)
	{
		if(n%2==0){
			x = (x*x)%MD;
			n=n/2;
		}
		else{
			ans = (ans * x)%MD;
			n = n-1;
		}
	}
	return ans%MD;
}

int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n,k;
		ll res=0;
		cin>>n>>k;	
		for(int i=k;i>=1;i--){
			dp[i]=MOD(k/i,n);
			for(int j=2*i;j<=k;j+=i){
				dp[i]=(dp[i]-dp[j]+MD)%MD;
			}
			res=(res+i*dp[i])%MD;
		}
		cout<<res;
	}	
	return 0;
}

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

signed main () {
	int n, k;
	cin >> n >> k;
	vector < int > a(n + 1, 0);
	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int c;
			cin >> c;
			++a[c];
		}
	}
	cout << count(a.begin(), a.end(), 0) - 1 << '\n';
}


Measured memory_bytes: 3628
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}
const int INF = 1e9 + 7;


void saiki(int nowy, int nowx, int nowd, vector<vector<int>> &dist, vector<string> &dat){
    int h = dat.size();
    int w = dat[0].size();
    if(dist[nowy][nowx] <= nowd)
        return;
    dist[nowy][nowx] = nowd;
    int vec[][2] = {{1, 0}, {-1,0},{0,1},{0,-1}};
    REP(k, 4){
        int toy = nowy + vec[k][0];
        int tox = nowx + vec[k][1];
        if(0<=toy&&toy<h&&0<=tox&&tox<w&&dat[toy][tox] == '.'){
            saiki(toy, tox, nowd+1, dist, dat);
        }
    }
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> dat(h);
    REP(i, h){
        cin >> dat[i];
    }

    int ans = -1;

    FOR(sy, 0, h){
        FOR(sx, 0, w){
            if(dat[sy][sx] =='#')
                continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            saiki(sy, sx, 0, dist, dat);
            REP(i, h)
                REP(j, w)
                    if(dat[i][j] == '.')
                    ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    LL d,l,r,cnt=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3648
import itertools
A = range(int(input()) + 1)
B = range(int(input()) + 1)
C = range(int(input()) + 1)
X = int(input())

ptn = list(itertools.product(A, B, C))
cnt = 0
for i in ptn:
        if i[0] * 500 + i[1] * 100 + i[2] * 50 == X:
                cnt += 1

print(cnt)

Measured memory_bytes: 13604
# Date [ 2020-09-13 21:05:36 ]
# Problem [ c.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class Combination:
    def __init__(self, n, p):
        self.n = n
        self.p = p
        self.note = [1, 1]
        self.noteinv = [1, 1]
        self.inv = [0, 1]
        self.calc()

    def calc(self):
        for i in range(2, self.n + 1):
            self.note.append((self.note[-1] * i) % self.p)
            self.inv.append((-self.inv[self.p % i] * (self.p // i)) % self.p)
            self.noteinv.append((self.noteinv[-1] * self.inv[-1]) % self.p)
    
    def nCr(self, n, r):
        n = self.n
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return (self.note[n] * self.noteinv[r] * self.noteinv[n - r]) % self.p


def Main():
    n = read_int()
    if n == 1:
        print(0)
        exit()
    elif n == 2:
        print(2)
        exit()
    ans = pow(10, n, MOD) - pow(9, n, MOD) * 2 + pow(8, n, MOD)
    ans %= MOD
    print(ans)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9320
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}


int main() 
{
	int n,k;
	cin>>n>>k;
	if((k-1)*2+1>n)
	{
		cout<<"NO";
	}
	else
	{
		cout<<"YES";
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if(B<=N){
            if(N != 1) N = B - 1;
        }
        long ans1 = (int)((A*N)/B);
        long ans2 = (long)A * (int)(N/B);
        long ans3 = ans1 - ans2;
        System.out.println(ans3);

    }
}

Measured memory_bytes: 37212
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line.split(" "));
});
reader.on('close', () => {
  solve();
});

function getInt(strArr){
  var rtn = [];
  for(elem of strArr)rtn.push(parseInt(elem));
  return rtn;
}

function getFloat(strArr){
  var rtn = [];
  for(elem of strArr)rtn.push(parseFloat(elem));
  return rtn;
}

function solve(){
  var [N,M] = getInt(lines[0]);
  console.log(N==M ? "Yes" : "No")
}

Measured memory_bytes: 29752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S, T;
  cin >> S >> T;
  ll A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (S == U)
    A--;
  else
    B--;
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    a=list(bin(i)[2:])
    a=['0']*(n-1-len(a))+a
    j=0
    num=s[0]
    while j<n-1:
        if a[j]!='0':
            ans += int(num)
            num=''
        j+=1
        num+=s[j]
    ans+=int(num)
print(ans)

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

int main(){
	int n, r;
	while(cin >> n >> r){
		if(n == 0 && r == 0) break;
		const int max = 50;
		int cards[max + 1];
		int pcards[max + 1];
		int ccards[max + 1];
		for(int i = 1; i <= n; i++)
			cards[i] = n - i + 1;
		for(int j = 0; j < r; j++){
			int p, c;
			int k = 1;
			int l = 1;
			cin >> p >> c;
			for(;k < p; k++)
				pcards[k] = cards[k];
			for(;k < p + c; k++)
				ccards[k - p + 1] = cards[k];
			for(; l <= c; l++)
				cards[l] = ccards[l];
			for(; l < p + c; l++)
				cards[l] = pcards[l - c];
		}
		cout << cards[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
M = 1000000007
h, w, a, b = list(map(int, input().split()))


def inv(k):
    return pow(k, M - 2, M)


def comb(n, k):
    if n < k:
        return 0
    elif k == 0:
        return 1
    else:
        r = 1
        for i in range(k):
            r = (r * ((n - i) * inv(k - i)) % M) % M
        return r


ans = comb(h + w - 2, h - 1)

if a == 1 and b == 1:
    ans -= 1
elif a == 1:
    ans -= comb(h + b - 2, h - 1)
elif b == 1:
    ans -= comb(w + a - 2, w - 1)
else:

    memo = [1] * b
    for i in range(1, b):
        memo[i] = (memo[i - 1] * (h - a + i) * inv(i)) % M

    memo2 = [0] * b
    height = a - 1
    width = w - b
    memo2[b - 1] = comb(height + width, height)
    for i in range(1, b):
        memo2[b - i - 1] = (memo2[b - i] * (height + width + i) * inv(width + i)) % M

    ans -= memo[0] * memo2[0]
    ans %= M
    for i in range(1, b):
        ans -= (memo[i] - memo[i - 1]) * memo2[i]
        ans %= M

print(ans % M)


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

struct node{
  int key;
  struct node *parent, *left, *right;
};

struct node *root, *NIL;

void insert(int);
void inorder(struct node *);
void preorder(struct node *);

int main(){
  int n, i, x;
  char array[10];  //"insert" or "print"

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s",&array[0]);
    if(strcmp(array, "insert")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else {
      scanf("%d", &x);
      insert(x);
    }
  }
  
  return 0;
}
void insert(int k){
  struct node *y = NIL;  //xの親。
  struct node *x = root;
  struct node *z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;  //挿入する節点は必ず葉になるから、z->left, z->right には NIL が入る。
  z->right = NIL;

  while(x != NIL){
    y = x;  //一時的に親。本当の親になるかもしれない。
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else {
    if(z->key < y->key) y->left = z;  //最後の insert 25 の場合。
    else y->right = z;                //20の左の子は既にうまっている。20の右の子に必ずなるようになっている。
  }                                   //もし、insert 19だったら、17の左の子か右の子になる。あたりまえだけど。
  
}
void inorder(struct node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(struct node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<"\n";
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	long long m, d;

	std::cin >> m >> d;

	long long ans = 0;
	long long temp = (m - d) * 100 + d * 1900;

	for (size_t i = 0; i < (1 << d); i++)
	{
		ans += temp;
	}

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

	return 0;
}

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  ll gedoku = a + b;
  if (gedoku >= c) {
    cout << b + c << endl;
  } else {
    cout << b + (gedoku) + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back
#define fi first
#define se second

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;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}

int N;
vector<int>G[200005];
int ch[200005];
int dp1[200005],dp2[200005];
void dfs1(int x,int p){
	vector<int>v;
	dp1[x]=1;
	for(int i:G[x])if(i!=p){
		dfs1(i,x);
		v.pb(ch[i]);
		(dp1[x]*=dp1[i])%=mod;
		ch[x]+=ch[i];
	}
	int memo=ch[x];
	for(int i:v){
		(dp1[x]*=nCk(memo,i))%=mod;
		memo-=i;
	}
	ch[x]++;
}
void dfs2(int x,int p){
	dp2[x]=dp2[x]*nCk(N-1,N-ch[x])%mod;
	for(int i:G[x])if(i!=p){
		dp2[i]=dp2[x]%mod*mod_pow(nCk(N-1,ch[i]),mod-2)%mod;
		dfs2(i,x);
	}
}
signed main(){
	init_perm();
	cin>>N;
	rep(i,N-1){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	dfs1(0,0);
	dp2[0]=dp1[0];
	dfs2(0,0);
	rep(i,N)cout<<dp2[i]<<endl;
}



Measured memory_bytes: 35156
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}

#define int ll
int gyaku(int now) {
	int b = MAX_MOD - 2;
	int ans = 1;
	while (b != 0) {
		if (b % 2) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		b /= 2;
	}
	return ans;
}
int sosuu[2000000];
void solve() {
	int n;
	cin >> n;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	vector<int> now = inputs;
	map<int, int> gogo;
	REP(i, n) {
		for (int j = 2; j*j <= now[i]; ++j) {
			int cnt = 0;
			while (now[i] % j == 0) {
				now[i] /= j;
				cnt++;
			}
			gogo[j] = max(gogo[j], cnt);
		}
		gogo[now[i]] = max(gogo[now[i]], 1LL);
	}
	ll ans = 1;
	for (auto x : gogo) {
		REP(q, x.second) {
			ans *= x.first;
			ans %= MAX_MOD;
		}
	}
	int final_ans = 0;
	REP(i, inputs.size()) {
		int geko = ans * gyaku(inputs[i]);
		geko %= MAX_MOD;
		final_ans += geko % MAX_MOD;
		final_ans %= MAX_MOD;
	}
	cout << final_ans << endl;
}

#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define lb(a,x) distance((a).begin(),lower_bound(all(a),(x)))
#define ub(a,x) distance((a).begin(),upper_bound(all(a),(x)))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll a;
  string b;
  cin >> a >> b;
  ll c = (b[0]-'0')*100 + (b[2]-'0')*10 + b[3]-'0';
  cout << a*c/100 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long

int main() {
	ll i,j,k,l,n,m,a,b,c,tot=0,ans=0;
	cin>>a>>b;
	a = a%b;
	cout<<min(a,abs(a-b))<<endl;
	return 0;
}



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

int main() {
  string a,b;
  cin >> a >> b;
  int N= stoi(a+b);

  int div= 1;
  while(div*div < N){
    div++;
  }
  if(div*div==N){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
ans = [0]*(n+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            i = x**2+y**2+z**2+x*y+y*z+z*x
            if 1 <= i <= n:
                ans[i] += 1

for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 74544
n = list(input())
ori = ''.join(map(str, n))
n = set(n)

if len(n) == 1:
    n = list(n)
    print(str(n[0] * 3))
else:
    print()
    if int(str(int(ori[0])) * 3) > int(ori):
        print(str(int(ori[0])) * 3)
    else:
        print(str((int(ori[0])+1)) * 3)

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

using namespace std;


int main()
{
    int N, M;
    long p[100000], y[100000];

    vector<long> pre[100001];
    //vector<long> ans[100001];

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> p[i] >> y[i];
        pre[p[i]].push_back(y[i]);
    }
    for (int i = 1; i < N+1; i++) {
        sort(pre[i].begin(), pre[i].end());
    }
    for (int i = 0; i < M; i++) {
        cout << setfill('0') << right << setw(12) <<
            p[i] * 1000000 + int(lower_bound(pre[p[i]].begin(), pre[p[i]].end(), y[i]) - pre[p[i]].begin() + 1) << endl;
    }
    
    return 0;   
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define LINF 1LL<<60

struct BIT {
	int N;
	vector<ll> bit;
	BIT(int N):N(N) {
		/* BIT???[1..N]??§??±??? */
		bit.resize(N + 1, 0);
	}

	void add(int x, int val)
	{
		while (x <= N) {
			bit[x] += val;
			x += x & -x;
		}
	}

	int sum(int x)
	{
		int ret = 0;
		while (x) {
			ret += bit[x];
			x &= (x - 1);
		}

		return (ret);
	}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	BIT bit(n);
	for (int i = 0; i < q; i++) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0) {
			bit.add(x, y);
		}
		else {
			cout << bit.sum(y) - bit.sum(x-1) << endl;
		}
	}
}

Measured memory_bytes: 3480
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <complex>
using namespace std;
typedef complex<double> P;

int main(){
	int n,T=0;
	while(cin >> n , n){
		vector<P> p(n+1);
		for(int i = 0 ; i < n ; i++)
			cin >> p[i].real() >> p[i].imag();
		p[n] = p[0];
		reverse(p.begin(),p.end());
		double S = 0 ; 
		for(int i = 0 ; i < n ; i++){
			S += (p[i].real() - p[i+1].real()) * (p[i].imag()+p[i+1].imag());
		}
		S /= 2.0;
		printf("%d %.1f\n",++T,S);
	}
}

Measured memory_bytes: 0
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let s = s.trim();
	let ans = match s {
		"RRR" => 3,
		"RRS" | "SRR" => 2,
		"SSS" => 0,
		_ => 1,
	};
	println!("{}", ans);
}


Measured memory_bytes: 2092
#include <stdio.h>

int main(){
	int H,W,i;
  	char C[101][101];
  
  	scanf("%d %d",&H,&W);
  	for(i=0;i<H;i++)
	  	scanf("%s",C[i]);

  	for(i=0;i<H;i++)
	  	printf("%s\n%s\n",C[i],C[i]);
  
  	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int x,y;
	while (true) {
		cin >> x;
		cin >> y;

		if (x == 0 && y == 0) {
			break;
		}

		if (x < y) {
			cout << x << " " << y << endl;
		}
		else {
			cout << y << " " << x << endl;
		}

		
	}

	return 0;
}

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

char s[4][200],x_x;
int len[4],i[4],p;
int main()
{
	scanf("%s %s %s",s[1],s[2],s[3]);
	len[1]=strlen(s[1])-1;
	len[2]=strlen(s[2])-1;
	len[3]=strlen(s[3])-1;

	void gun(char x);
	gun('a');
}

void gun(char x){	
	if(x=='a')
		p=1;
	else if(x=='b')
		p=2;
	else if(x=='c')
		p=3;

	if(i[p]<=len[p]){
		x_x=s[p][i[p]];
		s[p][i[p]]='\0';
		i[p]++;
		gun(x_x);
	}
	else
		printf("%c\n",x-32);
}

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

int a[50],n,p;
int main(){
	while(scanf("%d%d",&p,&n),n*p){
		memset(a,0,sizeof(int)*50);
		int t=n,z=0;
		for(;!(a[z]==n-1&&t==1);z=(z+1)%p){
			if(t){
				t--;
				a[z]++;
			}else{
				t=a[z];
				a[z]=0;
			}
		}
		printf("%d\n",z);
	}
	return 0;
}

Measured memory_bytes: 1028