akhauriyash/Code-Regression huggingface dataset:
#

import sys
input=sys.stdin.readline
from collections import deque

def main():
    N,X,Y=map(int,input().split())
    X-=1
    Y-=1
    adj=[[] for i in range(N)]
    adj[X].append(Y)
    adj[Y].append(X)
    for i in range(N-1):
        adj[i].append(i+1)
        adj[i+1].append(i)
    cnt=[0]*(N)
    for i in range(N):
        dist=[-1]*N
        qu=deque([i])
        dist[i]=0
        while(len(qu)>0):
            v=qu.popleft()
            for nv in adj[v]:
                if dist[nv]==-1:
                    dist[nv]=dist[v]+1
                    cnt[dist[nv]]+=1
                    qu.append(nv)
    for i in range(1,N):
        print(cnt[i]//2)
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 76324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n,m; cin >> n >> m;
  for(int i=n;i<=(m/2);i++){
    if(m%i==0){
      cout << m/i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,M;
    long double sum = 0.0,xdis,ydis;
    ll cnt = 0;
    cin >>N;
    vector<double> x(N);
    vector<double> y(N);
    rep(i,N){
        cin >>x[i]>>y[i];
    }
    vector<ll> a(N);
    rep(i,N){
        a[i] = i;
    }
    
    do {
    rep(i,N-1) {
        //if (i) cout << ",";
        //cout << a[i];
        xdis = x[a[i+1]]-x[a[i]];
        ydis = y[a[i+1]]-y[a[i]];
        sum += sqrt(xdis*xdis+ydis*ydis);
        
    }
    cnt++;
    //cout << endl;
    }while(next_permutation(a.begin(),a.end()));
    cout << fixed << setprecision(15)<< sum/(long double)cnt << endl;
    
    
    return 0;
    

}

Measured memory_bytes: 3792
using System;
class Volumen0
{
    static void Main()
    {
        const int MAX_SIZE = 6;
        double[] alpha = new double[MAX_SIZE];
        string[] numal;
        string line;
        while ((line = Console.ReadLine()) != null)
        {
            numal = line.Split();
            for (int i = 0; i < 6; i++)
            {
                alpha[i] = double.Parse(numal[i]);
            }
            double y = (alpha[2] * alpha[3] - alpha[0] * alpha[5]) / (alpha[1] * alpha[3] - alpha[0] * alpha[4]);
            double x = (alpha[2] - alpha[1] * y) / alpha[0];
            Console.WriteLine("{0:f3} {1:f3}", x, y);
        }
    }
}


Measured memory_bytes: 15916
def main():
    N, K, S = [int(_) for _ in input().split()]
    A = []
    if S == 10 ** 9:
        A = [S] * K + [1] * (N-K)
    else:
        for i in range(N):
            if i < K:
                A.append(S)
            else:
                A.append(S+1)
    print(*A)
main()


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

int main() {
    int h, w;
    vector<string> v;
    string s;
    
    //入力
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> s;
        v.push_back(s);
    }
    
    for (int i = 0; i < h; i++) {
        cout << v[i] << endl;
        cout << v[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int n, m;
	cin >> n >> m;
	int ans = 0;
	rep(i, n + 1) {
		rep(j, n + 1) {
			int k = m - i - j;
			if(k>=0&&k<=n){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
/*input
2 3
1 2 3
0 1 1
*/

#include <bits/stdc++.h>
using namespace std;
int grid[505][505];

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int cnt = 0;
	for(int i = 1; i<=n; i++)
	{
		for(int j = 1; j<=m; j++)
		{
			scanf("%d", &grid[i][j]);
			if(grid[i][j] & 1) cnt++;
		}
	}
	if(cnt <= 0){
		printf("0\n"); return 0;
	}
	vector<pair<pair<int, int> , pair<int, int> > > move, ans;
	for(int i = 1; i<=n; i++){
		if(i & 1){
			int flag = 0;
			for(int j = 1; j<m; j++)
			{
				move.push_back({{i, j}, {i, j+1}});
			}
			if(i != n)
				move.push_back({{i, m}, {i+1, m}});
		} else{
			for(int j = m; j>1; j--)
			{
				move.push_back({{i, j}, {i, j-1}});
			}
			if(i != n)
				move.push_back({{i, 1}, {i+1, 1}});

		}
	}
	for(auto PP : move)
	{
		auto fs = PP.first, sc = PP.second;
		int i = fs.first, j = fs.second, a = sc.first, b = sc.second;
		if(grid[i][j]&1){
			ans.push_back(PP);
			grid[i][j]--;
			grid[a][b]++;
		}
	}
	printf("%d\n", (int)ans.size());
	for(auto PP : ans)
	{
		printf("%d %d %d %d\n", PP.first.first, PP.first.second, PP.second.first, PP.second.second);
	}

	return 0;

}


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

char s[100005],ans[100005];
int n;

int main(){
	scanf("%d%s",&n,&s);
	char tmp;
	bool f=false;
	for(int i=0;i<4;i++){
		if(i/2==0) ans[0]='S';
		else ans[0]='W';
		if(i%2==0) ans[1]='S';
		else ans[1]='W';
		for(int j=2;j<n;j++){
			tmp=s[j-1];
			if(ans[j-1]=='W') tmp='o'+'x'-tmp;
			if(tmp=='o') ans[j]=ans[j-2];
			else ans[j]='S'+'W'-ans[j-2];
		}
		if(ans[n-2]==ans[0]) tmp='o';
		else tmp='x';
		if(ans[n-1]=='W') tmp='o'+'x'-tmp;
		if(s[n-1]!=tmp) continue;
		if(ans[n-1]==ans[1]) tmp='o';
		else tmp='x';
		if(ans[0]=='W') tmp='o'+'x'-tmp;
		if(s[0]!=tmp) continue;
		f=true;
		break;
	}
	if(!f) printf("-1\n");
	else printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main() {
    int a, b;
    cin >> a >> b;
    
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
    int i,len;
    char s[4096],p[4096],s2[4096];
    scanf("%s",s);
    scanf("%s",p);
    sprintf(s2,"%s%s",s,s);
    if(strstr(s2, p) == NULL) {
        printf("No\n");}
    else{
    printf("Yes\n");
    }    
    return 0;
}



Measured memory_bytes: 2144
import sys
import numpy as np

input=sys.stdin.readline

N,M,Q=map(int,input().split())

x=np.zeros((N+1,N+1),dtype=np.int32)
for _ in range(M):
    l,r=map(int,input().split())
    x[l,r]+=1

x=np.cumsum(x,axis=0)
x=np.cumsum(x,axis=1)
for _ in range(Q):
    p,q=map(int,input().split())
    print(x[N,q]-x[p-1,q])

Measured memory_bytes: 17372
n, w = map(int, input().split())
dp = [[(10**9+1) for _ in range(10**5+1)] for _ in range(n)]
wn, vn = map(int, input().split())
dp[0][0] = 0
dp[0][vn] = wn
for i in range(1, n):
    wn, vn = map(int, input().split())
    for j in range(10**5+1):
        if (j - vn) >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-vn] + wn)
        else:
            dp[i][j] = dp[i-1][j]
#print(dp)
ansl = dp[n-1][::-1]
#print(ansl)
for k in range(len(ansl)):
    if ansl[k] <= w:
        print(10**5-k)
        break

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

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#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 << endl; }
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__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;

	int x = (n * 100 + 107) / 108;

	int m = x * 1.08;

	//cout << x << " "  << m << endl;

	if(n != m)
		cout << ":(";
	else
		cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=2005,INF=1e9;
struct edge
{
	int to,nxt;
}e[N<<1]; int n,head[N],cnt,x,y,f[N],sz[N],g[N],ans=INF; char s[N];
inline void addedge(CI x,CI y)
{
	e[++cnt]=(edge){y,head[x]}; head[x]=cnt;
	e[++cnt]=(edge){x,head[y]}; head[y]=cnt;
}
#define to e[i].to
inline void DFS(CI now,CI fa=0)
{
	RI i; f[now]=g[now]=0; sz[now]=s[now]-'0'; 
	for (i=head[now];i;i=e[i].nxt) if (to!=fa)
	DFS(to,now),f[now]+=f[to]+sz[to],g[now]+=g[to]+sz[to],sz[now]+=sz[to];
	int x,y; for (i=head[now];i;i=e[i].nxt) if (to!=fa)
	if ((x=g[to]+sz[to])>(y=f[now]-(f[to]+sz[to]))) return (void)(g[now]=x-y); g[now]&=1;
}
#undef to
int main()
{
	RI i; for (scanf("%d%s",&n,s+1),i=1;i<n;++i)
	scanf("%d%d",&x,&y),addedge(x,y); for (i=1;i<=n;++i)
	if (DFS(i),!g[i]) ans=min(ans,f[i]>>1);
	if (ans==INF) puts("-1"); else printf("%d",ans); return 0;
}

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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        long N = in.i();
        for (int h = 1; h < 3501; h++) {
            for (int n = 1; n < 3501; n++) {
                long a = 4 * h * n - N * (h + n);
                if (a > 0) {
                    long b = N * h * n;
                    if (b % a == 0) {
                        long w = b / a;
                        System.out.printf("%d %d %d\n", h, n, w);
                        return;
                    }
                }
            }
        }
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; i <= cbuf.length; i++) {
            if ((c = next()) == ' ' || c == '\n') break;
            cbuf[i] = c;
        }
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 34108
s = int(input())

x1 = 0
y1 = 0
x2 = int(s ** 0.5)
y3 = -(-s // x2)
x3 = 1
if y3 > 10 ** 9:
    x2 += 1
    y3 = -(-s // x2)
y2 = x2 * y3 - s
print(x1, y1, x2, y2, x3, y3)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b,k;
cin>>a>>b>>k;
  if(a<k)
  {
    if(b<k-a)
      b=0;
    else 
      b=b-(k-a);
     
    a=0;
  }
  else 
    a=a-k;
  
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{

    ll n;
    cin >> n;
    VL v(n);
    rep(i, n) cin >> v[i];
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, n)
    {
        mp[v[i]]++;
        sum += v[i];
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        ll b, c;
        cin >> b >> c;
        sum -= mp[b] * b;
        sum += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 10020
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "YES" : "NO"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int h, w, n;
	Pi st;
	string s, t;
	bool ans = true;

	cin >> h >> w >> n >> st >> s >> t;
	Pi at = st, high = st;

	rep(i, n) {
		if (s[i] == 'U') {
			at.F--;
			chmin(high.F, at.F);
		} else if (s[i] == 'L') {
			at.S--;
			chmin(high.S, at.S);
		}

		if (t[i] == 'D' and at.F + 1 <= h) {
			at.F++;
		} else if (t[i] == 'R' and at.S + 1 <= w) {
			at.S++;
		}
	//	clog << at << endl;
	}
	clog << high << endl << endl;
	;
	if (high.F <= 0 or high.S <= 0) {
		ans = false;
	}
	at   = st;
	high = st;
	rep(i, n) {
		if (s[i] == 'D') {
			at.F++;
			chmax(high.F, at.F);
		} else if (s[i] == 'R') {
			at.S++;
			chmax(high.S, at.S);
		}

		if (t[i] == 'U' and at.F - 1 > 0) {
			at.F--;
		} else if (t[i] == 'L' and at.S - 1 > 0) {
			at.S--;
		}
	//	clog << at << endl;
	}
	if (high.F > h or high.S > w) {
		ans = false;
	}
	clog << high << endl << endl;

	cout << solve(ans) << endl;
}

Measured memory_bytes: 3920
h, w= map(int, input().split())
a = [['.']*w for _ in range(h)]
b = [['.']*w for _ in range(h)]
for i in range(h):
  s = input()
  for j in range(w):
    if i % 2 and j != w - 1 or j == 0 or s[j] == '#':
      a[i][j] = '#'
    if (i+1) % 2 and j != 0 or j == w - 1 or s[j] == '#':
      b[i][j] = '#'
for x in a + [[]] + b :
  print(''.join(x))


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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

ll yo(ll n)
{
    if(n <= 1) return n;
    return yo(n / 2)*2 + 1;
}
int32_t main()
{
    ll n; cin >> n;
    cout << yo(n) << nl;
    return 0;
}


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

int main() {
	int a, b; scanf("%d%d", &a, &b);
	puts(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main()
{
	ll k;
	cin >> k;

	ll m = 7 % k;

	vector<bool> vis(k, false);

	ll ans = 1;
	while (1)
	{
		if (m % k == 0) break;
		vis[m] = true;

		m *= 10;
		m += 7;
		m %= k;

		if (vis[m]) {
			ans = -1;
			break;
		}
		
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <complex>
#define maxn 2098000
#define eps 0.01
#define Lovelive long long
typedef std::complex<double> C;
const double PI2 = 2.0 * acos(-1);
C coa[maxn], cob[maxn], x[maxn], ax[maxn], temp[maxn];
long long Ans[maxn];

inline int r() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}

inline int lowbit(int x) {
	return x & -x;
}

void FFT(int n, C *A, C* X) {
	int m = n >> 1;
	for(int step = m; step; step >>= 1) {
		for(int off = 0; off != step; ++off) {
			for(int i = 0, j = 0; j < m; ++i, j += step) {
				C &ta = A[j * 2 + off], tb = X[j] * A[j * 2 + off + step];
				temp[j] = ta + tb, temp[j + m] = ta - tb;
			}
			for(int j = 0; j < n; j += step) A[off + j] = temp[j];
		}
	}
}

void work(int n) {
//	freopen("3803.in", "r", stdin);
//	freopen("out.txt", "w", stdout);
	int m, res;
	m = n;
	res = (n += m + 1);
	while(__builtin_popcount(n) != 1) n += lowbit(n);
	double part = PI2 / n;
	for(int i = 0; i < n; i++) {
		double deg = part * i;
		x[i] = C(cos(deg), sin(deg));
		ax[i] = conj(x[i]);
	}
	FFT(n, coa, x);
	FFT(n, cob, x);
	for(int i = 0; i < n; i++) coa[i] = coa[i] * cob[i];
	FFT(n, coa, ax);
	for(int i = 0; i < res; i++) 
		Ans[i] = (long long)(coa[i].real() / n + eps);
//        printf("%d%c", (int)(coa[i].real() / n + eps), i == res-1 ? '\n' : ' ');
}

#define MOD 200003
#define g 2
int Exp[MOD + 233];
int Pow[MOD + 233];
int a[maxn];
int b[maxn];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", a + i);
	Pow[0] = 1;
	for(int i = 1, j = 1; i < MOD; ++i) {
		j = j * g % MOD;
		Exp[j] = i;
		Pow[i] = j;
	} 
	for(int i = 1; i <= n; ++i) if(a[i]) ++b[Exp[a[i]]];
	for(int i = 0; i <= MOD; ++i) cob[i] = coa[i] = b[i];
	work(MOD);
	Lovelive ans = 0;
//	for(int i = 0; i <= MOD; ++i) coa[2 * i] -= b[i] * b[i];
	for(int i = 0; i <= MOD; ++i) Ans[2 * i] -= b[i];
	for(int i = 0; i <= 2 * MOD; ++i) ans = ans + (Ans[i] / 2) * Pow[i % (MOD - 1)];
	printf("%lld", ans);
}

Measured memory_bytes: 49888
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int n = sc.nextInt();
      String s = sc.next();
      int ans = 0;
      for (int i = 0; i < n; i++) {
        int a = mask(s.substring(0, i));
        int b = mask(s.substring(i, n));
        int cnt = Integer.bitCount(a & b);
        if (ans < cnt) ans = cnt;
      }
      System.out.println(ans);
    } finally {
      sc.close();
    }
  }

  private static int mask(String s) {
    int mask = 0;
    for (int i = 0; i < s.length(); i++) {
      mask |= 1 << (s.charAt(i) - 'a');
    }
    return mask;
  }
}

Measured memory_bytes: 35484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*typedef vector<int> vi;
typedef vector<ll> vl;*/
vector<vector<int>>v(200002);
bool visited[200002] = { false };
int c = 0;
void dfs(int i, int n)
{
    if (i > n || visited[i])
        return;
    visited[i] = true;
    c++;
    for (int j = 0; j < v[i].size(); j++)
    {
        dfs(v[i][j], n);
    }
}

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

    for(int i=0;i<m;i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        c = 0;
        if (!visited[i])
        {
            dfs(i + 1, n);
        }
        res = max(c, res);
    }
    cout << res << endl;
}


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

int main(){
  int n, sum=0;
  cin >> n;
  
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    sum = sum + b - a + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L_max = max(L)
    L_sum = 0
    L_sum -= L_max
    for l in L:
        L_sum += l
    if L_max < L_sum:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import itertools

N, M, Q = map(int, input().split())
# q回入力させる
abcd = [tuple(map(int, input().split())) for _ in range(Q)]

Max = 0
# 順列なのでM+1=Nになったらストップ
for C in itertools.combinations_with_replacement(range(1, M + 1), N):
  score = sum([d for a, b, c, d in abcd if C[b-1] - C[a-1] == c])
  Max = max(Max, score)
print(Max)

Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;
int A[100010];

void solve() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	ll g = A[0];
	vl gl;
	gl.eb(0);
	for (int i = 1; i < N; i++) {
		ll tmp = g;
		g = gcd(g, A[i]);
		if (g < tmp) {
			gl.eb(i);
		}
	}

	vl ans;

	for (int i = 0; i < gl.size(); i++) {
		ll tmp = gl[i] ? A[0] : A[1];
		for (int j = 0; j < N; j++) {
			if (j != gl[i]) {
				tmp = gcd(tmp, A[j]);
			}
		}
		ans.eb(tmp);
	}

	cout << *max_element(ans.begin(), ans.end()) << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[3];
	For(i,0,3) a[i] = -1;

	ll ans = 1;

	For(waste,0,n){
		ll x;cin>>x;
		ll ways = 0;
		For(i,0,3) if(a[i]==x-1) ways++;
		ans = (ans*ways)%Mod;

		For(i,0,3) if(a[i]==x-1){
			a[i]=x;
			break;
		}
	}

	cout<<ans<<endl;
































	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=100;i>=1;i--){
		if(a%i==0&&b%i==0){
			c--;
			if(c==0){
				printf("%d\n",i);return 0;
			}
		}
	}
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, x; cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (x - a[i] < 0) break;

        if (i == n - 1) {
            if (x - a[i] == 0) ans++;
        } else {
            x -= a[i];
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = 0LL;
	
	if( (b - a) % 2LL == 0 ) {
		ans = (b - a) / 2LL;
	} else {
		if( a - 1LL < n - b ) {
			ans = a - 1LL;
		} else if( a - 1LL >= n - b ) {
			ans = n - b;
		}
		
		ans += 1LL + (b - a - 1LL) / 2LL;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var pmax = 1000000;
			var primes = new bool[pmax+1];
			var maxsq = (int)Math.Sqrt(pmax);
			for(var i=2;i<=pmax;i++)
				primes[i]=true;
			for(var i=2;i<=maxsq;i++)
				if(primes[i])
					for(var j=i*2;j<pmax;j+=i)
						primes[j]=false;
			List<int> num;
			while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
				var menu = new List<int>();
				var order = new bool[num[1]+1];
				var max = 0;
				for(var i=0;i<num[0];i++)
					menu.Add(int.Parse(Console.ReadLine()));
				order[0]=true;
				for(var i=0;i<=num[1];i++)
					if(order[i]){
						menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
						if(primes[i]&&max<i)
							max=i;
					}
				Console.WriteLine(max<1?"NA":"{0}",max);
			}
			
		}
	}
}

Measured memory_bytes: 11144
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int D,N;
    int ans=0;
    cin>>N;
    int prev=-1;
    int k=0;
    int A[N],B[N],C[N],good[N]={};
    rep(i,N){
        cin>>A[i];
                if(A[i]==1+prev){
                    good[k]=prev;
                    k++;
                }
        prev=A[i];
    }
    rep(i,N){
        cin>>B[i];
        ans+=B[i];
    }
    rep(i,N-1){
        cin>>C[i];
        rep(j,N)
        if(good[j]==i+1){
            ans+=C[i];
        }
    }
    Out(ans);
    return 0;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;
const ll INF = 1ll << 60;
ll N, M, S, T;
vector<vector<pair<ll, ll>>> DOut;
vector<ll> Dist;
vector<bool> RSeen;
vector<vector<ll>> Out, In, XOut, XIn;
vector<ll> Order, ROrder;
vector<ll> Count, RCount;

void dijkstra() {
  Dist.resize(N, INF);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
      pool;
  pool.push(make_pair(0, S));
  while (!pool.empty()) {
    auto distv = pool.top();
    pool.pop();
    ll dist = distv.first, v = distv.second;
    if (dist >= Dist[v]) continue;
    Dist[v] = dist;
    for (auto wd : DOut[v]) {
      ll w = wd.first, d = wd.second;
      if (Dist[w] > Dist[v] + d) pool.push(make_pair(Dist[v] + d, w));
    }
  }
}
void rsee(ll v) {
  if (RSeen[v]) return;
  RSeen[v] = true;
  for (ll w : In[v]) {
    XOut[w].push_back(v);
    XIn[v].push_back(w);
    rsee(w);
  }
  Order.push_back(v);
}
void prune() {
  Out.resize(N);
  In.resize(N);
  for (ll v = 0; v < N; ++v) {
    for (auto wd : DOut[v]) {
      ll w = wd.first, d = wd.second;
      if (Dist[w] == Dist[v] + d) {
        Out[v].push_back(w);
        In[w].push_back(v);
      }
    }
  }
  RSeen.resize(N);
  XOut.resize(N);
  XIn.resize(N);
  rsee(T);
  assert(Order.front() == S && Order.back() == T);
  ROrder = Order;
  reverse(ROrder.begin(), ROrder.end());
}
ll solve() {
  Count.resize(N);
  Count[S] = 1;
  for (ll v : Order) {
    for (ll w : XOut[v]) {
      (Count[w] += Count[v]) %= MOD;
    }
  }
  RCount.resize(N);
  RCount[T] = 1;
  for (ll v : ROrder) {
    for (ll w : XIn[v]) {
      (RCount[w] += RCount[v]) %= MOD;
    }
  }
  ll dup_count = 0;
  for (ll v : Order) {
    if (Dist[v] * 2 == Dist[T])
      (dup_count +=
       Count[v] * Count[v] % MOD * RCount[v] % MOD * RCount[v] % MOD) %= MOD;
    for (ll w : XOut[v]) {
      if (Dist[v] * 2 < Dist[T] && Dist[T] < Dist[w] * 2)
        (dup_count +=
         Count[v] * Count[v] % MOD * RCount[w] % MOD * RCount[w] % MOD) %= MOD;
    }
  }
  return (Count[T] * Count[T] % MOD + MOD - dup_count % MOD) % MOD;
}
int main() {
  cin >> N >> M >> S >> T;
  --S;
  --T;
  DOut.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll u, v, d;
    cin >> u >> v >> d;
    --u;
    --v;
    DOut[u].push_back(make_pair(v, d));
    DOut[v].push_back(make_pair(u, d));
  }
  dijkstra();
  prune();
  cout << solve() << endl;
  return 0;
}


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

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

    if((4 * a * b < (c - a - b) * (c - a - b)) && c - a - b >= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,m,x[N];
struct matrix {
    int val[3][3];
    matrix() { memset(val,0,sizeof(val)); }
    int* operator[](int x) { return val[x]; }
    void init() { for(int i=0;i<3;i++) val[i][i]=1; }
} S,T,V;
matrix operator*(matrix a,matrix b) {
    matrix ret;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++) inc(ret[i][j],1ll*a[i][k]*b[k][j]%mod);
    return ret;
}
matrix qpow(matrix a,int b) {
    matrix ret;ret.init();
    while(b) {
        if(b&1) ret=ret*a; a=a*a; b>>=1;
    }
    return ret;
}
int main() {
    cin>>n>>m;
    for(int i=1;i<=m;i++) x[i]=gi();
    S[0][0]=1;S[0][1]=2;S[0][2]=1;
    T[0][0]=1;T[0][1]=2;T[0][2]=1;
    T[1][0]=0;T[1][1]=1;T[1][2]=1;
    T[2][0]=1;T[2][1]=2;T[2][2]=2;
    V[0][0]=1;V[0][1]=2;V[0][2]=1;
    V[1][0]=0;V[1][1]=1;V[1][2]=1;
    V[2][0]=0;V[2][1]=0;V[2][2]=1;
    for(int i=1;i<=m;i++) S=S*qpow(T,x[i]-x[i-1]-1)*V;
    S=S*qpow(T,n-x[m]-1);
    printf("%d\n",S[0][2]);
    return 0;
}


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

int main(){
  int K,N;
  cin >> K>>N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  }
  vector<int> B(N);
  for(int j = 0; j < A.size()-1; j++){
    B.at(j) = A.at(j+1)-A.at(j);
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  int c =K-A.at(N-1)+A.at(0);
  int ans;
  if(c > B.at(0)){
    ans = K - c;
  }
  else{
    ans = K - B.at(0);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 1792
A=[]
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
count=0
rem=10
for t in A:
    if t%10==0:
        count+=t
    else:
        count+=(((t//10)+1)*10)
        if t%10<rem:
            rem=t%10
print(count-10+rem)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int a,b;
	int i=1;
	int outlet;
	scanf("%d %d",&a,&b);
	if(b==1){
		puts("0");
		return 0;
	}
	outlet =a;
	while(outlet < b){
		outlet += (a-1);
		i++;
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env ruby


if $0 == __FILE__
  H, W = gets.split(' ').map &:to_i

  black_count = 0
  input = []

  queue = []
  (0...H).each do |i|
    input[i] = []
    str = gets.chomp
    (0...W).each do |j|
      if str[j] == '#'
        input[i][j] = 1
        queue << [i,j]
        black_count += 1
      else
        input[i][j] = 0
      end
    end
  end

  ans = 0
  while black_count < H * W do
    ans += 1
    tmp_queue = []

    queue.each do |i, j|
      if i-1 >= 0
        if input[i-1][j] == 0
          input[i-1][j] = 1
          tmp_queue << [i-1, j]
          black_count += 1
        end
      end

      if i+1 < H
        if input[i+1][j] == 0
          input[i+1][j] = 1
          tmp_queue << [i+1, j]
          black_count += 1
        end
      end

      if j-1 >= 0
        if input[i][j-1] == 0
          input[i][j-1] = 1
          tmp_queue << [i, j-1]
          black_count += 1
        end
      end

      if j+1 < W
        if input[i][j+1] == 0
          input[i][j+1] = 1
          tmp_queue << [i, j+1]
          black_count += 1
        end
      end
    end

    queue = tmp_queue
  end

  puts ans
end


Measured memory_bytes: 87804
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fileio freopen("in","r",stdin);freopen("out","w",stdout);

const int N = 200005;
char s[N];
map<char, int> f;
int main(){
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < n; i++){
		f[s[i]]++;
	}
	LL ans = 1;
	for (int i = 0; i < n; i++){
		ans += (n - i - f[s[i]]);
		f[s[i]]--;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int a, b;

int main() {
	int gcd, lcm;

	a = -1;
	cin >> a >> b;

	while (a != -1) {
		int cpyA = a;
		int cpyB = b;

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

		gcd = b;

		lcm = cpyA / gcd * cpyB;
		
		cout << gcd << " " << lcm << endl;

		a = -1;
		cin >> a >> b;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i = int(s);i<int(n);i++)
#define dforsn(i,s,n) for(int i = int(n)-1;i>=int(s);i--)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) dforsn(i,0,n)
#define DBG(x) do{cout<<#x<<" = "<<x<<endl;}while(false)
#define SZ(v) int(v.size())
template<class U> ostream operator<<(ostream & u, vector<U> v){
    u<<"[ ";
    for(auto x : v) u<<x<<" ";
    u<<"] ";
    return u;
}
typedef long long intl;
typedef long long ll;
intl powmod (intl a, intl b, intl p) {
    intl res = 1;
    while (b)
        if (b & 1)
            res = intl (res * 1ll * a % p),  --b;
        else
            a = intl (a * 1ll * a % p),  b >>= 1;
    return res;
}

intl generator (intl p) {
    vector<intl> fact;
    intl phi = p-1,  n = phi;
    for (intl i=2; i*i<=n; ++i)
        if (n % i == 0) {
            fact.push_back (i);
            while (n % i == 0)
                n /= i;
        }
    if (n > 1)
        fact.push_back (n);

    for (intl res=2; res<=p; ++res) {
        bool ok = true;
        for (size_t i=0; i<fact.size() && ok; ++i)
            ok &= powmod (res, phi / fact[i], p) != 1;
        if (ok)  return res;
    }
    return -1;
}
using cd = complex<double>;
const double PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    intl n = a.size();
    if (n == 1)
        return;

    vector<cd> a0(n / 2), a1(n / 2);
    for (intl i = 0; 2 * i < n; i++) {
        a0[i] = a[2*i];
        a1[i] = a[2*i+1];
    }
    fft(a0, invert);
    fft(a1, invert);

    double ang = 2 * PI / n * (invert ? -1 : 1);
    cd w(1), wn(cos(ang), sin(ang));
    for (intl i = 0; 2 * i < n; i++) {
        a[i] = a0[i] + w * a1[i];
        a[i + n/2] = a0[i] - w * a1[i];
        if (invert) {
            a[i] /= 2;
            a[i + n/2] /= 2;
        }
        w *= wn;
    }
}
vector<intl> multiply(vector<intl> const& a, vector<intl> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    intl n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (intl i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<intl> result(n);
    for (intl i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}
int main(){
	cin.tie(0);
    cin.sync_with_stdio(0);
    intl p=2;
    vector <intl> pot(200003);
    intl r=1;
    pot[1]=0;
    for(intl i=1;i<200002;i++){
    	r*=p;
    	r=r%200003;
    	pot[r]=i;
	}
   	intl n;
   	cin>>n;
   	vector <intl> pol(200002,0);
   	for(intl i=0;i<n;i++){
   		intl a;
   		cin>>a;
   		if(a!=0){
   			pol[pot[a]]++;
		}
	}
	vector <intl> pol1=multiply(pol,pol);
	for(intl i=0;i<pol1.size();i++){
		if(i>=200002){
			pol1[i%200002]+=pol1[i];
			pol1[i]=0;
		}
	}
	for(intl i=0;i<pol.size();i++){
		intl r=(2*i)%200002;
		intl k=pol[i];
		pol1[r]-=k;
	}
	intl ans=0;
	intl acum=1;
	for(intl i=0;i<200002;i++){
		ans+=(pol1[i]/2)*acum;
		acum*=p;
		acum=acum%200003;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 39612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MOD = 998244353;

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> d(n, 0);
	REP(i, n) {
		int D; cin >> D;
		d[D]++;
		if (i == 0 && D != 0) {
			cout << 0 << '\n';
			return 0;
		}
	}

	ll res = 1;
	if (d[0] != 1) res = 0;
	else {
		for (int i = 1; i < n; i++) {
			REP(j, d[i]) {
				res *= d[i - 1];
				res %= MOD;
			}
		}
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	double[][] s = new double[100][1000];
	int[] n = new int[1000];
	int x = 0;
	double A;
	double sou;
	double[] m = new double[1000];
	
	while(scan.hasNext()){
		sou = 0;
		n[x] = scan.nextInt();
		if(n[x] == 0){
			break;}
		for(int i=0; i<n[x]; i++){
			s[x][i] = scan.nextDouble();
			sou += s[x][i];}
			m[x] = sou / n[x];
		x++;}
		
	for(int q=0; q<x; q++){
		A = 0;
		for(int i=0; i<n[q]; i++){
			A += (s[q][i] - m[q]) * (s[q][i] - m[q]) / n[q];}
			double a = Math.sqrt(A);
			System.out.printf("%.8f\n", a);}
	}
}


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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll a[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll n;
    cin >> n;
    cout << a[n-1];
    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 22 16:06:57 2017

@author: 0048005387
"""

N = input()
T = map(int, raw_input().split())

M = input()
PX=[]
for i in range(M):
    PX.append(map(int, raw_input().split()))

for i in range(M):
    ans = 0
    for j in range(N):
        if(j+1 == PX[i][0]):
            ans = ans + PX[i][1]
        else:
            ans = ans + T[j]
    print(ans)


Measured memory_bytes: 29548
import java.util.Scanner;


public 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");
        }
        else if(a>b){
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
    }

}

Measured memory_bytes: 26192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！


int main() {
    int a, b, h;
    cin >> a >> b >> h;
    int ans;
    ans = ((a + b) * h) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A = []; B = []; C = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    A.append(a); B.append(b)
    
for j in range(m):
    C[A[j]-1] += 1
    C[B[j]-1] += 1

for k in range(n):
    print(C[k])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,n) for(i=a;i<n;i++)
#define in(x) scanf("%lld",&x)
void solve()
{
    ll n,i;
    in(n);
    ll a[2*n];
    f(i,0,2*n)
    in(a[i]);
    sort(a,a+2*n);
    ll ans=0;
    for(i=0;i<2*n;i+=2)
        ans+=a[i];
    printf("%lld\n",ans);
}
int main()
{
    ll t;
	// cin>>t;
	// while(t--)
		solve();
}

Measured memory_bytes: 3840