akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env ruby

team = Hash.new
points = Array.new

loop do
  i, s = gets.chomp!.split(?,).map(&:to_i)
  break if i.zero? && s.zero?

  # ??´????????????????????????????????¢???
  team[i] = s
  # ???????????????????´???????
  points << s
end

# ???????????????????????????????????????????????????
points.uniq!.sort!.reverse!

while line = gets
  q = line.to_i
  # ??????????????????????????¢?´¢????????????
  p (points.index(team[q])+1)
end

Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main(void){
    long long k;
    cin >> k;

    int n = 50;
    long long a[51];
    long long quo = k/n;
    int rem = k%n;

    for(int i=0; i<n; i++){
        a[i] = i + quo;
    }
   
    if(rem != 0){
        for(int i=0;i<rem;i++){
            a[i] += n;
            a[i] -= (rem-1);
        }
        for(int i=rem; i<n; i++){
            a[i] -= rem;
        }
    }
    cout << n << endl;
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

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

void Push(int, int);

#define LEN 10
#define MAX 100000
int main() {
  int n,q;
  int i;
  int q_time=0;
  int judge=0;
  char name[MAX][LEN] = {};
  int time[MAX] = {};
  char subname[MAX][LEN] = {};
  int subtime[MAX] = {};
  int sum_time=1;

  scanf("%d %d",&n,&q);

  /*入力*/
  for(i=0;i<n;i++) {
    scanf("%s",name[i]);
    scanf("%d",&time[i]);
  }

  while(sum_time != 0) { //時間の合計が０=全タスク完了
    sum_time = 0;
    /*時間の計算*/
    for(i=0;i<n;i++) {
      
      strcpy(name[i-judge],name[i]);
      time[i-judge] = time[i];
      if((time[i-judge] - q) <= 0) {
	q_time += time[i-judge];
	time[i] = 0;
	printf("%s %d\n",name[i-judge],q_time);
	judge+=1;
      } else {
	q_time += q;
	time[i-judge] -= q;
      }
      sum_time += time[i-judge]; 
    }
    n-=judge;
    judge=0;
      
  }
  return 0;
}



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

namespace LearningAtCoder
{
    class ABC146
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            Dictionary<string, int> days = new Dictionary<string, int>();
            days.Add("SUN", 7);
            days.Add("MON", 6);
            days.Add("TUE", 5);
            days.Add("WED", 4);
            days.Add("THU", 3);
            days.Add("FRI", 2);
            days.Add("SAT", 1);

            Console.WriteLine(days[input]);
        }
    }
}


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

int main(){
	string S;
	cin>>S;
	int total;
	for(int bit=0;bit<8;++bit){
		total = int(S[0] - '0');
		for(int i=0;i<3;++i){
			if(bit&(1<<i)){
				total += int(S[i+1] - '0');
			}
			else{
				total -= int(S[i+1] - '0');
			}
		}
		if(total == 7){
			cout<<S[0];
			for(int i=0;i<3;++i){
				if(bit&(1<<i)){
					cout<<'+';
				}
				else{
					cout<<'-';
				}
				cout<<S[i+1];
			}
			cout<<"=7"<<endl;
			break;
		}
	}
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
trace _ = id

type MyS = (Int, Int, Int, Bool, Int)

solve :: Int -> Int -> [Int] -> Int
solve bigL bigN xs = max (sub vec1 vec2) (sub vec2 vec1)
  where
  vec1 = VU.fromListN bigN xs
  vec2 = VU.map (bigL -) (VU.reverse vec1)

  sub :: VU.Vector Int -> VU.Vector Int -> Int
  sub vec1 vec2 = trace ("sub " ++ show a) a
    where a = sub0 vec1 vec2
  sub0 vec1 vec2 = maximum lst
    where
    lst = trace ("lst " ++ show lst0) lst0
    lst0 = unfoldr f initState
      where f Nothing = Nothing
            f (Just st) = Just (valState st, nextState st)

    initSum = VU.sum (VU.take initLen vec1) + VU.sum (VU.take initLen vec2)
    initLen = bigN `div` 2
    initState = trace ("initState " ++ show initStateA) initStateA
    initStateA = Just (0, initLen-1, initLen-1, even bigN, initSum)
  
    nextState :: MyS -> Maybe MyS
    nextState st = trace ("nextState " ++ show (st, a)) a
      where a = nextStateA st
    nextStateA (idx1T, idx1B, idx2B, isEven, sum)
      | (not isEven) && idx2B < 0 = Nothing
      | not isEven = Just (idx1T+1, idx1B+1, idx2B, True,
                           sum - vec1 VU.! idx1T + vec1 VU.! (idx1B+1))
      | idx2B > 0 = Just (idx1T+1, idx1B, idx2B-1, False,
                           sum - vec1 VU.! idx1T - vec2 VU.! idx2B)
      | otherwise = Nothing
  
    valState :: MyS -> Int
    valState (idx1T, idx1B, idx2B, isEven, sum)
      | isEven    = 2 * sum - (min (vec1 VU.! idx1B)     (vec2 VU.! idx2B))
      | otherwise = 2 * sum + (max (vec1 VU.! (idx1B+1)) (vec2 VU.! (idx2B+1)))

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bigL,bs_bigN]:remLines1 = remLines0
      bigL = readBInt bs_bigL
      bigN = readBInt bs_bigN
      xs = map (\[x] -> readBInt x) remLines1
  in solve bigL bigN xs

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 35068
N = int(input())
A = list(map(int, input().split()))
# 中央値
B = []
for i in range(N):
    B.append(A[i] - (i+1))
