akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  vector<int> line(3);
  foreach(i,line)i=in();
  cout << accumulate(all(line),line[0],lambda(int,int a,int b){return min(a,b);}) << " ";
  cout << accumulate(all(line),line[0],lambda(int,int a,int b){return max(a,b);}) << endl;
}



Measured memory_bytes: 3256
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$a = $sc->nextInt();
$b = $sc->nextInt();
$count = 0;

for($i=$a;$i<$b+1;$i++){
    $original_num = (string)$i;
    $reversed_num = strrev($original_num);
    if($original_num == $reversed_num){
        $count++;
    }
}

echo $count.PHP_EOL;


Measured memory_bytes: 16208
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 18;

int n, a[N][2];
int dp[1LL << N][52];

int solve(int idx, int msk, int lst){
   if (msk + 1 == 1LL << n){
      return 0;
   }
   int &ans = dp[msk][lst];
   if(ans != -1)
      return ans;
   ans = inf;
   int notused = 0;
   for (int i = 0; i < n; ++i)
   {
      if(msk & (1LL << i)){
         continue;
      }
      int sign = (idx % 2) != (i % 2);
      if(a[i][sign] >= lst){
         smin(ans, notused + solve(idx+1, msk | (1LL << i), a[i][sign]));
      }
      notused++;
   }
   return ans;
}

int32_t main(){_
   
   cin>>n;

   for (int i = 0; i < 2; ++i)
   {
      for (int j = 0; j < n; ++j)
      {
         cin >> a[j][i];
      }
   }
   
   memset(dp, -1, sizeof dp);   

   int ans = solve(0, 0, 0);
   if(ans >= inf)ans = -1;
   cout<<ans;

   return 0;
}

Measured memory_bytes: 106752
n, m, l = map(int, input().split())
A = []
B = []
for line in range(n):
    A.append(list(map(int, input().split())))
for line in range(m):
    B.append(list(map(int, input().split())))

C = []
for lines in range(n):
    C.append([sum([A[lines][i] * B[i][j] for i in range(m)]) for j in range(l)])
    print(" ".join(map(str, C[lines])))

Measured memory_bytes: 8976
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
lis = []
for i in range(5):
    lis.append(I())
print(4+math.ceil(n/min(lis)))


Measured memory_bytes: 3316
H, W = map(int, input().split())
S = ['.'*(W+1)] + ['.'+input() for h in range(H)]

dp = [[float('inf')]*(W+1)] + [[float('inf')] + [0]*W for h in range(H)]
for h in range(1, H+1):
  for w in range(1, W+1):
    if h*w == 1:
      if S[h][w] == '#':
        dp[h][w] = 1
      continue
    if S[h][w] == '.':
      dp[h][w] = min(dp[h][w-1], dp[h-1][w])
    else:
      if S[h][w-1] == S[h-1][w] == '.':
        dp[h][w] = min(dp[h-1][w], dp[h][w-1]) + 1
      elif S[h][w-1] == '#' and S[h-1][w] == '.':
        dp[h][w] = min(dp[h][w-1], dp[h-1][w]+1)
      elif S[h][w-1] == '.' and S[h-1][w] == '#':
        dp[h][w] = min(dp[h][w-1]+1, dp[h-1][w])
      else:
        dp[h][w] = min(dp[h][w-1], dp[h-1][w])

print(dp[H][W])

Measured memory_bytes: 3188
/*
	@author: cheerioskun
*/
#pragma GCC target("popcnt")
#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(N) for(int i = 0;i < N; ++i)
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;

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

int main(){
	fast_io
	int N;
	cin>>N;
	forn(N){
		cin>>a[i]>>b[i]>>c[i];
	}
	ll next[3], cur[3];
	cur[0] = a[0], cur[1] = b[0], cur[2] = c[0];
	next[0] = -1, next[1] = -1, next[2] = -1;
	for(int i = 1;i < N; ++i){
		next[0] = a[i] + max(cur[1], cur[2]);
		next[1] = b[i] + max(cur[0], cur[2]);
		next[2] = c[i] + max(cur[0], cur[1]);
		for(int j = 0;j < 3; ++j) cur[j] = next[j];
	}
	cout<<max(cur[0], max(cur[1], cur[2]))<<endl;
	#ifndef ONLINE_JUDGE
    	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}



