akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    string S;
    cin >> S;
    cout << S.substr(0, 3) << '\n';
}


Measured memory_bytes: 3656
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
GCDs = [-1] * (K + 1)

ans = 0
for i in range(K, 0, -1):
    num = K // i
    GCDs[i] = pow(num, N, MOD)
    for n in range(2, num + 1):
        GCDs[i] -= GCDs[i * n] % MOD
    ans = (GCDs[i] * i % MOD + ans) % MOD

print(ans)


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

int main()
{

	int N,W;
	cin>>N>>W;
	long long v[N+1];
	int w[N+1];
	long long dp[N+1][W+1];
	for(int i=1; i<=N; i++)
	{
		int temp1,temp2;
		cin>>temp1>>temp2;
		w[i] = temp1;
		v[i] = temp2;
	}
	for(int i=0; i<=N; i++)
	{
		for(int j=0; j<=W; j++)
		{
			if(!(i==0 || j==0))
			{
				if(j-w[i]>=0)
					dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
				else
					dp[i][j] = dp[i-1][j];
			}
			else
			{	
				dp[i][j] = 0;
			}
		}
	}

	cout<<dp[N][W];
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
typedef pair <int, int> pii;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s, t;
	//long long n, A[1000000000];
	long long n, m;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	
	string s[2001];
	cin >> a;
	//cin >> b;
	for ( b = 0; b < 26; b++)
	{
		if ((a-b*4)%7==0&& (a - b * 4)>=0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	/*for ( b = a; b > 0; b-=3)
	{
		if (b%4==0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}*/
	cout << "No" << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;

	//cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string s;
    cin >> s;
    vector<int> news = {0,0,0,0};
    rep(i,s.size()){
        if (s[i] == 'N'){
            news[0]++;
        }
        if (s[i] == 'E'){
            news[1]++;
        }
        if (s[i] == 'W'){
            news[2]++;
        }
        if (s[i] == 'S'){
            news[3]++;
        }
    }
    //p(news);
    if (news[0] > 0 && news[3] == 0){
        cout << "No";
    }
    else if (news[1] > 0 && news[2] == 0){
        cout << "No";
    }
    else if (news[2] > 0 && news[1] == 0){
        cout << "No";
    }
    else if (news[3] > 0 && news[0] == 0){
        cout << "No";
    }
    else cout << "Yes";
}



Measured memory_bytes: 256
import java.util.*;

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

    int N = in.nextInt();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

    for (int i = 1; i <= 100; i++) {
      for (int j = 1; j <= 100; j++) {
        for (int k = 1; k <= 100; k++) {
          int n = i*i + j*j + k*k + i*j + j*k + i*k;
          
          if (!map.containsKey(n)) {
            map.put(n, 0);
          }
          map.put(n, map.get(n) + 1);
        }
      }
    }

    for (int i = 1; i <= N; i++) {
      if (map.containsKey(i)) {
        System.out.println(map.get(i));
      } else {
        System.out.println(0);
      }
    }
  }

  public static int gcd(int a, int b) {
        if (b == 0) return a;
    return gcd(b, a % b);

  }

  public static long gcd(long a, long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
  }
}

Measured memory_bytes: 48828
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
dp_ppp=[]
dp_mpp=[]
dp_pmp=[]
dp_ppm=[]
dp_mmp=[]
dp_mpm=[]
dp_pmm=[]
dp_mmm=[]
for i in range(N):
  x,y,z=map(int,input().split())
  dp_ppp.append(x+y+z)
  dp_mpp.append(-x+y+z)
  dp_pmp.append(x-y+z)
  dp_ppm.append(x+y-z)
  dp_mmp.append(-x-y+z)
  dp_mpm.append(-x+y-z)
  dp_pmm.append(x-y-z)
  dp_mmm.append(-x-y-z)
