akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            long a = NextLong, b = NextLong, c = NextLong, d = NextLong;

            long tmp1 = b / c - (a - 1) / c;
            long tmp2 = b / d - (a - 1) / d;
            long gcd = c * d / MyMath.Gcd(c, d);
            long tmp3 = b / gcd - (a - 1) / gcd;

            System.Console.WriteLine(b - a + 1 - tmp1 - tmp2 + tmp3);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}
namespace Library
{
    class MyMath
    {
        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long Sqrt(long n)
        {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2)
            {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        public static long Nck(int n, int k)
        {
            if (k == 0) return 1;
            if (n == 0) return 0;
            return n * Nck(n - 1, k - 1) / k;
        }
    }
}


Measured memory_bytes: 13268
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int n;
  while (cin >> n, n) {
    string s;
    getline(cin, s);
    vs v;
    map<string, int> m;
    while (n--) {
      getline(cin, s);
      istringstream ss(s);
      while (ss >> s) v.pb(s), m[s]++;
    }
    char k;
    cin >> k;
    set<string> t;
    for (auto &x : v) {
      if (x.front() == k) t.insert(x);
    }
    vs w;
    copy(all(t), back_inserter(w));
    stable_sort(all(w), [&](string a, string b) { return m[a] > m[b]; });
    if (w.size() > 5) w.resize(5);
    if (w.size() == 0) w.pb("NA");
    cout << join(w, " ") << endl;
  }
}

Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

Int binary(Int bina) {
	Int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}

int main() {
	IOS;
	int a, b, c; cin >> a >> b >> c;
	int temp = max(a, b);
	int maxx = max(temp, c);
	temp = min(a, b);
	int c1 = min(temp, c), c2 = a + b + c - maxx - c1;
	
	int cnt1 = 0;
	//0
	int r = maxx - c2;
	c2 += r; c1 += r;
	cnt1 += r;
	if ((maxx - c1) % 2 == 0) {
		cnt1 += (maxx - c1) / 2;
	}
	else {
		cnt1 += (maxx - c1) / 2 + 2;
	}

	cout << cnt1;


	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c, d, e;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	if (a == 0) {
		printf("1\n");
	}
	else if (b == 0) {
		printf("2\n");
	}
	else if (c == 0) {
		printf("3\n");
	}
	else if (d == 0) {
		printf("4\n");
	}
	else if (e == 0) {
		printf("5\n");
	}
	return 0;
}


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

pub 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 s: String = read();
    let c: String = read();
    let mut sv: Vec<char> = s.chars().collect();
    let cv: Vec<char> = c.chars().collect();

    for _ in 0..s.len() {
        let a = sv.remove(0);
        sv.push(a);


        if sv == cv {
            println!("Yes");
            return;
        }

    }
    println!("No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	int min_ = 0;
	int cnt_l = 0, cnt_r=0;
	for (auto&& c : str) {
		if (c == '(')cnt_l++;
		else cnt_r++;
		min_ = min(min_, cnt_l-cnt_r);
	}
	min_ *= -1;
	for (int i = 0; i < min_; i++)
		str = '(' + str;
	cnt_l += min_;
	if (cnt_l - cnt_r < 0) {
		int t = cnt_r - cnt_l;
		for (int i = 0; i < t; i++)
			str = '(' + str;
	}
	else {
		int t = cnt_l - cnt_r;
		for (int i = 0; i < t; i++)
			str = str + ')';
	}
	cout << str << endl;
	return 0;
}

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

using namespace std;

struct Node
{
	int idx;
	int cost;
	bool operator < (const  Node& n) const {
		return cost < n.cost;
	}
	bool operator > (const  Node& n) const {
		return cost > n.cost;
	}
};