Measured memory_bytes: 4816
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static ConsoleApplication.Utils;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine();
            var res = s.Zip(s.Skip(1), (first, second) => new {first, second}).Count(x => x.first != x.second);
            WriteLine(res);
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static long ReadLong()
            => ReadLine().ToLong();
        public static int ReadInt()
            => ReadLine().ToInt();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<string> ReadStrings()
            => ReadLine().Split(' ');

        public static IEnumerable<string> ReadLines(int n)
        {
            foreach (var i in Enumerable.Range(0, n))
            {
                yield return ReadLine();
            }
        }

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;

        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static double ToDouble(this string str)
            => double.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }

        public static IEnumerable<T> Peek<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
            return source;
        }
    }
}


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

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class agcD {
private:
    void dfs(int u, int par, const vector<vector<int>>& g, vector<int>& fin) {
        for (int v : g[u]) {
            if (v != par && !fin[v]) {
                dfs(v, u, g, fin);
            }
        }
        
        for (int v : g[u]) {
            if (v != par && !fin[v]) {
                fin[v] = fin[u] = 1;
                return;
            }
        }
    }
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<vector<int>> g(N);
        for (int i = 0; i + 1 < N; ++i) {
            int a, b;
            in >> a >> b;
            g[a-1].push_back(b-1);
            g[b-1].push_back(a-1);
        }
        
        vector<int> fin(N, 0);
        dfs(0, -1, g, fin);
        
        for (int u = 0; u < N; ++u) {
            if (!fin[u]) {
                out << "First\n";
                return;
            }
        }
        out << "Second\n";
    }
};


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

	agcD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
int AB = max(a,b) - min(a,b) , AC = max(a,c) - min(a,c) , BC = max(b,c) - min(b,c);


if(AC <= d || AB <=d && BC <= d){
	cout << "Yes" << endl;
}

else {
	cout << "No" << endl;
}
}


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

using ll = long long;

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

int a[N], mem[N], n, k;

