akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
    int A,B,K;
    int soeji,work;
    cin >> A >> B >> K;
    if(A <= B){
        soeji = A;
    }else{
        soeji = B;
    }
    int ans[soeji] = {};

    work = A;
    if(A>B) work=B;
    int kazu = 0;
    for(int i=1; i<=work; i++){
        if(A%i==0 && B%i==0){
            ans[kazu]=i;
            kazu++;
        }
    }    
    cout << ans[kazu-K] << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w: i32 = read();
    let h: i32 = read();
    let x: i32 = read();
    let y: i32 = read();
    let r: i32 = read();

    if y >= r && x >= r && (x + r) <= w && (y + r) <= h {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);
    static int INF = (int)1e9+7;
    public static void main(String[] args) {
        
        int n = r.nextInt();
        int m = r.nextInt();
        int[] keys = new int[m];
        int[] prices = new int[m];
        for(int i = 0; i < m; i++){ // inputting the keys
            prices[i] = r.nextInt();
            int b = r.nextInt();
            for(int j = 0; j < b; j++){
                keys[i] |= 1 << r.nextInt() - 1;
            }
        }
        int[] dp = new int[1 << n];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for(int i = 0; i < 1 << n; i++){
            if(dp[i] < INF){
                for(int k = 0; k < m; k++){
                    dp[i | keys[k]] = Math.min(dp[i | keys[k]], dp[i] + prices[k]);
                }
            }
        }
        if(dp[(1 << n) - 1] >= INF){
            pw.println(-1);
        } else {
            pw.println(dp[(1 << n) - 1]);
        }

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 24404
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Set  as S
import qualified Data.IntMap.Strict as IM
import Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [(Int, Int)] -> String
solve n m = 
    let
        nums = if n == 1 then show <$> [0..9] else show <$> [10 ^ (n - 1)..(10 ^ n - 1)]
        takeKeta keta num 
            | keta > n = Nothing
            | otherwise =  Just $ digitToInt $ num !! (keta - 1)
        satisfy number = all (\(keta, num) -> takeKeta keta number == Just num) m
        ans = filter satisfy nums
    in
    case ans of
        [] -> "-1"
        (x:xs) -> x
    


main = do
    (n, m) <- readTuple2
    conds <- replicateM m readTuple2
    putStrLn $ solve n conds


Measured memory_bytes: 508
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
      H: usize,
      W:usize,
      h: usize,
      w:usize,
    }
    println!("{}", (H - h) * (W - w));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
	Main(){
		Scanner sc = new Scanner(System.in);
		String[][] str = new String[101][];
		int[][] a = new int[101][];
		int p=0, maxl=0, l, q=0;
		
		while(sc.hasNext()){
			str[p] = (sc.nextLine()).split(",");
			l = str[p].length;
			a[p] = new int[l+1];
			for(int i = 0; i < l; i++){
				a[p][i] = Integer.parseInt(str[p][i]);
			}
			if(l > maxl){
				q = p;
				maxl = l;
			}
			p++;
		}
		
		for(int i = 1; i <= q; i++){
			for(int j = 0; j < a[i].length-1; j++){
				if(j-1 < 0){
					a[i][j] += a[i-1][j];
				} else if(j == a[i].length-2){
					a[i][j] += a[i-1][j-1];
				} else {
					if(a[i-1][j] > a[i-1][j-1]){
						a[i][j] += a[i-1][j];
					} else {
						a[i][j] += a[i-1][j-1];
					}
				}
			}
		}
		
		for(int i = q; i < p-1; i++){
			for(int j = 0; j < a[i].length-1; j++){
				if(a[i][j] < a[i][j+1]){
					a[i+1][j] += a[i][j+1];
				} else {
					a[i+1][j] += a[i][j];
				}
			}
		}
		
		System.out.println(Integer.toString(a[p-1][0]));
	}
	
	public static void main(String[] args){
		new Main();
	}
}

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

const int N_MAX = 2000005;
const int NIL = -1;

int TEL[N_MAX + 5];
int A[N_MAX + 5];
int town[N_MAX + 5];