b = sorted(B)[N//2]

ans = 0
for i in range(N):
    ans += abs(A[i] - (i + 1) - b)

print(ans)



Measured memory_bytes: 101332
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d %d", &a,&b);
	char code[a+b+2]="";
	scanf("%s", code);
	if(code[a]=='-'){
		for(int i=0;i<a+b+1;i++){
			if(i==a+b){
				if((code[i]>=48)&&(code[i]<=57)){
					printf("Yes");
				}
				else{
					printf("No");
					break;
				}
			}
			if(i!=a){
				if((code[i]>=48)&&(code[i]<=57)) continue;
				else{
					printf("No");
					break;
				}
			}
		}
	}
	else printf("No");
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;



void solve(void){
    int N;
    cin >> N;
    vector <ll> ss(N);
    ll sum = 0LL;
    rep(N, i) {
        cin >> ss.at(i);
        sum += ss[i];
    }
    sort(all(ss));
    ll ans = sum;
    if (sum % 10 == 0) {
        int i = 0;
        while(ss[i] % 10 == 0 && i < N) i++;
        if (i == N) ans = 0LL;
        else ans -= ss[i];
    }

    cout << ans << '\n';
}

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


Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int h, n;
    cin >> h >> n;
    ll sum = 0;
    rep (i, 0, n-1) {
    	ll x; cin >> x;
    	sum += x;
    }

    if (sum < h)
    	cout << "No";
    else
    	cout << "Yes";
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        ll n,k;

        Int(n,k);

        ll res = min(n%k,k- (n%k));

        printf("%lld\n",res); 

        //printf("Case %d: ",++te);
    }
    return 0;
}



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

typedef long long ll;
const ll INF = 1e15;

struct P {
  ll x, y;
  bool operator<(const P& rhs) const {
    return (x == rhs.x) ? (y < rhs.y) : (x < rhs.x);
  }
};

int main() {
  ll W, H;
  int N;
  while (cin >> W >> H >> N) {
    vector<P> ps(N);
    vector<ll> xsorted(N), ysorted(N);
    for (int i = 0; i < N; ++i) {
      cin >> ps[i].x >> ps[i].y;
      xsorted[i] = ps[i].x;
      ysorted[i] = ps[i].y;
    }
    sort(begin(xsorted), end(xsorted));
    sort(begin(ysorted), end(ysorted));
    vector<P> candidates;
    for (int i = 0; i < min(3, N); ++i) {
      for (int j = 0; j < min(3, N); ++j) {
        candidates.push_back({xsorted[(N - 1) / 2 + (i + 1) % 3 - 1],
                              ysorted[(N - 1) / 2 + (j + 1) % 3 - 1]});
      }
    }
    pair<ll, P> ans = {INF, {INF, INF}};
    for (P c : candidates) {
      ll maxDist = -1, totalDist = 0;
      for (int i = 0; i < N; ++i) {
        ll dist = abs(ps[i].x - c.x) + abs(ps[i].y - c.y);
        totalDist += dist;
        maxDist = max(maxDist, dist);
      }
      ans = min(ans, make_pair(2 * totalDist - maxDist, c));
    }
    cout << ans.first << endl << ans.second.x << " " << ans.second.y << endl;
  }
}

Measured memory_bytes: 4176
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define limit int(1e6)
int dst[ limit ][ 3 ];
int ans[ limit ][ 3 ];

