akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	X, Y, Z, K := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(X)
	B := sc.nextIntSlice(Y)
	C := sc.nextIntSlice(Z)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	sort.Sort(sort.Reverse(sort.IntSlice(B)))
	sort.Sort(sort.Reverse(sort.IntSlice(C)))
	D := []int{}
	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			for k := 0; k < Z; k++ {
				if (i+1)*(j+1)*(k+1) <= K {
					D = append(D, A[i]+B[j]+C[k])
				} else {
					break
				}
			}
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(D)))
	for i := 0; i < K; i++ {
		fmt.Fprintln(wtr, D[i])
	}
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    int N;cin>>N;
    int ans = 0;
    for(int i = 1;i<=N;i++){
        if (i%2==0) continue;
        ll cnt = 0;
        for(int j = 1; j * j <= i; j++)
        {
            if (j*j==i) cnt = -INF;
            if(i%j == 0) cnt++;
        }
        if(cnt == 4){
            ans++;
            //cout<<i<<endl;
        }
        
    }
    cout<<ans<<endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];

    map<int, int> mp1, mp2;
    REP(i, n){
        if(i % 2 == 0){
            mp1[v[i]]++;
        }else{
            mp2[v[i]]++;
        }
    }

    int max1 = 0, max2 = 0;
    int num1 = 0, num2 = 0;
    
    for(auto x : mp1){
        if(x.second > max1) num1 = x.first;
        max1 = max(max1, x.second);
        
    }
    for(auto x : mp2){
        if(x.second > max2 && num1 != x.first) num2 = x.first, max2 = max(max2, x.second);
    }
    int ans = n - max1 - max2;
	
  	max1 = 0, max2 = 0, num1 = 0, num2 = 0;
    for(auto x : mp2){
        if(x.second > max1) num1 = x.first;
        max1 = max(max1, x.second);
        
    }
    for(auto x : mp1){
        if(x.second > max2 && num1 != x.first) num2 = x.first, max2 = max(max2, x.second);
    }

    cout << min(ans, n - max1 - max2) << endl;
}


Measured memory_bytes: 5376
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
n = int(input())
A = list(map(int, input().split()))

B = [None for _ in range(n)]

B[0] = (sum(A[::2]) - sum(A[1::2]))//2

for i in range(1,n):
    B[i] = A[i-1] - B[i-1]

for b in B:
    print(2*b)


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

#define int long long
#define ll long long
#define vll vector<int>
#define mset(a) memset(a,0,sizeof(a))
#define pb push_back
#define range(c) c.begin() , c.end()
#define forn(i,n) for(ll i=0; i<(int)n; ++i)
#define for1(i,n) for(ll i=1; i<(int)n; ++i)
#define endl '\n'
#define MOD 1000000007
#define pii pair<int,int>
#define test ll t;cin>>t;while(t--)
using namespace std;

vector<bool> sieve(ll n){
    vector<bool>prime(n+1,true);
    prime[0]=prime[1]=false;
    for(ll i=2; i<=n; ++i){
        if(prime[i]&&(i*i)<=n)
        for(ll j=i*i; j<=n; j+=i)prime[j]=false;
    }
    return prime;
}

ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

     

    int n;cin>>n;
    vll a(n);
    forn(i,n) cin>>a[i];
    vll dp(n+2,INT_MAX);

    dp[0]=0;
    forn(i,n-1) {
        dp[i+1] = min(dp[i+1], dp[i]+abs(a[i+1]-a[i]));
        dp[i+2] = min(dp[i+2], dp[i]+abs(a[i+2]-a[i]));
    }    
    cout<<dp[n-1]<<endl;

    return 0;
}


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

p_one = input()
p_one_list = p_one.split(' ')

zmax = int(p_one_list[0]) + int(p_one_list[1])
zmin = int(p_one_list[0]) + int(p_one_list[1])
wmax = int(p_one_list[0]) - int(p_one_list[1])
wmin = int(p_one_list[0]) - int(p_one_list[1])


for i in range(1, n):
    line = input()
    tmp = line.split(' ')
    z = int(tmp[0]) + int(tmp[1])
    w = int(tmp[0]) - int(tmp[1])
    zmax = max(zmax, z)
    wmax = max(wmax, w)
    zmin = min(zmin, z)
    wmin = min(wmin, w)