dp_ppp.sort(key=lambda x:-x)
dp_mpp.sort(key=lambda x:-x)
dp_pmp.sort(key=lambda x:-x)
dp_ppm.sort(key=lambda x:-x)
dp_mmp.sort(key=lambda x:-x)
dp_mpm.sort(key=lambda x:-x)
dp_pmm.sort(key=lambda x:-x)
dp_mmm.sort(key=lambda x:-x)
ppp=sum(dp_ppp[0:M])
mpp=sum(dp_mpp[0:M])
pmp=sum(dp_pmp[0:M])
ppm=sum(dp_ppm[0:M])
mmp=sum(dp_mmp[0:M])
mpm=sum(dp_mpm[0:M])
pmm=sum(dp_pmm[0:M])
mmm=sum(dp_mmm[0:M])
ans=max([ppp,mpp,pmp,ppm,mmp,mpm,pmm,mmm])
print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

// main() { UnionFind uf(N); }
struct UnionFind
{
    vector<int> par; //par[i]:= iの親の番号
    vector<int> siz; //siz[i]:= iの属する連結成分の大きさ
    UnionFind(int N) {
        par.resize(N);
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
        siz.resize(N,1);
    }

    int root(int x){ // xが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }

    bool unite (int x, int y) { // xとyの木を併合
        x = root(x); y = root(y);
        if (x == y) return false;
 
        if (siz[x] < siz[y]) swap(x, y); // merge technique 小を大にくっつける
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    int size(int x) { // xの属する木の大きさを得る
        return siz[root(x)];
    }
};

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

int N,M; cin >> N >> M;
vi a(M),b(M);
rep(i,M) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
}

int ans = M;
rep(i,M) {
    UnionFind uf(N);
    rep(j,M) {
        if(j == i) continue;
        uf.unite(a[j],b[j]);
    }
    if(uf.size(0) == N) ans--;
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
n = int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int, input().split())))
ab = sorted(ab, key=lambda x:x[1], reverse=True)

cd=[]
for i in range(n):
    cd.append(list(map(int, input().split())))
cd = sorted(cd, key=lambda x:x[0])
# print(ab, flush=True)
# print(cd, flush=True)


ans = 0
for i in cd:
    for ji, j in enumerate(ab):
        if i[0]>j[0] and i[1]>j[1]:
            # print(i, j, flush=True)
            ans+=1
            ab.pop(ji)
            break;
print(ans, flush=True)



Measured memory_bytes: 9076
while true
    line = gets.chomp
    break if line == "0"
    q1, b, c1, c2, q2 = line.split.map(&:to_i)
    impossible = true
    [b / c1, q2].min.downto(1){|g1|
        g2 = (b - g1 * c1) / c2
        if g1 + g2 >= q1
            puts "#{g1} #{g2}"
            impossible = false
            break
        end
    }
    puts "NA" if impossible
end



Measured memory_bytes: 6860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int p, q, r;
  cin >> p >> q >> r;
  
  int a,b,c;
  a = p+q;
  b = q+r;
  c = r+p;
  
  cout << min({a,b,c});
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int mex(vi a)
{
	sort(all(a));
	if(a.empty()||a[0]>0)
		return 0;
	rep(i,a.size()-1)
		if(a[i]+1<a[i+1])
			return a[i]+1;
	return a.back()+1;
}

int calc(const vvi& g,int u,vi& grundy)
{
	if(grundy[u]!=-1)
		return grundy[u];
	vi a;
	for(int v:g[u])
		a.push_back(calc(g,v,grundy));
	return grundy[u]=mex(a);
}

bool check(const vvi& g,const vi& grundy)
{
	rep(u,g.size()){
		vi a;
		for(int v:g[u]){
			if(grundy[u]==grundy[v])
				return false;
			a.push_back(grundy[v]);
		}
		if(mex(a)!=grundy[u])
			return false;
	}
	return true;
}

int main()
{
	for(int n;cin>>n&&n;){
		vi p(n);
		vvi g(n);
		rep(i,n){
			cin>>p[i]; p[i]--;
			g[p[i]].push_back(i);
		}

		vi on_cycle(n);
		int root=0;
		rep(i,n) root=p[root];
		for(int v=root;!on_cycle[v];v=p[v])
			on_cycle[v]=1;

		vi grundy(n,-1);
		rep(i,n) if(on_cycle[i])
			for(int v:g[i]) if(!on_cycle[v])
				calc(g,v,grundy);

		bool ok=false;
		{
			int next=-1;
			for(int v:g[root]) if(on_cycle[v])
				next=v;

			vi a;
			for(int v:g[root]) if(!on_cycle[v])
				a.push_back(grundy[v]);
			int x=mex(a);
			grundy[root]=x;
			calc(g,next,grundy);
			ok|=check(g,grundy);

			a.push_back(x);
			int y=mex(a);
			grundy[root]=y;
			for(int v=p[root];v!=root;v=p[v])
				grundy[v]=-1;
			calc(g,next,grundy);
			ok|=check(g,grundy);
		}
		cout<<(ok?"POSSIBLE":"IMPOSSIBLE")<<endl;
	}
}