int main(){
    int n;
    long long int k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= n; i++) TEL[i] = NIL;
    TEL[1] = 0;
    int nowp = 1;
    int loopcount;
    int loopstart;
    town[0] = 1;
    int ansp = -1;
    for(int i = 1; i <= n + 5; i++){
        int nextp = A[nowp];
        town[i] = nextp;
        if (TEL[nextp] != NIL){
            loopcount = i - TEL[nextp];
            loopstart = TEL[nextp];
            break;
        }
        TEL[nextp] = i;
        nowp = nextp;
    }
    if (k < loopstart) ansp = town[k];
    else{
        long long int kl = k - loopstart;
        kl %= loopcount;
        ansp = town[loopstart + kl];
    }
    cout << ansp << endl;
    return 0;
}

Measured memory_bytes: 5912
<?php
$n = trim(fgets(STDIN));
$array = [];
$ans = 0;
for ($i=0; $i<$n; $i++){
	$num = trim(fgets(STDIN));
	$array[] = $num;
	$ans += $num;
}
rsort($array);
echo $ans - $array[0]/2;
echo "\n";

?>

Measured memory_bytes: 4604
N = int(input())
s = list()

for i in range(N):
    S = input()
    s.append(S)
    i += 1

a = s.count('AC')
b = s.count('WA')
c = s.count('TLE')
d = s.count('RE')

print("AC x ", a)
print("WA x ", b)
print("TLE x ", c)
print("RE x ", d)


Measured memory_bytes: 16124
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = []
    for _ in range(n):
        a, b = ns()
        d.append((a + b, a, b))

    d.sort(reverse=True)
    turn = 1
    taka = 0
    ao = 0
    for i in range(n):
        if turn:
            taka += d[i][1]
        else:
            ao += d[i][2]
        turn ^= 1
    print(taka - ao)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23132
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;



int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	bool ans = false;
	cin >> n;

	rep(i, 26) {
		rep(j, 16) {
			int sum = 4 * i + 7 * j;
			if (sum == n) {
				ans = true;
			}
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;

}

Measured memory_bytes: 256
S = input()
answer = ["A", "G", "C", "T"]
max_count = 0

for i in range(len(S)):
    if S[i] in answer:
        j = 0
        count = 0
        while S[i+j] in answer:
            count += 1
            if count > max_count:
                max_count = count
            j += 1
            if i + j >= len(S):
                break;
print(max_count)

Measured memory_bytes: 3060
def judge(n):
	lst = []
	for i in range(1, n+1):
		if n%i == 0: lst.append(i)
	if len(lst) == 8: return True
	return False

N = int(raw_input())
index = 1
cnt = 0
while index <= N:
	if judge(index): cnt += 1
	index += 2
print cnt

Measured memory_bytes: 28780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S; cin>>S;

    bitset<4> drc(0);
    for(auto s:S){
        if(s=='E') drc.set(0);
        if(s=='W') drc.set(1);
        if(s=='S') drc.set(2);
        if(s=='N') drc.set(3);
    }

    string ans="Yes";
    if(drc.test(0)^drc.test(1) || drc.test(2)^drc.test(3)) ans="No";
    cout<<ans<<endl;
}

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

using namespace std;

int memo[100][100][2][2];

int w, h;

int rec(int i, int j, int vec, int f)
{
	if (i < 0 || i >= w) return 0;
	if (j < 0 || j >= h) return 0;

	if (i == w - 1 && j == h - 1) return 1;

	if (memo[i][j][vec][f] >= 0) return memo[i][j][vec][f];

	int res;

	if (vec == 0) { // ??????????????§?????´???
		if (f) { // ????????£???
			res = rec(i + 1, j, 0, 0);
		} else {
			res = rec(i + 1, j, 0, 0) + rec(i, j + 1, 1, 1);
		}
	} else { // ??????????????§?????´???
		if (f) { // ????????£???
			res = rec(i, j + 1, 1, 0);
		} else {
			res = rec(i + 1, j, 0, 1) + rec(i, j + 1, 1, 0);
		}
	}

	return memo[i][j][vec][f] = res % 100000;
}

int main()
{
	while (cin >> w >> h, w || h) {
		memset(memo, -1, sizeof(memo));

		cout << (rec(1, 0, 0, 0) + rec(0, 1, 1, 0)) % 100000 << endl;
	}
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    int light = 0;
    bool x = true;

    for(int i=0;i<N;i++){
        cin >> list.at(i);
    }

    for (int i = 0;i < N; i++){
        light = list.at(light) - 1;
        if(light == 1){
            cout << i + 1;
            x = false;
            break;
        }
    }
    if(x)
        cout << "-1";
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    if(str[0].charAt(0)<str[1].charAt(0))
      System.out.println("<");
    else if(str[0].charAt(0)>str[1].charAt(0))
      System.out.println(">");
    else
      System.out.println("=");
  }
}

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