z_ans = zmax - zmin
w_ans = wmax - wmin


print(f'{max(z_ans, w_ans)}')


Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

int ans=INF;
int H,W;
vv<char> field;
vv<int> dp;

void dfs(int x,int y,int num) {
  if(x==W-1 && y==H-1){
    chmin(ans,num);
    return;
  }
  if(x+1<W && y<H){
    if(field[x][y]=='.' && field[x+1][y]=='#'){
      num++;
    }
    dfs(x+1,y,num);
  }
  if(x<W && y+1<H){
    if(field[x][y]=='.' && field[x][y+1]=='#'){
      num++;
    }
    dfs(x,y+1,num);
  }
}

signed _main(){
  cin >> H >> W;
  field.resize(H+1,v<char>(W+1,'.'));
  dp.resize(H+1,v<int>(W+1,0));
  for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
    cin >> field[i][j];
  }
  if(field[1][1]=='#') dp[1][1]=1;
  for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
    if(i==1 && j==1) continue;
    int tmp1=0,tmp2=0;
    if(field[i-1][j]=='.' && field[i][j]=='#') tmp1=1;
    if(field[i][j-1]=='.' && field[i][j]=='#') tmp2=1;
    if(i==1) dp[i][j]=dp[i][j-1]+tmp2;
    else if(j==1) dp[i][j]=dp[i-1][j]+tmp1;
    else dp[i][j]=min(dp[i-1][j]+tmp1,dp[i][j-1]+tmp2);
  }
  cout << dp[H][W] << endl;
/*

  if(field[0][0]=='#') dfs(0,0,1);
  else dfs(0,0,0);
  cout << ans << endl;
  */
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int i, a, h1, h2, h3;

    h1 = h2 = h3 = 0;
    for (i = 0; i < 10; i++){
        scanf("%d", &a);

        if (a >= h1){
            h3 = h2;
            h2 = h1;
            h1 = a;
        }else if (h1 > a && a >= h2){
            h3 = h2;
            h2 = a;
        }else if (h2 > a && a >= h3){
            h3 = a;
        }
        //printf("%d\n%d\n%d\n", h1, h2, h3);
    }

    printf("%d\n%d\n%d\n", h1, h2, h3);

    return (0);
}



Measured memory_bytes: 2104
#include <stdio.h>
 
int main(void)
{
    int i,o,p,q,n,m,l,hyou[100][100],youh[100][100],finish[100][100];
    long long sum;
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++)
    {
        for(o=0;o<m;o++)
        {
            scanf("%d",&hyou[i][o]);
        }
    }

    for(i=0;i<m;i++)
    {
        for(o=0;o<l;o++)
        {
            scanf("%d",&youh[i][o]);
        }
    }

    for(i=0;i<n;i++)
    {
        for(o=0;sum=0,o<l;o++)
        {
            for(p=0,q=0;p<m;p++,q++)
                sum+=hyou[i][p]*youh[q][o];
            printf("%lld%s",sum,o==l-1?"\n":" ");
        }
    }
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int pow2[100002];
int dp[100002][2];
int main(){
	string l;
	cin>>l;
	pow2[0]=1;
	for(int i=1;i<=100001;i++)
		pow2[i]=pow2[i-1]*2%mod;
	dp[0][0]=1;
	for(int n=0;n<l.size();n++)
			for(int smaller=0;smaller<2;smaller++)
				for(int x=0;x<=(smaller?1:l[n]-'0');x++)
					(dp[n+1][smaller||x<l[n]-'0']+=dp[n][smaller]*(x+1)%mod)%=mod;
	cout<<(dp[l.size()][0]+dp[l.size()][1])%mod<<endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

void monmo(){
    
}

int main() {
    map<string,int> m;
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"];
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main() {
 ll N;
  ll Q;
  cin >>N>>Q;
  string S;
  cin >>S;
  
  vl l(Q);
  vl r(Q);
  
  rep(i,Q) {
    cin >>l.at(i)>>r.at(i);
  }
 rep(i,N-1) {
if((S.at(i)=='A') &&(S.at(i+1)=='C')) {
  S.at(i)='a';
}
   }
   
   vl ps(N+1);
   rep(i,N+1) {
ps.at(i)=0;
   }
   
   if(S.at(0)=='a') {
ps.at(1)=1;
   }
   else {
     ps.at(1)=0;
   }
   
   
   repl(i,1,N) {
     if(S.at(i)=='a') {
       ps.at(i+1)=ps.at(i)+1;
     }
     else {
       ps.at(i+1)=ps.at(i);
     }
   }
   

   
   rep(i,Q) {
     cout<<ps.at(r.at(i)-1)-ps.at(l.at(i)-1)<<endl;
   }
   
   }
     
 

Measured memory_bytes: 3456
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int main(void) {
	int univ[2];
	for(int i = 0; i < 2; i++) {
		int score[10];
		for(int j = 0; j < 10; j++)
			scanf("%d", &score[j]);
		sort(score, score + 10, greater<int>());
		univ[i] = score[0] + score[1] + score[2];
	}
	printf("%d %d\n", univ[0], univ[1]);
	return 0;
}

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

using namespace std;

vector<vector<pair<int, int>>> edges;
vector<int> colors;

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

  int N;
  cin >> N;

  edges.resize(N);
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[--u].emplace_back(--v, w % 2);
    edges[v].emplace_back(u, w % 2);
  }
  colors.resize(N, -1);
  colors[0] = 0;

  queue<int> q;
  q.emplace(0);
  for (; !q.empty(); q.pop()) {
    auto cur = q.front();
    auto& nexts = edges[cur];
    for (auto next : nexts) {
      if (colors[next.first] == -1) {
        colors[next.first] = next.second ^ colors[cur];
        q.emplace(next.first);
      }
    }
  }

  for (auto color : colors) {
    cout << color << endl;
  }
}


