akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <bitset>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <ctype.h>
#include <cmath>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <complex>
#include <functional>
#include <climits>
#include <cassert>
#include <iterator>
#include <math.h>
#include <time.h>
#include <string.h>
#include <locale.h>

#define bit(n) (1<<(n))
#define inf 1000000000
#define eps 1e-9
#define PI 3.1415926535897932385
#define pb push_back
#define sz size()
#define mp make_pair
#define cl clear()
#define all(a) a.begin(),a.end()
#define fill(ar,val) memset(ar,val,sizeof(ar))
#define MIN(a,b) if(a>(b)) a=(b)
#define MAX(a,b) if(a<(b)) a=(b)
#define sqr(x) ((x)*(x))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
//#define MOD 1000000007
#define bsize 1111


using namespace std;
 // ================================================================== //

vector<int>  vi;
int main()
{
    // * Faster Input *//
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    // * ========================================================== * //
    int n,p;
    cin >> n;
    for(int i=0;i<(2*n) ;i++)
    {
        cin >> p;
        vi.pb(p);
    }
    sort(all(vi));
    int val = 0;
    for(int i=0;i<=(2*n)-2;i+=2)
    {
        val+= min(vi[i],vi[i+1]);
       // cout << val <<"*"<<endl;
    }
    cout << val << endl;
 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n;
  int a,b,c;
  int tmp;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> a >> b >> c;

  if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }

  if(a*a+b*b==c*c)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace AOJ_console
{
    class _1_6_A
    {
        static void Main()
        {
            Console.ReadLine();
            Console.WriteLine(Console.ReadLine().Split(' ').Reverse<string>().ToList().Aggregate((ans, x) => ans + " " + x).Trim());
        }
    }
}

Measured memory_bytes: 9260
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int lcm(int a, int b){
    return a / __gcd(a, b) * b ;
}
signed main(){
    fastio
    int n ;
    cin >> n ;
    int ans = 1 ;
    for(int i = 0; i < n; i++){
        int x ;
        cin >> x ;
        ans = lcm(ans, x) ;
    }
    cout << ans << endl;
    return 0; 
}

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

long long n, k, a[11], ans=1;

int main() {
    cin >> n >> k;
    a[0] = k;
    for (int i=0;n>0; i++) {
        if (n%2 == 1) ans*=a[i];
        ans = ans%1000000007;
        n/=2;
        a[i+1]=(a[i]*a[i])%1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3124
import java.util.Scanner;

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

        int S=sc.nextInt();
        int W=sc.nextInt();

        if (S>W) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }
    }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),M = in();
    vector<int> k(M);
    vector<vector<int>> s(M,vector<int>(0));
    REP(i,M){
        k[i] = in();
        REP(l,k[i]){
            s[i].pb(in()-1);
        }
    }
    int count = 0;
    vector<int> p(M);
    REP(i,M)p[i] = in();
    REP(i,modpow(2,N)){
        bool ok = 1;
        REP(l,M){
            int sum = 0;
            REP(t,k[l]){
                if(i & 1LL << s[l][t])sum++;
            }
            if(sum % 2 != p[l])ok = 0;
        }
        if(ok)count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
void solve(){
	string s,t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	ll mx = 0;
	for(int i=0;i<n-m+1;i++){
		ll cnt = 0; 
		for(int j=0;j<m;j++){
			if(s[j+i]==t[j]){
				cnt++;
			}
		}
		mx = max(mx,cnt);
	}
	cout<<m-mx<<endl;
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;
 

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

        for(int i=0; i<N; i++){
            A[i] = sc.nextLong();
        }

        int j=0;
        while(A[j]%2==0){
            A[j] /=2;
            if(j==N-1){
            count++;
            j=0;
            continue;
            }     
            j++;
        }

        System.out.println(count);

        }
    }    





Measured memory_bytes: 21844
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int maxn = 200200;

int n, k;

int p[maxn];
int c[maxn];
int mx[maxn], mn[maxn];

vector<int> q;