class Solver
{
private:
	int h;
	int w;
	vector<vector<int> > edge;
	vector<int> nums_map;
public:
	Solver() {
		cin >> h >> w;
		for (int i = 0; i < 10; ++i)
		{
			vector<int> v_tmp;
			for (int j = 0; j < 10; ++j)
			{
				int tmp;
				cin >> tmp;
				v_tmp.push_back(tmp);
			}
			edge.push_back(v_tmp);
		}
		nums_map = vector<int>(10, 0);
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				int tmp;
				cin >> tmp;
				if(tmp == -1) continue;
				nums_map[tmp]++;
			}
		}
	}
	int dijkstra(int from) {
		Node s_node = {from, 0};
		vector<int> min_cost;
		min_cost = vector<int>(10, -1);
		priority_queue<Node, vector<Node>, greater<Node> > pq;
		pq.push(s_node);
		while(!pq.empty()) {
			Node cur_node = pq.top();
			pq.pop();
			// cout << cur_node.idx << " " << cur_node.cost << endl;
			if(min_cost[cur_node.idx] == -1) {
				min_cost[cur_node.idx] = cur_node.cost;
			} else {
				continue;
			}
			for (int i = 0; i < 10; ++i)
			{
				Node next_node = {i, cur_node.cost + edge[cur_node.idx][i]};
				// cout << next_node.idx << " " << next_node.cost << endl;
				if(min_cost[i] != -1) {
					continue;
				}
				pq.push(next_node);
			}
		}
		return min_cost[1];
	}
	void exec() {
		int min_cost[10];
		for (int i = 0; i < 10; ++i)
		{
			min_cost[i] = dijkstra(i);
		}
		long ans = 0;
		for (int i = 0; i < 10; ++i)
		{
			ans += min_cost[i] * nums_map[i];
		}
		cout << ans << endl;
	}
};


int main() {
	Solver s = Solver();
	s.exec();
}

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

int main(void){
    int n;
    cin>>n;
    vector<int64_t> a(10010);
    int64_t MIN=1000000;
    int64_t MAX=-1000000;
    int64_t sum=0;
    
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        MAX=max(MAX,a.at(i));
        MIN=min(MIN,a.at(i));
        sum=a.at(i)+sum;
    }
    cout<<MIN<<" "<<MAX<<" "<<sum<<endl;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	double PI = acos(-1.0);
	int r;
	cin >> r;
	cout << fixed << setprecision(5) << 2.0 * r * PI << endl;
	return 0;
}


Measured memory_bytes: 3804
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader bf = new BufferedReader(is);
		String[] strAry = bf.readLine().split(" ");
		int[] intAry = {Integer.parseInt(strAry[0]), Integer.parseInt(strAry[1]), Integer.parseInt(strAry[2])};
		Arrays.sort(intAry);
		System.out.println(intAry[0] + " " + intAry[1] + " " + intAry[2]);
	}
}

Measured memory_bytes: 24380
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N; vector<int> s(N);
    for(int i = 0; i < N; i++){cin >> s[i];}
    auto check = [&](const int d){
        for(int i = 0; i < d; i++){
            for(int j = i; j < N; j+= d){if(s[j]!=s[i]){return false;}}
        }  
        return true;
    };
    deque<int> D1,D2;
    for(int d = 1; d*d <= N; d++){
        if(N % d > 0){continue;}
        D1.push_back(d);D2.push_front(N/d);
    }
    for(const int d:D1){if(check(d)){return (cout << N/d << endl),0;}}
    for(const int d:D2){if(check(d)){return (cout << N/d << endl),0;}}
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int h,m,s;
	scanf("%d",&s);
	m=s/60;
	s=s%60;
	h=m/60;
	m=m%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}
	

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

bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main(){
 string s;
 cin >> s;
 bool ans = true;
 if (!isPalindrome(s)) ans = false;
 if (!isPalindrome(s.substr(0, s.size()/2))) ans = false;
 cout << (ans ? "Yes" : "No") << endl;
}
   


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $N, $K);
for($i = 0; $i < $N; $i++){
    fscanf(STDIN, "%d%d", $t[$i], $d[$i]);
}
array_multisort($d, SORT_DESC, $t);

//美味しい寿司から食べてみる
$sum = 0;
for($i = 0; $i < $K; $i++){
    $sum += $d[$i];
    $map[$t[$i]][] = $d[$i];
}
//食べなかったのも残しておく
for($i = $K; $i < $N; $i++){
    $map2[$t[$i]][] = $d[$i];
}

//美味しさは$sum 種類数は count($map);
$kinds = count($map);
$max = $sum + $kinds**2;

//同じ種類を2個以上食べている場合、まずいほうから順に諦めていけばよい。ただし0個になるのは困る。
//種類Aを3個、種類Bを2個食べていた場合は、種類Aから2個、種類Bから1個は諦めていいよね
$mazuiArray = [];
foreach($map as $kind => &$array){
    sort($array);//不味いのから並べる
    $limit = count($array) - 1;
    for($i = 0; $i < $limit; $i++){
        $mazuiArray[] = $array[$i];
    }
}
//種類を区別せず、不味いもの総合ランキングを作る
sort($mazuiArray);

