akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

struct Node{
  int key, pk, lk, rk;
};

int main(){
  int n, x;
  Node temp;
  vector<int> data;
  vector<Node> tree;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >>x;
    data.push_back(x);
  }
  
  for(int i=0;i<n;i++){
    temp.key=data[i];
    if(i!=0) temp.pk=data[(i-1)/2];
    if(2*i+1<n) temp.lk=data[2*i+1];
    if(2*(i+1)<n) temp.rk=data[2*(i+1)];
    tree.push_back(temp);
  }
  
  for(int i=0;i<n;i++){
    cout << "node " << i+1 << ": key = " << tree[i].key << ", ";
    if(i!=0) cout << "parent key = " << tree[i].pk << ", ";
    if(2*i+1<n) cout << "left key = " << tree[i].lk << ", ";
    if(2*(i+1)<n) cout << "right key = " << tree[i].rk << ", ";
    cout << endl;
    }

  return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n;
    cin >> n;
    ll x[n][27];
    for (ll i=0;i<n;i++)fill(x[i],x[i]+26,0);
    for (ll i=0;i<n;i++){
        string s;
        cin >> s;
        for (ll j=0;j<s.size();j++){
            x[i][s[j]-'a']=x[i][s[j]-'a']+1;
        }
    }
    string s="";
    for (ll i=0;i<26;i++){
        ll c=INF;
        for (ll j=0;j<n;j++){
            c=min(x[j][i],c);
        }
        for (ll j=0;j<c;j++){
            s+=(char)('a'+i);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def rotate_right(self):
		s_ = self.s
		w_ = self.w
		n_ = self.n
		e_ = self.e
		self.s = e_
		self.w = s_
		self.n = w_
		self.e = n_
	
	def is_identical(self, other):		
		directions = 'NWNNWW'
		for direction in directions:
			for i in range(4):
				self.rotate_right()
				if self.is_matchall(other): return True
			self.roll(direction)
		return False

	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True

n = int(input())
dices = [None] * n
for i in range(n):
	faces = list(map(int, input().split()))
	dices[i] = Dice(faces)

for i in range(n):
	for j in range(n):
		if i != j:
			if dices[i].is_identical(dices[j]):
				print('No')
				sys.exit()

print('Yes')



Measured memory_bytes: 5620
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_C&lang=jp
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	scoreBoard := [2]int{}
	for i := 0; i < n; i++ {
		tarouCard := nextString(sc)
		hanakoCard := nextString(sc)

		if tarouCard > hanakoCard {
			scoreBoard[0] += 3
		} else if tarouCard < hanakoCard {
			scoreBoard[1] += 3
		} else {
			scoreBoard[0]++
			scoreBoard[1]++
		}
	}

	fmt.Printf("%d %d\n", scoreBoard[0], scoreBoard[1])
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



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

int main(){
	int N,M;
	bool ok = false;
	cin >> N >> M;
	vector<int> ans(N+1,0);
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		if(a==1){
			ans[b]++;
			if(ans[b]==2)ok=true;
		}
		if(b==N){
			ans[a]++;
			if(ans[a]==2)ok=true;
		}
	}
	if(ok){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 1024
#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 N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);   
    int t=1;
    //cin>>t;
    while(t--){
        int a,b,c;
        cin>>a>>b>>c;
        cout<<(b/c)-((a-1)/c)<<'\n';
    }



return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
using namespace std;
int m,n,w,a[1000011],c[201][201],x=1,y=1,now;
int main()
{
//	freopen("1.txt","r",stdin);
	cin>>m>>n>>w;
	for(int i=1;i<=w;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=w;i++)
	{
		now=a[i];
	sleep:
		if(now==0) continue;
		if(y%2)
		{
			if(now>=m-x+1)
			{
				for(int j=x;j<=m;j++)
				{
					c[y][j]=i;
				}
				now-=m-x+1;
				x=m;y++;
				goto sleep;
			}
			else
			{
				for(int j=x;j<=x+now-1;j++) 
				c[y][j]=i;
				x+=now;
				continue;
			}
		}
		else
		{
			if(now>=x)
			{
				for(int j=1;j<=x;j++)
				{
					c[y][j]=i;
				}
				y++;
				
				now-=x;x=1;
				goto sleep;
			}
			else
			{
				for(int j=x;j>=x-now+1;j--)
				{
					c[y][j]=i;
				}
				x-=now;
				continue;
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			printf("%d ",c[j][i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	isCrossed := "No"

	if a < c && c < b {
		isCrossed = "Yes"
	}

	if b < c && c < a {
		isCrossed = "Yes"
	}

	fmt.Println(isCrossed)
}


Measured memory_bytes: 512
from math import factorial
import collections

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

MEMO = {}
def fact(n):
    if MEMO.get(n):
        return MEMO[n]
    r = 2
    if n - r < 0:
        MEMO[n] = 0
        return 0
    MEMO[n] = factorial(n) // factorial(r) // factorial(n - r)
    return MEMO[n]

COUNTS = collections.Counter(BALLS)
TOTAL = sum(fact(n) for n in COUNTS.values())

MEMO2 = {}
def solve(n):
    if MEMO2.get(n):
        return MEMO2[n]

    MEMO2[n] = TOTAL - fact(COUNTS[n]) + fact(COUNTS[n] - 1)
    return MEMO2[n]

for i in range(N):
    print(solve(BALLS[i]))

Measured memory_bytes: 120652
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int main()
{
	int k;
	cin>>k;
    scanf("%s",s);
    int len=strlen(s);
    if(len<=k){
    	for(int i=0;i<len;i++)
    	printf("%c",s[i]);
	}
	else{
		for(int i=0;i<k;i++)
		printf("%c",s[i]);
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 3824
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < n-1; i++) {
        if(h[i]>=h[i+1]){
            tmp++;
            ans = max(ans,tmp);
        }else{
            tmp = 0;
        }
    }
    cout << ans << endl;
    
    
    
    
    
    
}





signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)
	const C = parseInt(args[0][2], 10)
	console.log((A === B && B === C) ? 'Yes' : 'No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int x[4], y[4], v[2];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	v[0] = -y[1] + y[0]; v[1] = x[1] - x[0];
	x[2] = x[1] + v[0]; y[2] = y[1] + v[1];
	x[3] = x[0] + v[0]; y[3] = y[0] + v[1];
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

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

	ll x;

	if(d == 0){
		x = (ll) n;
	}else if(2*d <= n){
		// x = (ll)2*d + (ll)(n- 2*d)*2;
		x = (ll)(n - d) * 2;
	}else if(2*d > n){
		x = (ll)(n - d) * 2;
	}

	// double res = (double)p * (m-1);
	long double res = (long double)(x * (m - 1)) / (long double)((ll)n*n);
	// cout << res << '\n';
	printf("%lf\n", (double)res);

	return 0;
}


Measured memory_bytes: 256
program switches
  implicit none
  integer :: n, m, k(10) = 0, s(10,10) = 0, p(10) = 0, u, x = 0, i, j, l, t
  read(*,*) n, m
  do i = 1, m
    read(*,*) k(i), s(i,1:k(i))
  end do
  read(*,*) p(1:m)
  u = ibset(0,n)-1
  do i = 0, u
    do j = 1, m
      t = 0
      do l = 1, k(j)
        if (btest(i,s(j,l)-1)) t = 1-t
      end do
      if (p(j) /= t) goto 100
    end do
    x = x+1
  100 end do
  write(*,'(i0)') x
end program switches

Measured memory_bytes: 256
#include<iostream>
#define MAX_N 20
#define MAX_M 200

int n;
int nums[MAX_N] = {};
int m[MAX_M] = {};
int Set[MAX_N] = {0};
int mp = 0;
bool end;

bool check(){
  int sum = 0;
  for(int j=0;j<n;j++){
    if(Set[j] == 1){
      sum = sum + nums[j];
    }
  }
  //std::cout << ' ' << sum << '\n';
  if(m[mp] == sum) return true;
  else return false;
}

void rec(int i){
  if(i==n){
    
    /*for(int j=0;j<n;j++){
      std::cout << Set[j] << ' ' ;
    }
    //std::cout << '\n';
    */
    
    if(check()){
      std::cout << "yes\n";
      end = true;
    }
    return;
  }
  if(end) return;
  rec(i+1);
  Set[i] = 1;
  rec(i+1);
  Set[i] = 0;
}

 int main(){
   std::cin >> n;
   for(int i=0;i<n;i++){
     std::cin >> nums[i];
   }
   /*for(int i=0;i<n;i++){
     std::cout << nums[i] << ' ';
   }
   std::cout << '\n';
   */
   int q;
   std::cin >> q;
   for(int j=0;j<q;j++){
     std::cin >> m[j];
   }
   
   for(mp=0;mp<q;mp++){
     end = false;
     for(int j=0;j<n;j++){
       Set[j] = 0;
     }
     rec(0);
     if(end == false) std::cout << "no\n";
   }

   return 0;
   
 }



Measured memory_bytes: 3064
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N;
vector<vector<int>> edge;
vector<int>step;
vector<bool>used;

int fennec;
int snuke;
//オリジナル変数


//サブ関数
//入力
void input() {
	cin >> N;
	REP(i, N) {
		edge.push_back(vector<int>());
	}
	REP(i, N-1) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	REP(i, N) {
		step.push_back(INF);
		used.push_back(false);
	}
}


//各頂点の、index=0からの距離を計算する。
void paint(int here, int dist) {
	step[here] = dist;
	for (auto to : edge[here]) {
		if (step[to] > dist + 1) {
			paint(to, dist + 1);
		}
	}
}


//ある木の頂点:nowLから、一つだけ高さの小さいところを返します。
int goDown(int nowL) {
	for (auto to : edge[nowL]) {
		if (step[to] == step[nowL] - 1) {
			nowL = to;
			break;
		}
	}
	return nowL;
}


//ある木の頂点:nowLを含む木の大きさを返します
int checkLengthOfTree(int nowL) {
	used[nowL] = true;
	int ans = 1;
	for (auto to : edge[nowL]) {
		if (!used[to]) {
			ans += checkLengthOfTree(to);
		}
	}
	return ans;
}


//計算
void calc() {
	paint(0, 0);

	//切断する枝を計算
	int nowL = N - 1;
	int dist = int((step[nowL] - 1) / 2);
	while (dist > 0) { nowL = goDown(nowL); dist--; }
	int nextL = goDown(nowL);

	//枝を切断
	edge[nowL].erase(find(edge[nowL].begin(), edge[nowL].end(), nextL));
	edge[nextL].erase(find(edge[nextL].begin(), edge[nextL].end(), nowL));


	//FennecとSnukeの塗れる頂点の数を計算しよう
	fennec = checkLengthOfTree(0);
	snuke = checkLengthOfTree(N - 1);
}


//出力
void output() {
	cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;
}


//デバッグ
void debug() {
	cin >> N;
}


//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 10096
S=set()
n=int(input())
for i in range(n):
    q,x=map(int,input().split())
    if q==0:
        if x in S:
            print(len(S))
        else:
            S.add(x)
            print(len(S))
    elif q==1:
        x={x}
        if S>=x:
            print(1)
        else:
            print(0)
    else:
            S.discard(x)


Measured memory_bytes: 23356
s=input()
ans=[0]*4
check='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	cin >> N;

	long long n = N - 1;
	char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
	vector<long long> v;
	while(true){
		long long r = n % 26;
		v.push_back(r);
		n = (n - r) / 26;
		if(n == 0){
			break;
		}
		n--;
	}
	reverse(v.begin(), v.end());
	for(int i=0; i<v.size(); i++){
		printf("%c", alpha[v[i]]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 3644
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve $ U.toList xs

solve xs = go 0 [1..] xs
  where
    go !res (i:is) (x:y:xs)
      | i == x = go (res + 1) is (x:xs)
      | otherwise = go res is (y:xs)
    go res (i:_) [x]
      | i == x = res + 1
      | otherwise = res


Measured memory_bytes: 2172
#include<complex>
#include<stdio.h>
#define F(a,b,c) acos((b*b+c*c-a*a)/2/b/c)
int main(){int n;float d,e,f,g,h,i;for(scanf("%d",&n);n--;){scanf("%f%f%f%f%f%f",&d,&g,&e,&h,&f,&i);std::complex<double> a(d,g),b(e,h),c(f,i);float A=abs(b-c),B=abs(c-a),C=abs(a-b),L=F(A,B,C),s=sin(2*L),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(L)/2);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) cout << "Left" << endl;
  if (A + B == C + D) cout << "Balanced" << endl;
  if (A + B < C + D) cout << "Right" << endl;
}


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

using namespace std;

int main() {
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        h -= a;
    }
    cout << (h <= 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    [a, b, c, k] <- map read . words <$> getLine
    putStrLn $ solve a b c k

solve :: Int -> Int -> Int -> Int -> String
solve a b c k
    | abs (a - b) > 10 ^ 18 = "Unfair"
    | even k      = show (a - b)
    | otherwise   = show (b - a)

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	string s, t; cin >> s >> t;
	sort( ALL( s ) );
	sort( ALL( t ), greater<>() );

	if( s < t ) cout << "Yes" << endl;
	else		cout << "No" << endl;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

ll f[2000010];

ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
ll binpow(ll a, ll b) {
     ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
 
ll find_ncr(ll n, ll r)
{
    ll m1=max(r,n-r);
    ll i,j,s,d=1,k;
    s=1;
 
    for(i=m1+1;i<=n;i++)
    {
        s=((s%m)*(i%m))%m;
    }
 
    m1=min(r,n-r);
 
    for(i=1;i<=m1;i++)
    {
        k=binpow(i,m-2);
        d=((d%m)*(k%m))%m;
    }
 
    k=(s%m*(d%m))%m;
 
    return k;
}

bool pall(string s)
{
  if(s.size() > 1)
  {
    for (int i = 0; i < s.size()/2; ++i)
    {
      if(s[i] != s[s.size()-i-1])
        return false;
    }
    return true;
  }
  else
    return true; 
}
int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  double n;
  cin >> n;
  double ans = (n/3)*(n/3)*(n/3);
  printf("%.10f",ans);
  return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int idex = -1;int c = 0;
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(idex==-1){
                if( s.charAt(i)=='A'){
                    idex = i;
                    c++;
                }

            }
            else {
                c++;
                if (s.charAt(i)=='Z'){
                    ans=c;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26272
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] a) {
    int p = 1;
    int step = 0;
    auto used = new int[a.length + 1];
    while (p != 2) {
        if (used[p]++) return -1;

        p = a[p];
        step++;
    }
    return step;
}

void main() {
    int n = readint;

    auto a = new int[n + 1];
    for (int i = 1; i <= n; i++) {
        a[i] = readint;
    }
    writeln(calc(a));
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

int gcd(int x,int y){
  if(!(x%y))return y;
  else return gcd(y,x%y);
}
int main() {
  int n;cin >> n;
  int as[n];
  int gcdl[n],gcdr[n];

  rep(i,n)cin >> as[i];
  gcdl[1]=as[0];gcdr[1]=as[n-1];

  reps(i,n-2){
    gcdl[i+1]=gcd(gcdl[i],as[i]);
    gcdr[i+1]=gcd(gcdr[i],as[n-i-1]);
  }
  gcdl[0]=gcdr[n-1];
  gcdr[0]=gcdl[n-1];
  int ans=1;
  
  rep(i,n)ans=max(ans,gcd(gcdl[i],gcdr[n-i-1]));
  cout << ans;
}


Measured memory_bytes: 1408
fn main() {
    let n = read::<i32>();

    if n % 2 == 0 {
        println!("{:?}", n /2);
    } else {
        println!("{:?}", n / 2 + 1);
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
typedef vector<int> Node;
typedef vector<Node> Graph;
int memo[50][50][101];
Graph G;
bool dfs(int u, int v, int c) {
    if(c == 0) {
        return u == v;
    }
    if(memo[u][v][c] != -1) return memo[u][v][c];
    for(int nu : G[u]) {
        if(dfs(nu, v, c-1)) return memo[u][v][c] = true;
    }
    return memo[u][v][c] = false;
}
int main(){
    iostream_init();
    int n, m, a, b, c;
    while(cin >> n >> m >> a >> b >> c) {
        memset(memo, -1, sizeof(memo));
        G.resize(n);
        REP(i, m) {
            int u, v;
            cin >> u >> v;
            u--; v--;
            G[u].push_back(v);
        }
        const int INF = 1e9;
        vector<int> dist(n, INF);
        dist[n-1] = 0;
        for(int iter = 1; ; iter++) {
            bool updated = false;
            for(int i = 0; i < n; i++) if(dist[i] == INF) {
                vector<int> cs = {a, b, c};
                vector<bool> oks(3, false);
                for(int k = 0; k < 3; k++) {
                    int C = cs[k];
                    for(int j = 0; j < n; j++) if(dist[j] < iter) {
                        if(dfs(i, j, C)) {
                            oks[k] = true;
                        }
                    }
                }
                if(all_of(oks.begin(), oks.end(), [](bool x){ return x; })) {
                    dist[i] = iter;
                    updated = true;
                }
            }
            if(!updated) break;
        }
        if(dist[0] == INF) {
            cout << "IMPOSSIBLE" << endl;
        } else {
            cout << dist[0] << endl;
        }
    }
    return 0;
}

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

typedef long long ll;

int n;
int a[100010];

int gcd(int a, int b){
    if (a % b == 0){
        return b;
    } else{
        return gcd(b, a%b);
    }
}


//gcd()を計算。
int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int GCD = gcd(a[0], a[1]);

    for (int i = 1; i < n; i++){
        GCD = gcd(GCD, a[i]);
    }
    cout << GCD << endl;
}

Measured memory_bytes: 640
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_HW(105);

namespace G
{
	const int Max_V(105 * 105 * 2 + 105 + 105);
	const int Max_E(105 * 105 * 5 * 2);
	const int INF(0X3F3F3F3F);
	int V, S, T, Head[Max_V], Total, To[Max_E], Next[Max_E], Cap[Max_E], Cur[Max_V], Dist[Max_V];
	inline void Add_Edge(int tot, int s, int t, int c)
	{
		To[tot] = t, Next[tot] = Head[s], Head[s] = tot, Cap[tot] = c;
	}
	inline void Add_Link(int s, int t, int c)
	{
		Total += 2, Add_Edge(Total, s, t, c), Add_Edge(Total ^ 1, t, s, 0);
	}
	int DFS(int u, int a)
	{
		if (u == T || a == 0)
			return a;
		int Ans(0);
		for (int &i = Cur[u], v, f;i;i = Next[i])
			if (Dist[v = To[i]] == Dist[u] + 1 && (f = DFS(v, min(a, Cap[i]))) > 0)
			{
				Ans += f, Cap[i] -= f, Cap[i ^ 1] += f;
				if ((a -= f) == 0)
					break;
			}
		return Ans;
	}
	bool BFS()
	{
		memset(Dist, 0, sizeof(Dist));
		queue<int> Q;
		Dist[S] = 1, Q.push(S);
		for (int u;Q.empty() == false;)
		{
			u = Q.front(), Q.pop();
			if (u == T)
				break;
			for (int i = Head[u], v;i;i = Next[i])
				if (Cap[i] && !Dist[v = To[i]])
					Dist[v] = Dist[u] + 1, Q.push(v);
		}
		return Dist[T];
	}
	int Dinic()
	{
		int Ans(0);
		while (BFS())
		{
			for (int i = 1;i <= V;++i)
				Cur[i] = Head[i];
			Ans += DFS(S, INF);
		}
		return Ans;
	}
}
using G::INF;

int H, W;
char A[Max_HW][Max_HW];

int main()
{
	scanf("%d%d", &H, &W), G::V = H * W * 2 + H + W + 2, G::S = H * W * 2 + H + W + 1, G::T = H * W * 2 + H + W + 2;
	for (int i = 1;i <= H;++i)
		scanf("%s", A[i] + 1);
	for (int Sx = 1;Sx <= H;++Sx)
		for (int Sy = 1;Sy <= W;++Sy)
		{
			if (A[Sx][Sy] != 'S')
				continue;
			for (int Tx = 1;Tx <= H;++Tx)
				for (int Ty = 1;Ty <= W;++Ty)
				{
					if (A[Tx][Ty] != 'T')
						continue;
					if (Sx == Tx || Sy == Ty)
					{
						printf("-1");
						return 0;
					}
					G::Add_Link(G::S, (Sx - 1) * W + Sy, INF);
					G::Add_Link(H * W + (Tx - 1) * W + Ty, G::T, INF);
					break;
				}
			break;
		}
	for (int x = 1;x <= H;++x)
		for (int y = 1;y <= W;++y)
		{
			if (A[x][y] == '.')
				continue;
			G::Add_Link((x - 1) * W + y, H * W + (x - 1) * W + y, (A[x][y] == 'o' ? 1 : INF));
			G::Add_Link(H * W * 2 + x, (x - 1) * W + y, INF);
			G::Add_Link(H * W * 2 + H + y, (x - 1) * W + y, INF);
			G::Add_Link(H * W + (x - 1) * W + y, H * W * 2 + x, INF);
			G::Add_Link(H * W + (x - 1) * W + y, H * W * 2 + H + y, INF);
		}
	printf("%d", G::Dinic());
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int m = n % 10;
    if (m == 2 || m == 4 || m == 5 || m == 7 || m == 9) cout << "hon" << endl;
    else if (m == 3) cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}


Measured memory_bytes: 3628
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = array.count(max(s, key = array.count))
for a in sorted(s):
    if array.count(a) == mx:
        print(a)

Measured memory_bytes: 7696
//  Friendly NUKE is ready!!
#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define dbg(x) cout<<#x<<": "<<x<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mo 1000000007
#define inf 1e18
#define eps 0.0000000001
#define stp setprecision(20)
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace std;
//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
 
#define N  int(2e5)+10
ll h[3][N] , dp[110][N] ,w[N],v[N];
int main()
{    SPEED;
      int n,Wmx;
      cin>>n>>Wmx;
      loop(i,1,n+1)cin>>w[i]>>v[i] ;
       loop(i,0,1){
      	   
      	   loop(Vs,1,1e5+1){ dp[i][Vs] = inf ;}}
      loop(i,1,n+1){
      	   
      	   loop(Vs,1,1e5+1){
      	   	 if(Vs-v[i]>=0)
      	   	 dp[i][Vs] = min(dp[i-1][Vs-v[i]]+w[i] , dp[i-1][Vs]) ;
      	   	 else dp[i][Vs] = dp[i-1][Vs] ;
      	   }
      	   
      	   
      }       int ans= 0;
      loop(i,1,n+1){
      	 
      	  loop(Vs,1,1e5+1){
      	  	 if(dp[i][Vs]<=Wmx)ans = max(ans ,Vs) ;
      	  }
      }
      cout<<ans;
}

Measured memory_bytes: 82936
N, C, K = map(int, raw_input().split())
T = sorted([int(raw_input()) for _ in range(N)])

cnt = 1
t0 = T[0]
c = 0
for t in T:
    if c < C and t <= t0 + K:
        c += 1
    else:
        c = 1
        t0 = t
        cnt += 1
print cnt


Measured memory_bytes: 9332
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
	string s;
	int count = 0;
	int a[30];
	cin >> s;
	for (int num = 0;num< 30;num++) {
		a[num] = 0;
	}
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'a')
			a[0] += 1;
		if (s[i] == 'b')
			a[1] += 1;
		if (s[i] == 'c')
			a[2] += 1;
		if (s[i] == 'd')
			a[3] += 1;
		if (s[i] == 'e')
			a[4] += 1;
		if (s[i] == 'f')
			a[5] += 1;
		if (s[i] == 'g')
			a[6] += 1;
		if (s[i] == 'h')
			a[7] += 1;
		if (s[i] == 'i')
			a[8] += 1;
		if (s[i] == 'j')
			a[9] += 1;
		if (s[i] == 'k')
			a[10] += 1;
		if (s[i] == 'l')
			a[11] += 1;
		if (s[i] == 'm')
			a[12] += 1;
		if (s[i] == 'n')
			a[13] += 1;
		if (s[i] == 'o')
			a[14] += 1;
		if (s[i] == 'p')
			a[15] += 1;
		if (s[i] == 'q')
			a[16] += 1;
		if (s[i] == 'r')
			a[17] += 1;
		if (s[i] == 's')
			a[18] += 1;
		if (s[i] == 't')
			a[19] += 1;
		if (s[i] == 'u')
			a[20] += 1;
		if (s[i] == 'v')
			a[21] += 1;
		if (s[i] == 'w')
			a[22] += 1;
		if (s[i] == 'x')
			a[23] += 1;
		if (s[i] == 'y')
			a[24] += 1;
		if (s[i] == 'z')
			a[25] += 1;
	}
	for (int j = 0;j < 26;j++) {
		if (a[j] % 2 == 1)
			count++;
	}
	if (count > 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        if(N%2==0){
        	long h = N;
        	long n = N;
        	long w = N/2;
        	System.out.println(h+" "+n+" "+w);
        }else{
        	//4hnw = nwN + hwN + nhN
        	//h(4nw-wN-nN)=nwN
        	//3500^2 search...?
        	for(long n=1;n<=3500;n++){
        		for(long w=1;w<=3500;w++){
        			if(4*n*w-w*N-n*N>0 && (n*w*N)%(4*n*w-w*N-n*N)==0){
        				long h = (n*w*N)/(4*n*w-w*N-n*N);
        				System.out.println(h+" "+n+" "+w);
        				System.exit(0);
        			}
        		}
        	}
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = a[0]; i <= a[n - 1]; i++) {
        int idx = lower_bound(a.begin(), a.end(), i) - a.begin();
        res += (idx == n / 2);
    }
    cout << res << "\n";
}


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

typedef struct Point
{
	double x;
	double y;
}point;

void koch(int n, point p1,  point p2)
{
	if(n==0)
	{
		return ; 
	}

	point s, t, u;
	double th =  60.0 * M_PI /180; //度からラジアンへ単位を変換
	
	s.x = (2.0*p1.x+1.0*p2.x)/3;
	s.y = (2.0*p1.y+1.0*p2.y)/3;
	t.x = (1.0*p1.x+2.0*p2.x)/3;
	t.y = (1.0*p1.y+2.0*p2.y)/3;
	u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x; 
	u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y; 
	
	koch(n-1, p1, s);
	printf("%.8f %.8f\n", s.x, s.y);
	
	koch(n-1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	
	koch(n-1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	
	koch(n-1, t, p2);
	

}
int main(void)
{
	point p1, p2;
	int n;
	
	scanf("%d", &n);
	
	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;
	
	
	printf("%.8f %.8f\n", p1.x, p1.y);
	koch(n,p1,p2);
	printf("%.8f %.8f\n", p2.x, p2.y);
	
	return 0;
}


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

unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if(b == 0)
	{
		return(a);
	}
	return gcd(b, a % b);
}

void solve()
{
	unsigned long long int a;
	while(cin >> a)
	{
		unsigned long long int b;
		cin >> b;
		if(a < b)
		{
			unsigned long long int temp = a;
			a = b;
			b = temp;
		}
		unsigned long long int g = gcd(a, b);
		unsigned long long int lcm = a * b / g;
		cout << g << " " << lcm << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int dist[100][100];
int bdist[100][100];
bool memo[100][100];

struct Info {
	int node;
	int dist;

	Info(int node, int dist) : node(node), dist(dist) {};

	bool operator< (const Info &a) const {
		return dist >= a.dist;
	}
};

int N, M;
void dijkstra(int start) {
	vector<bool> visited(N, false);
	priority_queue<Info> q;
	q.push(Info(start, 0));
	visited[start] = true;
	while (!q.empty()) {
		auto now = q.top(); q.pop();
		rep(i, N) {
			if (now.node == i) continue;
			if (dist[now.node][i] == INT_MAX) continue;
			int ndist = now.dist + bdist[now.node][i];
			if (ndist > dist[start][i]) continue;
			memo[now.node][i] = true;
			if (visited[i]) continue;
			visited[i] = true;
			q.push(Info(i, ndist));
		}
	}
}

signed main() {
	cin >> N >> M;

	rep(i, N) rep(j, N) dist[i][j] = INT_MAX;
	rep(i, N) dist[i][i] = 0;
	rep(i, N) rep(j, N) bdist[i][j] = INT_MAX;
	rep(i, N) bdist[i][i] = 0;

	vector<pair<int, int>> prs;
	rep(i, M) {
		int a, b, c;
		scanf("%lld %lld %lld", &a, &b, &c);
		a--; b--;
		dist[a][b] = c;
		dist[b][a] = c;
		bdist[a][b] = c;
		bdist[b][a] = c;
	}

	rep(k, N) rep(i, N) rep(j, N)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int ret = 2 * M;

	rep(i, N) {
		dijkstra(i);
	}

	rep(i, N) rep(j, N) {
		ret -= memo[i][j];
	}
	ret /= 2;

	cout << ret << endl;

    return 0;
}


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

int main(){
	ll h,w; cin >> h >> w;
	char s[20][20];
	rep(i,h){
		rep(j,w)cin >> s[i][j];
	}
	ll dist[20][20];
	queue<P> que;
	ll ans = 0;
	vl dx = {0,1,0,-1};
	vl dy = {1,0,-1,0};
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '#')continue;
			rep(p,h){
				rep(q,w)dist[p][q] = -1;
			}
			que.push(make_pair(i,j));
			dist[i][j] = 0;
			while(!que.empty()){
				P v = que.front();
				que.pop();
				rep(k,4){
					ll y = v.first+dy[k]; ll x = v.second+dx[k];
					if(y < 0 || y >= h || x < 0 || x >= w)continue;
					if(dist[y][x] != -1 || s[y][x] == '#')continue;
							dist[y][x] = dist[v.first][v.second] + 1;
							que.push(make_pair(y,x));
						
					
				}
			}
			rep(p,h){
				rep(q,w)ans = max(ans,dist[p][q]);
			}
		}
	}
	cout << ans << endl;
}

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

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

using namespace std;
using graph=vector<vector<int>>;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

vector<int> topological_order(const graph& D){
	int n=D.size();
	vector<int> deg(n);
	rep(u,n) for(int v:D[u]) deg[v]++;

	vector<int> res;
	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		res.emplace_back(u);
		for(int v:D[u]) if(--deg[v]==0) Q.emplace(v);
	}
	return res;
}

vector<int> Grundy(const graph& D){
	auto ord=topological_order(D);

	int n=D.size(),m=0;
	rep(u,n) m=max(m,(int)D[u].size());

	vector<int> g(n),last(m+1,-1);
	rep(i,n){
		int u=ord[n-i-1];
		for(int v:D[u]) last[g[v]]=u;
		while(last[g[u]]==u) g[u]++;
	}
	return g;
}

int main(){
	int n; scanf("%d",&n);
	vector<graph> G(3,graph(n));
	rep(i,3){
		int m; scanf("%d",&m);
		rep(j,m){
			int u,v; scanf("%d%d",&u,&v); u--; v--;
			if(u>v) swap(u,v);
			G[i][u].emplace_back(v);
		}
	}

	vector<vector<int>> g(3);
	rep(i,3) g[i]=Grundy(G[i]);

	int g_max=0;
	rep(i,3) rep(u,n) g_max=max(g_max,g[i][u]);

	vector<vector<mint>> wt(3,vector<mint>(g_max+1));
	rep(i,3) rep(u,n) wt[i][g[i][u]]+=pow(mint(10),18*(u+1));

	mint ans=0;
	rep(g0,g_max+1) rep(g1,g_max+1) {
		int g2=g0^g1;
		if(g2>g_max) continue;
		ans+=wt[0][g0]*wt[1][g1]*wt[2][g2];
	}
	cout<<ans<<'\n';

	return 0;
}


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

int main() {
	ll N, al = 0;
	cin >> N;
	vector<ll> A(N + 1), B(N);
	for (int i = 0;i < N + 1;i++) {
		cin >> A[i];
		al += A[i];
	}
	for (int i = 0;i < N;i++)
		cin >> B[i];
	for (int i = 0;i < N;i++) {
		if (A[i] < B[i]) {
			B[i] -= A[i];
			A[i] = 0;
			if (A[i + 1] < B[i])
				A[i + 1] = 0;
			else
				A[i + 1] -= B[i];
		}
		else {
			A[i] -= B[i];
		}
	}
	for (int i = 0;i < N + 1;i++) {
		al -= A[i];
	}
	cout << al << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		long ans = 0;
		int cnt = 0;
		for (int i = s.length - 1; i >= 0; i--) {
			if (s[i] == 'W') {
				cnt++;
			} else {
				ans += cnt;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26764
#include<cstdio>
const int maxn=100005;
struct edge{
  int to,next;
}lst[maxn<<1];int len=1,first[maxn];
void addedge(int a,int b){
  lst[len].to=b;lst[len].next=first[a];first[a]=len++;
}
int depth[maxn],sz[maxn],prt[maxn];
void dfs(int x,int p){
  sz[x]=1;
  for(int pt=first[x];pt;pt=lst[pt].next){
    if(lst[pt].to==p)continue;
    depth[lst[pt].to]=depth[x]+1;
    prt[lst[pt].to]=x;
    dfs(lst[pt].to,x);
    sz[x]+=sz[lst[pt].to];
  }
}
int main(){
  int n;scanf("%d",&n);
  for(int i=1,a,b;i<n;++i){
    scanf("%d%d",&a,&b);
    addedge(a,b);
    addedge(b,a);
  }
  depth[1]=1;
  dfs(1,0);
  int d=depth[n];
  int D=d/2;
  int v=n;
  for(int i=1;i<D;++i)v=prt[v];
  int a=n-sz[v],b=sz[v];
  if(a>b){
    printf("Fennec\n");
  }else{
    printf("Snuke\n");
  }
  return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

int a,b,c,k; cin>>a>>b>>c>>k;
  int ans=0;
 if(a<b&&b<c){ans=1;}
  
  int co=0;
   while(a>=b){b*=2;co++;}
  while(b>=c){c*=2; co++;}
 
  if(co<=k){ans=1;}
  
  if(ans==1){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
    

 
  
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define abs(a) ((a) < 0 ? (-(a)) : ((a)))

int main(void) {
	int n, sum = 0, t_i;
	double t = 10000;
	
	cin >> n;
	vector<int> a(n);
	
	for (int i=0; i<n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	t = a[0];
	t_i = 0;
	for (int i=1; i<n; i++) {
		if (abs((double)sum / n - (double)t) > abs((double)sum / n - (double)a[i])) {
			t = a[i];
			t_i = i;
		}
	}
	
	cout << t_i << endl;
	
	return 0;
}

Measured memory_bytes: 256