akhauriyash/Code-Regression huggingface dataset:
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var input = t.ConvertIntList(t.ReadInput());
            var temp = input[0];
            input[0] = input[1];
            input[1] = temp;
            temp = input[0];
            input[0] = input[2];
            input[2] = temp;
            Console.WriteLine(input[0] + " " + input[1] + " " + input[2]);

        }

        public int Gcd(int a, int b)
        {
            for (var i = b; i > 1; i -= 1)
            {
                if (a % i == 0 && b % i == 0)
                {
                    return i;
                }
            }
            return 1;
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ConvertIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }

        public List<double> ConvertDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ConvertLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

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

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

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll, ll>    pll;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define fastio          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_io         freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#define ld_io           cout << setprecision(10) << fixed;

#undef pow
ll pow(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pow(a * a % mod, b / 2, mod) % mod;
    return pow(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;
const ll LOG   = 32;      // log2(1e9)
const ll BLOCK = 320;     // sqrt(1e5)
const ld PI    = acos(-1);
const ld SADAT = 7.84e-17;  // The most important constant ever

ll n, k, tl, tr, ans, el, er, pl, pr;
string s;

int main() {
    fastio
    cin >> n >> k >> s;

    for (ll i = 0; i < n; i++) {
        ll j = i;
        for (; j < n && s[j] == s[i]; j++) {}
        if (s[i] == 'L')    tl++;
        else tr++;

        ans += j - i - 1;
        i = j - 1;
    }
    if (tl == 0 || tr == 0)
        kill(n - 1);

    el += (s[0] == 'L') + (s[n - 1] == 'L');
    er += (s[0] == 'R') + (s[n - 1] == 'R');

    if (k <= tl - el)  pl = k * 2;
    else    pl = min(k, tl) * 2 - min(k - tl + el, el);

    if (k <= tr - er)  pr = k * 2;
    else    pr = min(k, tr) * 2 - min(k - tr + er, er);

    ans += max(pl, pr);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using lint=long long;
using namespace std;

int main()
{
	int N,M;
	
	cin >> N >> M;
	vector<vector<int>> edge(N);
	vector<int> in(N);
	
	for(int i=0;i<M;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		edge[x].push_back(y);
		in[y]++;
	}
	
	//tsort and dp
	queue<int> q;
	for(int i=0;i<N;i++)
		if(in[i]==0)
			q.push(i);
	int dp[100010]={};
	int cur;
	while(!q.empty())
	{
		cur=q.front();
		q.pop();
		for(auto&& i:edge[cur])
		{
			//tsort
			in[i]--;
			if(in[i]==0)
				q.push(i);
			//dp
			dp[i]=max(dp[i],dp[cur]+1);
		}
	}
	
	cout << dp[cur] << endl; 
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	//int x1, x2, x3, x4, x5 = 0;
	//int a = 0;
	//cin >> x1 >> x2 >> x3 >> x4 >> x5;
	//if (x1 == 0)a = x2 - 1;
	//if (x2 == 0)a = x1 + 1;
	//if (x3 == 0)a = x2 + 1;
	//if (x4 == 0)a = x3 + 1;
	//if (x5 == 0)a = x4 + 1;
	//cout << a;

	//int x, y = 0;
	//int ans = 0;
	//cin >> x >> y;
	//for (int i = 0; i <= x; i++)
	//{
	//	if (y == 2 * i + 4 * (x - i))
	//	{
	//		ans = 1;
	//	}
	//}
	//if (ans == 1)
	//	cout << "Yes";
	//else
	//	cout << "No";

	int x, n = 0;
	cin >> x >> n;
	vector<int>duck;
	for (int i = 0; i < n; i++)
	{
		int d = 0;
		cin >> d;
		duck.push_back(d);
	}
	//sort(duck.begin(), duck.end());
	//for (int i = 0; i < n; i++)
	//{

	//	cout << duck[i] << " ";
	//}
	int key=x, pig = x;
 
	while (key >= 0) 
	{
		//cout << key << endl;
		vector<int>::iterator it = std::find(duck.begin(), duck.end(), key);
		if (it == duck.end())
		{
			break;
		}
		key  -= 1;
	}
	while (1) {
		vector<int>::iterator it = std::find(duck.begin(), duck.end(), pig);
		if (it == duck.end()) {
			break;
		}
		pig += 1;
	}
	if (abs(x - key) > abs(x - pig))
	{
		key = pig;
	}
	if (n == 0)
		key = x;
	cout << key;
    return 0;
}



Measured memory_bytes: 3596
io = DATA.eof? ? STDIN : DATA
x=io.gets.to_i
if x>=1800
 puts 1
elsif x>=1600
  puts 2
elsif x>=1400
  puts 3
elsif x>=1200
  puts 4
elsif x>=1000
  puts 5
elsif x>=800
  puts 6
elsif x>=600
  puts 7
elsif x>=400
  puts 8
end
__END__


Measured memory_bytes: 14308
N=int(input())
dict = {}
 
for i in range(N):
  s=input()
  if s in dict:
    dict[s]=dict[s]+1
  else:
    dict[s]=1

dict_maxval=max(dict.values())
    
res = [k for k, v in dict.items() if v == dict_maxval]
res.sort()
for word in res:
  print(word)

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

const ll MOD = 1000000007;

int main(){
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n+1; ++i) {
		ll a = i*n % MOD;
		a -= i*(i-1)/2 % MOD;
		ll b = i*(i-1)/2 % MOD;
		ans += a - b + 1;
		ans %= MOD;
	}
	if(ans < 0){
		cout << ans + MOD << endl;
	}else{
		cout << ans << endl;
	}
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(){
    long long jumlah;
    scanf("%lld", &jumlah);

    long long var[jumlah+1];
    long long result = 1;
    int flag = 1;
    int print_hasil;

    for(int i = 0; i<jumlah; i++){
        scanf("%lld", &var[i] );
        if ( var[i] == 0 ) {
            printf("0\n");
            flag = 0;
            break;
        }
    }

    if(flag){
        for(int i = 0 ; i < jumlah ; i++){
            if(var[i] > 1000000000000000000/result) {
                flag = 0;
                break;
            }
            result *= var[i]; 
            if ( i >= jumlah - 1 ){
          		print_hasil = 1;
        }
    }

    if ( print_hasil ) {
        flag ? printf("%lld\n", result) : printf("-1\n");
    }

    return 0;
    }
}

Measured memory_bytes: 2448
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n, k;
    int a[1000];
    cin >> n >> k;
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    int sum = 0;
    for (int i = 0;i < k;i++)
    {
        sum += a[i];
    }
    cout << sum << "\n";
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   cin>>N;
   int S=0,M=N;
   while(M!=0){
       S+=M%10;
       M/=10;
   }
   if(N%S==0){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
   
   
    
}

Measured memory_bytes: 3600
//RITIK RAI:
//#pragma GCC optimize("O3")
 
/*----------------------------------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
/*----------------------------------------------------------------------------------------------------------*/
 
#define ll long long int
#define ull unsigned long long int
#define ld long double

/*----------------------------------------------------------------------------------------------------------*/
 
#define pll pair<ll,ll>
#define mp make_pair
#define fir first
#define sec second
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

/*----------------------------------------------------------------------------------------------------------*/

#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(ll i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(ll i=0;i<r;i++){for(ll j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define ritik ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
 /*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll max3(ll a,ll b,ll c)
{
    return max(max(a,b),c);
}


ll nCr(ll n, ll r)
{
    ll x=n-r,y=0,z=1;
    while(y<r)
    {
        z=(z*(x+1))/(y+1);
        x++;y++;
    }
    return z;
}
 
/*-----------------------------------------------write your code here-----------------------------------------------------------*/


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;  
}

Measured memory_bytes: 384
package main

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

func main() {
	N := oneInt()
	K := oneInt()
	var Hs []int
	for index := 0; index < N; index++ {
		Hs = append(Hs, oneInt())
	}

	Hs = sortDesc(Hs)
	var result = 0
	for index := K; index < len(Hs); index++ {
		result += Hs[index]
	}
	fmt.Print(result)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 7552
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi A;

int main(){
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    int amin = *min_element(all(A));
    int amax = *max_element(all(A));

    int ans = INF;
    rep(n, amin, amax + 1) {
        int sqsum = 0;
        rep(i, N) sqsum += (n - A[i]) * (n - A[i]);
        chmin(ans, sqsum);
    }

    write(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s[3],res;
	for(int i=0;i<3;i++)
	  cin>>s[i];
	for(int i=0;i<3;i++)
	  res.push_back(s[i][0]-(int)('a'-'A'));
	cout<<res<<endl;
	return 0;
}

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

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

    if(C<=A+B+1){
        cout << B+C << endl;
    }
    else{
        cout << B+(A+B+1) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main() {
	int arr[26]{};
	std::string name;
	std::cin >> name;
	int n=name.size();
	bool yes = 1;
	for (int x = 0; x < n; x += 2) {
		if (name.substr(x, 2) != "hi") {
			yes = false;
		}
	}
	std::cout << (yes == 1 ? "Yes" : "No");

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
int a[200005],num=0;
long long ans=0;
int main()
{
	scanf("%d",&n);
	if(n==1)
	{
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	ans+=a[n];num++;
	for(int i=n-1;i>=1;i--)
	{
		if(num<n-1) num++,ans+=a[i];
		if(num<n-1) num++,ans+=a[i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main(){
 
 string S;
 int N, count=0;
 cin>>N;
 cin>>S;

for (int i=0; i<N-2; ++i){
  if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
    count++;
  }
 }
  cout<<count;
  return 0;
}
 


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

void swap(int *, int *);

int main()
{
	int a, b, c;
	int x, y, z;

	while (1)
	{
		cin >> a >> b >> c;
		if (a >= 1 && a <= 10000 && b >= 1 && b <= 10000 && c >= 1 && c <= 10000)
			break;
	}

	if (a > b)
		swap(&a, &b);

	if (b > c)
		swap(&b, &c);

	if (a > b)
		swap(&a, &b);

	cout << a <<" "<< b <<" "<< c << endl;

	return 0;
}

void swap(int *a, int *b)
{
	int temp;
	temp = *b;
	*b = *a;
	*a = temp;
}

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

signed main() {
	int c[3][3];
	vector<int> a(3);
	vector<int> b(3);
	bool flag;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> c[i][j];
		}
	}

	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			for (int k = 0; k <= 100; ++k) {
				flag = true;
				a[0] = i;
				a[1] = j;
				a[2] = k;
				b[0] = c[0][0] - i;
				b[1] = c[1][1] - j;
				b[2] = c[2][2] - k;
				for (int n = 0; n < 3; ++n) {
					for (int m = 0; m < 3; ++m) {
						if (a[n] + b[m] != c[n][m]) {
							flag = false;
						}
					}
				}
				if (flag) {
					cout << "Yes" << endl;
					return 0;

				}
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
from fractions import gcd

n,m = map(int,input().split())
a = set(map(int,input().split()))
a = list(a)
nn = len(a)

g = a[0]
    
x = a[0]
for i in range(1,nn):
    t = gcd(x,a[i])
    x *= a[i]
    x //= t
    
fl = 1
ff = x//2
for i in range(nn):
    if ff % a[i] != a[i] // 2:
        fl = 0
        
if fl == 1:
    xx = (m-ff) // x + 1
else:
    xx = 0
    
print(xx)

Measured memory_bytes: 89580
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def sieve(top: Int): Iterator[Int] = {
    val topId = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topId >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec
    def get(cndId: Int): Unit = {
      if(cndId <= sqrtLmtNdx){
        if(!isCmpst(cndId)){
          val p = 2 * cndId + 3

          @tailrec
          def cull(cmpstId: Int): Unit =
            if(cmpstId <= topId){
              setCmpst(cmpstId)
              cull(cmpstId + p)
            }

          cull((p * p - 3) >>> 1)
        }
        get(cndId + 1)
      }
    }

    get(0)

    @tailrec def next(cndId: Int): Int =
      if ((cndId > topId) || !isCmpst(cndId)) 2 * cndId + 3
      else next(cndId + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(sieve(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

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

int main()
{
    vector<int> nums;
    for(int i = 0; i < 3; ++i){
        int x;
        cin >> x;
        nums.push_back(x);
    }
    sort(nums.begin(), nums.end());
    if(nums[0] == nums[1] && nums[0] != nums[2]) cout << "Yes";
    else if(nums[1] == nums[2] && nums[0] != nums[2]) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N = int(input())
  ABn = [list(map(int, input().split())) for _ in range(N)]
  ABn = sorted(ABn,key=lambda x:x[1])

  if ABn[0][0] > ABn[0][1]:
    return False

  for i in range(1,N):
    ABn[i][0] += ABn[i-1][0]
    if ABn[i][0] > ABn[i][1]:
      return False
  
  return True


if __name__ == "__main__":
  if main():
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 89944
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(abs(n - m) > 1) {
    cout << "0\n";
    return 0;
  }
  (ans = frac(n) * frac(m)) %= MOD;
  if(abs(n - m) == 0) {
    (ans *= 2) %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    auto v = vector<vector<int>>(2, vector<int>(n, 0));
    for (size_t i = 0; i < 2; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            cin >> v[i][j];
        }
    }

    vector<int> sumvec(n);

    for (size_t i = 0; i < n; i++)
    {
        int sum = 0;
        for (size_t j = 0; j < i; j++)
        {
            sum += v[0][j];
        }
        sum += v[0][i];
        sum += v[1][i];
        for (size_t k = i + 1; k < n; k++)
        {
            sum += v[1][k];
        }
        sumvec.emplace_back(sum);
    }
    cout << *max_element(sumvec.begin(), sumvec.end()) << endl;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let t: usize = sc.read();
    let a: i32 = sc.read();
    let res = (0..n).map(|i|
        {
            let x = sc.read::<usize>();
            let tmp: f64 = t as f64 - x as f64 * 0.006;
            let res = (a as f64 - tmp).abs();
            res
        }).enumerate().min_by(|x, y| x.1.partial_cmp(&y.1).unwrap()).unwrap();

    println!("{}", res.0 + 1);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=1,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	x[a]++;
	if(x[b]==0){n++;}
	x[b]++;
	if(x[c]==0){n++;}
	x[c]++;
	cout<<n;
} 


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a, x, y, z;
    std::cin >> a ;
    x = floor(a/3600) ;
    y = floor(a - 3600*x) / 60 ;
    z = ((a-3600*x)-60*y);
    std::cout << x <<":" << y << ":"<< z << std::endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  char c;cin>>c;
  if(c - 'a' >= 0)print('a');
  else print('A');

  return 0;
}


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

int main()
{
    int* h = new int[10];

    for(int i=0; i<10; i++){
        cin >> h[i];
    }

    int tmp;
    for(int j=0; j<9; j++){
        for(int k=0; k<9; k++){
         if(h[k] < h[k+1]){
                tmp = h[k];
                h[k] = h[k+1];
                h[k+1] = tmp;
            }
        }
    }

    cout << h[0] << endl;
    cout << h[1] << endl;
    cout << h[2] << endl;
}

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

int main(){
  int m;
  cin >> m;
  while(m--){
    string train;
    set<string> st;
    cin >> train;
    for(int i = 0; i < train.size(); i++){
      string s1 = train.substr(0, i);
      string s2 = train.substr(i);
      for(int k = 0; k < 2; k++){
        for(int l = 0; l < 2; l++){
          st.insert(s1 + s2);
          st.insert(s2 + s1);
          reverse(s1.begin(), s1.end());
        }
        reverse(s2.begin(), s2.end());
      }
    }
    cout << st.size() << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<algorithm>
 
#define int long long
using namespace std;
int32_t main()
{ string s,t;
cin >> s >> t;
 int s_size=s.length();
 int t_size = t.length();
int ans=INT_MAX;
for(int i=0; i<s_size; i++)
{ int cnt=0;
for(int j=0; j<t_size; j++)
{ if(i+j>=s_size)
{  cnt=0;
    break;
}
if(s[i+j]==t[j])
{
    cnt++;
}
 
 
 
 
}
ans =min(ans,t_size-cnt);
 
 
}
cout << ans << endl;
 
 
}


Measured memory_bytes: 3568
N, A, B = map(int, input().split())

if N < A:
  print(N)

elif A <= N <= A + B:
  print(A)
  
else:
  count = N // (A+B)
  amari = N % (A + B)
  if amari < A:
    print(A*count + amari)
  else:
    print(A*count + A)

Measured memory_bytes: 3060
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut v = Vec::new();

    for _i in 0..3 {
        let tmp: i32 = sc.read();
        v.push(tmp);
    }

    v.sort();

    let mut res = v[2] * 10 + v[1];
    res = res + v[0];

    println!("{}", res);
}



Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int n,a[2];
  cin>>n;
  a[0] = n/10;
  a[1] = n - a[0]*10;
  if(a[0] == 9 || a[1] == 9){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
h = list(map(int,input().split()))
l = [1]*N
for i in range(Q):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a] > h[b]:
        l[b] = 0
    elif h[a] < h[b]:
        l[a] = 0
    else:
        l[a] = 0
        l[b] = 0
print(sum(l))

Measured memory_bytes: 20008
#include <stdio.h>

int main() {
	long a;
	int i, flag;
	while( scanf("%d", &a)!=EOF ) {
		flag = 0; // For Space
		for(i=1;i<1024;i*=2) {
			if ((i&a)==i) {
				// If you output Number before, insert Space
				if (flag==1) printf(" ");
				printf("%d", i);
				flag = 1;
			}
		}
		// Dont forget LF
		printf("\n");
	}
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int n, k, c;
    cin >> n >> k >> c;

    vector<bool> s(n, true);
    rep(i, 0, n) {
        char c;
        cin >> c;
        if (c == 'x') { s[i] = false; }
    }

    vi l, r;

    int next = 0;
    rep(i, 0, n) {
        if (s[i] && i >= next) {
            l.push_back(i + 1);
            next = i + c + 1;
        }
    }

    if ((int)l.size() != k) { return 0; }

    next = n - 1;
    rrep(i, 0, n) {
        if (s[i] && i <= next) {
            r.push_back(i + 1);
            next = i - c - 1;
        }
    }

    reverse(r.begin(), r.end());
    rep(i, 0, l.size()) {
        if (l[i] == r[i]) { cout << l[i] << endl; }
    }

    return 0;
}

Measured memory_bytes: 3188
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 n = read::<usize>();

    println!("{}", n.pow(3))
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] array = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                array[i][j] = (sc.nextInt() % 2);
            }
        }
        
        int[][] ans = new int[h * w * 2][2];
        for (int i = 0; i < h * w * 2; i++) {
            Arrays.fill(ans[i], -1);
        }
        
        int r = 0;
        int c = 0;
        int count = 0;
        int flag = 0;
        while (true) {
            if (r >= h) break;
            
            if (array[r][c] == 1) {
                if (flag == 0) {
                    flag = 1;
                } else {
                    flag = 0;
                }
                ans[count][0] = r+1;
                ans[count][1] = c+1;
                count++;
            } else {
                if (flag == 1) {
                    ans[count][0] = r+1;
                    ans[count][1] = c+1;
                    count++;
                    ans[count][0] = r+1;
                    ans[count][1] = c+1;
                    count++;
                }
            }
            
            if (r % 2 == 0) {
                c++;
                if (c == w) {
                    c = w - 1;
                    r++;
                }
            } else {
                c--;
                if (c == -1) {
                    c = 0;
                    r++;
                }
            }
        }
        
        System.out.println(count / 2);
        for (int i = 0; i < h * w * 2; i += 2) {
            if (ans[i+1][0] == -1) break;
            
            System.out.println(ans[i][0] + " " + ans[i][1] + " " + ans[i+1][0] + " " + ans[i+1][1]);
        }
    }
}


Measured memory_bytes: 118548
def counting_sort(array, maxval):
    m = maxval + 1000
    count = [0] * (m)
    for a in array:
        count[a] += 1
    i = 0
    for a in range(m):
        for c in range(count[a]):
            array[i] = a
            i += 1
    return array
 
if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))
    a = 0
    li = counting_sort(l, N)
    for a in range(N-1):
        print(li[a], end=" ") 
    print(li[N-1])

Measured memory_bytes: 233660
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 n: u32 = read();

	println!("{}", n*n*n);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

class xy{
  int x;
  int y;
public:
  xy(){}
  xy(int _x,int _y) : x(_x), y(_y){
  }
  void SetData(int _x, int _y){
    x = _x;
    y = _y;
  }
   
  int GetX(){
    return x;
  }
  int GetY(){
    return y;
  }

};

int main()
{
  int x,y;
  vector<xy> data;
  while(!cin.eof()){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x > y) swap(x,y);
    data.push_back(xy(x,y));
  }
  for (vector<xy>::size_type i = 0; i < data.size(); i++)
  {
    cout << data[i].GetX() << " " << data[i].GetY() << endl;
  }
  

  return 0;
}


Measured memory_bytes: 3052
import bisect

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

a.sort()
c.sort()

ans = 0

for i in b:
	ans += (bisect.bisect_left(a,i)) * (len(c) - bisect.bisect_right(c,i))

print(ans)


Measured memory_bytes: 105444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[400][400];


	
int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	//input
	int n,m;
	cin >> n;
	vector<int> S(n);
	vector<int> G(n);
	vector<int> P(n);
	for(int i=0;i<n;i++){
		cin >> S[i] >> G[i] >> P[i];
	}
	cin >> m;
	vector<int> L(m);
	for(int i=0;i<m;i++)cin >> L[i];
	memset(dp,-1,sizeof(dp));

	//algorithm
	for(int i=1;i<=n;i++){
		for(int j=1;j<395;j++){
			int maxx=0;
			if(j<S[i-1]) dp[i][j]=dp[i-1][j];
			else {
				for(int k=S[i-1];k<=G[i-1];k++){
					if(j<k)break;
					if(dp[i][j-k]==-1)maxx=max(maxx,dp[i][j-k]+P[i-1]+1);
					else maxx=max(maxx,dp[i][j-k]+P[i-1]);
				}
				dp[i][j]=max(maxx,dp[i-1][j]);
			}
		}
	}

	//output
	for(int i=0;i<m;i++) {
		if(dp[n][L[i]]==-1){cout << -1 << endl;return 0;}
	}

	
	for(int i=0;i<m;i++) {
		cout << dp[n][L[i]] << endl;
	}
	
	
}





Measured memory_bytes: 3872
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

struct pt
{
	int x, y, i;
	pt() { }
};

int n, r, c;
vector<pt> p;
int id[maxn];

bool read()
{
	if (scanf("%d %d %d", &r, &c, &n) != 3)
		return false;

	forn (i, n)
	{
		pt a, b;
		scanf("%d %d %d %d", &a.x, &a.y, &b.x, &b.y);
		a.i = b.i = i;

		if (a.x == 0 || a.x == r || a.y == 0 || a.y == c)
			if (b.x == 0 || b.x == r || b.y == 0 || b.y == c)
				p.push_back(a), p.push_back(b);
	}

	return true;
}

llong cross(pt a, pt b) { return 1ll * a.x * b.y - 1ll * b.x * a.y; }

bool cmp(pt a, pt b)
{
	if (cross(a, b) < 0)
		return true;

	if (cross(a, b) == 0)
	{
		if (a.x == 0 && a.y == 0)
			return false;

		if (b.x == 0 && b.y == 0)
			return true;

		if (a.x == 0)
			return a.y < b.y;

		if (a.y == 0)
			return a.x > b.x;
	}

	return false;
}

void solve()
{
	n = size(p);
	sort(p.begin(), p.end(), cmp);
	set<int> cur, ids;

	forn (i, size(p))
	{
		if (cur.count(p[i].i))
		{
			cur.erase(p[i].i);
			ids.erase(id[p[i].i]);

			if (!ids.empty() && *ids.rbegin() > id[p[i].i])
				return void(printf("NO\n"));
		}
		else
			cur.insert(p[i].i), ids.insert(id[p[i].i] = i);
	}

	printf("YES\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 7920
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


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


struct node {
	vector<int> link;
	int sign;
};

vector<node> nod;
int N, M;

int main() {
	cin >> N>> M;
	nod.resize(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		nod[a].link.push_back(b);
		nod[b].link.push_back(a);
	}
	rep(i, N) nod[i].sign = -1;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		for (int j : nod[i].link) {
			if (nod[j].sign != -1) continue;
			nod[j].sign = i;
			q.push(j);
		}
	}
	repi(i, 1, N) {
		if (nod[i].sign == -1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	repi(i, 1, N) {
		cout << 1 + nod[i].sign << endl;
	}
	return 0;
}

Measured memory_bytes: 10680
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main() {
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

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

int main()
{
	int n,k,b,min=999999999;
	vector<int> h;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> b;
		h.push_back(b);
	}
	sort(h.begin(),h.end());
	for(int i=0;i<h.size()-(k-1);i++){
		if(min>(abs(h[i]-h[i+k-1]))){
			min=abs(h[i]-h[i+k-1]);
		}
	}
	cout << min;
	return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(scn.useDelimiter("[\\s,]+"); scn.hasNextInt();) {
            int num = scn.nextInt();
            double weight = scn.nextDouble(), height = scn.nextDouble();
            if(weight / Math.pow(height, 2) >= 25) {
                System.out.println(num);
            }
        }
    }
}

Measured memory_bytes: 27752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    bool notcommon;
    cin >> s >> t;
    for (int i = s.size() - t.size(); i >= 0; i--) {
        notcommon = false;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] != '?' && s[i + j] != t[j]) {
                notcommon = true;
                break;
            }
        }
        if (notcommon) {
            continue;
        }

        for (int j = 0; j < t.size(); j++) {
            s[i + j] = t[j];
        }
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == '?') {
                s[j] = 'a';
            }
        }
        cout << s << endl;
        return 0;
    }

    puts("UNRESTORABLE");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x, y, a, b;

int main()
{
    //freopen("zzz.inp", "r", stdin);
    ios::sync_with_stdio(0);
    cin >> a >> b;
    x = ceil(a / 0.08);
    y = ceil(b / 0.1);
    if (x == y)
        return cout << x, 0;
    if (x > y)
        cout << ((x * 0.1 >= b && x * 0.1 < b + 1) ? x : -1);
    else
        cout << ((y * 0.08 >= a && y * 0.08 < a + 1) ? y : -1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    // 全部 mod5 = k であるような素数ならok
    vector<int> primes;
    vector<bool> isP(55556);
    for(int i=0; i<=55555; i++){
        isP[i] = true;
    }
    isP[0] = false;
    isP[1] = false;

    for(int i=2; i<=55555; i++){
        if(isP[i] == true){
            for(int j=i; j<=55555; j+=i){
                isP[j] = false;
            }
            if(i % 5 == 3){
                primes.push_back(i);
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << primes[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

//Mysterious Onslaught
public class Main{

	int[] d;
	int res, M = (0x1f)<<20;
	List<Integer> mask;
	
	void f(int S, int depth, int k){
		if((S&M)==0){
			res = Math.min(res, depth+d[S]);
			return;
		}
		if(res<=depth+d[(0xfffff)&S] || k==mask.size())return;
		f(S^mask.get(k), depth+1, k+1);
		f(S, depth, k+1);
	}
	
	void run(){
		d = new int[1<<20];
		int INF = 1<<28;
		Arrays.fill(d, INF);
		d[0] = 0;
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(0);
		while(!q.isEmpty()){
			int S = q.poll();
			for(int i=0;i<4;i++)for(int j=0;j<5;j++)for(int h=i;h<4;h++)for(int w=j;w<5;w++){
				int ns = S;
				for(int y=i;y<=h;y++)for(int x=j;x<=w;x++)ns^=1<<(y*5+x);
				if(d[ns]==INF){
					d[ns] = d[S]+1;
					q.add(ns);
				}
			}
		}
		mask = new ArrayList<Integer>();
		for(int j=0;j<5;j++)for(int h=4;h>=0;h--)for(int w=j;w<5;w++){
			int m = 0;
			for(int y=4;y>=h;y--)for(int x=j;x<=w;x++)m+=1<<(y*5+x);
			mask.add(m);
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
//			long T = System.currentTimeMillis();
			int x = 0;
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(sc.nextInt()==1)x|=1<<(i*5+j);
			res = 9;
			if(n<=4)res=d[x];
			else f(x, 0, 0);
			while(res--!=0)System.out.print("myon");
			System.out.println();
//			System.out.println(System.currentTimeMillis()-T);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 55000
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
typedef long long ll;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ll n, p;
    cin >> n >> p;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    ll i = 2, ans = 1;
    while(i <= sqrt(p)){
        ll d = (ll)pow(i, n);
        while(p%d == 0){
            ans *= i;
            p /= d;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int main(){
  int N;
  char str[10000+1];
  scanf("%d %s",&N,str);
  for(int i=0;i<strlen(str);i++){
    printf("%c",(str[i]+N-'A')%26+'A');
  }printf("\n");
  return 0;
}

Measured memory_bytes: 128
s=input()
p=int(s[:2])
q=int(s[2:])
if 0<q<13 and 0<p<13:print("AMBIGUOUS")
elif  0<q<13 and 0<=p:print("YYMM")
elif  0<p<13 and 0<=q:print("MMYY")
else: print("NA")

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        int input = inp.nextInt();
        int jam, menit, detik;
        jam = input / 3600;
        menit = (input % 3600)/60;
        detik = (input % 3600)%60;
        System.out.println(jam+":"+menit+":"+detik);
    }
}


Measured memory_bytes: 26388
#include<iostream>
#include<string>
#include<algorithm>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N;
    int t[100000];
    int x[100000];
    int y[100000];
    int me_x=0,me_y=0;
    bool can;
    cin >> N;
    rep(i,N){
        cin >> t[i];
        cin >> x[i];
        cin >> y[i];
    }
    rep(i,N){
        bool can2 = false;
        if (i == 0 && t[0] >= abs((x[i] + y[i]))){
            if ( (t[0] - abs((x[i] + y[i]))) % 2 == 0){
                me_x = x[i];
                me_y = y[i];
                can2 = true;
                continue;
            }
        }
        if((t[i] - t[i-1]) >= abs((x[i] + y[i]) - (me_x + me_y))){
            //cout << (t[i] - t[i-1]) - abs((x[i] + y[i]) - (me_x + me_y)) << endl;
            if ( ((t[i] - t[i-1]) - (abs((x[i] + y[i]) - (me_x + me_y)))) % 2 == 0){
                me_x = x[i];
                me_y = y[i];
                can2 = true;
                //cout << 1 << endl;
            }
        }
        if (can2) can = true;
        else {
            can = false;
            break;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408