//選ばれていない種類の寿司の旨さトップを抽出
$umaiArray = [];
for($i = 1; $i <= $N; $i++){
    if(isset($map[$i]))continue;//選ばれている種類の寿司はもうため
    if(isset($map2[$i])){//選ばれてない種別の寿司が存在したら、一番うまいものだけ食べてみよう
        $umaiArray[] = max($map2[$i]);
    }
}
rsort($umaiArray);
$maxSwap = min(count($mazuiArray), count($umaiArray));
for($i = 0; $i < $maxSwap; $i++){
    $kinds++;
    $sum -= $mazuiArray[$i];
    $sum += $umaiArray[$i];
    $score = $sum + $kinds**2;
    $max = max($max, $score);
}
echo $max;

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

const int maxn = 100 * 1000 + 10;
int n, sz[maxn];
vector <int> adj[maxn];
bool ans;

void dfs(int v, int papa) {
    if (ans)
        return;
    sz[v] = 1;
    int o = 0, tmp = 0;
    bool f = 1;
    for (int u: adj[v])
        if (u != papa) {
            dfs(u, v);
            sz[v] += sz[u];
            o += (sz[u] % 2);
        }
    if (o > 1)
        ans = 1;
}

int main() {
    cin >> n;
    for (int i = 0, a, b; i < n - 1; i++) {
        cin >> a >> b;
        adj[--a].push_back(--b);
        adj[b].push_back(a);
    }
    dfs(0, -1);
    cout << (((n % 2) || ans)? "First\n": "Second\n");
    return 0;
}

Measured memory_bytes: 9492
def solve():
    # N = int(input())
    mn = float('inf')
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a_min = sorted(a)[0]
    b_min = sorted(b)[0]
    
    for i in range(M):
        x, y, c = map(int, input().split())
        mn = min(a[x-1] + b[y-1] - c, mn)
    
    print(min(mn, a_min + b_min))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 65852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int N = 1e5+5;

int n,q,a[N],b[N],c[N],fa[N];
LL m;

int find(int x){return x==fa[x]?x:(fa[x]=find(fa[x]));}

int main(){
	scanf("%d%lld%d",&n,&m,&q);
	rep(i,1,n) fa[i] = i;
	rep(i,1,q){
		scanf("%d%d%d",a+i,b+i,c+i),++a[i],++b[i];
		if(c[i]==0){
			int x = find(a[i]), y = find(b[i]);
			fa[x] = y;
		}
	}
	if(m==n-1){
		printf(*max_element(c+1,c+q+1)==0 ? "Yes" : "No");
		return 0;
	}
	rep(i,1,q)if(c[i]==1 && find(a[i])==find(b[i]) ){
		printf("No"); return 0;
	}
	int k = 0;
	rep(i,1,n) k += (i==fa[i]);
	printf(m>=n && m<=n-k+1ll*k*(k-1)/2 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1792
t = 0
h = 0

num = input()
i = 0
while i < num:
    animals = raw_input().split()
    if animals[0] < animals[1]:
        h += 3
    elif animals[0] > animals[1]:
        t += 3
    else:
        t += 1
        h += 1
    i += 1

print t,h



Measured memory_bytes: 4644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	t := Scanner()
	dp := make([][]int, len(s)+1)
	trans := make([][]int, len(s)+1)
	for i := 0; i <= len(s); i++ {
		dp[i] = make([]int, len(t)+1)
		trans[i] = make([]int, len(t)+1)
	}
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
				trans[i][j] = 3
			} else {
				if dp[i-1][j] < dp[i][j-1] {
					dp[i][j] = dp[i][j-1]
					trans[i][j] = 2
				} else {
					dp[i][j] = dp[i-1][j]
					trans[i][j] = 1
				}
			}
		}
	}
	i, j := len(s), len(t)
	k := dp[i][j]
	ans := make([]string, k)
	k--
	for {
		if s[i-1] == t[j-1] {
			ans[k] = string(s[i-1])
			k--
		}
		if trans[i][j] == 1 {
			i--
		} else if trans[i][j] == 2 {
			j--
		} else {
			i--
			j--
		}
		if i == 0 || j == 0 {
			break
		}
	}
	fmt.Println(strings.Join(ans, ""))
}


