akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

typedef pair<int ,int > P;
int main()
{
    int h,n;
    cin >> h >> n;
    //vector<P> attack(n);
    vector<int> a(n);
    vector<int> d(n);
    rep(i,n)
    {
        cin >> a[i] >> d[i];
    }
    vector<vector<int>> dp(n+1,vector<int> (h+1,INF));

    rep(i,n+1)
    {
        dp[i][0] = 0;
    }

    rep(i,n)
    {
        rep(j,h+1)
        {
            if (j<a[i])
            {
                dp[i+1][j] = min(dp[i][j],dp[i+1][0]+d[i]);
            }else
            {
                dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+d[i]);
            }
        }
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long dp[110][100010];
int main(){
    int n,W; cin>>n>>W;
    int w[n],v[n]; rep(i,n) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i-1]>=0) dp[i][j]=dp[i-1][j-w[i-1]]+v[i-1];
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    long long ans=0;
    rep(i,W+1) ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int arr[3];
    arr[0]=a+b;
    arr[1]=b+c;
    arr[2]=c+a;
    sort(arr,arr+3);
    cout<<arr[0]<<endl;


    return 0;
}


Measured memory_bytes: 3580
use std::io;
use std::cmp;

fn main() {
    let (n, u, v) = {
        let i = read::<usize>();
        (i[0], i[1] - 1, i[2] - 1)
    };
    let mut g = vec![Vec::new(); n];
    for _ in 1..n {
        let (a, b) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        g[a].push(b);
        g[b].push(a);
    }
    let mut du = vec![0; n];
    let mut qu = Vec::new();
    qu.push((u, n + 1));
    while let Some((p, par)) = qu.pop() {
        for &x in &g[p] {
            if x == par { continue; }
            du[x] = du[p] + 1;
            qu.push((x, p));
        }
    }

    let mut dv = vec![0; n];
    let mut qv = Vec::new();
    qv.push((v, n + 1));
    while let Some((p, par)) = qv.pop() {
        for &x in &g[p] {
            if x == par { continue; }
            dv[x] = dv[p] + 1;
            qv.push((x, p));
        }
    }

    let mut ans = 0;
    for i in 0..n {
        if dv[i] < du[i] { continue; }
        ans = cmp::max(ans, dv[i] - 1);
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
    char s[3];
    char t[3];

    cin >> s;
    cin >> t;

    int ans=0;
    for(int x=0; x<3; x++){
        if(s[x]==t[x]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _155_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
            Console.WriteLine(
                (inputs[0] != inputs[1] && inputs[1] != inputs[2] && inputs[2] != inputs[0])
                || (inputs[0] == inputs[1] && inputs[1] == inputs[2] && inputs[2] == inputs[0])
                ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
const int INF=10001001;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<vector<int>> algo(n,vector<int>(m));
  vector<int> cost(n);
  for(int i=0;i<n;i++){
    cin>>cost[i];
    for(int j=0;j<m;j++){
      cin>>algo[i][j];
    }
  }
  int kotae=INF;
  for(int i=0;i<(1<<n);i++){
    int ans=0;
    vector<int> understand(m);
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        ans+=cost[j];
        for(int k=0;k<m;k++){
          understand[k]+=algo[j][k];
        }
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++){
      if(understand[j]<x)ok=false;
    }
    if(ok){
      kotae=min(kotae,ans);
    }
  }
  if(kotae!=INF){
    cout<<kotae<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int x;
	cin >> x;
	
	cout << 1 - x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3648
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, m;
    scan(n, m);

    auto a = readln.split.to!(int[]);
    a.sort();

    auto c = [1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6];

    auto dp = new int[][](m + 1, n + 1);
    fillAll(dp, -inf3);
    dp[0][0] = 0;

    foreach (i ; 0 .. m) {
        int ci = c[a[i]];
        foreach (j ; 0 .. n + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j - ci >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - ci] + 1);
            }
        }
    }

    debug {
        writefln("%(%s\n%)", dp);
    }

    int mp = m, np = n;
    string ans;

    while (mp > 0 && np > 0) {
        int ci = c[a[mp - 1]];
        if (np - ci < 0) {
            mp--;
            continue;
        }
        if (dp[mp][np] == dp[mp][np - ci] + 1) {
            np -= ci;
            ans ~= ('0' + a[mp - 1]).to!char;
            continue;
        }
        mp--;
    }

    writeln(ans);
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(){
  int x,y;
  cin>>x>>y;
  vector<int> a={4,6,9,11};
  bool flag=false,x_flag=false,y_flag=false;
  if(x==2 || y==2) flag=true;
  for (int i=0 ;i<4;i++){
	if(a[i]==x) x_flag=true;
    if(a[i]==y) y_flag=true;
  }
  if(flag){
	cout<<"No"<<endl;
    return 0;
  }
  else if(x_flag && y_flag){
	cout<<"Yes"<<endl;
    return 0;
  }
  else if(x_flag || y_flag){
    cout<<"No"<<endl;
    return 0;
  }
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
h = gets.split.map(&:to_i)

def calc(h)
  if h.size > 1
    m = h.min

    ret = []
    needle = 0
    h = h.map {|e| e - m}
    h.each_with_index do |e, i|
      if e == 0 || i == (h.size - 1)
        ret << h[needle..i].select{|elm| elm != 0} if h[needle..i].select{|elm| elm != 0} != []
        needle = i+1
      end
    end
    m + ret.map {|a| calc(a)}.inject(&:+).to_i
  else
    h.min
  end
end

puts calc(h)

Measured memory_bytes: 2044
n,a=int(input()),sorted(list(map(int,input().split())))
lb,ub=-1,n
def check(mid):
	sz=a[mid]
	for i in range(n):
		if i==mid: continue
		if 2*sz>=a[i]: 
			sz+=a[i]
		else:
			return False
	return True
while ub-lb>1:
	mid=(lb+ub)//2
	if check(mid):
		ub=mid
	else:
		lb=mid
print(n-ub)

Measured memory_bytes: 63856
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <std::uint_fast64_t Modulus>
class modint {
  using u64 = std::uint_fast64_t;

 public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept
      : a(x % Modulus) {
  }
  constexpr u64 &value() noexcept {
    return a;
  }
  constexpr const u64 &value() const noexcept {
    return a;
  }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(const modint rhs) noexcept {
    return *this *= ~rhs;
  }
  constexpr modint power(u64 exp) const noexcept {
    modint v = 1, x = *this;
    while (exp) {
      if (exp & 1) {
        v *= x;
      }
      x *= x;
      exp >>= 1;
    }
    return v;
  }
  constexpr modint operator~() const noexcept {
    return power(Modulus - 2);
  }
};

using mint = modint<1000000007>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    vector<mint> dp(K + 1);
    for (int g = K; g >= 1; g--) {
      dp[g] = mint(K / g).power(N);
      for (int kg = g + g; kg <= K; kg += g) {
        dp[g] -= dp[kg];
      }
    }
    mint res = 0;
    for (int g = 1; g <= K; g++) res += dp[g] * g;
    cout << res.value() << endl;
  }
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    
    int cnt=0;
    rep(i,N){
        int a;
        cin>>a;
        
        if(((i+1)&a)&1)++cnt;
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int n;
	cin >> n;
	if(n==1){
		cout << "Hello World" << endl;
	}else{
		int a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
 
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}

signed main() {
 
	ll a, b;
	scanf("%lld %lld", &a, &b);
	ll ans = 0;
	if (a > b) {
		ans++;
		if (a < 0) {
			ans += 1 + abs(abs(a) - abs(b));
		}
		else {
			if (b > 0)
				ans++;
			ans += abs(abs(a) - abs(b));
		}
	}
	else {
		if (a < 0 && b > 0) {
				ans += 1 + abs(abs(a) - abs(b));
		}
		else {
			ans += abs(abs(a) - abs(b));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

next :: (Int, Int) -> (Int, Int) -> (Int, Int)
next (t, a) (t', a') = (t' * r, a' * r)
  where t'' | t `mod` t' == 0 = t `div` t'
            | otherwise = t `div` t' + 1
        a'' | a `mod` a' == 0 = a `div` a'
            | otherwise = a `div` a' + 1
        r = max t'' a''

readLine :: String -> (Int, Int)
readLine line = (x, y)
  where [x, y] = fmap read $ words line

main :: IO ()
main = do
  n <- read <$> getLine
  ratios <- fmap readLine <$> replicateM n getLine
  print $ uncurry (+) $ foldl' next (1, 1) ratios


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

  int border;
  cin >> border;

  int k = 0;

  while (a >= b) {
    b = b * 2;
    k++;
  }

  while (b >= c) {
    c = c * 2;
    k++;
  }

  if (k <= border) {
    ANS("Yes");
  } else {
    ANS("No");
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e3 + 5;
#define int long long int


int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n, k , d, flag = false ; 
    cin >> n >> k >> d ;
    
    n = abs(n) ;  
    int x = n/d ;  
    x = min(x, k) ;
    n -= d*x ;
    k -= x ; 
    
    if(k&1) cout << abs(n-d) ;
    else cout << n ;
    
    return 0 ;
}


Measured memory_bytes: 3616
import sys


class BinaryIndexedTree():
    '''
    1-indexed
    '''
    def __init__(self, A):
        self.__n = len(A)
        self.__node = [0] * (self.__n + 1)
        self.__data = [0] * (self.__n + 1)

        S = [0] * (self.__n + 1)
        for i in range(self.__n):
            S[i + 1] = S[i] + A[i]

        for i in range(1, self.__n + 1):
            self.__data[i] = A[i - 1]
            self.__node[i] = S[i] - S[i - (i & -i)]

    def add(self, i, v):
        self.__data[i] += v
        while i <= self.__n:
            self.__node[i] += v
            i += i & -i

    def sum(self, i):
        ''' [1, i]の和
        '''
        rst = 0
        while i > 0:
            rst += self.__node[i]
            i -= i & -i
        return rst
    
    def get(self, i, j):
        '''[i, j]の和
        '''
        if i == j:
            return self.__data[i]
        else:
            return self.sum(j) - self.sum(i - 1)


def main():
    N, Q = map(int, input().split())
    C = list(map(int, input().split()))

    P = [[] for _ in range(N)]
    for i, c in enumerate(C):
        P[c - 1].append(i)

    right = [0] * N
    for p in P:
        if len(p):
            right[p.pop()] = 1
    BIT = BinaryIndexedTree(right)

    query = [[] for _ in range(N)]
    for i, s in enumerate(sys.stdin.readlines()):
        l, r = map(int, s.split())
        query[r - 1].append((l - 1, i))

    ans = [None] * Q

    cur = N - 1
    for r, q in enumerate(reversed(query)):
        r = (N - 1) - r
        while q:
            l, i = q.pop()
            while r < cur:
                c = C[cur] - 1
                p = P[c]
                if len(p):
                    BIT.add(p.pop() + 1, 1)
                cur -= 1
            tmp = BIT.get(l + 1, r + 1)
            ans[i] = tmp

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 281720
#include <iostream>
#include <array>
#include <limits>

using namespace std;

array<int, 50001> dp;
array<int, 20> coins;

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int coin;
        cin >> coin;
        coins[i] = coin;
    }

    dp[0] = 0;

    for (int val = 1; val <= n; ++ val) {
        int min = numeric_limits<int>::max();
        for (int i = 0; i < m; ++i) {
            int coin = coins[i];
            if (val >= coin) {
                min = dp[val-coin] < min ? dp[val-coin] : min;
            }
        }
        dp[val] = 1 + min;
    }
    cout << dp[n] << endl;
}



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

using namespace std;

const int HW_MAX = 301 * 301;

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

    int x[HW_MAX] = {};
    int y[HW_MAX] = {};
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            int a;
            cin >> a;
            x[a] = i;
            y[a] = j;
        }
    }

    int dp[HW_MAX] = {};
    for (int i = D + 1; i <= H * W; ++i) {
        dp[i] = dp[i - D] +
                abs(x[i - D] - x[i]) +
                abs(y[i - D] - y[i]);
    }

    int q;
    cin >> q;
    while (q--) {
        int L, R;
        cin >> L >> R;
        cout << dp[R] - dp[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  int a[1000];
  int cnt = 0;
  rep(i,n){
    cin >> a[i];
    cnt += a[i];
  }
  sort(a,a+n,greater<int>());
  rep(i,m){
    if(a[i] < cnt/(4.0*m)){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


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





int main() {
  string text;
  cin>>text;
  int size=int(text.size());
  
  string answer="yes";
  
  for (int i=0;i<size;i++){
    for (int j=i+1;j<size;j++){
      if (text.at(i)==text.at(j)){
        answer="no";
      break;
      }
    }
  }
  cout<<answer<<endl;

        
    
  
  
}













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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  //n = 2e5;
  
  vector<int> a(n), b(n), counta(n + 1), countb(n + 1);
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    //a.at(i) = rand() % 3 + 1;
    counta.at(a.at(i))++;
  }
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
    //b.at(i) = rand() % 3 + 1;
    q.push(b.at(i));
    countb.at(b.at(i))++;
  }
  
  if (n == 1) {
    if (a[0] == b[0]) {
      cout << "No\n";
      return 0;
    }
    else {
      cout << "Yes\n";
      cout << b[0] << '\n';
      return 0;
    }
  }
  
  //sort(a.begin(), a.end());sort(b.begin(), b.end());
  
  
  for (int i = 1; i <= n; i++) {
    if (counta.at(i) + countb.at(i) > n) {
      cout << "No\n";
      return 0;
    }
  }
  
  priority_queue<pair<int, int>> pq; // counta + countb, number
  for (int i = 1; i <= n; i++) {
    if (countb.at(i) == 0) continue;
    pq.push(make_pair(counta[i] + countb[i], i));
  }
  
  vector<int> ans(n, -1);
  int bad = -1;
  for (int i = 0; i < n; i++) {
    if (countb[a.at(i)] == 0) continue;
    auto [pri, num] = pq.top();
    pq.pop();
    if (num != a.at(i)) {
      ans.at(i) = num;
      countb[num]--;
      if (countb[num] > 0) pq.push(make_pair(pri, num));
    }
    else {
      if (pq.empty()) {
        int bad = num;
        ans.at(i) = num;
      	countb[num]--;
      	if (countb[num] > 0) pq.push(make_pair(pri, num));
        continue;
      }
      auto [pri2, num2] = pq.top();
      pq.pop();
      ans.at(i) = num2;
      countb[num2]--;
      if (countb[num2] > 0) pq.push(make_pair(pri2, num2));
      pq.push(make_pair(pri, num));
    }
  }
  
  for (int i = 0; i < n; i++) {
    if (ans.at(i) != -1) continue;
    auto [pri, num] = pq.top();
    pq.pop();
    ans.at(i) = num;
    countb[num]--;
    if (countb[num] > 0) pq.push(make_pair(pri, num));
  }
  
  for (int i = 0; i < n; i++) {
    if (ans.at(i) == a.at(i)) {
      while (true) {
        int die = rand() % i;
      	swap(ans.at(i), ans.at(die));
        if (ans.at(i) == a.at(i) || ans.at(die) == a.at(die)) {
          swap(ans.at(i), ans.at(die));
        }
        else {
          break;
        }
      }
    }
  }
  
  cout << "Yes\n";
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << '\n';
}

Measured memory_bytes: 9384
N = int(input())
X = input()
x = X[::-1]
one = X.count('1')
up = 0
down = 0
for i in range(N):
    up += (int(x[i]) * pow(2,i,one+1) % (one+1))
    up %= one+1
    if one > 1:
        down += (int(x[i]) * pow(2,i,one-1) % (one-1))
        down %= one-1
# print(up,down)
def f(ud,one):
    cnt = 1
    while ud != 0:
        one = format(ud,'b').count('1')
        ud = ud % one
        cnt += 1
    return cnt



for i in range(len(X)):
    if X[i] == '1':
        if one > 1:
            print(f((down - pow(2,(len(X)-1) - i, one-1)) % (one-1),one-1))
        #print(down - pow(2,(len(X)-1) - i, one-1) % (one-1))
        else:
            print(0)

    else:
        print(f((up + pow(2,(len(X)-1) - i, one+1)) % (one+1),one+1))
        #print(up + pow(2,(len(X)-1) - i, one+1) % (one+1))


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

int main()
{
  int N;
  cin >> N;
  ll sum = 0;
  for(int i = 1; i <= N; i++) {
    if (i % 15 == 0) {
      continue;
    }
    if (i % 5 == 0) {
      continue;
    }
    if (i % 3 == 0) {
      continue;
    }
    sum += i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N), edge1(N);
  int A, B;
  for(int i=0;i<N+M-1;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge1[B].push_back(A);
  }
  int parent;
  for(int i=0;i<N;++i) {
    if(edge1[i].size()==0) parent = i;
  }
  int dist[N];
  for(int i=0;i<N;++i) dist[i] = -1;
  queue<pair<int, int> > que;
  que.push(mp(parent, 0));
  pair<int, int> state;
  int node, tmpdist;
  int edgenum[N];
  for(int i=0;i<N;++i) edgenum[i] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    node = state.fi;
    tmpdist = state.se;
    if(dist[node]>=tmpdist) continue;
    dist[node] = tmpdist;
    for(int i=0;i<edge[node].size();++i) {
      edgenum[edge[node][i]]++;
      if(edgenum[edge[node][i]]<edge1[edge[node][i]].size()) continue;
      que.push(mp(edge[node][i], tmpdist+1));
    }
  }
  que.push(mp(parent, 0));
  int parents[N];
  parents[parent] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    node = state.fi;
    tmpdist = state.se;
    for(int i=0;i<edge[node].size();++i) {
      if(dist[edge[node][i]]!=tmpdist+1) continue;
      parents[edge[node][i]] = node+1;
      que.push(mp(edge[node][i], tmpdist+1));
    }
  }
  for(int i=0;i<N;++i) cout<<parents[i]<<endl;
}



Measured memory_bytes: 15340
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	  int N;
		cin>>N;
    double a;
    priority_queue<double, vector<double>, greater<double>> queue;

		for (int i = 0; i < N; ++i) {
		  cin>>a;
			queue.push(a);
		}

    double x1,x2;
    for (int i = 0; i < N-1; ++i) {
      x1=queue.top();
      queue.pop();
      x2=queue.top();
      queue.pop();
      queue.push((x1+x2)/2);
    }

      cout << queue.top() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    map <int,int> A;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        A[a]++;
    }
    for(pair<int,int> p:A){
        if(p.first % 2 == N % 2 || (p.second != 2 && p.first != 0) || p.first >= N || (p.second == 1 && p.first != 0)){
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 1;
    for(int i = 0; i < N / 2; i++){
        ans = ans * 2 % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6552
//
//  main.cpp
//  ABC139A
//
#include <iostream>
#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    string S,T;
    int count=0;
    cin >>S>>T;
    for (int i=0; i<3; i++) {
        if (S.at(i)==T.at(i)) {
            count++;
        }
    }
    cout << count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int h,w,i,n;
while(1){
scanf("%d %d",&h,&w);
if(h==0&&w==0){break;}else{
for(i=0;i<h;i++){
for(n=0;n<w;n++){
if(i%2==0){
if(n%2==0){
printf("#");}else
{printf(".");}
}else{
if(n%2==0){
printf(".");}else
{printf("#");}
}
}
printf("\n");
}
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <stdio.h>

int a[3];

void detect(int *max, int *min)
{
    int i;
    *max = 0;
    *min = 0;
    for (i = 1; i < 3; i++)
        if (a[*max] < a[i]) *max = i;
    for (i = 1; i < 3; i++)
        if (a[*min] > a[i]) *min = i;
}

int other(int max, int min)
{
    int res;
    for (res = 0; res < 3; res++)
        if (res != max && res != min) break;
    return res;
}

int main()
{
    int max;
    int min;
    int ans;

    scanf("%d %d %d", a, a+1, a+2);

    ans = 0;
    while (1) {
        detect(&max, &min);
        if (a[max] - a[min] <= 1) break;
        a[min] += 2;
        ans++;
    } 

    detect(&max, &min);
    if (a[max] == a[min]) printf("%d\n", ans);
    else if(a[min] == a[other(max, min)])
        printf("%d\n", ans+1);
    else printf("%d\n", ans+2);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 10e9
#define INFL 10e18;
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
//cout<< fixed << setprecision(10)

int main(){

    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n,k,i,j;
        cin>>k;
        string s;
        cin>>s;
        if(s.length()<=k)
        {
        	cout<<s;
        	return 0;
		}
        n=s.length();
        for(i=0;i<k;i++)
        {
        	cout<<s[i];
		}
		cout<<"...";
        
	}

}

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

bool mm(int n)
{
  bool ret =(1<=n && n<=12);
  return (ret);
}

bool yy(int n)
{
  bool ret = ((13<= n && n <= 99) || n==0);
  return (ret);
}

int main()
{
  string S;cin>>S;
  int a,b;
  a=10*(S[0]-'0')+(S[1]-'0');
  b=10*(S[2]-'0')+(S[3]-'0');
  //cout<<a<<" "<<b<<endl;
  
  if (mm(a) && yy(b)) cout<<"MMYY"<<endl;
  else if (yy(a) && mm(b)) cout<<"YYMM"<<endl;
  else if (mm(a) && mm(b)) cout<<"AMBIGUOUS"<<endl;
  else cout<<"NA"<<endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n) cin >>a[i];

    auto itr = unique(all(a));
    a.resize(distance(a.begin(),itr));
    n = a.size();

    vector<int> d(n-1);
    rep(i,n-1) d[i] = (a[i]<a[i+1]);

    int ans = 1;
    int s = 0;
    while(s<n-1){
        int idx = s;
        while(idx<n-1 && d[s]==d[idx]) ++idx;
        ans = max(ans, idx-s+1);
        s = idx;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3544
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    char a;
    cin >> a;

    printf("%c\n", a + 1);

}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

        



Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX (100000)
struct uni{
  P d[100001];
  void init(){
    fill(d,d+MAX,P(-1,0));
  }
  int find(int a){
    if( d[a].first<0 ) return a;
    else {
      int b = find(d[a].first);
      int w1 = d[a].second;
      int w2 = d[d[a].first].second;
      d[a] = P(b,w1+w2);
      return b;
    }
  }
  void marge(int x,int y,int k){
    int bk = get(x);
    x = find(x);
    d[x].second = k - bk;
    d[x].first = y;
    find(x);
  }
  bool same(int a,int b){
    if( find(a)==find(b) ) return true;
    return false;
  }
  int get(int x){
    find(x);
    return d[x].second;
  }
  int size(int x){
    x = find(x);
    return d[x].first;
  }
};

int N,M;
uni U;
int main(){
  while(cin >> N >> M && (N||M) ){
    char c;
    int a,b,k;
    U.init();
    for(int i=0;i<M;i++){
      cin >> c;
      if( c == '!' ){
	cin  >> a >> b  >> k;
	a--;b--;
	if( !U.same( a, b ) ) 
	  U.marge(a,b,k);

	//	cout << "marge " << a << " " << b << " " << k << endl;
	//cout << U.get(a) << " " << U.size(a) << "   "  << U.get(b)<< " " << U.size(b) << endl;
      } else {
	cin >> a >> b;
	a--;b--;
	if( U.same( a,b ) ) {
	  cout << U.get(a) - U.get(b) << endl;
	} else 
	  cout << "UNKNOWN" << endl;
      }
    }  
  }
}

Measured memory_bytes: 2776
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}



int main(){
    LL N,M;
    cin >> N >> M;
    LL X=0;
    LL ini=1900;
    LL res=N-M;
    LL act=res;
    LL tel=(int) pow(2,M)*(1900*M+res*100);
    cout << tel;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int m,d,count=0;
    cin>>m>>d;
    for(int i=4;i<=m;i++)
    {
        for(int j=22;j<=d;j++)
        {
            int dig1=j%10;
            int dig2=j/10;
            if(dig1>=2 && dig2>=2 && dig1*dig2==i)
                count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    ll ma = 0, mi = INF;
    rep(i, n) {
        ll a;
        cin >> a;
        chmax(ma, a);
        chmin(mi, a);
    }
    out(ma - mi);
    re0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            int N = int.Parse(L[0]);
            int M = int.Parse(L[1]);

            int[] s = new int[M];
            int[] c = new int[M];
            int[] res = new int[N];

            for (int i = 0; i < N; i++)
            {
                res[i] = -1;
            }

            bool ER = false;

            for (int i = 0; i < M; i++)
            {
                S = Console.ReadLine();
                L = S.Split(' ');
                s[i] = int.Parse(L[0]);
                c[i] = int.Parse(L[1]);

                if (N != 1 && s[i] == 1 && c[i] == 0)
                {
                    ER = true;
                }

                if (res[s[i] - 1] == -1)
                {
                    res[s[i] - 1] = c[i];
                }
                else if (res[s[i] - 1] != -1 && res[s[i] - 1] != c[i])
                {
                    ER = true;
                }
            }

            int ans = 0;

            if (ER == true)
            {
                Console.WriteLine(-1);
            }
            else
            {
                if(N != 1 && res[0] == -1)
                {
                    res[0] = 1;
                }
                for (int i = 0; i < N; i++)
                {
                    if (res[i] != -1)
                    {
                        ans += res[i] * (int)Math.Pow(10, N - i - 1);
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double a,b,c,S,L,h;
    cin >> a >> b >> c;
    double rad = (c * 3.14159265 / 180);
    S = a*b*sin(rad)/2;
    
    double d;
    d = sqrt((a*a)+(b*b)-2*a*b*cos(rad));
    L = a + b + d;
    
    h = 2*S/a;
    
    printf("%.8f\n",S);
    printf("%.8f\n",L);
    printf("%.8f\n",h);
}



Measured memory_bytes: 3436
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10029 "Sort 2"
//c++??§?????????????????¨??????????¨??????§???????§??????????STL??§????????????????????????????????????????????§?????????????????°?????????
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int t;
int n, k;
int x[100000];

void solve(){
	vector<int> v;
	cin >> n >> k;
	if(k > n) k = n;
	rep(i,n) cin >> x[i];
	for(int i = 1; i < n; i++) v.push_back(x[i]-x[i-1]);
	int ans = x[n-1]-x[0];
	sort(v.begin(),v.end(),greater<int>());
	rep(i,k-1) ans -= v[i];
	cout << ans << endl;
}

int main(){
	cin >> t;
	rep(i,t) solve();
}

Measured memory_bytes: 2472
#include<stdio.h>

int main()
{
	int a, b;

	while (1)
	{
		scanf("%d %d", &a, &b);
		if (1 <= a, b&&a, b <= 1000000000)
			break;
	}

	printf("%d %d %.5lf\n", a / b, a%b, (double)a/(double)b);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n, m;
    cin >> n >> m;
    ll p = (n - 1) / 2;


    if (n%2 != 0){
        rep(i, m){
            cout << p - i << " " << p + i + 1 << endl;
        }
        return 0;
    }


    int h = n / 2;

    rep(i, (m + 1) / 2){
        cout << h / 2 - i << " " << h / 2 + i + 1 << endl;
    }

    rep(i, m - (m + 1) / 2){
        cout << h + h / 2 - i - 1 << " " << h + h / 2 + i + 1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3644
def myAnswer(H:int,W:int,C:list) -> None:
   for c in C:
      print(c)
      print(c)

def modelAnswer():
   tmp=1

def main():
   H,W=map(int,input().split())
   C = []
   for _ in range(H):
      C.append(input())
   myAnswer(H,W,C[:])
   

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <iostream>
#include<cstring>
#include<iomanip>
using namespace std;

double dp[301][301][301];

double f(int x,int y,int z,int n){
    if(x<0 || y<0 || z<0)
    return 0;
    if(x==0 && y==0 && z==0)
    return 0;
    if(dp[x][y][z]>0)
    return dp[x][y][z];
    
    return dp[x][y][z] = (double)(n + x*f(x-1,y,z,n) + y*f(x+1,y-1,z,n) + z*f(x,y+1,z-1,n))/(x+y+z);
}

double expectedMoves(int a[],int n){
    memset(dp,-1,sizeof dp);
    int freq[4] = {0};
    for(int i=0;i<n;i++)
    freq[a[i]]++;
    return f(freq[1],freq[2],freq[3],n);
}

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<setprecision(10)<<expectedMoves(a,n);

    return 0;
}

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

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

  if(a>b){
    cout<<"a > b"<<endl;
  }
  else if(a<b){
    cout<<"a < b"<<endl;
  }
  else{
    cout<<"a == b"<<endl;
  }
}



Measured memory_bytes: 3080
piza = list(map(int,input().split()))
x = piza[0] * piza[3] + piza[1] * piza[4] #普通に買うパターン
y = piza[2] * 2 * max(piza[3],piza[4])

if piza[3] >= piza[4]:
    z = piza[2] * (2 * piza[4]) + piza[0] * (piza[3] - piza[4])
else:
    z = piza[2] * (2 * piza[3]) + piza[1] * (piza[4] - piza[3])
print(min(x,y,z))


Measured memory_bytes: 3064
N =int(input())
A = list(map(int, input().split()))
Q = int(input())
A2 = [0]*(10**5)
B = [0]*Q
C = [0]*Q
for q in range(Q):
    B[q],C[q]=map(int,input().split())
total = 0
Adict = dict()
for n in range(N):
    A2[A[n]-1]+=1
    total+=A[n]
for q in range(Q):
    total = total - B[q]*A2[B[q]-1] + C[q]*A2[B[q]-1]
    A2[C[q]-1] += A2[B[q]-1]
    A2[B[q]-1] = 0
    print(total)

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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int n;
    cin >> n;
    string str[110];
    bool ans = true;
    for(int i = 0; i < n; i++){
        cin >> str[i];
        if(i != 0 && str[i - 1].back() != str[i].front() ) ans = false;
        for(int j = 0; j < i; j++){
            if(str[j] == str[i]) ans = false;
        } 

    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	cout << n-k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    double r;
    cin >> r;
    cout << SP(10) << r * 2 * M_PI << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<long int> H(N);
  rep(i, N)
  {
    long int a;
    cin >> a;
    H[i] = -a;
  }
  sort(H.begin(), H.end());
  long long int sum = 0;
  for (int i = K; i < N; i++)
  {
    sum += -1 * H[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
Q=int(input())
Query=[tuple(map(int,input().split())) for i in range(Q)]

B=[(3,2)]
for i in range(2,31):
    B.append((3**i,B[-1][1]+3**(i-1)))

for a,b,c,d in Query:
    MINX=min(a,c)
    MAXX=max(a,c)
    MINY=min(b,d)
    MAXY=max(b,d)
    flag=0
    
    for i in range(29,-1,-1):
        r,q=B[i]
        l=3**i

        xcen=-(-(MINX-q)//r)*r+q
        ycen=-(-(MINY-q)//r)*r+q

        for xq in [xcen-r,xcen,xcen+r]:
            for yq in [ycen-r,ycen,ycen+r]:

                #print(xq,yq,MINX,MAXX,xq-l//2,xq+l//2,MINY,MAXY,yq-l//2,yq+l//2)

                if (MINX<xq-l//2 and xq+l//2<MAXX) and (yq-l//2<=MINY and MAXY<=yq+l//2):
                    #print(xq,yq,l)
                    flag=1
                    break
                
                if (xq-l//2<=MINX and MAXX<=xq+l//2) and (MINY<yq-l//2 and yq+l//2<MAXY):
                    #print(xq,yq,l)
                    flag=2
                    break
            if flag!=0:
                break
        if flag!=0:
            break

    if flag==0:
        print(MAXX-MINX+MAXY-MINY)

    elif flag==1:
        ANS=MAXX-MINX
        y1=yq+l//2+1
        y2=yq-l//2-1

        ANS+=min(abs(y1-b)+abs(y1-d),abs(y2-b)+abs(y2-d))

        print(ANS)

    else:
        ANS=MAXY-MINY
        x1=xq+l//2+1
        x2=xq-l//2-1

        ANS+=min(abs(x1-a)+abs(x1-c),abs(x2-a)+abs(x2-c))

        print(ANS)

Measured memory_bytes: 5492