int ans;

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

  cin >> n >> k;

  for (int i = 0; i < n; i ++)
    cin >> p[i];

  for (int i = 0; i < n; i ++)
    {
      while (q.size() and p[q.back()] < p[i])
	q.pop_back();
      if (q.size())
	mx[i] = q.back();
      else
	mx[i] = -1;
      q.push_back(i);
    }

  q.resize(0);

  for (int i = n; i --; )
    {
      while (q.size() and p[q.back()] > p[i])
	q.pop_back();
      if (q.size())
	mn[i] = q.back();
      else
	mn[i] = n;
      q.push_back(i);
    }

  c[0] = 1;
  for (int i = 1; i < n; i ++)
    if (p[i] > p[i - 1])
      c[i] = c[i - 1] + 1;
    else
      c[i] = 1;

  int d = n;
  for (int i = n; i --; )
    if (c[i] >= k)
      d = i;

  ans = n - k + 1;

  for (int i = 0, j = k; j < n; i ++, j ++)
    if (mn[i] >= j and mx[j] <= i)
      ans --;
    else if (c[j] >= k and j > d)
      ans --;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int main() {
	int n,a,b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%s\n", (a+b)%2 ? "Borys" : "Alice");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	string s; cin >> s;
	map<char,int> u;
	char one = s[0];
	for (int i = 0; i < 4; i++) {
		if (u.find(s[i]) != u.end())u[s[i]]++;
		else u[s[i]] = 1;
	}
	if (u.size() == 2) {
		if (u[one] == 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;






	return 0;
}


Measured memory_bytes: 256
/*......................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double   ld;

//#include <ext/pb_ds/assoc_container.hpp>   
//#include <ext/pb_ds/tree_policy.hpp>  
//#include <functional> 
//using namespace __gnu_pbds;  
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> OST;           //unique elements 

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    pf                       push_front
#define    mp                       make_pair
#define    T                        int t; cin >> t; while(t--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    setp(x)                  setprecision(x)
#define    ook(x)                   order_of_key(x)
#define    fbo(x)                   find_by_order(x)

//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int ans[200005];

int main(){                                       //constraints , long long
     speed upp
     string s; cin >> s;
     vector <int> left , rght;
     int size = sz(s);
     f(i,0,size-1){
         if(s[i]=='L'){
             left.pb(i);
         }
         else{
             rght.pb(-i);
         }
     }
     sort(all(rght));
     f(i,0,size-1){
         if(s[i] == 'R'){
             auto it = lower_bound(all(left) , i);
             int dif = *it - i;
             if(dif%2){
                 ans[*it-1]++;
             }
             else{
                 ans[*it]++;
             }
         }
         else{
             auto it = lower_bound(all(rght) , -i);
             int dif = *it - i;
             if(dif%2){
                 ans[-*it+1]++;
             }
             else{
                 ans[-*it]++;
             }
         }
     }
     f(i,0,size-1){
         cout << ans[i] << " ";
     }
}




Measured memory_bytes: 1612
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll MAX = 1e5 + 1;
const ll INF = 2e9 + 7;
ll dp[101][MAX];

int main(void)
{
	ll n, W;
	cin >> n >> W;
	ll w[n], v[n], sum = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> w[i] >> v[i];
		sum += v[i];
	}

	for(int i = 0; i <= sum; i++)
		dp[0][i] = INF;

	for(int i = 0; i <= n; i++)
		dp[i][0] = 0;

	ll j, ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(j = 1; j <= sum; j++)
		{
			if(j >= v[i])
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else
				dp[i][j] = dp[i - 1][j];

			if(dp[i][j] <= W)
				ans = max(ans, j);
		}
	}

	cout << ans << endl;





	return 0;
}

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

int main()
{
  	char arr[105];
  
  	scanf("%s",arr);
  
  	int len = strlen(arr);
  	int i=0;
  	int j= len-1;
  	int sum = 0;
  	while(i < j){
      		if(arr[i] != arr[j]){
              	sum += 1;
            }
            i++;
            j--;
    }
  	
  	printf("%d",sum);
  
  	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int N ,M;
    cin >> N >> M;
    char A[50][50], B[50][50];
    rep(i, N){
        rep(j, N){
            cin >> A[i][j];
        }
    }
    rep(i, M){
        rep(j, M){
            cin >> B[i][j];
        }
    }
    bool exist = false;
    rep(i, N-M+1){
        rep(j, N-M+1){
            bool match = true;
            rep(k, M){
                rep(l, M){
                    if(A[k+i][l+j]!=B[k][l]) match = false;
                }
            }
            if(match) exist =true;
        }
    }
    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N, A; cin >> N >> A;
    cout << N*N-A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int N=1000;
int lcs(string x,string y){
	int c[N+1][N+1];
	int m=x.size();
	int n=y.size();
	int maxl=0;
	x=' '+x;
	y=' '+y;
	for(int i=1;i<=m;i++)	c[i][0]=0;
	for(int j=1;j<=n;j++)	c[0][j]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i]==y[j])	c[i][j]=c[i-1][j-1]+1;
			else 	c[i][j]=max(c[i-1][j],c[i][j-1]);
			maxl=max(maxl,c[i][j]);
		}
	}
	return maxl;
}
int main(){
	string s1,s2;
	int n;	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s1>>s2;
		cout<<lcs(s1,s2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 5128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
    int n;
    cin >> n;
    ll ans = 0LL;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        ans+=(tmp-1);
    }
    cout << ans << endl;
    
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main (){
    int n, m;
    cin >> n >> m;
    vector<int> he(100001);
    rep(i,n) cin >> he[i];
    vector<int> A(100001);
    vector<int> B(100001);
    vector<int> judge(100001);
    rep(i,m){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    rep(i,n) judge[i] = 1;
    rep(i,m){
        if (he[A[i]] > he[B[i]]) judge[B[i]] = 0;
        else if(he[A[i]] < he[B[i]]) judge[A[i]] = 0;
        else judge[A[i]] = judge[B[i]] = 0;
    }
    int count  = 0;
    rep(i,n) if (judge[i] == 1) count += 1;
    cout << count << endl;
}

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

const string march = "MARCH";
const string combination[10] = {"MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH"};

int main(){
    long long N;
    map<char, long long> name2num;
    for(auto m:march) name2num[m] = 0;

    cin >> N;
    string tempS;
    for(long long i=0;i<N;i++){
        cin >> tempS;
        name2num[tempS[0]]++;
    }
    // for(auto nn:name2num) cout << nn.first << " " << nn.second << endl;
    long long ans = 0;
    for(long long i=0;i<10;i++){
        ans += name2num[combination[i][0]] * name2num[combination[i][1]] * name2num[combination[i][2]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
S = input()
SL = S[:N]
SR = S[N:][::-1]

ans = 0
memo = defaultdict(int)

for bit in range(1 << N):
    red = ""
    blue = ""
    for i in range(N):
        if bit & (1 << i):
            red += SL[i]
        else:
            blue += SL[i]
    memo[(red, blue)] += 1

for bit in range(1 << N):
    red = ""
    blue = ""
    for i in range(N):
        if bit & (1 << i):
            red += SR[i]
        else:
            blue += SR[i]
    ans += memo[(red, blue)]

print(ans)

Measured memory_bytes: 166008
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x/500) * 1000;
	x %= 500;
	ans += (x/5) * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3660
import Debug.Trace
import Data.List

main :: IO ()
main = do
  [n, k] <- (map read . words) <$> getLine :: IO [Int]
  print $ sum $ map (\b -> (subtotal n k b)) [k + 1 .. n]

subtotal n k b =
  let low = (n - (b - 1)) `div` b
      high = (n - k) `div` b
      d = if k == 0 then 1 else 0
  in
    if low < high
      then
        let m = low * b + b
        in
          (low + 1) * (m - (n - (b - 1))) + (high + 1) * (n - k - m + 1) - d
      else (low + 1) * (b - k) - d


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> num(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			num[j]++;
		}
	}

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += i * num[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 81328
import heapq

N = int(input())
A = list(map(int, input().split()))

leftQue = []
rightQue = []

leftSum = 0
rightSum = 0

for i in range(N):
    heapq.heappush(leftQue, A[i])
    leftSum += A[i]

    heapq.heappush(rightQue, -A[-1 - i])
    rightSum -= A[-1 - i]

left = [-float('inf') for _ in range(3 * N)]
right = [-float('inf') for _ in range(3 * N)]

left[N - 1] = leftSum

for middle in range(N, 2 * N):
    leftSum += A[middle]
    leftSum -= heapq.heappushpop(leftQue, A[middle])
    left[middle] = leftSum

right[2 * N - 1] = rightSum
for middle in range(2 * N - 1, N - 1, -1):
    rightSum -= A[middle]
    rightSum -= heapq.heappushpop(rightQue, -A[middle])
    right[middle - 1] = rightSum

ans = -float('inf')
for l, r in zip(left, right):
    ans = max(ans, l + r)

print(ans)

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

int main(){
 while(true){
  int h,w;
  cin >> h >> w;
  
  if(h==0 && w==0) break;

  int d = h*h+w*w;

  int H = 150;
  int W = 150;
  int D = 150*150+150*150;

  for(int y=1; y<=150; y++){
   for(int x=y+1; x<=150; x++){
    int z = y*y+x*x;

    if(z<=d){
     continue;
    }else{
     if(z<D){
      H = y; 
      W = x;
      D = z;
     }
     break;
    }
   }
  }
  
  for(int y=h+1; y<150; y++){
   bool flag = false;
   
   for(int x=y+1; x<=150; x++){
    int z = y*y+x*x;
 
    if(z==d){
     H = y; 
     W = x;
     D = z;
     flag = true;
    }
    if(z>=d) break;
   }   
   if(flag) break;
  }

  cout << H << ' ' << W << endl;
 }
 return 0;
}
 


Measured memory_bytes: 3104
import sys

# print('input >>')
N, K = map(int,(input().split()))
As = list(map(lambda x: int(x)-1,(input().split())))

visited = [0] * N
visited[0] = 1
roots = [0]
now = 0

# print('-----output-----')
while True:
    now = As[now]
    if visited[now] == 1:
        p = now
        rep_start = roots.index(now)
        move = len(roots) - rep_start
        break
    roots.append(now)
    visited[now] = 1

now = 0
if rep_start > K:
    for i in range(K):
        now = As[now]
    print(now+1)
    sys.exit()

# now = p
# for i in range(rep_start):
    # now = As[now]


K -= rep_start
K %= move
now = p

# print('K', K)
# print('now',now)

for i in range(K):
    now = As[now]

print(now+1)

Measured memory_bytes: 32392
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, A, B;
   cin >> N >> A >> B;
   if (abs(A - B) % 2 == 0) cout << "Alice" << endl;
   else cout << "Borys" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
#define vii vector <pair <int, int> >
using namespace std;

string s, al;
map <char, bool> mp;
vector < string > g;

void solve(string a) {


    for(auto it : a) {

        mp[it] = 1;

    }

    char ans;

    bool kek = 0;

    for(auto it : al) {

        if(!mp[it] && it > s[a.sz()]) {ans = it; kek = 1;break;}

    }

    if(kek) {a.pb(ans);g.pb(a);}

    mp.clear();


}

int main(){

//freopen("ladder.in", "r", stdin);
//freopen("ladder.out", "w", stdout);

for(int i = 0; i < 26; ++i) {

    al.pb(char(i + 97));

}

cin >> s;

if(s == "zyxwvutsrqponmlkjihgfedcba") {cout << -1;return 0;}

if(s.sz() != 26) {

    for(auto it : s) {

        mp[it] = 1;

    }

    char ans;

    for(auto it : al) {

        if(!mp[it]) {ans = it;break;}

    }

    cout << s << ans;

}

else {


    string a;

    for(int i = 0; i < s.sz(); ++i) {

        mp[s[i]] = 1;
        solve(a);
        a.pb(s[i]);

    }

    sort(all(g));

    cout << g[0];

}



return 0;
}


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

signed main(){
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.push_back(x);
	}
	if(n<3){
		cout<<"0";
		return 0;
	}
	int s=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(v[i]!=v[j]&&v[i]!=v[k]&&v[j]!=v[k]){
					if(v[i]+v[j]>v[k]&&v[i]+v[k]>v[j]&&v[j]+v[k]>v[i]) s++;
				}
			}
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = input[0];
		var a = input[1];
		var b = input[2];


		var ans = 0;
		for (var i = 1; i <= n; i++)
		{
			var currentAns = Solve(i);

			if (currentAns >= a && currentAns <= b)
			{
				ans += i;
			}
		}

		System.Console.WriteLine(ans);
	}

	static int Solve(int n)
	{
		int sum = 0;

		while (n > 0)
		{
			sum += n % 10;
			n /= 10;
		}

		return sum;
	}
}

Measured memory_bytes: 13268
N,L=map(int,input().split())
lis=[]
for i in range(N):
    lis.append(L+i)
if 0 in lis:
    print(sum(lis))
else:
    lis2=sorted(lis)
    ans=sum(lis2[1:-1])
    if lis2[0]/abs(lis2[0])==-1:
        ans+=lis2[0]
    else:
        ans+=lis2[-1]
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int ct = 0;
    int l, r, d; cin>>l>>r>>d;
    For(i, l, r+1){
        if(i%d==0)
            ct++;
    }
    cout<<ct;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3608
#
# 149C Next Prime
#

def isPrime(num):
    if num == 2:
        return True
    for p in range(2, num):
        if  num % p == 0:
            return False
    return True

if __name__ == "__main__":
    n = input()
    num = int(n)
    while True:
        if isPrime(num):
            print(num)
            break
        num += 1



Measured memory_bytes: 9144
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

sc = sorted(sc, key= lambda x: x[0])
ans = [0] * N

check = [-1] * N
for i in sc:
    if N == 3 and i[0] == 1 and i[1] == 0:
        print(-1)
        exit()
    if N == 2 and i[0] == 1 and i[1] == 0:
        print(-1)
        exit()
    if check[i[0]-1] == -1:
        check[i[0]-1] = i[1]
    elif check[i[0]-1] != i[1]:
        print(-1)
        exit()


for i in sc:
    ans[i[0] - 1] = i[1]

if len(ans) == 3 and ans[0] == 0:
    ans[0] = 1
if len(ans) == 2 and ans[0] == 0:
    ans[0] = 1
for i in ans:
    print(i, end="")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};

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

    string S;
    cin>>S;
    string T=S;
    reverse(T.begin(),T.end());
    bool flag=true;
    for(int i=0;i<(int)S.size();i++){
        if(S[i]=='b'){
            if(T[i]!='d') flag=false;
        }else if(S[i]=='d'){
            if(T[i]!='b') flag=false;
        }else if(S[i]=='p'){
            if(T[i]!='q') flag=false;
        }else if(T[i]!='p') flag=false;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	ll n;
	cin>>n;
	vector<ll> b(60);
	rep(i,n){
		ll a;
		cin>>a;
		rep(j,60){
			if(a & (1LL<<j)) b[j]++;
		}
	}
	ll ans=0;
	rep(i,60){
		ll ad=((1LL<<i)%MOD)*b[i]%MOD*(n-b[i])%MOD;
		ans=(ans+ad)%MOD;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
S=list(input().strip())

for i in range(N):
    if S[i]=="R":
        S[i]=0
    elif S[i]=="G":
        S[i]=1
    else:
        S[i]=2

ANS=0

CL=[[0,0,0] for i in range(N+1)]
for i in range(N-1,-1,-1):
    for j in range(3):
        CL[i][j]=CL[i+1][j]

    CL[i][S[i]]+=1


for i in range(N):
    for j in range(i+1,N):
        if S[i]!=S[j]:
            ANS+=CL[j][3-S[i]-S[j]]

            if j+(j-i)<N:
                x=j+(j-i)
                if S[x]!=S[i] and S[x]!=S[j]:
                    ANS-=1

print(ANS)


Measured memory_bytes: 74424
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

ll dsum(ll n){
  if( n == 0)
    return 0;
  else
    return n%10 + dsum(n/10);

}

int main()
{
  ll K;
  vector<ll> snukekoho(0),snuke(0);
  cin >> K;
  for(ll i=1;i<1000;i++){
    for(ll k=0;k<15;k++){
      ll dd = 1;
      REP(f,k)dd *= 10; 
      snukekoho.push_back(i*(dd)-1);
    }
  }
  sort(snukekoho.begin(),snukekoho.end());
  double d=(double)snukekoho[snukekoho.size()-1]/(double)dsum(snukekoho[snukekoho.size()-1]);
  for(int i=snukekoho.size()-2;i>=0;i--){
    double a = (double)snukekoho[i]/(double)dsum(snukekoho[i]);
      if(d > a){
        d = a;
        snuke.push_back(snukekoho[i]);
      }
  }
  REP(i,8)snuke.push_back(i+1);
  sort(snuke.begin(),snuke.end());
  REP(i,K){
    cout << snuke[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 512
#include<iostream>

using namespace std;

#define MAX 100000

typedef long long llong;

int n,k;

llong T[MAX];
int check(llong P){
	int i = 0;
	for( int j=0;j <k; j++ ){
		llong s = 0;
		while(s+T[i]<=P){
			s += T[i];
			i++;
			if( i == n ) return n;
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 10000*100000;
	llong mid;
	while( right-left > 1 ){
		mid = (left+right)/2;
		int v = check(mid);
		if( v >= n ) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	cin>>n>>k;
	for( int i = 0; i < n; i++ ) cin>>T[i];
	llong ans = solve();
	cout<<ans<<endl;
}


Measured memory_bytes: 3880
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int cnt[2][100001];
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &e: v) cin >> e;

    for (int i = 0; i < n; ++i) {
        ++cnt[i%2][v[i]];
    }

    int mi[2];
    for (int i = 0; i < 2; ++i) {
        mi[i] = max_element(begin(cnt[i]), end(cnt[i])) - begin(cnt[i]);
    }

    for (auto &v: cnt) sort(begin(v), end(v), greater<>());

    int ans;
    if (mi[0] == mi[1]) {
        int d = max(cnt[0][0] + cnt[1][1], cnt[0][1] + cnt[1][0]);
        ans = n - d;
    } else {
        ans = n - cnt[0][0] - cnt[1][0];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define here(s)      cout<<s<<endl;
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


typedef long long ll;


int main()
{
    run;
   ll h;
   cin>>h;
   ll ans=0;

   if(h==1)
   {
       cout<<1;
       return 0;
   }
   vector<ll> v;
   v.pb(1);
   ll kk=1;
   while(h>1)
   {
       h/=2;
       v.pb(kk*2);
       kk*=2;

   }
   ll s=0;
   fr(i,0,v.size())
   {
       s+=v[i];
   }
   cout<<s;

   /*queue<ll> q;
   q.push(h);
   ll c=0;
   ll k=0;
   while(!q.empty())
   {
       c++;
       ll p=q.front();
       q.pop();
       if(p==1)
       {
            k++;
       }else{
       q.push(h/2);
       //q.push(h/2);
       }
   }
   cout<<c;

*/



    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cstdlib>
#include <cstring> 
#define Max(A, B) A > B ? A : B 
#define Reg register
namespace Quick_In {
    char b[1<<15],*s = b,*t = b;
    #define GetC() (s == t && (t = (s = b) + fread(b, 1, 1 << 15, stdin), s == t) ? 0 : *s++)
    int Read() {
        Reg char C; Reg int A;
        while(C = GetC(),(C < '0' || C > '9'));
        A = C - '0';
        while(C = GetC(),C >= '0' && C <= '9')  A = (A << 3) + (A << 1) + C - '0';
        return A;
    }
}
using namespace Quick_In;
typedef long long LL;
std::queue<LL> Queue;
const LL MaxN = 1e6 + 10;
const LL Inf = 214748364;
LL N, K, M, X, Y;
LL Dis[MaxN * 2];
struct Edge {
    LL To, Next, Val;
}Road[MaxN];
LL Cnt = 0, Last[MaxN];
void Add(LL U, LL V, LL Val) {
    Road[++Cnt] = (Edge){V, Last[U], Val}, Last[U] = Cnt;
}
bool InQueue[MaxN];
LL Count[MaxN];
LL Spfa(int Now) {
    for(LL i = 0; i < MaxN; i++) Dis[i] = Inf, InQueue[i] = false;
    Queue.push(Now); InQueue[Now] = 1; Dis[Now] = 0;
    while(!Queue.empty()) {
        LL Top = Queue.front(); 
        for(LL i = Last[Top]; i; i = Road[i].Next) {
            LL To = Road[i].To;
            if(Dis[Top] + Road[i].Val < Dis[To]) {
                Dis[To] = Dis[Top] + Road[i].Val;
                if(!InQueue[To]) {                 
                    Queue.push(To);
                    InQueue[To] = true;
                } 
            }
        }
		Queue.pop(); InQueue[Top] = false; 
    }	
}
int main() {
    N = Read(); 
    for(int i = 0; i < N; i++)  
			Add(i, (i + 1) % N, 1),
			Add(i, (i * 10) % N, 0); 
	Spfa(1);
	printf("%lld", Dis[0] + 1); 
} 

Measured memory_bytes: 20992
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 4000400
const int mod=998244353;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,ifac[N],fac[N],ans;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	ifac[n]=qpow(fac[n],mod-2)%mod;
	for(int i=n-1;i>=0;--i){
		ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	if(n<0||m<0||n-m<0)return 0;
	return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline int calc(int n,int m){
	return C(n+m-1,n-1);
}
int main(){
	n=read(),m=read();
	init(n+3*m);
	for(int i=0;i<=min(n,m);++i){
		if((i&1)^(m&1))continue;
		ans=(ans+1LL*C(n,i)*calc(n,(3*m-i)>>1))%mod;
		ans=(ans-1LL*C(n-1,i)*n%mod*calc(n,(m-i-2)>>1))%mod;
		ans=(ans-1LL*C(n-1,i-1)*n%mod*calc(n,(m-i)>>1))%mod;
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}




Measured memory_bytes: 23292
#include<stdio.h>
#include<math.h>

int main(){

  long long n;
  scanf("%lld",&n);

  long long a[n];

  long long max=0;
  long long min=100000;

  for(long long i=0;i<n;i++){
    scanf("%lld",&a[i]);

    if(max<=a[i]){
      max=a[i];
    }
    if(min>=a[i]){
      min=a[i];
    }
  }

  long long k=max-min+3;
  long long b[k];

  for(long long i=0;i<k;i++){
    b[i]=0;
  }

  for(long long i=0;i<n;i++){
    b[a[i]-min]++;
    b[a[i]-min+1]++;
    b[a[i]-min+2]++;
  }
  long long ans=0;

  for(long long i=0;i<k;i++){
    if(ans<=b[i]){
      ans=b[i];
    }
  }

  printf("%lld\n",ans);
  return 0;
}


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

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
        --vec[i];
    }

    vector<int> path;
    vector<int> checker(n,-1);
    int cur = 0;
    for(int i = 0; i < n; ++i)
    {
        if(checker[cur] != -1)
        {
            break;
        }
        checker[cur] = i;
        path.push_back(cur);
        cur = vec[cur];
    }

    int l = checker[vec[*path.rbegin()]];
    int loop = (int)path.size() - l;

    if(k <= (int)path.size()-1)
    {
        cout << path[k] +1 << endl;
        return 0;
    }

    int target = (k-l) % loop;
    cout << path[l+target]+1 << endl;
}

Measured memory_bytes: 5888
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
                if(a < b)
		{
  			System.out.println("a < b");
		}
		if(a > b)
		{
			System.out.println("a > b");
		}
		if(a == b)
		{
			System.out.println("a == b");
		}
	}
}
		


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