Measured memory_bytes: 150272
#include<iostream>
#include<math.h>
#define MAX 1000002
using namespace std;
int a[52];

int main() {
	int n;
	int b[52];
	cin >> n;
	int max = -1;
	int max_i;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = abs(a[i]);
		if (b[i] > max) {
			max = b[i];
			max_i = i;
		}
	}
	cout << 2 * (n - 1)<< endl;
	for (int i = 1; i < max_i; i++) {
		cout << max_i << ' ' << i << endl;
	}
	for (int i = max_i + 1; i <= n; i++) {
		cout << max_i << ' ' << i << endl;
	}
	if (a[max_i] > 0) {
		for (int i = 1; i < n; i++) {
			cout << i << ' ' << i + 1 << endl;  
		}
	}
	else {
		for (int i = n-1; i >= 1 ; i--) {
			cout << i + 1 << ' ' << i << endl;
		}
	}
	
}

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

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int r,g,b;
	cin >> r >> g >> b;
	int A = r *100 + g*10 + b;
	if (A%4==0){printf("YES\n");}else{printf("NO\n");}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int L, R, d;
    cin >> L >> R >> d;
    int count=0;
    FOR(i, L, R+1){
        if(i%d==0) count++;
    }
    out(count);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3628
import numpy
N = int(input())
X = [int(x) for x in input().split()]
S = sorted(X)
m0 = numpy.median(S[:-1])
m1 = numpy.median(S[1:])

for x in X:
    if x < m1:
        print(int(m1))
    else:
        print(int(m0))



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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int n;cin >> n;
  vector<double>a(n);
  double d;
  for(auto&&e:a){
    cin >> e;
    d+=(1/e);
  }
  cout << fixed << setprecision(10) << (1/d) << endl;
  
  return 0;
}


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

#define MAX 1000000

int getNumber(){
  int n = 0;
  char ch;
  while(1){
    ch = getchar();
    if ( ch == ' ' || ch == '\n' ) break;
    n *= 10; n += ch-'0';
  }
  return n;
}

int n, A[MAX];
int main(){
  while( 1 ){
    n = getNumber();
    //scanf("%d", &n);
    if ( n == 0 ) break;

    for ( int i = 0; i < n;  i++ ) A[i] = getNumber();

    sort(A, A + n);

    int maxc = 0;
    int maxv = A[0];
    int pre = A[0];
    int cnt = 1;

    for ( int i = 1; i < n; i++ ){
      if ( pre == A[i] ){
	cnt++;
      } else {
	if ( maxc < cnt ){
	  maxc = cnt;
	  maxv = pre;
	}
	cnt = 1;
      }
      pre = A[i];
    }
    if ( maxc < cnt ){
      maxc = cnt;
      maxv = pre;
    }

    if ( maxc > n/2 ) cout << maxv << endl;
    else cout << "NO COLOR" << endl;


  }
}

Measured memory_bytes: 4748
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector           as V
import qualified Data.Vector.Unboxed   as VU

main :: IO ()
main = do
  s <- BS.getLine
  t <- BS.getLine
  let solve = solve2
  putStrLn $ solve s t

table2 :: ByteString -> ByteString -> V.Vector (VU.Vector Int)
table2 xs ys = V.scanl step (VU.replicate (m+1) 0) xs'
  where n = BS.length xs
        m = BS.length ys
        xs' = V.generate n $ BS.index xs
        ys' = VU.generate m $ BS.index ys
        -- <(i-1,j)> -> i -> <(i,j)>
        step :: VU.Vector Int -> Char -> VU.Vector Int
        step v x = VU.scanl innerStep 0 $ VU.zip3 v (VU.tail v) ys'
          where
            -- (i,j-1) -> ((i-1,j-1),(i-1,j),j) -> (i,j)
            -- 第二引数はvから生成されているので、i-1 (iではなく)
            innerStep :: Int -> (Int,Int,Char) -> Int
            innerStep a (b,c,y) | x == y = b + 1
                                | otherwise = max a c