Measured memory_bytes: 33664
import copy

N = int(input())
X = [int(i) for i in input().split()]
tmp = copy.deepcopy(X)

X = sorted(X)
for i in range(N):
    ans1 = X[int(len(X)/2)]
    ans2 = X[int(len(X)/2)-1]
    if tmp[i] < ans1:
        print(ans1)
    else:
        print(ans2)

Measured memory_bytes: 27156
# C
N = int(input())
S = list(input())

white_cum = [0]*(N+1)
black_cum = [0]*(N+1)

cum = 0
for i in range(N):
    if S[i] == "#":
        cum += 1
    white_cum[i+1] = cum

cum = 0    
for i in range(N):
    if S[N-1-i] == ".":
        cum += 1
    black_cum[N-1-i] = cum
    
res = min([white_cum[i] + black_cum[i] for i in range(N+1)])
print(res)

Measured memory_bytes: 22320
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        String[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);

        if (a < b && b < c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8988
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int main() {

	int N;
	int A[100000];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(A, A + N);
	if (A[N - 1] - A[0] >= 2) {
		cout << "No" << endl;
	}
	else if (A[N - 1] - A[0] == 1){
		int cnt = 1;
		while (cnt < N && A[0] == A[cnt])cnt++;
		if (A[0] != A[A[0]] && (A[0] - cnt + 1) * 2 <= N - cnt)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (A[0] == N - 1 && A[N - 1] == N - 1) {
			cout << "Yes" << endl;
		}
		else if (A[0] * 2 <= N) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}

type String string

func (s String) revese() string {
	b := []byte(s)
	for i := 0; i < len(b)/2; i++ {
		b[i], b[len(b)-1-i] = b[len(b)-1-i], b[i]
	}
	return string(b)
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
ll dx[4] = {0, 0, -1, 1};
ll dy[4] = {1, -1, 0, 0};
ll mat[1001][1001];
ll vis[1001][1001];
ll n,m;
bool isvalid(ll x,ll y)
{
	if(x>=0&&x<=n&&y>=0&&y<=m)
	{
		return true;
	}
		return false;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);

cin>>n>>m;

ll a,b,c,d;
string s;
cin>>a>>b>>c>>d;
a--,b--,c--,d--;
for(ll i=0;i<n;i++)
{
	cin>>s;
	for(ll j=0;j<m;j++)
	{
if(s[j]=='.')
{
	mat[i][j]=1;
	}	
	}
}
deque<pair<pair<ll, ll>, ll>> q;
q.push_front({{a,b},0});
while(!q.empty())
{
	pair<pair<ll,ll>,ll> x=q.front();
	q.pop_front();
	pair<ll,ll> p=x.first;
	if(vis[p.first][p.second]==1)
	{
		continue;
	}
	vis[p.first][p.second]=1;
	if(c==p.first&&d==p.second)
	{
		cout<<x.second<<endl;
		return  0;
	}
	for(ll i=0;i<4;i++)
	{
		ll np=p.first+dx[i];
		ll ns=p.second+dy[i];
		if(isvalid(np,ns)==true&&vis[np][ns]==0&&mat[np][ns]==1)
		{
			q.push_front({{np,ns},x.second});
		}
	}
	for(ll i=-2;i<=2;i++)
	{
		for(ll j=-2;j<=2;j++)
		{
			ll np=p.first+i;
			ll ns=p.second+j;
			if(isvalid(np,ns)==true&&vis[np][ns]==0&&mat[np][ns]==1)
			{
				q.push_back({{np,ns},x.second+1});
			}
		}
	}
	}
	cout<<-1<<endl;
	return 0;	
}
 
 
 

 


Measured memory_bytes: 20544
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
lint n,k,a[64][200010];
int main() {
	std::cin>>n>>k;
	REP(i,n)std::cin>>a[0][i];
	rep(i,60){
		REP(j,n)a[i+1][j]=a[i][a[i][j]];
	}
	lint m=k,now=1;
	for(int i=60;i>=0;i--){
		if(m-((lint)1<<i)>=0){
			now=a[i][now];
			m-=(lint)1<<i;
		}
	}
	std::cout<<now<<std::endl;
	return 0;
}

Measured memory_bytes: 98952
from decimal import Decimal
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(input())
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = int(round(float(input())*10**9))
    p,q = waru(a,2)-9-50,waru(a,5)-9-50
    num[p][q] += 1
    lis[i] = [p,q]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(99,-1,-1):
    for j in range(99,-1,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    p,q = lis[i]
    x,y = p+50,q+50
    p = -x-50
    q = -y-50
    ans += cum2[p][q]
    if x>=0 and y>=0:
      ans -= 1
  return ans//2
print(solve())

Measured memory_bytes: 39996
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
   int num = n%m;
  
   if(num==0){
     cout << 0 << endl;
   }else{
     cout << 1 << endl;
   }
  
   //cout << n << endl;
   // cout << m << endl;
  
   
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  int count = 0;
  int max;
  int i = N;
  while (i != 0) {
    max = 0;
    for (int j=0; j<N; j++) {
      if (max < d.at(j))
        max = d.at(j);
    }
    count++;
    for (int j=0; j<N; j++) {
      if (max == d.at(j)) {
        d.at(j) = 0;
        i--;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])

n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    for j in range(i):
        if a[j] > a[i]:
            a.insert(j, a[i])
            a.pop(i+1)
            break
    show(a)



Measured memory_bytes: 5976
import java.util.Scanner;

//What Color?
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] c = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
		int[][] a = {
				{0,0,0},
				{0,0,255},
				{0,255,0},
				{0,255,255},
				{255,0,0},
				{255,0,255},
				{255,255,0},
				{255,255,255}
		};
		while(true){
			String s = sc.next();
			if(s.equals("0"))break;
			int r = Integer.parseInt(s.substring(1,3),16);
			int g = Integer.parseInt(s.substring(3,5),16);
			int b = Integer.parseInt(s.substring(5,7),16);
			double min = Integer.MAX_VALUE;
			int k = 0;
			for(int i=0;i<8;i++){
				double d = Math.sqrt(Math.pow(r-a[i][0], 2)+Math.pow(g-a[i][1], 2)+Math.pow(b-a[i][2], 2));
				if(d < min){
					k=i;
					min = d;
				}
			}
			System.out.println(c[k]);
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> C.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  
  vector<int64_t> div(N+1); 
  int x = 0;
  bool flag = true;
  for(int i=1; i<N+1; i++){
   if(flag){
    while(B.at(i-1) > A.at(x)){
      if(x == N-1){
       x++;
       flag = false;
       break;
      }
      x++;
    }
   }
    div.at(i) += div.at(i-1) + x;
  }
  
  int64_t ans = 0;
  int j = N-1;
  flag = true;
  for(int i=N-1; i>=0; i--){
    int cnt = 0;
   if(flag){
    while(C.at(i) <= B.at(j)){
      if(j == 0){
        j--;
        flag = false;
        break;
      }
      j--;
    }
   }
    ans += div.at(j+1);
  }

  cout << ans << endl;   
}

Measured memory_bytes: 2176
from operator import itemgetter
import copy

n = int(input())
ab = sorted([list(map(int, input().split())) for i in range(n)])
abr = copy.copy(ab)
abr.sort(key=itemgetter(1))
if n % 2:
    a1,b1 = ab[n//2]
    a2,b2 = abr[n//2]
    ans = b2 - a1 + 1
else:
    a1,b1 = ab[n//2-1]
    a2,b2 = abr[n//2-1]
    a3,b3 = ab[n//2]
    a4,b4 = abr[n//2]
    ans = b4 - a3 + b2 - a1 + 1
print(ans)

Measured memory_bytes: 116520
var
	L,R,M,S:int64;
begin
	read(S);
	L:=0;
	R:=1000000000;
	while R-L>1 do begin
		M:=(L+R)div 2;
		if M*M<=S then
			L:=M
		else
			R:=M;
	end;
	writeln('0 0 ',R,' 1 ',R*R-S,' ',R);
end.

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        if(a<0){
            a=-a;
            b=-b;
            c=-c;
        }
        if(d<0){
            d=-d;
            e=-e;
            f=-f;
        }
        y=((c*d)-(a*f))/((b*d)-(a*e));
        x=((b*f)-(c*e))/((b*d)-(a*e));
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int pa=0,pb=0;
  rep(i,n){
    if(i % 2 == 0){
      pa += a.at(i);
    }else{
      pb += a.at(i);
    }
  }
  cout << pa - pb << endl;
    
  
}

Measured memory_bytes: 256
#include<stdio.h>
//#define scanf scanf_s
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
char a[4001];
int main()
{
	int n, i,j,k,l,R,G,B;
	long long sum=0,sum1=0;
	j = k = l =R=G=B=0;
	scanf("%d", &n);
	getchar();
	gets(a);
	for (i = 0; i < n; i++)
	{
		if (a[i] == 'R')R++;
		else if (a[i] == 'G') G++;
		else if (a[i] == 'B') B++;
	}
	sum = (long long)R * G * B;
	/*for (i = 0; i < n; i++)
	{
		if (a[i] == 'R')  R--, sum += G*B;
		else if (a[i] == 'G')  G--,sum+=R*B;
		else if (a[i] == 'B')  B--,sum+=R*G;	
	}*/
	for (i = 0; i < n; i++)
	{
		for (j = i+2; j < n; j++)
		{
			if ((i + j) % 2 != 0) continue;
			if (a[i] != a[j] && a[i] != a[(i + j) / 2]&&a[j]!=a[(i+j)/2]) sum--;
		}
	}
	printf("%lld", sum );
}

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

int main()
{
  int N;
  vector<int> V, C;

  cin >> N;
  int tmp;
  for (int i=0;i<N;i++){
    cin >> tmp;
    V.push_back(tmp);
  }
  for (int i=0;i<N;i++){
    cin >> tmp;
    C.push_back(tmp);
  }

  int X=0, Y=0;
  for (int i=0;i<N;i++){
    if (V[i] > C[i]){
      X += V[i];
      Y += C[i];
    }
  }

  cout << X-Y << endl;

  return 0;
}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "set/union_find_g.h"
template<class T>
struct gufs {
	map<T,T> f;
	map<T,int> c;
	T find(T v) {
		T r, u;
		for(r=v; f.find(r) != f.end(); r=f[r]);
		for(u=v; u!=r; ) {
			T t = f[u];
			f[u] = r;
			u = t;
		}
		if (c.find(r)==c.end()) c[r] = 1;
		return r;
	}
	T merge(T a, T b) {
		a = find(a);
		b = find(b);
		if (a!=b) {
			f[a] = b;
			c[b] += c[a];
		}
		return b;
	}
	void clear() {
		f.clear();
		c.clear();
	}
	int count(int v){
		return c[find(v)];
	}
	void get_sets(map<T,vector<T>> &s) {
		for (auto &x: f) {
			s[find(x.first)].push_back(x.first);
		}
		for (auto &x: s) {
			s[x.first].push_back(x.first);
		}
	}
};

#define MAXN 100000

int n, m;
vector<pair<int,int>> g[MAXN];

map<int, gufs<int>> u;
map<int, map<int, vector<int>>> us;

int q[MAXN];
int h, t;
int dist[MAXN];

void adde(int a, int b, int c) {
	g[a].push_back({b,c});
	g[b].push_back({a,c});
	u[c].merge(a, b);
}

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	for (int i=0; i<m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--, b--, c--;
		adde(a,b,c);
	}
	return 1;
}

void init() {
	for (int i=0; i<n; i++) dist[i] = INT_MAX;
	for (auto &x: u)
		x.second.get_sets(us[x.first]);
}

void push_q(int v, int c, int d) {
	int r = u[c].find(v);
	for (auto &x: us[c][r]) {
		if (d < dist[x]) {
			dist[x] = d;
			q[t++] = x;
		}
	}
	//!! speed up
	us[c][r].clear();
}

int solve() {
	h=0, t=0;
	dist[0] = 0;
	q[t++] = 0;
	while (h<t) {
		int v = q[h++], d = dist[v];
		//printf("-->v=%d d=%d\n", v, d);
		for(auto &x: g[v]) {
			int u = x.first, c = x.second;
			//need to process when dist[u]==d
			if (dist[u] <= d) continue;
			push_q(u, c, d+1);
		}
	}
	//cout << us << endl; printa(dist,n);
	return dist[n-1];
}

void output(int ans) {
	printf("%d\n", ans==INT_MAX? -1: ans);
}

void cleanup() {
	for (int i=0; i<n; i++) g[i].clear();
	u.clear();
	us.clear();
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 101504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class34
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = NK[0];
            long K = NK[1];
            var H = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Array.Sort(H);
            Array.Reverse(H);
            if (K > H.Length) K = H.Length;
            for (int i = 0; i < K; i++) H[i] = 0;
            Console.WriteLine(H.Sum());
        }
    }
}


Measured memory_bytes: 39552
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int A,B;
    cin >> A >> B;

    if(A <= 8 && B <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}

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

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int n, k;
  cin >> n >> k;
  vector <int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  ll ans = 0;
  rep(i, k) {
    ans += p[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, L, pos=0,count=1;
  
  cin >> N >> X;

  for (int i=0; i<N; i++){
    cin >> L;
    
    if(pos+L>X)
      break;
    
    pos += L;
    count++;

  }

  cout << count << endl;

}

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


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

  vector<int> A(n), B(n), C(n + 1), D(n + 1);
  rep(i, n) {
    int a;
    cin >> a;
    A[i] = a;
    C[a]++;
  }
  rep(i, n) {
    int b;
    cin >> b;
    B[i] = b;
    D[b]++;
  }

  rep(i, n) {
    if (C[i + 1] + D[i + 1] > n) {
      cout << "No" << endl;
      return 0;
    }
  }

  rep(i, n) C[i + 1] += C[i];
  rep(i, n) D[i + 1] += D[i];

  int x = 0;
  rep(i, n) x = max(x, C[i + 1] - D[i]);

  cout << "Yes" << endl;
  rep(i, n) {
     cout << B[(i + n - x) % n] << ' ';
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include<string>

using namespace std;

int main(){
    long long int s;
    long long int c;
    cin>>s;
    cin>>c;
    if(s>c/2){
        cout<<c/2<<endl;
    }else{
        c=c-2*s;
        cout<<s+c/4<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int a[N], num[N], win[N], n;
vector<int> gr[N], v;
void getAns() {
	for (int i = 0; i < v.size(); i++) {
		int u = v[i], z = 0;
		for (auto x : gr[u]) {
			if (a[x] != a[u] && win[x] == -1)
				z = 1;
		}
		if (z == 1)
			win[u] = 1;
		else
			win[u] = -1;
	}
	for (int i = 0; i < v.size(); i++) {
		int u = v[i];
		if (win[u] == -1) {
			for (auto x : gr[u]) {
				if (a[x] != a[u])
					win[x] = 1;
			}
		}
	}
	return;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
			cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	iota(num, num + n, 0);
	sort(num, num + n, [] (int x, int y) { return a[x] < a[y]; });
	v.push_back(num[0]);
	for (int i = 1; i < n; i++) {
		if (a[num[i]] != a[num[i - 1]]) {
			getAns();
			v.clear();
		}
		v.push_back(num[i]);
	}
	getAns();
	for (int i = 0; i < n; i++) {
		if (win[i] == 1)
			cout << i + 1 << " ";
	}
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

const MAX = 45

var dp [MAX]int

func fin(n int) int {
	if dp[n] != 0 {
		return dp[n]
	}

	switch n {
	case 0:
		dp[n] = 1
	case 1:
		dp[n] = 1
	default:
		dp[n] = fin(n-1) + fin(n-2)
	}
	return dp[n]
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(fin(n))
}



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

const int N = 1e5 + 5 , INF = 2e9;

int dp[N];
int h[N];

main(){
    int n;

    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; i ++){
        scanf("%d" , &h[i]);
    }

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for(int i = 3 ; i <= n ; i ++){
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1] , abs(h[i] - h[i-2]) + dp[i-2]);
    }

    printf("%d\n" , dp[n]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int prime[55556];
bool is_prime[55556];

int sieve(int n){
    int p=0;
    FOR(i,0,n+1) is_prime[i]=true;
    is_prime[0]=false;
    is_prime[1]=false;
    FOR(i,2,n+1){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j]=false;
            }
        }
    }
  return p;
}

int main(){
    sieve(55555);
    int N;cin>>N;
    int cnt=0;
    FOR(i,0,55556){
        if (prime[i]%5!=1)continue;
        else{
            if(cnt!=0) cout<< " ";
            cout << prime[i];
            cnt ++;
        }
        if(cnt==N) break;        
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int gcd(int x,int y){
	if(y==0) return x;
	gcd(y,x%y);
}

int main()
{
	unsigned long a,b,g,l;

	while(scanf("%ld%ld",&a,&b)!=EOF){
		g=gcd(a,b);
		l=a/g*b;

		cout<<g<<" "<<l<<endl;
	}

	return 0;
}

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

int main(void) {
	long long i, N, A[100000], r;
	long long Ans;
	scanf("%lld", &N);
	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}

	Ans = 0;
	r = 0;
	for (i = 0; i < N; i++) {
		Ans = Ans + (A[i] + r) / 2;
		if (A[i] > 0) {
			r = (A[i] + r) % 2;
		}
		else {
			r = 0;
		}
	}
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

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;
}
int H, W, ch, cw, dh, dw;
vector<vector<bool>> s(1010, vector<bool>(1010, false));
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
    cin >> H >> W >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            char tmp;
            cin >> tmp;
            if(tmp == '.')s[i][j] = true;
        } 
    }
    vector<vector<int> > cost(H, vector<int>(W, -1));
    deque<pair<int, int>> dq;
    dq.push_front(make_pair(ch, cw));
    cost[ch][cw] = 0;
    int cnt = 0;
    while(!dq.empty()){
        pair<int, int> pos = dq.front();
        int x = pos.first;
        int y = pos.second;
        dq.pop_front();
        for (int i = 0; i < 4; i++)
        {
            if(x+dx[i]<0||y+dy[i]<0)continue;
            if(s[x+dx[i]][y+dy[i]]){
                if(cost[x+dx[i]][y+dy[i]]<0||cost[x][y]<cost[x+dx[i]][y+dy[i]]){
                    dq.push_front(make_pair(x+dx[i], y+dy[i]));
                    cost[x+dx[i]][y+dy[i]] = cost[x][y];
                }
            }
        }
        for (int i = -2; i <= 2; i++)
        {
            for (int j = -2; j <= 2; j++)
            {
                if(x+i<0||y+j<0)continue;
                if(s[x+i][y+j]){
                    if(cost[x+i][y+j]<0||cost[x][y]+1<cost[x+i][y+j]){
                        dq.push_back(make_pair(x+i, y+j));
                        cost[x+i][y+j] = cost[x][y]+1;
                    }
                }
            }
        }
        
    }
    
    cout << cost[dh][dw] << endl;

}

Measured memory_bytes: 7696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int x, y, z;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        x = sc.nextInt();
        y = sc.nextInt();
        z = sc.nextInt();
        solve();
    }

    void solve() {
        int count = 0;
        x -= z;
        while (x >= y + z) {
            x -= y + z;
            count++;
        }
        System.out.println(count);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22228
local n,h=io.read("*n","*n")
local a={}
local b={}
for i=1,n do
    a[i],b[i]=io.read("*n","*n")
end
table.sort(a)
table.sort(b)

local attack=0
for i=n,1,-1 do
    if b[i]>=a[n] then
        h=h-b[i]
        attack=attack+1
    end
    if 0>=h then
        print(attack)
        return
    end
end
print(attack+math.ceil(h/a[n]))

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

int main() {
  ll inf = 1e18;
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll>s(a);
  vector<ll>t(b);
  rep(i,0,a) cin >> s[i];
  rep(i,0,b) cin >> t[i];
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  rep(i,0,q){
    ll x;
    cin >> x;
    ll pos1 = lower_bound(s.begin(),s.end(),x)-s.begin();
    ll pos2 = lower_bound(t.begin(),t.end(),x)-t.begin();
    vector<ll>s1,t1;
    if(pos1 != 0) s1.push_back(s[pos1-1]);
    if(pos1 != a) s1.push_back(s[pos1]);
    if(pos2 != 0) t1.push_back(t[pos2-1]);
    if(pos2 != b) t1.push_back(t[pos2]);
    ll ans = inf;
    rep(i,0,s1.size()) rep(j,0,t1.size()){
      ans = min(ans,abs(x-s1[i])+abs(s1[i]-t1[j]));
      ans = min(ans,abs(x-t1[j])+abs(s1[i]-t1[j]));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4844
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,r,t[10]={},a,b,c,ans=1e18,dist[205][205]={},cnt;
  cin >> n >> m >> r;
  for(int i=0; i<r; i++) {
    cin >> t[i];
    t[i]--;
  }
  sort(t,t+r);
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j) {
        dist[i][j]=1e18;
      }
    }
  }
  for(int i=0; i<m; i++) {
    cin >> a >> b >> c;
    a--,b--;
    dist[a][b]=dist[b][a]=c;
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
        if(i!=j&&i!=k&&j!=k) {
          dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
        }
      }
    }
  }
  do{
    cnt=0;
    for(int i=0; i<r-1; i++) {
      cnt+=dist[t[i]][t[i+1]];
    }
    ans=min(ans,cnt);
  }while(next_permutation(t,t+r));
  cout << ans << endl;
}

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

typedef long long ll;
const int maxn = 100005;
typedef pair<int, int>par;
const ll mod = 1e9+7;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm


    int K, A, B;
    cin >> K >> A >> B;


    int ok = 0;
    for( int i = A; i <= B; i++ )
        if( i % K == 0 )
            ok = 1;

    if( ok ) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int quickpow(int x,int y)
{
	long long res=1,base=x;
	while(y)
	{
		if(y&1) res*=base,res%=mod;
		y>>=1;
		base*=base,base%=mod;
	}
	return res;
}
int prod[2000001];
int invn[2000001];
int inv(int x){return quickpow(x,mod-2);}
int c(int n,int m)
{
	if(m>n||m<0)
		return 0;
	return 1ll*prod[n]*invn[n-m]%mod*invn[m]%mod;
}

long long dp[2000001];
int f(int x,int y)
{
	if(x>y)swap(x,y);
	dp[0]=1;
	int ans=1;
	for(int i=1;i<=x+y;i++)
	{
		dp[i]=dp[i-1]*2;
		dp[i]-=c(i-1,x);
		dp[i]-=c(i-1,y);
		dp[i]%=mod;
		ans+=dp[i],ans%=mod;
	}
	return ans;
}
signed main()
{
	int l1,l2,r1,r2;
	cin>>l1>>l2>>r1>>r2;
	prod[0]=1;
	invn[0]=1;
	for(int i=1;i<=r1+r2;i++)
	{
		prod[i]=1ll*prod[i-1]*i%mod;
		invn[i]=inv(prod[i]);
	}
	printf("%d",((((f(r1,r2)-f(l1-1,r2))%mod
	-f(r1,l2-1))%mod+f(l1-1,l2-1))%mod+mod)%mod);
}


Measured memory_bytes: 31488
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def solve(h):\n"
"    if len(h)<2:\n"
"        return h[0]\n"
"    s=[i for i in range(len(h))if h[i]<1]\n"
"    s=[-1]+s+[len(h)]\n"
"    a=0\n"
"    for l in[h[i+1:j]for i,j in zip(s,s[1:])]:\n"
"        if not l:continue\n"
"        v=min(l)\n"
"        l=[t-v for t in l]\n"
"        a+=v+solve(l)\n"
"    return a\n"
"input()\n"
"print(solve(list(map(int,input().split()))))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3408
n = int(input())
a = list(map(int, input().split()))
l = sum(a)
accu = 0
for i in a:
    accu += i
    if accu>l/2:
        if abs(l/2-accu)<abs(l/2-accu+i):
            print(accu*2-l)
        else:
            print(l-(accu-i)*2)
        break

Measured memory_bytes: 26060