int main() {
    int x, i = 0; cin >> x;
    while(true)
    {
        i++;
        if (x * i % 360 == 0) break;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int x;
	cin >> x;
	cout << (x + x * x + x * x * x);
	return 0;
}

Measured memory_bytes: 3636
N = gets.to_i
hash = {}
sum = 0
gets.split.map{|n|
    hash[n.to_i] = hash[n.to_i].to_i + 1
    sum += n.to_i
}
Q = gets.to_i
ret = []
Q.times do
    b, c = gets.split.map(&:to_i)
    hash[c] = hash[c].to_i + hash[b].to_i
    sum = sum + c * hash[b].to_i - b * hash[b].to_i
    ret << sum
    hash.delete(b)
end
ret.each do |n|
    puts n
end

Measured memory_bytes: 25876
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long mod_inv(long long n)
{
    long long left=MOD-2;  // define MOD!
    long long num=n;
    long long ans=1;
    while(left!=0)
    {
        if(left%2==1)ans=(ans*num)%MOD;
        left/=2;
        num=(num*num)%MOD;
    }
    return ans;
}

int main()
{
  long long n;cin>>n;
  vector<long long> a(n);
  long long i,j;
  for(i=0;i<n;i++)cin>>a.at(i);
  vector<bool> isp(1001,true);
  isp.at(0)=false;
  isp.at(1)=false;
  vector<long long> ptable(0);
  long long now=2;
  while(now<=1000)
  {
    if(!isp.at(now))
    {
      now++;
      continue;
    }
    else
    {
      for(i=now*2;i<=1000;i+=now)
      {
        isp.at(i)=false;
      }
      now++;
    }
  }
  for(i=2;i<=1000;i++)if(isp.at(i))ptable.emplace_back(i);
  vector<long long> copa(n);
  for(i=0;i<n;i++)copa.at(i)=a.at(i);
  long long divps=0;
  vector<long long> comp(ptable.size(),0);
  for(i=0;i<n;i++)
  {
    long long ind=0;
    divps=0;
    while(ind<ptable.size())
    {
      while(copa.at(i)%ptable.at(ind)==0)
      {
        divps++;
        if(comp.at(ind)<divps)comp.at(ind)=divps;
        copa.at(i)/=ptable.at(ind);
      }
      ind++;
      divps=0;
      if(copa.at(i)==1)break;
    }
  }
  long long ab=1;
  for(i=0;i<ptable.size();i++)
  {
    for(j=0;j<comp.at(i);j++)
    {
      ab=(ab*ptable.at(i))%MOD;
    }
  }
  sort(copa.begin(),copa.end());
  for(i=1;i<n;i++)if(copa.at(i)==copa.at(i-1))copa.at(i-1)=1;
  for(i=0;i<n;i++)ab=(ab*copa.at(i))%MOD;
  long long ans=0;
  for(i=0;i<n;i++)
  {
    ans=(ans+(ab*mod_inv(a.at(i)))%MOD)%MOD;
  }
  cout<<ans<<endl;
}


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

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

const ll mod = 1e9+7;

int main(){
	ll n, m, v, p;
	cin>> n>> m>> v>> p;
	ll a[n+1];
	irep(i, 1, n){
		cin>> a[i];
	}
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	ll lo = p + 1, hi = n, ans = p;
	ll mid;
	while(lo <= hi){
		mid = (lo + hi) / 2;
		ll vleft = v - (n-mid+1);
		vleft -= (p-1);
		ll more = 0;
		for(ll i = p; i < mid; ++i){
			if(a[mid]+m < a[i]){
				more = -1;
				break;
			}
			more += (a[mid]+m-a[i]);
		}
		if(more == -1){
			hi = mid - 1;
			continue;
		}
		if(vleft <= 0){
			ans = mid;
			lo = mid + 1;
			continue;
		}
		if(more >= (ll)m*vleft){
			ans = mid;
			lo = mid + 1;
			continue;
		}else{
			hi = mid - 1;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

st = lambda n: bin(n)[2:]
n,k = map(int,readline().split())
a = np.array([int(i) for i in readline().split()])

INF = 10**12
mm = INF.bit_length()
chk = [((a >> k) & 1).sum() for k in range(mm)]

ll = []
q = 0
for num,cc in enumerate(chk):
  if cc < n/2:
    q += 2**(num)
  ll.append((num,2**num*(n-cc),2**num*cc))
    
max_V = 0
KK = (k+1).bit_length()
sk = st(k+1).zfill(mm)
sq = st(q).zfill(mm)

for i in range(KK):
  if (k+1)>>i&1 == 1:
    op = q
    if q>>i&1 == 1:
      op -= 2**i
    I = KK-i
    for j in range(mm-KK+I):
      if sq[j] == '1' and sk[j] == '0':
        op -= 2**(mm-1-j)
    V = 0
    for nm,v_1,v_0 in ll:
      if op>>nm & 1 == 1:     
        V += v_1
      else:
        V += v_0
    max_V = max(max_V, V)
    
print(max_V)

Measured memory_bytes: 36184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,K,P,answer=-1000000007;
  cin>>N>>K;
  vector<ll> NV(N);
  vector<ll> C(N);
  for(ll i=0;i<N;i++){
    cin>>P;
    NV.at(i)=P-1;
  }
  for(ll i=0;i<N;i++){
    cin>>C.at(i);
  }
  for(ll i=0;i<N;i++){
    ll roop=0,roopValue=0,v1=i,answerI=0;
    vector<ll> visited1(N,0);
    while(visited1.at(v1)==0){
      visited1.at(v1)=1;
      v1=NV.at(v1);
      roop++;
      roopValue+=C.at(v1);
    }
    if(roopValue>0){
      if(K/roop==0){
        answerI=C.at(NV.at(i));
        //cout<<i<<" "<<answerI<<endl;
        ll v2=i,count=1,memo=0;
        //vector<ll> visited2(N,0);
        while(count<=(ll)min(roop,K)){
          count++;
          v2=NV.at(v2);
          memo+=C.at(v2);
          answerI=max(answerI,memo);
        }
      }
      else{
        answerI=(K/roop-1)*roopValue;
        ll remain=K%roop+roop,v2=i,count=1,memo=answerI;
        if(K/roop==1 && remain==roop){
          answerI+=C.at(NV.at(i));
        }
      //cout<<i<<" "<<answerI<<endl;
      //vector<ll> visited2(N,0);
        while(count<=remain){
          count++;
          v2=NV.at(v2);
          memo+=C.at(v2);
          answerI=max(answerI,memo);
        }
      }
    }
    else if(roopValue<0){
      answerI=C.at(NV.at(i));
      //cout<<i<<" "<<answerI<<endl;
      ll v2=i,count=1,memo=0;
      //vector<ll> visited2(N,0);
      while(count<=(ll)min(roop,K)){
        count++;
        v2=NV.at(v2);
        memo+=C.at(v2);
        answerI=max(answerI,memo);
      }
    }
    answer=max(answer,answerI);
  }
  cout<<answer<<endl;
}

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

int main(){
  const int Smax= 10000;
  int N;
  cin >> N;

  int P_remain= N;
  int S= Smax;
  while(P_remain > 0){
    while(S*(S-1)/2 >= P_remain){
      S--;
    }

    cout << S << endl;
    P_remain-= S;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.next().split("/")[1]);
        if(m > 4){
            System.out.println("TBD");
        } else{
            System.out.println("Heisei");
        }
    }
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  map<int,int> mp;
  rep(i, n) {
    int a; cin >> a;
    ++mp[a];
  }

  int ans = 0;
  for (auto e : mp) if (e.se % 2) ++ans;

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

Measured memory_bytes: 8304
#include<iostream>
#include<cstdio>
#include<cmath>
#define N 1000
using namespace std;

int main(){
    int n;
    
    while(1){
        cin >> n;
        if(n == 0) break;
        int s[N];
        double sum = 0.0;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        double ave = sum / n;
        double a = 0, A;
        for(int i = 0; i < n; i++){
            a += (ave-s[i])*(ave-s[i]) / n;
        }
        A = sqrt(a);
        
        printf("%lf\n", A);
        
    }
}


Measured memory_bytes: 3212
using System;
using System.Linq;

public class Hello {
    public static void Main() {
        //使わないのはコメントアウトしないとエラー
        var nums = NumInput();
//        var loop = nums[0];
//        var underLine = nums[1];
        // var text = StringInput();
      
      int res = nums[0] * nums[1];
      if(res%2 == 0) Result("Even");
      else Result("Odd");
        
    }
    static int[] NumInput(){
        var input_line = Console.ReadLine().Split(' ');
        return input_line.Select(int.Parse).ToArray();
    }
    static string[] StringInput(){
        return Console.ReadLine().Split(' ');
    }
    
    static void Result(string text){
        Console.WriteLine( text );
    }   
    static void Result(int num){
        Console.WriteLine( num );
    }
    static void Result(float num){
        Console.WriteLine( num );
    }
}

Measured memory_bytes: 11348