using namespace std;

typedef long long ll;
const ll mod = 1000000007;

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

/* ------------- ANSWER ------------- */
/* ---------------------------------- */


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {

    ll n, m, k;
    cin >> n >> m >> k;
    COMinit();

    // sum for x
    ll sum_x = 0;
    rep(i, m) sum_x += i * (m - i) * n * n;
    sum_x %= mod;
    sum_x *= COM(n * m - 2, k - 2);
    sum_x %= mod;

    // sum for y
    ll sum_y = 0;
    rep(i, n) sum_y += i * (n - i) * m * m;
    sum_y %= mod;
    sum_y *= COM(n * m - 2, k - 2);
    sum_y %= mod;

    cout << (sum_y + sum_x) % mod << endl;
    return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a == b)
  {
    cout << "Draw" << endl;
  }
  else if(a == 1)
  {
    cout << "Alice" << endl;
  }
  else if(b == 1)
  {
    cout << "Bob" << endl;
  }
  else if(a > b)
  {
    cout << "Alice" << endl;
  }
  else
  {
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //モンスターの数
		int k = stdIn.nextInt(); //必殺技の回数
		
		long cnt = 0;
		
		int[] h = new int[n];
		
		
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}

		if(n <= k) {
			System.out.println(0);
		}else {
			Arrays.sort(h);
			for(int i = 0; i < n-k; i++) {
				cnt += h[i];
			}
			System.out.println(cnt);
		}



	}

}


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

//#define _debug
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back
//#define _online_judge

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, //data type
        null_type, //
        less<int>, //
        rb_tree_tag, //red-black tree
        tree_order_statistics_node_update> new_data_set;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = static_cast<const int>(1e6 + 5);
const int MOD = 1000000007;




int main (){
	FASTIO
#ifdef _online_judge
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

    int x,y,z,l;cin >> x >> y >> z >> l;
    vector<ll> v1(x),v2(y),v3(z);
    FOR(i,0,x){
        cin >> v1[i];
    }sort(v1.begin(),v1.end(),greater<>());

    FOR(i,0,y){
        cin >> v2[i];
    }sort(v2.begin(),v2.end(),greater<>());

    FOR(i,0,z){
        cin >> v3[i];
    }sort(v3.begin(),v3.end(),greater<>());

    vector<ll> ans;
    FOR(i,0,x){

        FOR(j,0,y){

            FOR(k,0,z){

                if((i+1)*(j+1)*(k+1) > l) break;
                ans.pb(v1[i]+v2[j]+v3[k]);
            }
        }
    }
    sort(ans.begin(),ans.end(),greater<>());
    FOR(i,0,l){
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<int> cnt(26);
        int ans=INF;
        for(int i=0;i<N;i++){
            char a;cin>>a;
            cnt[a-'A']++;
            
            vector<int> B=cnt;
            sort(all(B));
            if(B[24]+N-1-i<B[25]) ans=min(ans,i+1);
        }
        
        if(ans==INF) cout<<"TIE"<<endl;
        else{
            int ma=-1;
            char a;
            for(int i=0;i<26;i++){
                if(ma<cnt[i]){
                    ma=cnt[i];
                    a='A'+i;
                }
            }
            
            cout<<a<<" "<<ans<<endl;
        }
    }
}



Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int n;
  int h[100000];
  int max=0;
  int i;
  int j;
  int tmp=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&h[i]);
  //printf("%d",h[i]);
  }
  
  for(i=0;i<n-1;i++){
      if(h[i]>=h[i+1]){
        tmp++;
        if(max<tmp){
          max=tmp;
        }
      }
      else if(max<tmp){
        max=tmp;
        tmp=0;
        //printf("max:%d j:%d\n",max,j);
      }
    else tmp=0;
  }
  
  printf("%d",max);
  
  return 0;
}


Measured memory_bytes: 512
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn to_nums(ss: &str) -> Vec<i32> {
    ss.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect()
}

fn main() {
    let input = get_stdin();
    let ss = input.split('\n');
    let vs = ss.map(|x| to_nums(x));
    for mut v in vs {
        if v[0] + v[1] == 0 {
            break;
        } else {
            v.sort();
            println!("{} {}", v[0], v[1]);
        }
    }
}



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