int f_answer(int n) {
	for(int i = 1; i <= 3; i++) {
		ans[ 1 ][ i ] = dst[ 1 ][ i ];
	}

	for(int i = 1; i <= n; i++) {
		// what are you doing? MAN!!!!!!
		// what happened
		ans[ i + 1 ][ 2 ] = max(ans[ i ][ 1 ] + dst[ i + 1 ][ 2 ], ans[ i + 1 ][ 2 ]);
		ans[ i + 1 ][ 3 ] = max(ans[ i ][ 1 ] + dst[ i + 1 ][ 3 ], ans[ i + 1 ][ 3 ]);

		ans[ i + 1 ][ 1 ] = max(ans[ i ][ 3 ] + dst[ i + 1 ][ 1 ], ans[ i + 1 ][ 1 ]);
		ans[ i + 1 ][ 2 ] = max(ans[ i ][ 3 ] + dst[ i + 1 ][ 2 ], ans[ i + 1 ][ 2 ]);

		ans[ i + 1 ][ 1 ] = max(ans[ i ][ 2 ] + dst[ i + 1 ][ 1 ], ans[ i + 1 ][ 1 ]);
		ans[ i + 1 ][ 3 ] = max(ans[ i ][ 2 ] + dst[ i + 1 ][ 3 ], ans[ i + 1 ][ 3 ]);
	}

	return max(ans[ n ][ 1 ], max(ans[ n ][ 2 ], ans[ n ][ 3 ]));
}

int main() {
	int n;
	scanf("%i", &n);

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

	printf("%i", f_answer(n));
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

long cnt[101];
void fact(long x){
    for(long t = x; t >= 2; t--){
        long tmp = t;
        for(long i = 2; i <= x; i++){
            while(tmp % i == 0){
                tmp = tmp / i;
                cnt[i]++;
            }
        }
    }
}
long Cbn(long b, long c){
    return c*(b+c-1);
}
long Cbn3(long b, long c){
    return c*(c-1)*(b+c-2)/2;
}
int main(){
long N;
cin >> N;
fact(N);
vector<long> cnt2;
rep(i, 101) cnt2.push_back(cnt[i]);
sort(all(cnt2));
long c2, c4, c14, c24, c74, c2_4, c2_24, c4_14;
c2 = 101 - (lower_bound(cnt2.begin(), cnt2.end(), 2) - cnt2.begin());
c4 = 101 - (lower_bound(cnt2.begin(), cnt2.end(), 4) - cnt2.begin());
c14 = 101 - (lower_bound(cnt2.begin(), cnt2.end(), 14) - cnt2.begin());
c24 = 101 - (lower_bound(cnt2.begin(), cnt2.end(), 24) - cnt2.begin());
c74 = 101 - (lower_bound(cnt2.begin(), cnt2.end(), 74) - cnt2.begin());
c2_4 = c2 - c4;
c2_24 = c2 - c24;
c4_14 = c4 - c14;


long ans = 0;
ans = Cbn(c2_24, c24)+Cbn(c4_14, c14)+c74+Cbn3(c2_4, c4);
show(ans);
// rep(i, 101) show(cnt[i]);
// show(c2);
// show(c4);
// show(c14);
// show(c24);
// show(c74);
// show(c2_4);
// show(c2_24);
// show(c4_14);

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using ll = long long;
using namespace std;

int main(){
  ll N,T; cin >> N >> T;
  vector<ll>t(N);
  for(ll i=0;i<N;i++) cin >> t.at(i);

  ll X = 0;

  for(ll i=0;i<N-1;i++){
    X += min(t.at(i+1)-t.at(i),T);
  }

  cout << X + T << endl;

  return 0;
}

Measured memory_bytes: 1792
str_input_list = input().rstrip().split(' ')
int_input_list = []
for a in str_input_list:
    int_input_list.append(int(a))
    
keyence_list = [1, 9, 7, 4]

for a in range(4):
    if keyence_list[a] in int_input_list:
        keyence_list[a] = '*'

if keyence_list == ['*', '*', '*', '*']:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    n=int(input())
    if n==0:
        print(1)
    else:
        print(0)


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


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

int main() {
    int N;
    cin >> N;
    vector<int> t(N);
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int sum = accumulate(t.begin(), t.end(), 0);
    vector<double> maxv(40010, 0);
    double TIME = 0;
    for (int i = 0; i < N; i++) {
        for (double j = TIME + 0.5; j <= TIME + t[i]; j += 0.5) {
            int k = j * 2;
            if (j == TIME + t[i]) {
                maxv[k] = min({v[i], v[i + 1], maxv[k - 1] + 0.5});
            } else {
                maxv[k] = min(v[i], maxv[k - 1] + 0.5);
            }
        }
        TIME += t[i];
    }
    TIME = sum;
    maxv[TIME * 2] = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (double j = TIME; j >= TIME - t[i] + 0.5; j -= 0.5) {
            int k = j * 2;
            if (maxv[k] < maxv[k + 1] + 0.5) continue;
            maxv[k] = min({v[i], maxv[k], maxv[k + 1] + 0.5});
        }
        TIME -= t[i];
    }
    double ans = 0;
    for (int i = 1; i <= sum * 2; i++) {
        if (maxv[i - 1] != maxv[i]) {
            ans += (maxv[i - 1] + maxv[i]) * 0.5 / 2.0;
        } else {
            ans += maxv[i] * 0.5;
        }
    }

    cout << setprecision(15) << ans << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    ll mi=1111111,idxmi,ma=-1111111,idxma;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<mi){
            mi=a[i];
            idxmi=i;
        }
        if(a[i]>ma){
            ma=a[i];
            idxma=i;
        }
    }
    int idx,num;
    cout<<2*n-1<<endl;
    if(abs(mi)<=ma){
        idx=idxma;
        num=ma;
    }
    else{
        idx=idxmi;
        num=mi;
    }
    for(int i=0;i<n;i++){
        cout<<idx+1<<" "<<i+1<<endl;
    }
    if(num>=0){
        for(int i=0;i<n-1;i++){
            cout<<i+1<<" "<<i+2<<endl;
        }
    }
    else{
        for(int i=n-1;i>=1;i--){
            cout<<i+1<<" "<<i<<endl;
        }
    }
}