solve2 :: ByteString -> ByteString -> String
solve2 s t = go (BS.length s) (BS.length t) ""
  where tbl = table2 s t
        go 0 _ ss = ss
        go _ 0 ss = ss
        go i j ss
          | tbl V.! i VU.! j == tbl V.! (i-1) VU.! j = go (i-1) j ss
          | tbl V.! i VU.! j == tbl V.! i VU.! (j-1) = go i (j-1) ss
          | otherwise                                = go (i-1) (j-1) ((s `BS.index` (i-1)):ss)


Measured memory_bytes: 75004
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=1e5;
int fa[N];inline int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
int in[N],out[N];
bool vis[N],f[N],g[N];
int main()
{
	int n=gi(),a,b,c,d,l,r,i;gi();
	for (i=0;i<=400;i++) fa[i]=i;
	for (i=1;i<=n;i++) {
		a=gi(),b=gi(),c=gi(),d=gi();
		l=c?-c:a;
		r=d?d:-b;
		l+=200,r+=200;
		out[l]++,in[r]++;
		vis[l]=vis[r]=true;
		fa[find(l)]=find(r);
	}
	for (i=0;i<200;i++)
		if (out[i]>in[i]) return puts("NO"),0;
		else if (out[i]!=in[i]) f[find(i)]=true;
	for (i=201;i<=400;i++)
		if (in[i]>out[i]) return puts("NO"),0;
		else if (out[i]!=in[i]) g[find(i)]=true;
	for (i=0;i<=400;i++)
		if (vis[i]&&fa[i]==i&&(!g[i]||!f[i])) return puts("NO"),0;
	puts("YES");
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// constexprな素数列挙(エラトステネスの篩)
template <int N> struct calc_prime {
    bool p[N + 1];

    constexpr calc_prime() : p() {
        for (int_fast64_t i = 0; i <= N; ++i)
            p[i] = true;
        p[0] = p[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            for (int_fast64_t j = i * i; j <= N; j += i)
                p[j] = false;
        }
    }
};
calc_prime<200000> prime;

// BIT(Binary-Indexed-Tree) 別名：Fenwick Tree
template <typename T> struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    // 要素iにxを加算
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    // 区間[0, i]の合計を求める（閉区間）
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

const int SZ = 1e5 + 1;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    BIT<int> bit(SZ);
    for (int i = 1; i < SZ; i += 2) {
        if (prime.p[i] && prime.p[(i + 1) / 2]) {
            bit.add(i, 1);
        }
    }
    int Q;
    cin >> Q;
    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << bit.sum(r) - bit.sum(l - 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3968
CUP = ['A', 'B', 'C']

def i(x):
    if x=='A':
        x = 0
    if x=='B':
        x = 1
    if x=='C':
        x = 2
    return x

while True:
    try:
        x, y = input().split(',')
    except:
        break
    x = i(x)
    y = i(y)
    CUP[x], CUP[y] = CUP[y], CUP[x]

ball = CUP.index('A')
if ball==0:
    print('A')
if ball==1:
    print('B')
if ball==2:
    print('C')


Measured memory_bytes: 5564
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, c; ll K;
    scanf("%d%d%lld", &n, &c, &K);
    vector<ll> t(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &t[i]);
    }
    sort(t.begin(), t.end());

    int ans = 0;
    int cnt = 0;
    ll save = LINF;
    for (i = 0; i < n; i++) {
        if (save < LINF && cnt && save + K < t[i]) {
            ans++;
            cnt = 0;
            save = LINF;
        }
        cnt++;
        if(cnt==1) save = t[i];
        if (cnt == c) {
            ans++;
            cnt = 0;
            save = LINF;
        }
    }
    if (cnt) {
        ans++;
    }
    printf("%d\n", ans);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int i, N, A, B;
	long long X[100001];
	scanf("%d %d %d", &N, &A, &B);
	for (i = 1; i <= N; i++) scanf("%lld", &(X[i]));
	
	long long sum = 0;
	for (i = 2; i <= N; i++) sum += ((X[i] - X[i-1]) * A < B)? (X[i] - X[i-1]) * A: B;
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

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

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  swap(a[0],a[1]);
  swap(a[0],a[2]);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <class T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N, K;
    cin >> N >> K;

    int M = 0;
    Graph<int> G(N);
    for (int i = 1; i < N; ++i) {
        G[0].push_back(i);
        M++;
    }

    K = (N - 1) * (N - 2) / 2 - K;
    for (int i = 2; i < N && K > 0; ++i) {
        for (int j = 1; j < i && K > 0; ++j) {
            G[j].push_back(i);
            M++;
            K--;
        }
    }

    cout << (K >= 0 ? M : -1) << '\n';
    if (K >= 0) {
        for (int i = 0; i < N; ++i)
            for (auto j : G[i])
                cout << i + 1 << ' ' << j + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#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() {
    string a, b;
    cin >> a >> b;
    string ans;
    if (a.size() > b.size()) ans = "GREATER";
    else if (a.size() < b.size()) ans = "LESS";
    else {
        rep(i,a.size()) {
            if (a[i] > b[i]) {
                ans = "GREATER";
                break;
            }
            else if (a[i] < b[i]) {
                ans = "LESS";
                break;
            }
            ans = "EQUAL";
        }
    }
    cout << ans << endl;
}

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

int main() {
 string s;

 cin >> s;
 
 if(s == "Sunny") cout << "Cloudy" << endl;
 else if(s ==  "Cloudy") cout << "Rainy" << endl; 
  else if(s ==  "Rainy") cout << "Sunny" << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// F(0, x)を求める
const LLONG f(const LLONG x)
{
    if (x % 2 == 0)
    {
        // 偶-奇ペアの数
        const LLONG pairNum = x / 2;
        if (pairNum % 2 == 0)
        {
            return x;
        }
        else
        {
            return x ^ 1;
        }
    }
    else
    {
        // 偶-奇ペアの数
        const LLONG pairNum = (x + 1) / 2;
        return pairNum % 2 == 0 ? 0 : 1;
    }
}

int main()
{
    LLONG A, B;
    cin >> A >> B;
    cout << (f(A - 1) ^ f(B)) << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class DDisjointSetOfCommonDivisors {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll a,b;
	    in >> a >> b;
	    vector<ll> c;
	    if(a>b){
	        ll t=a;
	        a=b;
	        b=t;
	    }
	    for(ll i=1;i<=sqrt(a);i++){
	        if(a%i==0&&b%i==0){
	            c.push_back(i);
	        }
	        if(b%(a/i)==0&&a/i!=i){
	            c.push_back(a/i);
	        }
	    }
	    sort(c.begin(),c.end());
	    vector<ll> aa;
	    ll ans=1L;
	    for(int i=1;i<c.size();i++){
	        bool f=true;
	        rep(j,aa.size()){
	            if(c[i]%aa[j]==0){
	                f=false;
	                break;
	            }
	        }
	        if(f){
	            aa.push_back(c[i]);
	            ans++;
	        }
	    }
	    out <<ans << endl;
	}
};


int main() {
	DDisjointSetOfCommonDivisors solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100009, inf = 1000000000000000000;
int n, m;

vector<pair<int, int>> graph[N];
int d[N];

void nope() {
    cout << -1 << endl;
    exit(0);
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i = 2; i <= n; ++i) {
        graph[i].emplace_back(i-1, 0);
    }
    for(int i = 0; i < m; ++i) {
        int l, r, c; cin >> l >> r >> c;
        graph[l].emplace_back(r, c);
    }

    for(int i = 1; i <= n; ++i) d[i] = inf;

    priority_queue<pair<int, int>> pq;
    pq.emplace(0, 1);

    while(!pq.empty()) {
        int w = -pq.top().first, v = pq.top().second; pq.pop();
        if(d[v] == inf) {
            d[v] = w;
            for(auto child : graph[v]) {
                if(d[child.first] == inf) {
                    pq.emplace(-w - child.second, child.first);
                }
            }
        }
    }

    if(d[n] == inf) cout << -1 << endl;
    else cout << d[n] << endl;
    
    return 0;
}


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

int main() {
  string a, b;
  cin >> a >> b;

  int num = stoi(a + b);

  int i = 0;
  string Ans = "No";
  while(i < num) {
    int temp = i * i;
    if (temp == num) {
      Ans = "Yes";
      break;
    }
    i++;
  }

  cout << Ans << endl;
}


Measured memory_bytes: 3592
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	prime := make([]bool, 55556)
	for i := 2; i <= 55555; i++ {
		prime[i] = true
	}

	for i := 2; i <= 55555; i++ {
		if prime[i] {
			j := i * 2
			for j <= 55555 {
				prime[j] = false
				j += i
			}
		}
	}

	cnt := [5]int{}
	for i := 2; i <= 55555; i++ {
		if prime[i] {
			cnt[i%5]++
		}
	}

	for i := 0; i < 5; i++ {
		if cnt[i] >= N {
			cnt := 0
			p := 2
			for cnt < N {
				if prime[p] && p%5 == i {
					fmt.Printf("%d ", p)
					cnt++
				}
				p++
			}
			break
		}
	}
}


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

int main(){
  string s;
  int t=0;
  cin >> s;
  if(s.at(0)=='1'){
    t++;
  }
  if(s.at(1)=='1') t++;
  if(s.at(2)=='1') t++;
  cout <<t<<endl;
}

Measured memory_bytes: 3584
n = int(input())
s = input()
s = [ n for n in s ]
ans = 0

for i in range(1,n):
  a = set(s[:i])
  b = set(s[i:])
  c = len([ k for k in a if k in b ])
  if c > ans:
    ans = c
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
LL MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for(int i=0; i<N-1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    queue<int> qu;
    vector<int> order(N, 0);
    vector<int> parent(N, -1);
    qu.push(0);
    vector<vector<LL>> dp(N, vector<LL>(2, 1));
    while(!qu.empty()) {
        int cur = qu.front();
        //cout << cur << endl;
        qu.pop();
        order.push_back(cur);

        for(auto v: G[cur]) {
            if(parent[cur] == v) continue;
            parent[v] = cur;
            qu.push(v);
        }
    }
//    cout << order.size() << endl;
    reverse(order.begin(), order.end());

    for(auto v: order) {
        if(parent[v] == -1) continue;
        dp[parent[v]][0] *= (dp[v][0] + dp[v][1]);
        dp[parent[v]][1] *= dp[v][0];
        dp[parent[v]][0] %= MOD;
        dp[parent[v]][1] %= MOD;

    }

    cout << (dp[0][0] + dp[0][1] ) % MOD << endl;

    return 0;
}

Measured memory_bytes: 13180
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t K, A, B;

    std::cin >> K >> A >> B;

    for (int64_t i = A; i <=B; ++i) {
        if (i % K == 0) {
            std::cout << "OK" << std::endl;
            return 0;
        }
    }

    std::cout << "NG" << std::endl;

    return 0;
}