map<long, int> pf(long n) {
  map<long, int> ma;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

int main() {
  long N;
  cin >> N;
  int ans = 0;
  for (auto [a, b] : pf(N)) {
    int now = 1;
    while (b - now >= 0) b -= now, ans++, now++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3576
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1000000000 + 7;

fn solve(n: i64) -> i64 {
    let mut res = 1;
    for i in 1..n+1 {
        res = ((res % MOD) * i) % MOD;
    }
    res
}

fn main() {
    input! {
        n: i64
    }
    println!("{}", solve(n));
}


Measured memory_bytes: 4352
n=list(map(int,input().split()))
x=[[0 for i in range(n[1])] for j in range(n[0])]
for i in range(n[0]):
	y=list(map(int,input().split()))
	for j in range(n[1]):
		x[i][j]=y[j]
z=[]
for k in range(n[1]):
	z.append(int(input()))
	
for l in range(n[0]):
	a=0
	for m in range(n[1]):
		a+=x[l][m]*z[m]
	print(a)
		
	
	 


Measured memory_bytes: 5948
using System;

namespace ABC109A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if (a * b % 2 == 0)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e2+9, M = 1e5+9, OO = 0x3f3f3f3f;
LL memo[N][M];
LL V[N];
int W[N],n,w;

LL solve(int idx=0,int rem=w)
{
  if(idx==n) return 0;
  LL &ret = memo[idx][rem];
  if(~ret) return ret; 
  ret = solve(idx+1,rem); 
  if(rem-W[idx]>=0) ret=max(ret,solve(idx+1,rem-W[idx])+V[idx]);
  return ret;
  
}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d%d",&n,&w);
  for(int i=0;i<n;++i) scanf("%d%lld",W+i,V+i);
  printf("%lld\n",solve());
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

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

void Main()
{
	double a,b,x;
  	double y, theta;
  	cin >> a >> b >> x;
	if( x >= a*a*b/2 ) {
		y = 2*x/(a*a) - b;
      	theta = atan((b-y)/a);
    }
  	else {
  		y = 2*x/(a*b);
      	theta = atan(b/y);
    }
  
  	double ans = theta * 180 / M_PI ;
  	cout << ans << endl;
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
 	return 0;
  
}

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

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {
    return a < b ? a: b;
}

int main(void) {
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for ( i = 1; i <= n; i++ ) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while ( head != tail ) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if ( u.t > 0 ) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define EPS 1e-6
typedef vector <double> WORK;
int main( void )
{
	string L;
	int N, P, A, B, C, D, E, F, S, M;
	while ( cin >> N && N )
	{
		vector <string> names( N );
		WORK works( N );
		for ( int seed = 0; seed < N; seed++ )
		{
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;

			// í1ÂÌêÅV~[V
			int fruits = M * F;	// ûnµ½À
			int time = A + B + C + ( D + E ) * M;	// |©Á½Ô

			// ÀÍ1Â ½èS~Åêé
			// íÌliÍP~
			double work = (double)( fruits * S - P ) / (double)time;
			names[seed] = L;
			works[seed] = work;
		}

		// ìÆø¦Ì~É\[g
		for ( int i = 0; i < N - 1; i++ )
		{
			for ( int j = i+1; j < N; j++ )
			{
				if ( works[i] < works[j] )
				{
					swap( names[i], names[j] );
					swap( works[i], works[j] );
				}
				else if ( works[i] == works[j] )
				{
					if ( names[i] > names[j] )
					{
						swap( names[i], names[j] );
						swap( works[i], works[j] );
					}
				}
			}
		}

		// oÍ
		for ( int i = 0; i < N; i++ ) cout << names[i] << endl;
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int zet(int a){
  if(a > 0){
    return a;
  }
  return -a;
}

int main(){
  int x,a,b;
  scanf("%d %d %d",&x,&a,&b);
  if(zet(x - a) > zet(x - b)){
    printf("B\n");
  }else{
    printf("A\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
 int a,b;
 char op;
 scanf("%d %c %d", &a, &op, &b);
 while( !(op == '?')){if ( op == '+' ){
  printf("%d\n",a+b);}
   else if ( op == '-' ){
   printf("%d\n",a-b);}
 else if ( op == '*' ){
printf("%d\n",a*b);}
 else if ( op == '/' ){
 printf("%d\n",a/b);} 
  else {}
  scanf("%d %c %d", &a, &op, &b);}
  return 0;}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

int main()
{
  int a, b, x;
  cin >> a >> b >> x;
  string ans = "YES";
  if (x<a || x>a+b) ans = "NO";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(1000000)
# N, Q = map(int, sys.stdin.readline().split())
# a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(N-1)]
# p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]
n = int(input())
h_l = list(map(int,input().split()))
c_l = [0 for _ in range(n)]
s = 0
# for i in range(n-1):
while s < n-1:
        for j in range(0,n-s-1):
                if h_l[s+j] >= h_l[s+1+j]:
                        c_l[s] += 1
                else:
                        break
        s = s+c_l[s]+1
        
# print(c_l)
print(max(c_l))



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

int main() {
    int N, M;
    long long K;
    cin >> N >> M >> K;
    vector<long long> A(N), B(M);
    vector<long long> SA(N+1, 0), SB(M+1, 0); // 累積和
    for (int i = 0; i < N; ++i) cin >> A[i], SA[i+1] = SA[i] + A[i];
    for (int i = 0; i < M; ++i) cin >> B[i], SB[i+1] = SB[i] + B[i];

    int result = 0;
    for (int x = 0; x <= N; ++x) {
        if (SA[x] > K) break;

        int y = lower_bound(SB.begin(), SB.end(), K - SA[x] + 1) - SB.begin();
        --y;
        result = max(result, x + y);
    }
    cout << result << endl;
}

Measured memory_bytes: 9520
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {
	
	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

int main(void) {
	ll x;
	cin >> x;
	ll max = 0;
	while (x >= 500) {
		x -= 500;
		max += 1000;
	}
	while (x >= 5) {
		x -= 5;
		max += 5;
	}
	cout << max;
}

/*
2 1  1
3 3  2
4 6  3
5 10 4

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
T GET() {
	T val;
	cin >> val;
	return val;
}
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

struct uni_find
{
	vector<int> par;
	vector<int> rank;
	int sz;
	uni_find(){} 
	uni_find(int n) {init(n);}
	void init(int n) {
		par.resize(n);
		rank.resize(n);
		rep(i, n) par[i] = i, rank[i] = 0;
		sz = n;
	}
	int root(int x) {return par[x] == x ? x : par[x] = root(par[x]);}
	bool same(int x, int y) {return root(x) == root(y);}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int size() {return sz;}
};

uni_find a, b;
int N;

void init()
{
	int K, L;
	cin >> N >> K >> L;
	a.init(N);
	b.init(N);
	rep(i, K) {
		a.unite(GET<int>()-1, GET<int>()-1);
	}
	rep(i, L) {
		b.unite(GET<int>()-1, GET<int>()-1);
	}
}


void solve()
{
	map<pair<int,int> , int> m;
	rep(i, N) {
		m[MP(a.root(i), b.root(i))]++;
	}
	rep(i, N) {
		cout << m[MP(a.root(i), b.root(i))] << " \n"[i==N-1];
	}
}



Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define MAX 100010
using namespace std;

const int INF = 1e9;
void bfs(int s, vector<ll> &d, vector<int> g[]) {
    vector<bool> used(MAX, false);
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        if (used[v]) continue;
        used[v] = true;
        for (int nx : g[v]) {
            if (!used[nx] && d[nx] > d[v] + 1) {
                d[nx] = d[v] + 1;
                que.push(nx);
            }
        }
    }
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    vector<int> g[n];
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<ll> ds(MAX, INF), dt(MAX, INF);
    bfs(s, ds, g);
    bfs(t, dt, g);
    vector<int> ca(MAX, 0);
    for (int i = 0; i < n; i++) {
        if (dt[i] == INF) continue;
        ca[dt[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        if(dt[i] == INF || ds[i] == INF) continue;
        int x = ds[t] - 2 - ds[i];
        if (x >= 0) ans += ca[x];
    }
    cout << ans << endl;
    return 0;
}


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

typedef pair<long long,long long>P;

vector<P>v;

int main(){

  int N,M;

  cin>>N>>M;

  int a[100001],b[100001],c[100001];

  long long ans1=0,ans2=0;
  
  for(int i=0;i<N;i++){
	cin>>a[i];

	v.push_back(P(a[i],1));
  }

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

	cin>>b[i]>>c[i];
	
	v.push_back(P(c[i],b[i]));
  }

	 
  sort(v.begin(),v.end(),greater<P>());


  long long ans=0;
  long long cnt=0;

  long long i=0;
  while(1){

	if(cnt==N){
	  break;
	}

	if(cnt+v[i].second>=N){
	  ans+=(v[i].first*(N-cnt));
	  cnt+=(N-cnt);
	}else{
	  ans+=(v[i].first*v[i].second);
	  cnt+=v[i].second;
	}

	i++;
  }

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


Measured memory_bytes: 6896
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef int ll;

int main(){
    ll a,b;
    cin >> a >> b;
    if (a > 9 or b > 9 ) cout << -1;
    else cout << a * b;
 }




Measured memory_bytes: 256
#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 >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t k;
  cin >> k;
  vector<vector<int64_t>> a(10);
  vector<int64_t>b;
  a[0] = {1,2,3,4,5,6,7,8,9};
  rep(i,9){
    b.push_back(i+1);
  }
  rep(i,9){
    rep(j,a[i].size()){
      if(a[i][j]%10 == 0){
        a[i+1].push_back(a[i][j]*10);
        a[i+1].push_back((a[i][j]*10)+1);
        b.push_back(a[i][j]*10);
        b.push_back((a[i][j]*10)+1);
      }else if(a[i][j]%10 == 9){
        a[i+1].push_back((a[i][j]*10)+9);
        a[i+1].push_back((a[i][j]*10)+8);
        b.push_back((a[i][j]*10)+9);
        b.push_back((a[i][j]*10)+8);
      }else{
        int64_t h = a[i][j]%10;
        a[i+1].push_back((a[i][j]*10)+h);
        a[i+1].push_back((a[i][j]*10)+h-1);
        a[i+1].push_back((a[i][j]*10)+h+1);
        b.push_back((a[i][j]*10)+h);
        b.push_back((a[i][j]*10)+h-1);
        b.push_back((a[i][j]*10)+h+1);
      }
    }
  }
  sort(b.begin(),b.end());
  /*rep(i,100){
    cout << b[i] << " ";
  }*/
  cout << b[k-1] << endl;
}
      
    

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


def main():
    mod = 1000000007
    N = int(input())
    A = list(map(int, input().split()))
    cnt = [[0, 0, 0] for i in range(N+1)]
    ans = 1
    for i in range(N):
        a = A[i]
        ans = ans * cnt[i].count(a) % mod
        for j in range(3):
            cnt[i+1][j] = cnt[i][j]
        for j in range(3):
            if cnt[i][j] == a:
                cnt[i+1][j] = a+1
                break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20792
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
int K;
string S;
cin>>K;
cin>>S;

int len = S.size();
if(K>=len)cout<<S<<endl;
else {
    rep(i,K)cout<<S[i];
    cout<<"..."<<endl;
}



return 0;

}

Measured memory_bytes: 3628
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
##import operator
input=sys.stdin.readline
import random
##sys.setrecursionlimit(10**6)
##fo=open("output1.txt","w")
##fi=open("input1.txt","w")
mod=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())

    
for _ in range(1):
    n=inin();cont=0;f=0
    for i in range(n):
        a,b=cin()
        if(a==b):
            cont+=1
        else:
            cont=0
        if(cont==3):
            f=1
    if(f):print("Yes")
    else:print("No")
    

    
    
        
        
      
    

##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far


Measured memory_bytes: 76544
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	map<string, int_least32_t> m;
	int k;
	cin >> k;
	string s;
	REP(i, k){
		cin >> s;
		m[s]++;
	}
	cin >> k;
	REP(i, k){
		cin >> s;
		m[s] --;
	}
	for(auto x = m.begin(); x !=  m.end(); x++){
		ans = max(ans, x->second);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >>a >> b;
    if(a < 6) cout << 0 << endl;
    else if( a < 13) cout << b/2 << endl;
    else  cout << b << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n;
    cin >> n;
    int ans=0;
    while(true){
        if(n > ans){
            ans += 1000;
        }else{
            cout << ans - n << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	int a, b, c, temp;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c) {
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	
	printf("%d %d %d\n", a, b, c);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main()
{
	int a = 1, e = 0, f = 0, c, d;
	while (1)
	{
		cin >> a;
		if (a == 0)
		{
			break;
		}
		e = 0;
		f = 0;
		for (int b = 0; b < a; b++)
		{
			cin >> c;
			cin >> d;
			if (c > d)
			{
				e += c;
				e += d;
			}
			else if (d > c)
			{
				f += c;
				f += d;
			}
			else
			{
				e += c;
				f += d;
			}
		}
		cout << e << " " << f << endl;
	}	return 0;
}

Measured memory_bytes: 1160
n,t=io.read("*n","*n","*l")
s={}
for i=1,n do
    s[i]=io.read("*n")
end
sumt=t
for i=2,n do
    ds=s[i]-s[i-1]
    if ds>t then
        ds=t
    end
    sumt=sumt+ds
end
print(sumt)

Measured memory_bytes: 4472
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use itertools::Itertools;

fn main() {
    input! {
        n: i32,
        l_vec: [i32; n]
    }

    let it = (0..n).combinations(3);
    let mut num_patterns = 0;
    for pattern in it {
        let mut l_pattern = vec![
            l_vec[pattern[0] as usize],
            l_vec[pattern[1] as usize],
            l_vec[pattern[2] as usize],
        ];
        l_pattern.sort();
        let first = l_pattern[0];
        let second = l_pattern[1];
        let third = l_pattern[2];
        let is_all_diff = first != second && first != third && second != third;
        let is_triangle = first + second > third;
        if is_all_diff && is_triangle {
            num_patterns += 1;
        }
    }
    println!("{}", num_patterns);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define rep2(i,x,n) for(ll i=x; i<(n); i++)
#define MOD 1000000007
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; }
const long long INF = 1LL << 60;
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
  ll k, x;
  cin >> k >> x;
  if(500*k>=x)
    cout << "Yes" << endl;
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
from itertools import product
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def solve(N, M):
    C = [int(input()) for _ in range(M)]
    X = [int(input()) for _ in range(N)]

    ret = [float('inf')] * 256
    ret[128] = 0
    cor = set((max(min(i + c, 255), 0), i) for c, i in product(C, list(range(256))))
    xt = tuple(tuple((x - t)**2 for x in range(256)) for t in range(256))
    for x in X:
        tmp = [float('inf')] * 256
        xt_now = xt[x]
        for t, i in cor:
            v = ret[i]
            if v + xt_now[t] < tmp[t]:
                tmp[t] = v + xt_now[t]
        ret = tmp[:]

    return min(ret)


def main():
    ans = []
    while True:
        N, M = inpl()
        if N == M == 0:
            break
        ans.append(solve(N, M))
    for a in ans:
        print(a)
    return


main()




Measured memory_bytes: 8476
# C
from math import ceil
N = int(input())
T = [[int(i) for i in input().split()] for n in range(N)]
m = T[0]

def hoge(a, b):
    if a%b==0:
        return a//b
    else:
        return a//b+1

for n in range(1, N):
    a = max(hoge(m[0],T[n][0]), hoge(m[1],T[n][1]))
    m = [T[n][0] * a, T[n][1] * a]
print(sum(m))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
 
public class Main {
	static List<Long> a;
	static List<Long> b;
	static List<Long> c;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int k = sc.nextInt();
		a = new ArrayList<>();
		b = new ArrayList<>();
		c = new ArrayList<>();
		for(int i =0; i < x; i++)
			a.add(Long.parseLong(sc.next()));
		for(int i = 0; i < y; i++)
			b.add(Long.parseLong(sc.next()));
		for(int i = 0; i < z; i++)
			c.add(Long.parseLong(sc.next()));
		
		Collections.sort(a, Collections.reverseOrder());
		Collections.sort(b, Collections.reverseOrder());
		Collections.sort(c, Collections.reverseOrder());
		
		List<Long> ab = new ArrayList<>();
		for(int i = 0; i < x; i++)
			for(int j = 0; j < y; j++)
				ab.add(a.get(i) + b.get(j));
		Collections.sort(ab, Collections.reverseOrder());
		int size = Math.min(k, ab.size());
		List<Long> abc = new ArrayList<>();
		
		for(int i = 0; i < size; i++) 
			for(int j = 0; j < z; j++)
				abc.add(ab.get(i) + c.get(j));
		
		Collections.sort(abc, Collections.reverseOrder());

		for(int i = 0; i < k; i++)
			System.out.println(abc.get(i));
	}
}

class Scanner {
	
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private Deque<String> input = new ArrayDeque<>();
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = -1;
		loop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case 10:
					if(length == -1)
						break;
					
					if((int)sb.charAt(length) == 13)
						sb.deleteCharAt(length);
				case 32:
					break loop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 188280