akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
S,Tの両方動くが,片方固定して考える.(S = 0とする)
{
    (入力例2に対して)
    S = (0,0)と固定
    T = (0,0)の場合 S≠Tより考えない
    T = (0,1)の場合 8
    T = (1,0)の場合 5
    T = (1,1)の場合 min(5*2+8,8*2+5)
    よって, 8+5+min(5*2+8,8*2+5) = 31
    S = (0,1),(1,0),(1,1)に対しても同じ結果が得られる.
    つまり,S = (0,0)と固定したときの結果が分かれば2**nを掛けると答えが得られる
}
Cは降順ソートしておく.(並び順は関係ないので)
dp[i] := Σ(0<=j<=2**i) f(0,j)とするとans = dp[n]*(2**n)
dp[0] = C[0]
dp[i+1] := dp[i] + Σ(2**i<=j<=2**(i+1)-1) f(0,j) (右辺の左側はi+1桁目が0,右側はi+1桁目が1)
        := dp[i] + (2**i + i*(2**(i-1))*C[i] + dp[i] 
        := 2*dp[i] + (2**i + i*(2**(i-1)))*C[i]
        := 2*dp[i] + 2**(i-1)*(2+i)*C[i]
{
    (具体例(n=3))
    桁　3 2 1　個数
    --------------
        0 0 0
        0 0 1
        0 1 0
        0 1 1
        1 0 0　1(1*C[3]だけ増える)
        1 0 1　2(2*C[3]だけ増える)
        1 1 0　2(2*C[3]だけ増える)
        1 1 1　3(3*C[3]だけ増える)

    3桁目を見ているとする
    0のとき,dp[2]の分だけ増える
    1のとき,(個数の和)*C[3]+dp[2]だけ増える
        個数の和を求めたいときに,縦で数える
        ⇒3桁目は2**2,2桁目は2**1,3桁目は2**1
        ⇒2**2 + 2*2**1
        3桁目は常に1,2桁目以下は半分だけ1
        つまり,i桁目では2**(i-1) + (i-1)*2**(i-2)
    よって,
    dp[3] = dp[2] + (2**2 + 2*2**(2-1))*C[3] + dp[2]
}
dpは常にmodを取り,2**iも常に計算していては間に合わないので逐次*2をしていく(modをとりながら)
"""
n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
    p %= mod
p *= 2
p %= mod
print(dp[-1]*p % mod)

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

int main(){
	int s, i;
	scanf("%d", &s);
	vector<int> last(1000001, -1);
	for(i = 1; ; i++){
		if(last[s] >= 0){
			printf("%d\n", i);
			return 0;
		}
		else{
			last[s] = i;
		}
		if(s % 2 == 0){
			s = s / 2;
		}
		else{
			s = 3 * s + 1;
		}
	}
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,E,N,X[10];
    ll ans=0;
    string S;
    bool F=false;
int main(){
    cin>>A>>B;
    ans=A*2-2;
    REP(i,A+1){
        ans+=2;
        DEB(ans)END
        if(ans==B){F=true;}
    }
    if(F)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3620
n = int(input())
A = list(map(int, input().split()))
A.sort()
l = 0
h = 0
i = n-1
while i >= 0:
    if i > 0 and A[i] == A[i-1] and l == 0:
        l = A[i]
        i -= 2
    elif i > 0 and A[i] == A[i-1] and h == 0:
        h = A[i]
        break
    else:
        i-=1
print (l*h)

Measured memory_bytes: 20100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b)
    out(c);
  else if (a == c)
    out(b);
  else
    out(a);
}
int main(void) { solve(); }


Measured memory_bytes: 3604
arr = []
key = 0
3.times do |i|
	arr[i] = gets.split.map(&:to_i)
end

num = gets.to_i

num.times do |g|
	tmp = gets.to_i
	3.times do |i|
		num.times do |j|
			if tmp == arr[i][j]
				arr[i][j] = 0
			end
		end
	end
end

3.times do |i|
	if arr[i][0] == arr[i][1] && arr[i][1] ==  arr[i][2]
		key = 1
	end
end

3.times do |i|
	if arr[0][i] == arr[1][i] && arr[1][i] ==  arr[2][i]
		key = 1
	end
end

if arr[0][0] == arr[1][1] && arr[1][1] ==  arr[2][2]
	key = 1
elsif arr[0][2] == arr[1][1] && arr[1][1] ==  arr[2][0]
	key = 1
end
if key == 1
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1788
#include "math.h"
#include <algorithm>
#include <set>
#include <complex>
#include <stack>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <random>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
    lli n, W;
    cin >> n >> W;
    vector<lli> d[4];
    lli w_1, v_1;
    // 重さがよんしゅるいなら全探索できる?
    cin >> w_1 >> v_1;
    lli a, b;
    d[0].push_back(v_1);
    rep(i, n - 1)
    {
        cin >> a >> b;
        d[a - w_1].push_back(b);
    }
    rep(i, 4) sort(d[i].begin(), d[i].end(), greater<lli>());
    lli w = 0, ans = 0;
    lli temp = 0;
    rep(i, d[0].size() + 1)
    {
        if (i != 0) {
            ans += d[0][i - 1];
        }

        lli t = ans;
        rep(j, d[1].size() + 1)
        {
            if (j != 0) {
                ans += d[1][j - 1];
            }
            lli memo = ans;
            rep(k, d[2].size() + 1)
            {
                if (k != 0) {
                    ans += d[2][k - 1];
                }
                lli meo = ans;
                rep(l, d[3].size() + 1)
                {
                    if (l != 0) {
                        ans += d[3][l - 1];
                    }
                    if (i * w_1 + j * (w_1 + 1) + k * (w_1 + 2) + l * (w_1 + 3) <= W) {
                        temp = max(temp, ans);
                    }
                }
                ans = meo;
            }
            ans = memo;
        }

        ans = t;
    }
    cout << temp << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];int c[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    c[0]=0;
    c[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    c[i]=min(c[i-1]+abs(a[i]-a[i-1]),c[i-2]+abs(a[i]-a[i-2]));
    cout<<c[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int alphabetCount[26]{0};
    char in, pre_in;
    while (in = getc(stdin))
    {
        // if(pre_in == '\n' && in == '\0')
        if(in == EOF)
            break;
        if ('A' <= in && in <= 'Z' || 'a' <= in && in <= 'z') {
            if ('A' <= in && in <= 'Z')
                    in += 'a' - 'A';
            alphabetCount[in - 'a']++;
        }
    }
    
    // cout << 'b' - 'a' << '\n';
    for(int i = 0 ; i < 26 ; i++)
        printf("%c : %d\n", 'a' + i, alphabetCount[i]);
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    ll n;
    cin >> n;
    ll ans;
    while(true){
        ll x = sqrt(n);
        if(x==sqrt(n)){
            ans=n;
            break;
        }
        n--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, c, k;
	cin >> n >> c >> k;
	vector<int> t(n);
	for(int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int j = i;
		while(j < n && j - i + 1 <= c && t[j] <= t[i] + k) {
			j++;
		}
		ans++;
		if(j == n) break;
		i = j - 1;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 640
use std::i64;
use std::cmp;

// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main(){
    input! {
        n: usize, w_lim: usize,
        wv: [(usize, usize); n],
    }

    let mut dp = vec![vec![0; w_lim+1]; n+1];
    for i in 1 .. w_lim+1 {
        for j in 1 .. n+1 {
            if i >= wv[j-1].0 {
                dp[j][i] = cmp::max(dp[j-1][i], dp[j-1][i-wv[j-1].0]+wv[j-1].1);
            } else {
                dp[j][i] = dp[j-1][i];
            }
        }
    }
    println!("{}", dp[n][w_lim]);
}




Measured memory_bytes: 106748
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }

  int prev = -1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int d = a[i];
    ans += b[d];

    if (prev != -1 && prev + 1 == d) {
      ans += c[prev];
    }

    prev = d;
  }

  cout << ans << endl;

  return 0;
}


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

const int INF = 1001001001;
int dist[100005][3];

int main()
{
    int n, m, a, b, s, t;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
    }
    cin >> s >> t;
    s--;
    t--;
    rep(i,n) rep(j,3) dist[i][j] = INF;
    queue<P> q;
    q.push(P(s,0));
    dist[s][0] = 0;
    while(!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (int u : to[v]) {
            int nl = (l + 1) % 3;
            if (dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u, nl));
        }
    }
    int ans = dist[t][0];
    if (ans == INF) cout << -1 << endl;
    else cout << ans/3 << endl;

    return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>
#define N 100000
typedef struct
{
    int parent;
    int left;
    int right;
} node;

node T[N];
 int finddepth(int x)
{
    int c=0;
    while(T[x].parent >= 0)
    {
        c++;
        x = T[x].parent;
    }
    return c;
}
void preorder(int root)
{
    if(root == -1) return;
     
    printf(" %d", root);
    preorder(T[root].left);
    preorder(T[root].right);
}
void inorder(int root)
{
    if(root == -1) return;
     
    inorder(T[root].left);
    printf(" %d", root);
    inorder(T[root].right);
}
void postorder(int root)
{
    if(root == -1) return;
     
    postorder(T[root].left);
    postorder(T[root].right);
    printf(" %d", root);
}
int main()
{
    int pa, x, y, i, j, n, k, c, root;
     
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        T[i].parent = -1;
        T[i].left = -1;
        T[i].right = -1;
    }
     
     
    for(i=0; i<n; i++)
    {
        scanf("%d", &pa);
         
        scanf("%d%d", &x, &y);
        if(x!=-1)T[x].parent = pa;
        if(y!=-1)T[y].parent = pa;
        T[pa].left = x;
        T[pa].right = y;
         
    }
     
    for(i=0; i<n; i++)
    {
        if(T[i].parent == -1)
        {
            root = i;
            break;
        }
    }
     
    printf("Preorder\n");
    preorder(root);
    printf("\n");
     
    printf("Inorder\n");
    inorder(root);
    printf("\n");
     
    printf("Postorder\n");
    postorder(root);
    printf("\n");
     
    return 0;
}



Measured memory_bytes: 2096
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int a,b; cin >>a >>b;
  if(a>b)swap(a,b);
  rep(i,b){
    printf("%d",a);
  }
}

/// confirm df==0 ///


Measured memory_bytes: 256
using System;

class E
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = h[0], m = n * (n - 1) / 2 - h[1];

		if (m < n - 1) { Console.WriteLine(-1); return; }

		Console.WriteLine(m);
		for (int c = 0, i = 1; i <= n; i++)
			for (int j = i + 1; j <= n && c < m; j++, c++)
				Console.WriteLine($"{i} {j}");
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d) cout << "Left" << endl;
    if (a + b < c + d) cout << "Right" << endl;
    if (a + b == c + d) cout << "Balanced" << endl;
    
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  ll x, ans = 0, table = 100;
  cin >> x;
  while (table < x) {
    table = (ll)(table*1.01);
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 10*60
#define EPS 1e-9

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  int dist_x=tx-sx,dist_y=ty-sy;
  string ans="";
  REP(i,0,dist_y){
    ans+='U';
  }
  REP(i,0,dist_x){
    ans+='R';
  }
  ans+='U';
  REP(i,0,dist_x+1){
    ans+='L';
  }
  REP(i,0,dist_y+1){
    ans+='D';
  }
  ans+='R';
  REP(i,0,dist_x){
    ans+='R';
  }
  REP(i,0,dist_y){
    ans+='U';
  }
  ans+='R';
  REP(i,0,dist_y+1){
    ans+='D';
  }
  REP(i,0,dist_x+1){
    ans+='L';
  }
  ans+='U';

  print(ans)



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  int N,M,X;
  cin>>N>>M>>X;
  vector<int> COST(N);
  vector<vector<int> > data (N,vector<int>(M,0));
  for (int i = 0; i < N; i++)
  {
    cin>>COST[i];
    for (int j = 0; j < M; j++)
    {
      cin>>data[i][j];
    }
    
  }
  int ANS = INF;
  
  for (int bit = 0; bit < (1<<N); bit++)
  {
    vector<int> b(N,0);
    for (int i = 0; i < N; i++)
    {
      if((bit>>i)&1)
      {
        b[i] = 1;
      }
    }
    int SUM_COST = 0;
    vector<int> skill(M,0);
    for (int i = 0; i < N; i++)
    {
      if(b[i] == 1)
      {
        SUM_COST += COST[i];
        for (int j = 0; j < M; j++)
        {
          skill[j] += data[i][j];
        }
        
      }
    }

    int check = 1;
    for (int i = 0; i < M; i++)
    {
      if(skill[i] < X)check = 0;
    }
    if(check == 1)
    {
      chmin(ANS,SUM_COST);
    }
    
    
    
  }
  if(ANS == INF)
  {
    cout<<-1<<endl;
  }
  else
  {
    cout<<ANS<<endl;
  }
  
  

  return; 
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3660
function main()
    d,t,s=myreads(Int)
    if s*t<d
        println("No")
    else
        println("Yes")
    end
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=parse.(ty,sreads())
main()

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

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

 for(int i=0;i<Q;i++){
	int c,a,n;
	cin>>c>>a>>n;

	int can=min(min(c,a),n);
	c-=can;
	a-=can;

 	int cca=min(c/2,a);
	c-=cca*2;

	int ccc=c/3;

	cout<<can+cca+ccc<<endl;
 }
return 0;
}

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto whn = readln.split.map!(to!int);
    auto w = whn[0];
    auto h = whn[1];
    auto n = whn[2];

    int t = h, b = 0, l = 0, r = w;

    foreach (_; 0..n) {
        auto xya = readln.split.map!(to!int);
        auto x = xya[0];
        auto y = xya[1];
        auto a = xya[2];

        switch (a) {
            case 1:
                l = l < x ? x : l;
                break;
            case 2:
                r = r > x ? x : r;
                break;
            case 3:
                b = b < y ? y : b;
                break;
            case 4:
                t = t > y ? y : t;
                break;
            default:
        }
    }

    writeln(r <= l || t <= b ? 0 : (r-l)*(t-b));
}

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int> Solve(int N)
        {
            var primes = new List<int> { 2 };
            var ans = new List<int>();
            for (int i = 3; ans.Count < N; ++i)
            {
                if (primes.All(prime => i % prime != 0))
                {
                    primes.Add(i);
                    if (i % 10 == 3) { ans.Add(i); }
                }
            }
            return ans;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            Console.WriteLine(string.Join(" ", Solve(N)));
        }
    }
}


Measured memory_bytes: 13268
R,G,B,N=list(map(int,raw_input().strip().split(' ')))
R,G,B=sorted([R,G,B])[::-1]
dic={}
count=0
for i in xrange(0,N//(R)+1):
    temp=i*R
    for j in xrange(0,(N-temp)//G+1):
        temp2=j*G
        if (temp+temp2)<N+1 and (N-temp-temp2)%B==0:
            count+=1
print(count)


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;

char S[101010][20];
vector<string> sv;
ll alp[256];
ll i,j,k,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%s", S[i]);
        fornum(j,0,10){
            alp[S[i][j]]++;
        }
        string s;
        fornum(j,'a','z'+1){
            fornum(k,0,alp[j]){
                s += j;
            }
            alp[j] = 0;
        }
        sv.push_back(s);
    }
    sort(sv.begin(), sv.end());
    j = 0;
    fornum(i,1,N){
        //cout << sv[i] << endl;
        if(sv[i]==sv[i-1]){
            j++;
            ans += j;
        }else{
            j = 0;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 9204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}


int main(void){
    int n, a;
    scanf("%d %d", &n, &a);
    if (n%500 <= a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 384
x1,y1,x2,y2 = map(int,input().split())

x_dif = x2-x1
y_dif = y2-y1

x4, y4 = x1 - y_dif, y1 + x_dif
x3, y3 = x2 - y_dif, y2 + x_dif

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
c = {
    "S":[0]*13,
    "H":[0]*13,
    "C":[0]*13,
    "D":[0]*13,
    }
n = int(input())
for i in range(n):
	s, num = input().split()
	c[s][int(num)-1]=1
for i in ["S", "H", "C", "D"]:
	for j in range (13):
		if c[i][j] ==0:
			print(i, j+1)
		


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
double test[213456], aa[213456]; string uiop[213456];
signed main() {
	int n, a, k, c = 1234567890; double b = 0, ans = 0; cin >> n >> k;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a;
	}
	for (int h = 0; h < n; h++) {
		aa[h] = (test[h] + 1) / 2;
	}
	for (int h = 0; h < k - 1; h++) {
		b += aa[h];
	}
	for (int h = k - 1; h < n; h++) {
		ans = max(ans, b + aa[h]);
		b += aa[h] - aa[h - k + 1];
	}
	printf("%.10f\n", ans);
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, L;
const int MAX_N = 100000;
ll a[MAX_N];

int main(){
  cin >> N >> L;
  REP(i, N) cin >> a[i];

  ll x = N;
  REP(i, N - 1) {
    if(a[i] + a[i + 1] >= L) {
      x = i;
      break;
    }
  }

  if(x == N) cout << "Impossible" << endl;
  else {
    cout << "Possible" << endl;
    REP(i, x) {
      cout <<  i + 1 << endl;
    }
    for(int i = N - 1; i >= x + 1; i--) {
      cout << i << endl;      
    }
  }

  return 0;
}




Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll h, n;
	cin >> h >> n;
	
	vector<ll> a(n), b(n);
	for(ll i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	
	const ll oo = 1e15;
	
	vector<ll> dp(h + 5, oo);
	dp[0] = 0;
	
	for(ll i = 1; i <= h; i++){
		for(ll j = 0; j < n; j++){
			dp[i] = min(dp[i], dp[max(i - a[j], 0ll)] + b[j]);
		}
	}

	cout << dp[h] << endl;

	return 0;
}


Measured memory_bytes: 384
def p(a):
    for i in a[:-1]:
        print(i,end=' ')
    print(a[-1])


def bubble_sort(a):
    cnt = 0
    for i in range(len(a)-1):
        for j in range(i+1,len(a))[::-1]:
            if a[j-1]>a[j]:
                cnt+=1
                tmp = a[j]
                a[j] = a[j-1]
                a[j-1] = tmp
    p(a)
    print(cnt)


n = int(input())
l = list(map(int,input().split()))
bubble_sort(l)


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

template<typename T> 
struct BIT{
  Int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_,T d):n(n_),bit(n_+1,d){}
  
  T sum(Int i){
    T s=bit[0];
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  
  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
	w-=bit[x+k];
	x+=k;
      }
    }
    return x+1;
  }
  
  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }

  T query(Int l,Int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(Int l,Int r){
    return sum(r)-sum(l);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  auto calc=
    [&](Int x)->Int{
      vector<Int> b(n);
      for(Int i=0;i<n;i++) b[i]=a[i]<=x?1:-1;
      BIT<Int> bit(n*2+100,0);
      Int res=0,tmp=n+1;
      bit.add(tmp,1);
      for(Int i=0;i<n;i++){
	tmp+=b[i];
	res+=bit.sum(tmp-1);
	bit.add(tmp,1);
      }
      return res;
    };
  
  Int k=(n*(n+1)/2)/2;
  Int l=0,r=1.1e9;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(calc(m)<=k) l=m;
    else r=m;
  }
  //cout<<k<<":"<<calc(l)<<" "<<calc(r)<<endl;
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 3416
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{
    char c;
    cin >> c;
    if(c>='A' && c<='Z') cout << "A" << endl;
    else cout << "a" << endl;
	bye;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int h,w,a,b;

    cin >> h >> w >> a >> b;

    string str1,str2;
    if(a == 0){
        str1 = string(w-a,'1');
        str2 = string(w-a,'0');
    }else{
        str1 = string(a,'0')+string(w-a,'1');
        str2 = string(a,'1')+string(w-a,'0');
    }

    
    for(int i = 0; i < b; i++){
        
        cout << str1 << endl;
    }
    for(int i = b; i < h; i++){
        
        cout << str2 << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;



int main(){

    string s;
    cin >> s;

    int index = s.size();
    bool ans = true;

    while(true){
        
        index = index - 5;

        if(index < 0){
            ans = false;
            break;
        }

        string tmp = s.substr(index,5);

        if(tmp != "dream" && tmp != "erase"){
            index = index - 1;

            if(index < 0){
                ans = false;
                break;
            }

            tmp = s.substr(index,6);

            if(tmp != "eraser"){
                index = index - 1;
                
                if(index < 0){
                    ans = false;
                    break;
                }
                
                tmp = s.substr(index,7);

                if(tmp != "dreamer"){
                    ans = false;
                    break;
                }
            }
        }

        if(index == 0) break;

    }

    cout << (ans ? "YES" : "NO") << endl;


    return 0;
}

Measured memory_bytes: 512
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    long ans;
    auto infomat = new long[][](n, n);
    foreach (ref e; infomat)
        e[] = -1;
    foreach (i; iota(n))
    {
        auto a = lread();
        foreach (_; iota(a))
        {
            long x, y;
            scan(x, y);
            infomat[i][x - 1] = y;
        }
    }
    // 右から1スタートで扱う
    foreach (mask; iota(1 << n))
    {
        auto state = new long[](n);
        bool contradict;
        // writefln("%02b", mask);
        foreach (shift; iota(n))
            state[shift] = (mask & (1 << shift)) ? 1 : 0;
        foreach (i; iota(n))
        {
            if (state[i])
            {
                foreach (j; iota(n))
                {
                    if (infomat[i][j] == -1)
                        continue;

                    contradict |= (state[j] != infomat[i][j]);
                }
            }
        }
        if (!contradict)
            ans = max(mask.popcnt(), ans);
    }
    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 1276
N = int(input())
A = str(input()).split(" ")

target_list = []
for i in range(len(A)):
    target_list.append([int(A[i]), i + 1])

target_list = sorted(target_list)

result = ""
for target in target_list:
    result += str(target[1]) + " "

print(result)


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

struct UnionFind{
// 同値関係をサポートするデータ構造
// 併合,所属する同値類の代表元: O(a(n)), 集合の分割はNG
// (a(n): アッカーマン関数A(m,n)について,f(n)=A(n,n)としたときの逆関数)
  vector<int> m_root;
  vector<int> m_size;
  int m_Ngroup;

  UnionFind(int N)
  : m_root(N)
  , m_size(N,1)
  , m_Ngroup(N)
  { iota(m_root.begin(), m_root.end(), 0); }

  int find(int a){
    if(m_root.at(a)==a){
      return a;
    }
    else{
      return m_root.at(a)= find(m_root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);

    if(r_a != r_b){
      m_Ngroup--;
      if(m_size.at(r_a) < m_size.at(r_b)){
        m_root.at(r_a)= r_b;
        m_size.at(r_b)+= m_size.at(r_a);
        return;
      }
      else{
        m_root.at(r_b)= r_a;
        m_size.at(r_a)+= m_size.at(r_b);
        return;
      }
    }
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

  int get_size() const{
    return m_Ngroup;
  }
  int get_size(int a){
    return m_size.at(find(a));
  }
};

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

  UnionFind uf(N);
  int buf1,buf2;
  for(int j=0; j<M; j++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    uf.unify(buf1, buf2);
  }

  int ans= uf.get_size()- 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3928
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N;  cin >> N;
    vector<pl> vp;
    for (int i = 0; i < N; i++){
        long long a,b; cin >> a >> b;
        vp.push_back({b,a});
    }
    sort(vp.begin(),vp.end());
    long long time = 0;
    bool flg = true;
    for (int i = 0; i < N; i++){
        time += vp[i].second;
        if (time > vp[i].first){
            flg = false;
        }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}





Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
int a[200000];
int main() {
	int n;
	cin>>n;
	vector<int> v;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int r=0;
	bool flg=true;
	rep(i,n){
		if(a[i]==r)flg=false;
		r=a[i];
	}
	if(flg){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}


Measured memory_bytes: 3456
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 1e5+5;

int N, K;
int x[MAXN];

int main(){
	scan(N, K);
	for(int i=0; i<N; i++) scan(x[i]);
	int ans = 6e8;
	for(int i=0; i+K-1<N; i++){
		int l = x[i], r = x[i+K-1];
		mnze(ans, abs(l-r) + abs(l));
		mnze(ans, abs(l-r) + abs(r));
	}
	printf("%d\n", ans);
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];

    unordered_map<int,int> m;
    for(int i = 0; i < n; ++i)
        ++m[a[i]];
    vector<int> v;
    for(auto& p : m)
        v.push_back(p.second);
    sort(v.begin(), v.end());
    vector<int> rui(n + 1, 0);
    vector<i64> cnt(n + 1, 0);
    for(int i = 0; i < v.size(); ++i)
        ++rui[v[i]];
    for(int i = n; i > 0; --i){
        cnt[i - 1] = cnt[i] + rui[i];
        rui[i - 1] += rui[i];
    }

    // rui[k]: k以上の物の数

    // k減らすのをc回できるかどうか
    auto f = [&](int k, int c){
        return n - cnt[c] >= 1LL * k * c;
    };

    for(int k = 1; k <= n; ++k){
        int ok = 0, ng = n + 1;
        while(ng - ok > 1){
            int mid = (ok + ng) / 2;
            (f(k, mid) ? ok : ng) = mid;
        }
        printf("%d\n", ok);
    }
}



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

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

struct edge { int to, cost; };

void dijkstra(vector<vector<edge>>& G, vector<ll>& d, int s) {
	priority_queue<P, vector<P>, greater<P>> que;
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) { continue; }

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<edge>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		g[u].push_back({v, w % 2});
		g[v].push_back({u, w % 2});
	}

	vector<ll> d(N, 1e8);
	dijkstra(g, d, 0);

	for (int i = 0; i < N; ++i) {
		cout << d[i] % 2 << endl;
	}

	return 0;
}


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

const int mod = 1e9 + 7;

long long binpow(long long b, int e) {
  long long res = 1;
  while (e) {
    if (e & 1) res *= b, res %= mod;
    e >>= 1;
    b *= b;
    b %= mod;
  }
  return res;
}

long long inv(long long x) {
  return binpow(x, mod - 2);
}

const int N = 80, OFFSET = N * 2 * N;
int a[N][N], b[N][N], dp[N][N][N * 4 * N + 10];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> a[i][j];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x;
      cin >> x;
      a[i][j] = abs(a[i][j] - x);
      // cerr << a[i][j] << ' ';
    }
    // cerr << endl;
  }
  dp[0][0][OFFSET - a[0][0]] = dp[0][0][OFFSET + a[0][0]] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = OFFSET - N * (i + j + 1); k <= OFFSET + N * (i + j + 1); k++) {
        if (dp[i][j][k]) {
          if (i + 1 < h) {
            dp[i + 1][j][k + a[i + 1][j]] = dp[i + 1][j][k - a[i + 1][j]] = 1;
          }
          if (j + 1 < w) {
            dp[i][j + 1][k + a[i][j + 1]] = dp[i][j + 1][k - a[i][j + 1]] = 1;
          }
        }
      }
    }
  }
  int ans = 1e9;
  for (int i = OFFSET - (h + w) * N; i <= OFFSET + (h + w) * N; i++) {
    if (dp[h - 1][w - 1][i]) {
      // cout << i - OFFSET << endl;
      ans = min(ans, abs(OFFSET - i));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 638720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	a.erase(unique(a.begin(), a.end()), a.end());

	long long now = 1000;
	long long kabu = 0;
	for (int i = 0; i < a.size() - 1; i++) {
		if (a[i] > a[i + 1]) {
			now += a[i] * kabu;
			kabu = 0;
		} else {
			if (now / a[i]) {
				kabu += now / a[i];
				now -= kabu * a[i];
			}
		}
	}
	now += kabu * a[a.size() - 1];

	cout << now << endl;
	
	return 0;
}

Measured memory_bytes: 3624