int dp(int i)
{
    if(i > n)
        return INF;
        
    if (i == n - 1)
        return 0;

    if(mem[i] != -1)
        return mem[i];

    int ans = INF;
    for (int j = 1; j <= k; j++)
        ans = min(ans, abs(a[i] - a[i + j]) + dp(i + j));

    mem[i] = ans;

    return mem[i];
}

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

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    memset(mem, -1, sizeof(mem));

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


Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		
		int n = in.nextInt();
		
		
		for(int i = 0; i < 2 * n; i++) {
			list.add(in.nextInt());
		}
		in.close();
		
		Collections.sort(list);
		
		int ans = 0;
		for(int i = 0; i < list.size(); i++) {
			ans += list.get(i);
			i++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22228
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, h, w;

int m[1005][1005];
int dp[1005][1005];
void change(int n){
	memset(dp, 0, sizeof(dp));
	dp[0][0] = n;
	REP(i, h)REP(j, w){
		dp[i+1][j] += dp[i][j]>>1;
		dp[i][j+1] += dp[i][j]>>1;
		if(dp[i][j]&1) (m[i][j] ? dp[i][j+1] : dp[i+1][j]) ++;
		m[i][j] ^= dp[i][j]&1;
	}
}

pii go(int y, int x){
	while(y<h && x<w){
//		cout << x << ", " << y << endl;
		if(m[y][x]) x++;
		else y++;
	}
	return pii(y+1, x+1);
}

main(){
	while(scanf("%d%d%d", &h, &w, &n), h){
		vi p(n);
		REP(i, h)REP(j, w) scanf("%d", &m[i][j]);
		change(n-1);
		pii res = go(0, 0);
		cout << res.first << " " << res.second << endl;
	}
	return 0;
}

Measured memory_bytes: 48092
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main(){
	int n;
	string str;
	while(cin>>n,n){
		int a[26][26]={0};
		int b[26][2]={0};
		int c[26]={0};
		int flag=1;
		for(int i=0;i<n;i++){
			cin>>str;
			a[str[0]-'a'][str[str.size()-1]-'a']++;
			b[str[0]-'a'][0]++;
			b[str[str.size()-1]-'a'][1]++;
		}
		for(int i=0;i<26;i++)if(b[i][0]!=b[i][1])flag=0;
		
		if(flag){
			int POS=-1;
			for(int i=0;POS==-1;i++)if(b[i][1])POS=i;
			
			c[POS]=1;
			queue<int>name;
			name.push(POS);
			
			while(name.empty()==0){
				for(int i=0;i<26;i++){
					if(a[name.front()][i]>0&&c[i]==0){
						c[i]=1;
						name.push(i);
					}
				}
				name.pop();
			}
			
			for(int i=0;i<26;i++)if(b[i][1]>0&&c[i]==0)flag=0;
			
		}
		
		if(flag)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  cout<<(ll)(n-1)*(n)/2<<endl;

  return 0;

}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::{stdin, stdout, BufRead, BufWriter, Write};

fn main() {
    let mut n = String::new();
    let stdin = stdin();
    let mut stdinlock = stdin.lock();
    let _ = stdinlock.read_line(&mut n).expect("read_line");
    let n: usize = n.trim().parse().expect("N");
    let mut balls: Vec<u32> = Vec::with_capacity(n);
    let mut scores: HashMap<u32, u32> = HashMap::new();
    {
        let mut input = String::new();
        let _ = stdinlock.read_line(&mut input).expect("read_line");
        for a in input
            .trim()
            .split_whitespace()
            .map(|n| n.parse().expect("parse"))
        {
            balls.push(a);
            let e = scores.entry(a).or_insert(0);
            *e += 1;
        }
    }
    let mut total: u64 = 0;
    for &v in scores.values() {
        let v = v as u64;
        total += v * (v - 1) / 2;
    }

    let stdout = stdout();
    let mut stdoutlock = stdout.lock();
    for ak in &balls {
        let this_original = *scores.get(ak).expect("ak") as u64;
        let _ = write!(stdoutlock, "{}\n", total + 1 - this_original).expect("Flush");
    }
    stdoutlock.flush().expect("flush");
}


Measured memory_bytes: 7564
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <string>

using namespace std;

int main() {
	int64_t N,M;
	cin>>N>>M;
	int64_t *favorite=new int64_t[M];
	for(int i=0;i<M;i++){
		favorite[i]=0;
	}
	for(int loop=0;loop<N;loop++){
		int64_t num ;
		cin>>num;
		for(int loop2=0;loop2<num;loop2++){
			int64_t v;
			cin>>v;
			++favorite[v-1];
		}
	}
	int64_t ans=0;
	for(int i=0;i<M;i++){
		if(favorite[i]==N){
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;

}


Measured memory_bytes: 256
from collections import Counter, defaultdict

N, M = map(int, input().split())
X = list(map(int, input().split()))

cntMod = defaultdict(int)
cntDup = defaultdict(int)

for x, c in Counter(X).items():
    cntMod[x % M] += c
    cntDup[x % M] += c // 2

ans = 0
for m in range(M):
    if m > M // 2:
        break
    n = (M - m) % M

    if n == m:
        ans += cntMod[n] // 2
    else:
        mi = min(cntMod[n], cntMod[m])
        ans += mi
        cntMod[n] -= mi
        cntMod[m] -= mi
        ans += min(cntMod[n] // 2, cntDup[n])
        ans += min(cntMod[m] // 2, cntDup[m])

print(ans)


Measured memory_bytes: 36056
#include<cstdio>;
//入出力を行う関数が使える//(scanf,printf)
#include<cctype>;
//文字の種類の判定や文字の変換を行う関数を使うことができる//

int main(){
    char ch;
    
    while(true){
        scanf("%c",&ch);
        //文字（1文字）として入力する//
        if (isalpha(ch)){
            //chがアルファベットならtrueを返す//
            if(islower(ch)) printf("%c",toupper(ch));
            //chが小文字ならtrueを返す// //chの大文字を返す//
            else printf("%c", tolower(ch));
            //chの小文字を返す//
        } else printf("%c",ch);
        //アルファベット以外はそのまま出力//
        
        if (ch == '\n') break;
        //終端文字が現れたら終了//
    }
    return 0;
}


Measured memory_bytes: 2600
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<pll> A(n);
    for(auto &I:A){cin>>I.F>>I.S;}
    sort(A.begin(),A.end());
    ll ans=0;
    for(auto &I:A){
        if(I.S>=m){ans+=m*I.F; m=0;}
        else{ans+=I.F*I.S; m-=I.S;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int[] NK = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = NK[0];
            int K = NK[1];

            List<long> nbrs = new List<long>();

            for(int i = 0; i < N; i++)
            {
                nbrs.Add(long.Parse(Console.ReadLine()));
            }

            long res = long.MaxValue;
            nbrs.Sort();

            for(int i = 0; i < N - (K - 1); i++)
            {
                long temp = Math.Abs(nbrs[i] - nbrs[i + K - 1]);

                if (temp < res)
                    res = temp;
            }

            
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 17116
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> v(n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < d; j++)
		{
			v[i].resize(d);
			cin >> v[i][j];
		}

	//for (auto v1 : v)
	//{
	//	for (auto v2 : v1)
	//	{
	//		cout << v2 << " ";
	//	}
	//	cout << endl;
	//}
	//system("pause");
	//return 0;

	int count = 0;
	for (int k = 0;k < n;k++)
		for (int i = k+1; i < n; i++)
		{
			float sum = 0;
			for (int j = 0; j < d; j++)
			{
				sum += pow(v[k][j] - v[i][j], 2);
			}
			float sq = sqrt(sum);
			if (sq == (int)sq)
				count++;
		}
	cout << count;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(void){

    int A,B,C,i,AB=0,AC=0,BC=0;
       scanf("%d %d %d",&A,&B,&C);
    
    if(A == B) AB = 1;
    if(A == C) AC = 1;
    if(B == C) BC = 1;

    //printf("%d %d %d\n",AB,AC,BC);
    if(AB == 1 && AC == 1 && BC == 0) printf("Yes\n");
    else if(AB == 1 && AC == 0 && BC == 1) printf("Yes\n");
    else if(AB == 0 && AC == 1 && BC == 1) printf("Yes\n");
    else if(AB == 0 && AC == 0 && BC == 1) printf("Yes\n");
    else if(AB == 0 && AC == 1 && BC == 0) printf("Yes\n");
    else if(AB == 1 && AC == 0 && BC == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
arr = []
for i in range(n):
    x,y = list(map(int,input().split()))
    arr.append([x,y])
f = 0
cnt = 0
for i in arr:
    if i[0]==i[1]:
        cnt+=1
        if cnt==3:
            f = 1
    else:
        cnt = 0
if f==1:
    print("Yes")
else:
    print("No")


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	ll n,m;cin >> n >> m;
	vector<vector<pair<ll,ll>>> v(n);
	vector<pair<ll,pair<ll,ll>>> edge(m);
	
	REP(i,m){
		ll a,b,c;cin >> a >> b >> c;
		a--;b--;
		edge[i] = MP(c,MP(a,b));
		v[a].PB(MP(b,c));
		v[b].PB(MP(a,c));
	}
	
	vector<ll> val(n,-INF);
	vector<ll> color(n);

	DBG(cout << "VAL" << endl;SHOW1d(val,n);)

	val[0] = 1;
	color[0] = 1;
	
	queue<ll> q;
	q.push(0);
	bool kisuu = false;
	
	while(!q.empty()){
		
		ll now = q.front();q.pop();
		DBG(cout << "IN WHILE " << now << ' ' << val[now] << endl;)
		REP(i,v[now].size()){
			ll aite = v[now][i].FI;
			ll cost = v[now][i].SE;
			if(val[aite] == -INF){
				val[aite] = cost - val[now];
				color[aite] = -color[now];
				q.push(aite);
			}
			else{
				if(color[now] == color[aite]){
					kisuu = true;
				}
			}
		}
	}
	
	ll pla = - INF;
	REP(i,m){
		ll a = edge[i].SE.FI;
		ll b = edge[i].SE.SE;
		ll c = edge[i].FI;
		
		if(val[a] + val[b] != c){
			if(color[a] == color[b]){
				ll tmp = c - (val[a] + val[b]);
				if(tmp % 2 != 0){
					cout << 0 << endl;
					return 0;
				}
				if(pla != -INF){
					if((tmp / 2) * color[a] != pla){
						cout << 0 << endl;
						return 0;
					}
				}
				pla = (tmp / 2) * color[a];
			}
			else{
				cout << 0 << endl;
				return 0;
			}
		}
	}
	
	if(pla != -INF){
		REP(i,n){
			val[i] += pla * color[i];
		}
	}
	
	ll mip = INF;
	ll mim = INF;
	
	REP(i,n){
		if(color[i] == 1){
			mip = min(mip,val[i]);
		}
		else{
			mim = min(mim,val[i]);
		}
	}
	
	if(mip <= 0 && mim <= 0){
		cout << 0 << endl;
		return 0;
	}
	
	DBG(cout << "VAL" << endl;SHOW1d(val,n);)
	DBG(cout << mip << ' ' << mim << endl;)
	if(kisuu){
		if((mip + mim - 1LL) > 0)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else{
		cout << max(0LL,(mip + mim - 1LL)) << endl;
	}

	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char str[5];
    while(cin>>str){
        int a,b;
        a=(str[0]-'0')*10+(str[1]-'0');
        b=(str[2]-'0')*10+(str[3]-'0');
        //cout<<a<<b<<endl;
        if(a>0&&a<13 && b>0 && b<13)cout<<"AMBIGUOUS"<<endl;
        else if(a>0&&a<13)cout<<"MMYY"<<endl;
        else if(b>0&&b<13)cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
X = int(input())
flag = 1
if X < 100:
  flag = 0
else:
  a = X%100
  b = a%10
  c = (a-b)/10
  count = 2*c
  if 1 <= b <= 5:
    count += 1
  elif 6<= b <= 9:
    count += 2
  if X//100 < count:
    flag = 0
print(flag)

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

n,m=map(int,input().split())
kosu=[1]*n
can=[0]*n
can[0]=1
for _ in range(m):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    if can[x]==1:
        can[y]=1
    kosu[x]-=1
    kosu[y]+=1
    if kosu[x]==0:
        can[x]=0
print(can.count(1))


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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d);
	
	random_device rnd;
    mt19937 mt(rnd());
	rep (i, d) t[i] = mt()%n + 1;
	int ans = -1;
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 200000) break;
		vector<int> old = t;
		const int CH = mt()%5 + 1; // CH箇所変える
		rep(i, CH) {
			int nd = mt()%d;
			int nq = mt()%n + 1;
			t[nd] = nq;
		}
		
		// 点数の再計算
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]-1];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
			// cout << cnt << " :" << ans << endl;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3796
package main

import "fmt"

func main() {
	var (
		a, b, c int
	)

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if (a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1764
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a,b;
    cin >> a >> b;
    string res = "Impossible";

    if(a % 3 == 0)res = "Possible";
    if(b % 3 == 0)res = "Possible";
    if((a+b) % 3 == 0)res = "Possible";

    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt();
        int h = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        
        if(2*x == w && 2*y == h ) {
        	System.out.println((Double.valueOf(w)*Double.valueOf(h) / Double.valueOf(2))+ " 1");
        } else {
        	System.out.println((Double.valueOf(w)*Double.valueOf(h) / Double.valueOf(2))+ " 0");
        }
    }
    
    
 
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define P pair<ll,ll>
#define fs first
#define sc second

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    
    if(k <= a) cout << k << endl;
    else if(k <= a+b) cout << a << endl;
    else cout << a - (k - a - b) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int s = 0, t = 0;

  while (c > 0) {
    c -= b;
    s += 1;
  }
  while (a > 0) {
    a -= d;
    t += 1;
  }

  if (s > t) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

def main():
    n = int(input())

    li = []
    flag = 0

    def check(x):
        return x >= 1 and x < 10

    for i in reversed(range(1, 10)):
        if n % i == 0:
            x = n // i
            if check(x):
                print("Yes")
                flag = 1
                break
            else:
                print("No")
                flag = 1
                break


    if flag == 0:
        print("No")




if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    const char* str = s.c_str();
    int ans = strlen(str);
    int count[4] = {0};
    int last,flag = 0;
    for(int i = 0;i < ans;i+=2){
        if(i == ans-1){
            last = str[i];
            flag = 1;
        }else {
            std::string answer(str, i, 2);
            if (answer == "00") {
                count[0] = count[0] + 1;
            } else if (answer == "01") {
                count[1] = count[1] + 1;
            } else if (answer == "10") {
                count[2] = count[2] + 1;
            } else if (answer == "11") {
                count[3] = count[3] + 1;
            }
        }
    }
    int answer = 0;
    if(count[1] > count[2]) {
        answer = count[0] + count[2] * 2 + count[3];
    }else{
        answer = count[0] + count[1] * 2 + count[3];
    }
    if(str[0] != last && flag == 1){
        answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int h,w,cnt,dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
string ans,dir = "URDL";
vector<string> g;

bool dfs(int y,int x,int d,int rem){
  if(rem==cnt)return true;
  char tmp = g[y][x];
  g[y][x] = '.';

  for(int i=3;i<=5;i++){
    int nd = (d+i)%4, ny = y + dy[nd], nx = x + dx[nd];
    while(ny>=0 && nx>=0 && ny<h && nx<w){
      if(g[ny][nx] == 'o'){
	ans[rem] = dir[nd];
	if(dfs(ny,nx,nd,rem+1))return true;
	break;
      }
      ny += dy[nd]; nx += dx[nd];
    }
  }

  g[y][x] = tmp;
  return false;
}

int main(){
  int y,x,d;
  cin >> h >> w;
  g.resize(h);
  for(int i=0;i<h;i++){
    cin >> g[i];
    for(int j=0;j<w;j++){
      if(isupper(g[i][j])){
	y = i; x = j;
	for(int k=0;k<4;k++){
	  if(dir[k] == g[i][j])d = k;
	}
      }else if(g[i][j] == 'o')cnt++;
    }
  }
  ans.resize(cnt);
  dfs(y,x,d,0);
  cout << ans << endl;
}

Measured memory_bytes: 1220
N = int(input())
L = [int(i) for i in input().split()]
L.sort()

from bisect import bisect_left

ans = 0
# a < b < c
for a in range(N):
    for b in range(a+1, N):
        right = bisect_left(L, L[a] + L[b])
        # [b+1, right)
        ans += max(0, right - (b + 1))

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N, S;
	cin >> N >> S;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	vector<vector<ll>> dp(N + 1, vector<ll>(S + 1, 0));

	repn(i, N)dp[i][0] = 1;

	repn(i, N)repn(j, S) {
		if (j < A[i]) { dp[i][j] = dp[i - 1][j]; }
		if (j == A[i]) {
			dp[i][j] = dp[i - 1][j] + i;
		}
		if (j > A[i]) {
			dp[i][j] = dp[i - 1][j] + dp[i - 1][j - A[i]];
		}

		dp[i][j] %= MOD;
	}

	ll ans = 0;

	repn(i, N) {
		ll X = dp[i][S] - dp[i - 1][S];
		X *= (N - i + 1);
		ans += X;
		ans %= MOD;
		if (ans < 0) { ans += MOD; }
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 71032
#C-115
n, k = [int(i) for i in input().split()]
h = []
for ni in range(n):
  h.append(int(input()))
h.sort()
ans = max(h)
for ni in range(n-k+1):
  tmp = h[ni+k-1] - h[ni]
  if tmp < ans:
    ans = tmp
print(ans)
    

Measured memory_bytes: 7444
program proA
  implicit none
  integer*8 n,i,ans,j,max,tmp,keta
  character(20) str

  read(*,*) n

  do j=0,16
     if(dble(n)<10**j) exit
  end do

  tmp=0
  keta=j
  j=j-1

  ans=n-10**j+1
  ans=ans/10**j+9*j
  write(*,*)ans
      
end program proA


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> A(N),B(N);
    rep(i,N)cin>>A.at(i)>>B.at(i);
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2!=0)cout<<B.at(N/2)-A.at(N/2)+1<<endl;
    else cout<<B.at(N/2)+B.at(N/2-1)-A.at(N/2)-A.at(N/2-1)+1<<endl;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1e18;
int n;
string s;
vector<long long> Esum(300300, 0);
vector<long long> Wsum(300300, 0);

int main() {
    cin >> n >> s;
    for(int i = 0; i < n; ++i) {
        if(s.at(i) == 'W') {
            Wsum.at(i+1)++;
        }else {
            Esum.at(i+1)++;
        }
    }

    for(int i = 0; i <= n; ++i) {
        Wsum.at(i+1) += Wsum.at(i);
        Esum.at(i+1) += Esum.at(i);
    }

    /*for(int i = 0; i <= n+1; ++i) {
        cout << Wsum.at(i) << " " << Esum.at(i) << endl;
    }*/

    long long ans = INF;
    for(int i = 1; i <= n; ++i) {
        long long Wcnt = Wsum.at(i-1) - Wsum.at(0);
        long long Ecnt = Esum.at(n+1) - Esum.at(i);
        // cout << "W E " << Wcnt << " " << Ecnt << endl;
        long long sum = Ecnt + Wcnt;
        chmin(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,s1,s2,minv=2100000000;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)  cin>>a[i];
	for(i=0;i<n;i++)
	{
		s1=0;
		s2=0;
		for(j=0;j<=i;j++)   s1+=a[j];
		for(j=i+1;j<n;j++)  s2+=a[j];
		if(fabs(s1-s2)<minv)  minv=fabs(s1-s2);
	}
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

static void do_calc(int m, int f, int r);

int
main(int argc, char *argv[])
{
  for(;;) {
    int m, f, r;
    scanf("%d%d%d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    do_calc(m, f, r);
  }
  return 0;
}

static void
do_calc(int m, int f, int r)
{
  if (m == -1 || f == -1) {
    printf("%s\n", "F");
    return;
  }
  int sum = m + f;
  if (sum >= 80) {
    printf("%s\n", "A");
    return;
  } else if (sum >= 65 && sum < 80) {
    printf("%s\n", "B");
    return;
  } else if (sum >= 50 && sum < 65) {
    printf("%s\n", "C");
    return;
  } else if (sum >= 30 && sum < 50) {
    if (r >= 50) {
      printf("%s\n", "C");
      return;
    }
    printf("%s\n", "D");
    return;
  } else {
    printf("%s\n", "F");
    return;
  }
}

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

bool ss[100010];

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

    int uniq = 0;
    int dup = 0;
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        if (ss[a]) {
            dup++;
        } else {
            ss[a] = true;
            uniq++;
        }
    }

    cout << (dup % 2 ? uniq - 1 : uniq) << endl;
    return 0;
}


Measured memory_bytes: 384
s = input()
ans = []
for x in s:
    if x == 'B' and len(ans):
        ans.pop()
    elif x == 'B' and len(ans) == 0:
        pass
    else:
        ans.append(x)
ans_s = ''
for x in ans:
    ans_s += x
print(ans_s)

Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		StringBuffer S = new StringBuffer(sc.next());
		int v=0;
		
		for(int i=1;i<S.length();i++) {
			
			if(S.charAt(i)!=S.charAt(i-1))v++;
			
			
		}
		p(v);
		
		
	}
	
		
	
	
		
	
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 26860
#include<iostream>
#include<algorithm>
using namespace std;
int dp[101][10001];
int main(){
  int n,W;
  int v[101],w[101];
  cin>>n>>W;
  for(int i=1;i<=n;i++){
    cin>>v[i]>>w[i];
  }
  
  for(int i=0;i<=W;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<=n;i++){
    dp[i][0]=0;
  }
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=W;j++){
      if(j>=w[i]){
	dp[i][j]=max(dp[i-1][j],dp[i][j-w[i]]+v[i]);
      }else{
	dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 5104
# -*- coding: utf-8 -*-

def main():
    l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())

    print(l[K-1])

if __name__ == "__main__":
    main()


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

int main() {
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    string S;
    cin >> S;
    cout << mp[S] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,x,y;

	cin >> a >> b >> c >> x >>y;

	int MIN = a * x + b * y;

	rep(i, 0, max(x, y) + 1) {
		int ans = 2 * c * i + max(0, x - i) * a + max(0, y - i) * b;

		MIN = min(MIN, ans);
	}

	
	cout << MIN << endl;

}
	

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end


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

    ll n, m;
    in >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    vector<bool> node(200001, false);
    bool ans = false;
    REP(i, m){
        in >> a[i] >> b[i];
        if(b[i] == n){
            node[a[i]] = true;
        }
    }
    REP(i, m){
        if(a[i] == 1 and node[b[i]]){
            ans = true;
        }
    }
    if (ans) out << "POSSIBLE" << endl;
    else out << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 3456
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    A=bisect_left(a,b[i])
    C=n-bisect_right(c,b[i])
    ans+=A*C
print(ans)


Measured memory_bytes: 23232
n = int(input())

a = [int(x) for x in input().split() ]
sum = a[0]

if 0 in a:
        sum = 0
else:
    for i in range(1,len(a)):
        sum = sum * a[i]
        if sum > 10**18:
            break
        


if sum > 10**18:
    print(-1)
else:
    print(sum)

Measured memory_bytes: 21688
import sys


def resolve(in_):
    A, B = map(int, in_.readline().split())

    for i in range(1, 1251):
        if i * 8 // 100 == A and i // 10 == B:
            return i 

    return -1


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>

using namespace std;

int main( void )
{
	double a;
	while(cin >> a) {
		double sum = a;
		for(int i=2; i <= 10; ++i) {
			if(i & 1)	a /= 3.0;
			else		a *= 2.0;
			sum += a;
		}
		printf("%.8lf\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;
int par[100002];
int dep[100002];
// n要素で初期化
void init (int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        dep[i] = 0;
    }
}

// 木の根を求める
int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (dep[x] < dep[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (dep[x] == dep[y]) dep[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> r;
    r.resize(N+1);
    int x, y;
    init(N);
    rep(i, N){
        int tmp;
        cin >> tmp;
        r[tmp-1] = i;
    }

    rep(i, M){
        cin >> x >> y;
        unite(x-1, y-1);
    }

    int ans = 0;

    rep(i, N){
        if (same(i, r[i])) {
            ans++;
        }
    }

    cout << ans << endl;




}

Measured memory_bytes: 1408