Measured memory_bytes: 3636
N = int(input())
P = list(map(str,input().split()))
Q = list(map(str,input().split()))
#%%
import sys
sys.setrecursionlimit(10**8)
permu = []
def next_permutation(A,T,n):
    if n==0:
        permu.append(''.join(T))
    
    nxtlist = list(A)
    for l in nxtlist:
        A2 = set(nxtlist)
        T2 = T[:]
        A2.discard(l)
        T2.append(l)
        next_permutation(A2,T2,n-1)
    
    return 
    
    


A = [str(i) for i in range(1,N+1)]  
A = set(A)      

next_permutation(A,[],N)
permu.sort()
a,b= 0,0
ps = ''.join(P)
qs = ''.join(Q)
for i in range(len(permu)):
    if ps==permu[i]:
        a = i
    
    if qs==permu[i]:
        b = i

print(abs(a-b))

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-10);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(ll mask) {int ret=0; while (mask) 	{mask &= (mask-1ll);++ret;	}return ret;}
ll arr[52];
int main()
{
    ll k;
    cin>>k;
    
  if(k==0)
  {
      cout<<"2\n0 1\n";
      return 0;
  }

  if(k==1)
  {
      cout<<"2\n0 2\n";
      return 0;
  }
  
  if(k<=50)
  {
      cout<<k<<endl;
      for(int i=1;i<=k;i++)
        cout<<i<<" ";
  }
  else
  {
      ll q=k/50;
      ll rem=k%50;
      cout<<"50\n";
      for(int i=1;i<=50;i++)
      {
          arr[i]=i+(q-1);
      }
      int st=1;
      while(rem>0)
      {
          for(int i=1;i<=50;i++)
          {
              if(i==st)
              arr[i]+=50;
              else
                arr[i]-=1;
          }
          st++;
          rem--;
      }
      
      for(int i=1;i<=50;i++)
        cout<<arr[i]<<" ";
      
  }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a,b,c,i=1;
  cin >> n;
  cin >> a;
  do{
    cin >> b;
    if(a<b){c=b;b=a;a=c;}
    while(a%b){
      c=b;b=a%b;a=c;
    }
    a=b;i++;
  }while(i<n);
  cout << a;
  return 0;
}