Measured memory_bytes: 256
def fact(n):
    fact_lst = [0] * 100005
    fact_lst[0] = 1

    for i in range(1, n):
        fact_lst[i] = (i+1) * fact_lst[i-1]
        if fact_lst[i] > 10 ** 9 + 7:
            fact_lst[i] %= 10 ** 9 + 7

    return fact_lst[n-1]


n, m = map(int, input().split())

if abs(n-m) > 1:
    print(0)
else:
    comb = fact(min(n, m)) ** 2
    comb %= 10 ** 9 + 7

    if n == m:
        comb *= 2
    else:
        comb *= max(n, m)

    comb %= 10 ** 9 + 7
    print(comb)


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " = " << x << endl
#define print_array(arr, len) {cerr << #arr << " = "; for (int i = 0; i < len; i++) cerr << arr[i] << " "; cerr << endl;}
#define print_iterable(it) {cerr << #it << " = "; for (const auto &e : it) cerr << e << " "; cerr << endl;}
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0
#define print_iterable(it) (void)0
#endif

using ll = long long;

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

void solve()
{
    int n;
    scanf("%d", &n);
    ll ans = 1;
    for (int i = 0; i < n; i++)
    {
        ll d;
        scanf("%lld", &d);
        ans = ans / gcd(ans, d) * d;
    }
    printf("%lld\n", ans);
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    eprintf("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


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

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int a,b,c=1;
    cin>>b;
    f(i,1,b)
    {
        cin>>a;
        if(a%2==0)
        {
            if(a%3!=0 && a%5!=0)
                c=0;
        }
    }
    if(c==0)
        cout<<"DENIED";
    else
        cout<<"APPROVED";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    
    int dp[N];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    
    for(int i=2; i<N; i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

# 各recipeを使用した結果を使用するrecipe同士のxorだと考えると
# 作れる状態数は高々2 ^ min(n, m)通り

while 1:
    n, m = LI()
    if n == 0 and m == 0:
        quit()
    recipe = []
    for _ in range(n):
        c = list(map(int, list(input())))
        s = 0
        t = 1
        for i in range(m):
            s += c[m - i - 1] * t
            t *= 2
        recipe.append(s) 
    dp = defaultdict(int)
    dp[0] = 0
    for r in recipe:
        dp1 = defaultdict(int)
        for j, k in dp.items():
            dp1[j] = k
        for j, k in dp.items():
            dp1[j ^ r] = max(dp1[j ^ r], k + 1)
        dp = dp1
    print(dp[0])




Measured memory_bytes: 161968
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int N,Q; cin >> N >> Q;
    vector<double> x(N),y(N),z(N),r(N);
    vector<ll> l(N);
    for(int i = 0; i < N;i++){
        cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
    }
    
    for(int i = 0; i < Q;i++){
        double sx,sy,sz,dx,dy,dz;
        cin >> sx >> sy >> sz >> dx >> dy >> dz;
        
        dx -= sx; dy -= sy; dz -= sz;
        
        ll ans = 0;
        for(int j = 0; j < N;j++){
            double Dx = sx - x[j], Dy = sy - y[j], Dz = sz - z[j];

            double DD = dx*dx + dy*dy + dz*dz;
            
            double t = -(Dx * dx + Dy * dy + Dz * dz)/DD;
            if(t < 0 || t > 1 + 1e-9) continue;
            
            double nx = sx + t*dx,ny = sy + t*dy,nz = sz + t*dz;
            double ddx = nx - x[j],ddy = ny - y[j],ddz = nz - z[j];

            
            double R2 = ddx * ddx + ddy * ddy + ddz * ddz;
            if(R2 < r[j]*r[j] + 1e-9)  ans += l[j];
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  int A, B, C; cin >> A >> B >> C;

  if (A > B) {
    cout << 0 << endl;
  } else {
    cout << min(C, B / A) << endl;
  }

}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
L = list(input())
N = len(L)

dp0 = 0
dp1 = 1
for l in L:
    if l == '0':
        dp0 = (dp0 * 3) % MOD
    else:
        dp0 = (dp0 * 3 + dp1) % MOD
        dp1 = (dp1 * 2) % MOD

print ((dp0 + dp1) % MOD)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
bool a[2000001],b[2000001];
int x,y,n,m,tmp;
int main()
{
    cin>>n>>m;
    tmp=m;//存下 m 的值 
    while(tmp--)
    {
        cin>>x>>y;
        if(x==1)
			a[y]=true;
        if(y==n)
			b[x]=true;
    }
    for(int i=1;i<n;i++)
        if(a[i] && b[i])
        {
            cout<<"POSSIBLE";
			return 0;
        }
    cout<<"IMPOSSIBLE";
}

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

template <typename D, typename T = D>
class Tree
{
public:
	Tree( long long int size = 0, D InitialValueArg = D() ) {
		long long int n = 1LL;
		CalcTree.emplace_back( vector<T>( n ) );
		while( n <= size ) {
			n <<= 1LL;
			addOneLine( n );
		}
		InitialValue = InitialValueArg;
		Data.resize( n, InitialValue );
		for( size_t i = 0; i < Data.size(); i++ ) {
			update( i, Data[i] );
		}
		MaxSize = n;
		NowIndex = 0LL;
	}

	virtual T preprocessing( D a ) {
		return T( a );
	}

	virtual T treeupdate( T a, T b ) {
		return a;
	}

	void update( long long int idx, D data ) {
		Data[idx] = data;
		(*(CalcTree.rbegin()))[idx] = preprocessing( data );
		for( auto ite = CalcTree.rbegin(); ite + 1 < CalcTree.rend(); ) {
			idx >>= 1LL;
			T updatedata = treeupdate( (*ite)[idx * 2], (*ite)[idx * 2 + 1] );
			ite++;
			if( (*ite)[idx] != updatedata ) {
				(*ite)[idx] = updatedata;
			} else {
				break;
			}
		}
	}

	void show() {
		for( auto x : CalcTree ) {
			for( auto y : x ) {
				cout << y << " ";
			}
			cout << endl;
		}
	}

	void push( D data ) {
		if( NowIndex == MaxSize ) {
			MaxSize <<= 1LL;
			addOneLine( MaxSize );
			vector<D>Datamemo( MaxSize, InitialValue );
			copy( Data.begin(), Data.end(), Datamemo.begin() );
			for( long long int i = 0; i < Datamemo.size(); i++ ) {
				update( i, Datamemo[i] );
			}
		}
		Data[NowIndex] = data;
		update( NowIndex, data );
		NowIndex++;
	}

	vector<T>range( long long int l, long long int r ) {
		return rangeProcessing( 0, l, r, 0, 0, MaxSize );
	}

	long long int t() {
		return 10;
	}

private:
	vector<vector<T>> CalcTree;
	vector<D> Data;
	long long int MaxSize;
	long long int NowIndex;
	D InitialValue;

	void addOneLine( long long int n ) {
		CalcTree.emplace_back( vector<T>( n ) );
	}

	vector<T> rangeProcessing( long long int d, long long int a, long long int b, long long int k, long long int l, long long int r ) {
		vector<T>ret;
		if( !(r <= a || b <= l) && d < CalcTree.size() ) {
			if( a <= l&&r <= b ) {
				ret.emplace_back( CalcTree[d][k] );
			} else {
				vector<T>retret;
				ret = rangeProcessing( d + 1, a, b, k * 2, l, (l + r) / 2 );
				retret = rangeProcessing( d + 1, a, b, k * 2 + 1, (l + r) / 2, r );
				ret.insert( ret.end(), retret.begin(), retret.end() );
			}
		}
		return ret;
	}
};

class RQM : public Tree<long long int>
{
public:
	RQM( long long int a, long long int b ) :Tree( a, b ) {

	}
	long long int treeupdate( long long int a, long long int b ) {
		return min( a, b );
	}
};

int main() {
	long long int n, q;
	cin >> n >> q;
	RQM rqm( n, (1LL << 31) - 1 );
	for( long long int i = 0; i < q; i++ ) {
		long long int c, x, y;
		cin >> c >> x >> y;
		if( c == 0 ) {
			rqm.update( x, y );
		} else {
			auto d = rqm.range( x, y + 1 );
			long long int ans = (1LL << 31) - 1;
			for( auto d1 : d ) {
				ans = min( d1, ans );
			}

			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 5956
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// Fenwick Tree
int n;
int bit[575]; 

void add( int a, int x ){
	for( int i = a; i <= n; i += ( i & -i ) ) bit[i] += x;
}

int sum( int a ){
	int res = 0;
	for( int i = a; i > 0; i -= ( i & -i ) ) res += bit[i];
	return res;
}

struct abschnitt{
	int link;
	int recht;
	bool art; // query wenn true, zug wenn false
	int nummer;
};
	
int main(){
	vector<abschnitt> v;
	map<int, int> karte;
	int m, q; cin >> n >> m >> q;
	
	for( int i = 0; i < m; ++i ){
		int l, r; cin >> l >> r;
		v.push_back( (abschnitt){ l, r, false, 0 } );
	}
	for( int i = 0; i < q; ++i ){
		int l, r; cin >> l >> r;
		v.push_back( (abschnitt){ l, r, true, i } );
	}
	
	sort(
		v.begin(), v.end(),
		[]( const abschnitt& x, const abschnitt& y ){
			return ( x.recht == y.recht ) ? ( x.art ? false : y.art ) : ( x.recht < y.recht );
		}
	);
	
	for( int i = 0; i < m+q; ++i ){
		// cout << v[i].link << " " << v[i].recht << " " << v[i].art <<  " " << v[i].nummer << endl;
		if( v[i].art ) karte.emplace( v[i].nummer, sum( v[i].recht ) - sum( v[i].link - 1 ) );
		else add( v[i].link, 1 );
	}
	
	for ( int i = 0; i < q; ++i ) cout << karte.at(i) << endl;
	return 0;
}

Measured memory_bytes: 12008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  char C[N];
  for(int i = 0; i < N; i++){
  	cin >> C[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
  	if(C[i] == 'Y'){
    	ans = 1;
      	break;
    }
  }
  
  if(ans == 1){
  	cout << "Four" << endl;
  }else{
  	cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();
    ll ans = 0;

    for (int msk = 0; msk < 1 << (len-1); msk++) {
        ll num = S[0] - '0';
        for (int i = 0; i < len-1; i++) {
            if (1 << i & msk) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        ans += num;
    }
    cout << ans << "\n";
    return 0;
}


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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

void solve() {
        int n,m;
        cin >> n >> m;
        if(n == m) {
        	cout << "Yes" << endl;
        }
        else {
        	cout << "No" << endl;
        }
}

Measured memory_bytes: 256
N = gets.to_i
x = 1; y = 1
N.times { |n|
  a,t = gets.split.map &:to_i
  n = [(x % a == 0 ? 0 : 1) + x/a, (y % t == 0 ? 0 : 1) + y/t].max
  x = a*n
  y = t*n
}
p x+y

Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  ll prod = 1;
  int pos = 0;
  REP(i, 0, n) {
    if (a[i] < 2 * pos + 1) {
      // solve cut
      prod = prod * ll(pos + 1) % mod;
    } else {
      pos += 1;
    }
  }
  REP(i, 1, pos + 1) {
    prod = prod * i % mod;
  }
  cout << prod << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    double ans=0;
    int n;
    cin>>n;

    if(n%2==0){
        ans=1/2.0;
    }else{
        ans=(n/2+1)/(double)n;
    }

    cout<<ans<<endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    ll h;
    cin >> h;
    ll pow2 = 1;
    ll res = 0;
    while (true) {
        if (h == 1) {
            res += pow2;
            break;
        } else {
            h /= 2;
            res += pow2;
            pow2 *= 2;
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N,K;
    cin>>N>>K;
    
    vector<long> A(N);
    for(int i=0;i<N;i++) cin>>A.at(i);
    
    vector<vector<long>> dp(52,vector<long>(2,-INF));
    dp.at(51).at(1)=0;
    
    
    long beki=pow(2,50);
    for(int i=50;i>=0;i--){
        long count=0;
        for(int j=0;j<N;j++) count+=((beki^A.at(j))==A.at(j)-beki);
        
        if((K^beki)==K-beki){
            dp.at(i).at(1)=dp.at(i+1).at(1)+beki*(N-count);
            if(dp.at(i+1).at(0)>=0) dp.at(i).at(0)=max(dp.at(i+1).at(0)+beki*max(N-count,count),dp.at(i+1).at(1)+beki*count);
            else dp.at(i).at(0)=dp.at(i+1).at(1)+beki*count;
        }else{
            dp.at(i).at(1)=dp.at(i+1).at(1)+beki*count;
            if(dp.at(i+1).at(0)>=0) dp.at(i).at(0)=dp.at(i+1).at(0)+beki*max(N-count,count);
        }
        
        beki/=2;
    }
    
    cout<<max(dp.at(0).at(0),dp.at(0).at(1))<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char a[100],b[100];
int main()
{
	cin>>a>>b;
	int c=strlen(a);
	int d=strlen(b);
	if(c==d)
	{
		for(int i=0;i<c;i++)
		{
			cout<<a[i]<<b[i];
		}
	}
	else
	{
		for(int i=0;i<d;i++)
		{
			cout<<a[i]<<b[i];
		}
		cout<<a[c-1];
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0) break;
        a-=d;
        if(a<=0) break;
    }
    if(c<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
int main() {
    map<string,int>a,b;
    set<string>c;
    int n,m;
    cin>>n;
    string s;
    for(int i=1;i<=n;i++){
        cin>>s;
        a[s]++;
        c.insert(s);
    }
    cin>>m;
    while(m--){
        cin>>s;
        b[s]++;
    }
    int mmax=0;
    for(set<string>::iterator it=c.begin();it!=c.end();it++){
        mmax=max(mmax,a[*it]-b[*it]);
    }
    cout<<mmax<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.*;
public class Main {
	public static void main(String[]args){
		Scanner s =new Scanner(System.in);
		while(s.hasNext()){
			int a =s.nextInt();
			int b =s.nextInt();
			int[] y =yakusu(a);
			int[] z =yakusu(b);
			int n[]=kobaisu(z,y);
			System.out.println(Integer.toString(n[1])+" "+Integer.toString(n[0]));
		}
	}
	public static int[] yakusu(int a){
		int[] l =new int[(int)Math.sqrt((double)a)+1];
		int counta=0;
		for(int i=2;i<=a;i++){
			if(a%i==0){
				l[counta]=i;
				counta++;
				a=a/i;
				i--;
			}
		}
		int[] y=new int[counta];
		for(int j=0;j<counta;j++){
			y[j]=l[j];
		}
		return y;
	}
	
	public static boolean sosu(int a){
		for(int j=2;j<=a;j++){
			if(a==j){
				return true;
			}else if(a%j==0)return false;
		}
		return false;
	}
	public static int[] kobaisu(int[] a,int[] b){
		int[] n= {1,1};
		int j=0,i=0;
		
		while(i<a.length&&j<b.length){
			if(a[i]==b[j]){
				n[0]=n[0]*a[i];
				n[1]=n[1]*a[i];
				i++;j++;
			}else if(a[i]>b[j]){
				n[0]=n[0]*b[j];
				j++;		
			}else if(a[i]<b[j]){
				n[0]=n[0]*a[i];
				i++;
			}
		}
		while(i<a.length){
			n[0]=n[0]*a[i];
			i++;
		}
		while(j<b.length){
			n[0]=n[0]*b[j];
			j++;
		}
		return n;
	}
}

Measured memory_bytes: 18028
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

ll PRS(ll N, ll P){
	if (P == 0){
		return 1;
	}else if (P % 2 == 0){
		ll t = PRS(N, P/2); 
		return t * t;
	}else{
		return N * PRS(N, P - 1);
	}
}  

int main(){
	ll h, ans;
	scanf("%lld", &h);
	int n = 0;
	while(h > 0){
		h /= 2;
		n++;
	}
	ans = PRS(2, n) - 1;
  	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 128
h= []
w= []
while True:
	a,b= map(int,input().split())
	if(not (a==0 or b==0)):
		h.append(a)
		w.append(b)
	elif(a==b==0):
		break
n= 0
for e in h:
	c= 0
	for f in range(e):
		if(w[n]%2==0):
			if(c== 0):
				print('#.'*(w[n]//2))
				c= 1
			else:
				print('.#'*(w[n]//2))
				c= 0
		else:
			if(c== 0):
				print('#.'*(w[n]//2)+'#')
				c= 1
			else:
				print('.#'*(w[n]//2)+'.')
				c= 0
	print()
	n+= 1

Measured memory_bytes: 7700
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N, Z, W = reads()
A = reads()

ans = abs(A[-1]-W)
if N >= 2:
  ans = max(ans, abs(A[-1]-A[-2]))
print(ans)


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

int main(){
  int m, n;
  string s1[50];
  string s2[50];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s1[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> s2[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bool flag = true;
      for (int k = 0; k < m; k++) {
        if (!flag) break;
        for (int l = 0; l < m; l++) {
          if (i+k >= n || j+l >= n) {
            flag = false;
            break;
          }
          if (s1[i+k][j+l] != s2[k][l]) {
            flag = false;
            break;
          }
        }
        if (k == m-1 && flag) {
          printf("Yes\n");
          return 0;
        }
      }
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define pb push_back
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	int i, n;
	cin >> n;
	vector<int> a;
	for(i=0; i<n; i++){
		int x;
		cin >> x;
		a.pb(x);
	}
	sort(a.begin(), a.end(), greater<int>());
	int alice = 0, bob = 0;
	for(i=0; i<n; i++){
		if(i%2==0) alice += a[i];
		else bob += a[i];
	}
	cout << alice-bob << endl;
	return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <stdio.h>
using namespace std;
int N, K;
char COM[12];
struct Node {
    Node* prev;
    int data;
    Node* next;
};
Node* SENTINEL;
void initList(void);
bool cmpStr(char* a, const char* b);
void ins(int k);
void del(int k);
void delF(void);
void delL(void);
void printList(void);
int main(void){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &N);
    initList();
    for(int i = 0; i < N; i++){
        scanf("%s%d", COM, &K);
        if (cmpStr(COM, "insert"))
            ins(K);
        else if (cmpStr(COM, "delete"))
            del(K);
        else if (cmpStr(COM, "deleteFirst"))
            delF();
        else
            delL();
    }
    printList();
    cout << endl;
    return 0;
}
void initList(void){
    SENTINEL = new Node;
    SENTINEL->prev = SENTINEL;
    SENTINEL->data = -1;
    SENTINEL->next = SENTINEL;
}
void ins(int k){
    Node* x = new Node;
    x->data = k;
    x->next = SENTINEL->next;
    SENTINEL->next->prev = x;
    SENTINEL->next = x;
    x->prev = SENTINEL;
    return;
}
void del(int k){
    Node* x = SENTINEL->next;
    while (x != SENTINEL){
        if (x->data == k){
            x->prev->next = x->next;
            x->next->prev = x->prev;
            break;
        }
        x = x->next;
    }
}
void delF(void){
    SENTINEL->next->next->prev = SENTINEL;
    SENTINEL->next = SENTINEL->next->next;
}
void delL(void){
    SENTINEL->prev->prev->next = SENTINEL;
    SENTINEL->prev = SENTINEL->prev->prev;
}
void printList(void){
    Node* x = SENTINEL->next;
    while(x != SENTINEL) {
        cout << x->data;
        x = x->next;
        if (x != SENTINEL) cout << " ";
    }
}
bool cmpStr(char* a, const char* b){
    int i = 0;
    while (*(a + i) != '\0'){
        if (*(a + i) != *(b + i)) return false;
        i++;
    }
    if (*(b + i) == '\0')
        return true;
    else
        return false;
}

Measured memory_bytes: 37588
S = gets.chomp.codepoints
T = gets.chomp.codepoints
s_size = S.size
t_size = T.size

dp = Array.new(S.size + 1) { Array.new(T.size + 1, 0) }

def max a,b
  a > b ? a : b
end

S.size.times do |s0|
  s1 = s0 + 1
  cdp = dp[s0]
  ndp = dp[s1]

  t_size.times do |t0|
    t1 = t0 + 1
    if S[s0] == T[t0]
      ndp[t1] = cdp[t0] + 1
    else
      ndp[t1] = max(ndp[t0], cdp[t1])
    end
  end
end

i = dp[S.size][T.size]
s = S.size
t = T.size
a = []

while i > 0
  if dp[s-1][t] == i
    s -= 1
  elsif dp[s][t-1] == i
    t -= 1
  else
    a.unshift(S[s - 1])
    i -= 1
    s -= 1
    t -= 1
  end
end

print a.pack('U*')

Measured memory_bytes: 73340
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    H[0] -= 1
    for i in range(1, N - 1):
        if H[i-1] < H[i]:
            H[i] -= 1
        if H[i] > H[i+1]:
            print('No')
            break
    else:
        print('Yes')
    return

main()

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

int main() {
    int x, n;
    cin >> x >> n;
    
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    
    bool includeX = false;
    
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        if(a[i] == x) includeX = true;
    }
    
    if(!includeX){
        cout << x << endl;
        return 0;
    }
    
    int res = 0;
    
    for(int dif = 1; dif < 51; ++dif){
        int small = x - dif;
        int big = x + dif;
        
        auto result_s = find(a.begin(), a.end(), small);
        if(result_s == a.end()){
            res = small;
            break;
        }
        auto result_b = find(a.begin(), a.end(), big);
        if(result_b == a.end()){
            res = big;
            break;
        }
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3644