Measured memory_bytes: 6784
exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def search(l,r,d,ind,table)
  c = 0
  if(l == r)
    @ans[ind] = d
    return 0
  end
  if(@memo[l] != nil)
    c += @memo[l][1]
    c += search(@memo[l][0],r,d+@memo[l][1],ind,table)
  else
    c += (table[l][0]-table[l+@d][0]).abs + (table[l][1]-table[l+@d][1]).abs
    c += search(l+@d,r,d+(table[l][0]-table[l+@d][0]).abs + (table[l][1]-table[l+@d][1]).abs,ind,table)
  end
  @memo[l] = [r,c]
  return c
end

h,w,@d = inp
a = []
h.times{a<<inp}
table = na(h*w+10)
h.times do |i|
  w.times do |j|
    table[a[i][j]] = [i,j]
  end
end
q = inp[0]
qt = []
q.times{|i|qt<<(inp+[i])}
@memo = na(h*w+10,nil)
@ans = na(q)
qt.sort_by!{|u|u[1]}
qt.each do|a|
  search(a[0], a[1], 0, a[-1],table)
end
puts @ans


Measured memory_bytes: 46188
import java.util.Scanner;

//ALDS1_1_B
public class Main {
	int euclidean(int x, int y) {
		int result = -1, z = 1;
		while (z > 0) {
			z = x % y;
			if (z == 0) result = y;
			x = y; y = z;
		}
		return result;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (y > x ) {
			int tmp = x; x = y; y = tmp;
		}
		int factor = euclidean(x, y);
		if (factor == -1) {
			System.out.println("not exist Greatest common factor");
		} else {
			System.out.println(factor);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 26340
N = int(input())

r_dic = {}

for i in range(N):
    si,ppi = input().split()
    pi = int(ppi)
    if si in r_dic.keys():
        r_dic[si].append((i+1,pi))
    else:
        r_dic[si] = [(i+1,pi)]
    
skey = sorted(r_dic.keys())
for key in skey:
    line = r_dic[key]
    if len(r_dic[key]) == 1:
        print(line[0][0])
    else:
        sline = sorted(line, key = lambda x:x[1], reverse=True)
        for s in sline:
            print(s[0])
    
    

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

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k;
    cin>>k;
    
    char c = s[k-1];
    
    for(int i=0; i<n; i++)
        if(s[i]!=c) cout<<"*";
        else cout<<c;
    
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int i,n,j,k,m,l,o,p;
string s,a;
int main()
{
	cin>>s;
	a=s;
	for(i=0,j=a.length()-1;i<=j;i++,j--)
	{
	swap(a[i],a[j]);
	}
	for(i=0;i<s.length();i++)
	{
	if(a[i]=='d') a[i]='b';
		else if(a[i]=='b') a[i]='d';
			else if(a[i]=='p') a[i]='q';
				else if(a[i]=='q') a[i]='p';
	}
	if(a==s) cout<<"Yes";
		else cout<<"No";
	return 0;
}

Measured memory_bytes: 512
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        char c = sc.NextChar();
        if ('a' <= c && c <= 'z')
        {
            Console.WriteLine("a");
        }
        else
        {
            Console.WriteLine("A");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 25880
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto sum = 0ull;
	for (auto i = 0; i < N; ++i)
	{
		auto A = 0ull;
		cin >> A;
		for (; A % 2 == 0; A /= 2)
		{
			++sum;
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

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

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N, 0);
    for (int i = 0; i < N; i++)
        cin >> h[i];

    sort(all(h));

    vector<int> gap(N-K+1, 0);
    for (int i = 0; i < N-K+1; i++)
        gap[i] = h[i+K-1] - h[i];

    sort(all(gap));

    //test down
    // for (int i = 0; i < N-K+1; i++)
    //     cout << gap[i] << " ";
    // cout << endl;
    //test up
    int ans = gap[0];

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


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;

    ll C;
    if(W == 1 || H == 1) C = 1;
    else {
        if(H % 2 == 0) C = W * (H / 2);
        else C = W * ((H - 1) / 2) + (W + 1) / 2;
    }
    PR(C);

    return 0;
}

/*

# # #
 # # 
# # #

*/

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template<typename T> struct Combination
{
    vector<T> fact, rfact, inv;
    Combination(int n) : fact(n + 1), rfact(n + 1), inv(n + 1)
    {
        fact[0] = fact[1] = 1;
        rfact[0] = rfact[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            rfact[i] = rfact[i - 1] * inv[i] % MOD;
        }
    }
    T C(int n, int k)
    {
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n] * (rfact[k] * rfact[n - k] % MOD) % MOD;
    }
};

void solve()
{
    ll x, y; cin >> x >> y;
    if((x + y) % 3)
    {
        cout << 0 << endl;
        return;
    }
    Combination<ll> comb(2 * (int)1e6 + 10);
    ll a = (-x + 2 * y) / 3;
    ll b = (2 * x - y) / 3;
    ll ans = comb.C(a + b, a);
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int k;
string s;
vector<string> v;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> k;
	for (int i=0;i<(int)s.size();i++){
		string t;
		for (int j=0;j<k&&i+j<(int)s.size();j++){
			t+=s[i+j];
			v.push_back(t);
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout << v[k-1] << "\n";
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
const int M=200001;
int n,A[M],m,B[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=n;i>=1;i--){
		int cnt=0;
		for(int j=i+i;j<=n;j+=i)cnt+=B[j];
		if(cnt%2!=A[i])B[i]=1;
	}
	for(int i=1;i<=n;i++)if(B[i])m++;
	printf("%d\n",m);
	for(int i=1;i<=n;i++)if(B[i])printf("%d ",i);
}

Measured memory_bytes: 2432
//下一个状态选上一个状态不与自己相同的另外两个的最大值 
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;
const int MaxN = 100005;

ll n, i;
ll a[MaxN], b[MaxN], c[MaxN];
ll dp[MaxN][5];

int max(int x, int y){
	x>y?x:y;
} 

int main(){
	cin >> n;
	for( i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
	dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for(i = 2; i <= n; i++){
        dp[i][1] += max(dp[i-1][2], dp[i-1][3]) + a[i];
        dp[i][2] += max(dp[i-1][1], dp[i-1][3]) + b[i];
        dp[i][3] += max(dp[i-1][1], dp[i-1][2]) + c[i];
    }
    cout << max( max(dp[n][1], dp[n][2]), dp[n][3] );
    return 0; 
}

Measured memory_bytes: 6528
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1 :
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



Measured memory_bytes: 7004
// C
 #ifndef _GLIBCXX_NO_ASSERT
 #include <cassert>
 #endif
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
 #include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <cstddef>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <ctime> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
 #include <cstdbool>
 #include <cstdint>
 #include <ctgmath>
 #include <cwchar>
 #include <cwctype>
 #endif
 
 // C++
 #include <algorithm>
 #include <bitset>
 #include <complex>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <functional>
 #include <iomanip>
 #include <ios>
 #include <iosfwd>
 #include <iostream>
 #include <istream>
 #include <iterator>
 #include <limits>
 #include <list>
 #include <locale>
 #include <map>
 #include <memory>
 #include <new>
 #include <numeric>
 #include <ostream>
 #include <queue>
 #include <set>
 #include <sstream>
 #include <stack>
 #include <stdexcept>
 #include <streambuf>
 #include <string>
 #include <typeinfo>
 #include <utility>
 #include <valarray>
 #include <vector> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <array>
 #include <atomic>
 #include <chrono>
 #include <condition_variable>
 #include <forward_list>
 #include <future>
 #include <initializer_list>
 #include <mutex>
 #include <random>
 #include <ratio>
 #include <regex>
 #include <system_error>
 #include <thread>
 #include <tuple>
 #include <typeindex>
 #include <type_traits>
 #include <unordered_map>
 #include <unordered_set>
 #endif
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin >> a[i];
    int q; cin >> q;
    vector<int> m(q);
    for(int i=0;i<q;++i) cin >> m[i];
    map<int,bool> mp;
    for(int bit=0;bit<(1<<n);++bit){
        int sum=0;
        for(int i=0;i<n;++i){
            if(bit & (1<<i)){
                sum += a[i];
            }
        }
        mp[sum] = true;
    }
    for(int j=0;j<q;++j){
        if(mp[m[j]]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int x;
  cin>>x;
  bool ans=false;
  if(x<1200){ans=true;}
  cout<<(ans?"ABC":"ARC")<<endl;
}


Measured memory_bytes: 256
n = int(input())
hhh = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(hhh[1] - hhh[0])
for i in range(2, n):
    dp[i] = min(abs(hhh[i] - hhh[i - 1]) + dp[i - 1], abs(hhh[i] - hhh[i - 2]) + dp[i - 2])
print(dp[-1])

Measured memory_bytes: 13928
n, a, b = map(int, input().split())
if (a+b) % 2 == 0:
  print((b-a)//2)
else:
  if b == a + 1:
    print(min(b-1, n-a))
  else:
    cnt_1 = a + (b-a-1)//2
    cnt_n = n - b + 1 + (b-a-1)//2
    print(min(cnt_1, cnt_n))


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n+1];
    int total = 0;
    int now = n;
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
      total += Math.abs(a[i] - a[now]);
      now = i;
    }
    total += Math.abs(a[n-1]-a[n]);
    now = n;
    for(int i = 0;i<n;i++){
      int to = total;
      to += Math.abs(a[now] - a[i+1]) - Math.abs(a[i] - a[now]) - Math.abs(a[i+1] - a[i]);
      System.out.println(to);
      now = i;
    }
  }
}


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

int main()
{  
    string a,b;
    cin >> a >> b;
    string c = a + b;
    
    int d = atoi(c.c_str());
    
    for(int n=1; n<320; n++)
    {
       if(n*n == d){ 
       	cout << "Yes" << endl;
        return 0;
       }
       else if(n*n > d){
        cout << "No" << endl;
        return 0;
       }
    }

	return 0;
}

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

using namespace std;

int main() {
    long double h,w,x,y;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(10);
    cout << (h*w) / 2.0 << " ";
    cout << (x*2==w && y*2==h) << endl;
}


Measured memory_bytes: 3192
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_string () = Scanf.scanf " %s" (fun x -> x)
let print_string s = Printf.printf "%s\n" s

let rot c n = Char.chr ((Char.code c - Char.code 'A' + n) mod 26 + Char.code 'A')

let convert s n =
  for i = 0 to String.length s - 1 do
    s.[i] <- rot s.[i] n
  done

let () =
  let n = scan_int() in
  let s = scan_string() in
  let () = convert s n in
  print_string s

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
const int N=200010;
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int a[N],n;
long long ans;
int main()
{
	n=(int)read();
	for(int i=1;i<=n;i++)a[i]=read()-i;
	sort(a+1,a+n+1);
	int mid=(1+n)>>1;
	for(int i=1;i<=n;i++)ans+=(long long)abs(a[i]-a[mid]);
	printf("%lld\n",ans);
	return 0;
}

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

#define ll long long

ll LCM(ll a, ll b)
{
    ll g = __gcd(a, b);

    ll ret=(a/g)*b;

    return ret;
}

int main()
{
    int n;

    ll ans=1;

    scanf("%d", &n);

    while(n--)
    {
        ll x;
        scanf("%lld", &x);

        ans=LCM(ans, x);
    }

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

    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    double t, x;
    cin >> t >> x;

    double ans = t / x;

    cout << fixed << setprecision(8) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    ll l,r;
    std::cin >> l>>r;
    ll ans=INF64;
    rrep(i,l,min(r+1,l+2020ll)){
        rrep(j,l,min(r+1,l+2020ll)){
            if(i==j)continue;
            ans=min(ans,(ll(j)*ll(i))%2019ll);
       //     std::cout << (j*i)%2019ll << std::endl;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		int digit = 1;
		while (n >= k) {
			n = n / k;
			digit++;
		}
		print(digit);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}

Measured memory_bytes: 22996
N, K = map(int, input().split())
x = []
y = []
for i in input().split():
    n = int(i)
    if n < 0:
        x.append(-n)
    elif n == 0:
        K -= 1
    else:
        y.append(n)

x = x[::-1]

len_x = len(x)
len_y = len(y)
now = 10 ** 18

if len_x == 0:
    if len_y == 0:
        print(0)
    else:
        print(y[K-1])
elif len_y == 0:
    print(x[K-1])
else:
    for i in range(K+1):
        if K - i > len_y:
            continue
        if len_x < i:
            break
        if i == 0:
            now = min(y[K-1], now)
        elif i == K:
            now = min(x[K-1], now)
        else:
            now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)

    print(now)

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A,B,C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    for (int i=0;i<=K;i++){
        for (int j=0;j<=K;j++){
            for (int k=0;k<=K;k++){
                if (i+j+k==K) {
                    int AA = A;
                    int BB = B;
                    int CC = C;
                    for (int l=0;l<i;l++){
                        AA *= 2;
                    }
                    for (int l=0;l<j;l++){
                        BB *= 2;
                    }
                    for (int l=0;l<k;l++){
                        CC *= 2;
                    }
                    if (AA < BB && BB < CC){
                        cout << "Yes" << "\n";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  string a;cin>>a;
  ll b,c,d,e=INT_MAX;
  rep(i,a.size()-2){
    b=(a[i]-'0')*100;
    c=b+(a[i+1]-'0')*10;
    d=c+(a[i+2]-'0');
    e=min(e,abs(d-753));
  }
  cout<<e;
}


Measured memory_bytes: 27028
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    String[] s = br.readLine().split(" ");
    long a = Long.parseLong(s[0]);
    long b = Long.parseLong(s[1]);
    long c = Long.parseLong(s[2]);
    long k = Long.parseLong(s[3]);
    if (k%2==0) {
      System.out.println(a-b);
    } else {
      System.out.println(-a+b);
    }
  }
}


Measured memory_bytes: 21076
#include <iostream>

int main(){
   int N;
   std::string S;

   std::cin >> N >> S;

   int max = 0;
   for(int i=1; i<N-1; ++i){
      int count = 0;
      for(int j=0; j<i; ++j){
	 
	 bool flag = true;
	 for(int k=j-1; k>-1; --k){
	    if(S[j]==S[k]) flag = false;
	 }
	 if(!flag) continue;
	 for(int k=i; k<N; ++k){
	    if(S[j]==S[k]) {
	       ++count;
	       break;
	    }
	 }
      }
      if(max<count) max = count;
   }
   std::cout << max << std::endl;

   return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a,b,c;
		a = n/100;
		b = n/10%10;
		c = n%100%10;
		if(a==7 || b ==7 || c == 7) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35772
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 2000
#define LOG 21
#define PI 3.141592653589
#define EPS 1e-6
#define MOD 1000000007
#define YJSNPI 810
#define INF (1 << 30)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define RER(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;

void debug() {cout << endl; }

template<class FIRST, class... REST>
void debug(FIRST arg, REST... rest) { cout << arg << " "; debug(rest...); }

int N;
ll dp[1000010];
ll dp2[1000010];

int main() {
	scanf("%d", &N);
	dp[0] = dp2[0] = 1;
	for(int i = 1; i <= N - 1; i++) {
		if(i >= 3) dp[i] = dp[i - 1] + dp2[i - 3];
		else dp[i] = dp[i - 1];
		dp2[i] = dp[i] + dp2[i - 1];
		dp[i] %= MOD;
		dp2[i] %= MOD;
	}
	ll res = 0;
	for(int i = 0; i < N - 1; i++) {
		//debug(i, res);
		res += dp[i] * (N - 1) % MOD * (N - 1) % MOD; res %= MOD;
		if(N - i == 2) res += dp[i] * (i + 1) % MOD;
		else res += dp[i] * (i + 2) % MOD;
		res %= MOD;
	}
	res += dp[N - 1] * N % MOD;
	res %= MOD;
	printf("%lld\n", res);
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    
    int n;
    cin>>n;
    vector<ll> A(n), B(n);
    vector<P> pr(n);
    ll sum=0;
    rep(i,n){
        cin>>A[i]>>B[i];
        pr[i] = make_pair(B[i], A[i]);
    }
    sort(pr.begin(), pr.end());
    rep(i,n){
        sum+=pr[i].second;
        if(sum>pr[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
    
}


Measured memory_bytes: 9552
from math import factorial

n = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

def f(X):
    c = 0
    a = [i+1 for i in range(n)]
    for i in range(n):
        a.sort()
        # print(X, a, c)
        if X[i]!=min(a):
            c += factorial(n-i-1)*(a.index(X[i]))
        del a[a.index(X[i])]
    return c+1

print(abs(f(P)-f(Q)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	ll max = -1e18;
	ll acc = 0;
	rep(i,n) {
		cin >> a[i];
		acc += a[i];
		chmax(max, a[i]);
	}
	vector<ll> ans(n);
	ll acc2 = 0;
	for(int i=1; i<n; i += 2) {
		acc2 += 2*a[i];
	}
	
	ans[0] = acc - acc2;
	for(int i=1; i<n; i++) {
		ans[i] = 2*a[i-1] - ans[i-1];
	}
	rep(i,n) {
		cout << ans[i];
		if (i != n-1) cout << " ";
		else cout << endl;
	}


  return 0;
}


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

using namespace std;

struct Node {
  int id, p, val;
  bool operator < (const Node &b) const {
    return val < b.val; 
  }
};

int main() {
  Node var[5];
  for (int i = 1; i <= 4; ++i) {
    var[i].id = i;
    cin >> var[i].p;
    var[i].val = (1 << (4 - i)) * var[i].p;
  }
  int n;
  cin >> n;
  long long res = 0;
  sort(var + 1, var + 5);
  for (int i = 1; i <= 4 && n; ++i) {
    if (var[i].id == 1) {
      res += var[i].p * 4LL * n;
      n = 0;
    }
    else if (var[i].id == 2) {
      res += var[i].p * 2LL * n;
      n = 0;
    }
    else if (var[i].id == 3) {
      res += var[i].p * 1LL * n;
      n = 0;
    }
    else {
      res += var[i].p * 1LL * (n / 2);
      n %= 2;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
int main()
{
    std::string s1,s2,s3;
    std::cin >> s1 >> s2 >> s3;
    char d1,d2,d3;
    d1 = s1[0];
    d2 = s2[0];
    d3 = s3[0];
    char a1,a2,a3;
    a1 = std::toupper(d1);
    a2 = std::toupper(d2);
    a3 = std::toupper(d3);
    std::cout << a1 << a2 << a3 << std::endl;
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  double sum = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum += 1 / (double)A[i];
  }

  cout << 1 / sum << endl;

  
 return 0;
}





Measured memory_bytes: 256
while gets
  w = $_.to_i
  n = gets.to_i
  a = (1..w).to_a

  #a = Array.new
  #for i in 1..w
  #  a.push(i)
  #end

  for i in 1..n
    x, y = gets.split(",").map{|val| val.to_i}
    x -= 1
    y -= 1
    #s = gets.split(",")
    #x = s[0].to_i - 1
    #y = s[1].to_i - 1
    a[x], a[y] = a[y], a[x]
  end

  puts a

  #for i in 0...w
  #  puts a[i]
  #end
end

Measured memory_bytes: 2384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    cin >> N;
    int l[N], r[N];
    rep(i, N) cin >> l[i] >> r[i];
    rep(i, N){
        ans += r[i] - l[i] + 1;
    }
    cout << ans << endl;
    return 0;
    
}

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

const int INF = 1e9+5;

int main(){
    int n;
    cin>>n;
    vector<int> a;
    for(int i=0,val;i<n;++i){
        cin>>val;
        a.push_back(val);
    }
    vector<int> dp(n , INF);
    dp[0] = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<=i+2 && j<n;++j){
            dp[j] = min(dp[j],dp[i] + abs(a[i]-a[j]));
        }
    }
    // for(auto i:dp) cout<<i<<' ';
    //     cout<<'\n';
    cout<<dp[n-1]<<'\n';
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb; 

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

ll adjust(ll num){
    while (num % 10 != 0){
        num++;
    }
    return num;
}

int main() {
    vector<ll> ryouri(5);
    rep(i,5){
        cin >> ryouri[i];
    }

    ll ans=LLONG_MAX;
    do{
        ll a = adjust(ryouri[0]);
        ll b = adjust(a+ryouri[1]);
        ll c = adjust(b+ryouri[2]);
        ll d = adjust(c+ryouri[3]);
        ll result = d + ryouri[4];
        ans = min(ans,result);

    }while(next_permutation(ryouri.begin(),ryouri.end()));//辞書順で次の順列が存在すれば真

    cout << ans << endl;

}


Measured memory_bytes: 3624
N = int(input())
K = []
for i in range(N):
  K.append(int(input()))
L = [K[0]]
for j in range(1,N):
  if K[j] != L[len(L)-1]:
    L.append(K[j])
dp = [0]*len(L)
dp[0] = 1
used = [-1]*(max(L)+1)
used[L[0]] = 0
for i in range(1,len(L)):
  if used[L[i]] == -1:
    dp[i] = dp[i-1]
  else:
    dp[i] = (dp[i-1]+dp[used[L[i]]])%(10**9+7)
  used[L[i]] = i
print(dp[len(L)-1])

Measured memory_bytes: 22068
#include<cstdio>

int main() {
    int S;
    scanf("%d",&S);
    int h = S / 3600;//時間
    S %= 3600;// S = S % 3600
    int m = S / 60;//分
    int s = S % 60;//秒

    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
	#define endl "\n"
	#define ll long long int
	
	using namespace std;
	
	signed main()
	{

	std::ios::sync_with_stdio(false);
	
	

	ll a,b;
	cin>>a>>b;
	ll s = a+b;
	ll p = s/2;
	if(2*p==s)
		cout<<p;
	else
		cout<<"IMPOSSIBLE";

	return 0;
	}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll order(vector<ll> v, int k){
	int n,i,l,r,p=0,q=0;
	ll pivot;
	n = v.l_ength();
	if(n<5){
		sort(v.begin(),v.end());
		return v[k];
	}
	vector<ll> u;
	for(i=0; i<n; i+=5){
		l = i; r = min(i+5,n);
		sort(&v[l],&v[r]);
		u.push_back(v[(l+r)/2]);
	}
	pivot = order(u,n/10);
	u.clear();
	for(i=0; i<n; ++i){
		if(v[i]<pivot){
			++p;
		}else if(v[i]==pivot){
			++q;
		}
	}
	if(k<p){
		for(i=0; i<n; ++i){
			if(v[i]<pivot){
				u.push_back(v[i]);
			}
		}
		return order(u,k);
	}else if(k>=p+q){
		for(i=0; i<n; ++i){
			if(v[i]>pivot){
				u.push_back(v[i]);
			}
		}
		return order(u,k-p-q);
	}else{
		return pivot;
	}
}

ll a[1111][3];

int main(void){
	int n,m,i,j,k,cnt=0;
	ll pivot,tmp,ans=-INFLL;
	cin >> n >> m;
	vector<ll> v(n);
	if(!m){
		cout << 0ll << endl;
		return 0;
	}
	for(i=0; i<n; ++i){
		for(k=0; k<3; ++k){
			cin >> a[i][k];
		}
	}
	for(j=0; j<8; ++j){
		tmp = 0ll; cnt = 0;
		fill(v.begin(),v.end(),0ll);
		for(i=0; i<n; ++i){
			for(k=0; k<3; ++k){
				if(j&(1<<k)){
					v[i] += a[i][k];
				}else{
					v[i] -= a[i][k];
				}
			}
		}
		pivot = order(v,n-m);
		for(i=0; i<n; ++i){
			if(v[i]>pivot){
				++cnt;
				tmp += v[i];
			}
		}
		tmp += pivot*(m-cnt);
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256