Measured memory_bytes: 256
using System;

class lyoz{
	static void Main(){
		for(string line;(line=Console.ReadLine())!="0 0";){
			string a=line.Split(' ')[0];
			string b=line.Split(' ')[1];
			
			int hit=0,blow=0;
			for(int i=0;i<4;i++){
				if(b[i]==a[i])
					hit++;
				else if(a.IndexOf(b[i])!=-1)
					blow++;
			}
			Console.WriteLine(hit+" "+blow);
		}
	}
}

Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(void){
    int n;
    cin >> n;
    VI vec(n);
    REP(i, n) cin >> vec.at(i);
    int minnum = vec.at(0); 
    int maxnum = -1000000000;
    FOR(i,1, n){
        maxnum = max(maxnum, vec.at(i) - minnum);
        minnum = min(minnum, vec.at(i));
    }
    cout << maxnum  << endl;
}



Measured memory_bytes: 3544
import java.util.*;

class Main {

    static void solve (int a1, int a2, int b) {
        ArrayList<Integer> cards = new ArrayList<Integer>();
        for(int i = 1; i <= 10; i++) {
            cards.add(i);
        }

        cards.remove(cards.indexOf(a1));
        cards.remove(cards.indexOf(a2));
        cards.remove(cards.indexOf(b));

        int ok = 0;
        for(int i = 0; i < 7; i++) {
            if (cards.get(i) + a1 + a2 <= 20) {
                ok += 1;
            } else {
                break;
            }
        }

        if (ok >= 4) System.out.println("YES");
        else         System.out.println("NO");
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            int a1 = sc.nextInt();
            int a2 = sc.nextInt();
            int b = sc.nextInt();
            solve(a1, a2, b);
        }

    }
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int Mod = 1e9 + 7, N = 4010;

int fpm(int x, int power) {
    int res = 1;
    for (; power; power >>= 1, x = 1ll * x * x % Mod)
        if (power & 1) res = 1ll * res * x % Mod;
    return res;
}

int fac[N], ifac[N];

void Fac_Init(int maxn) {
    fac[0] = ifac[0] = 1;
    For (i, 1, maxn)
        fac[i] = 1ll * fac[i - 1] * i % Mod;
    ifac[maxn] = fpm(fac[maxn], Mod - 2);
    Fordown (i, maxn - 1, 1)
        ifac[i] = 1ll * ifac[i + 1] * (i + 1) % Mod;
}

inline int Comb(int n, int m) {
	if (n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * ifac[n - m] % Mod * ifac[m] % Mod;
}

inline int f(int n, int m) {
	if (m > n) return 0;
	return (Comb(n + m - 1, m - 1) - Comb(n + m - 1, m - 2) + Mod) % Mod;
}

int main () {

	File();

	int n = read(), k = read();

	Fac_Init(n << 1);

	printf ("%lld\n", 1ll * (f(n, k) - f(n, k - 1) + Mod) % Mod * fpm(2, max(n - k - 1, 0)) % Mod);

	return 0;

}

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

int main(){

    int a, b;

    cin >> a >> b;

    if(a == 1)a += 13;
    if(b == 1)b += 13;

    if(a > b)cout << "Alice\n";
    else if(a < b)cout << "Bob\n";
    else cout << "Draw\n";

    return 0;

}

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

int main(){
	int n,d; cin >>  n >>d;
	int x[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin >> x[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int sum=0;
			for(int l=0;l<d;l++){
				sum+=(x[i][l]-x[j][l])*(x[i][l]-x[j][l]);
			}
			for(int l=0;l<1000;l++){
				if(sum==l*l)ans++;
			}
		}
	}
	cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int x = sc.nextInt();

        int tmp = 1;
        while (360*tmp % x != 0){
            tmp++;
        }

        System.out.println(360*tmp / x);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 32668
import math

n = int(input())

array = []
ans = []

def n2divide(n):
    for i in range(1, int(math.sqrt(n))+1):
            if n % i == 0:
                array.append(i)
                
    for j in array:
        ans.append(j + n/j -2)
        
    return ans
    
    
a = n2divide(n)
print(int(min(a)))

Measured memory_bytes: 3188