akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A[200000];
  cin>>N;
  for (int i(0);i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);
  for (int i(1);i<N;i++){
    if (A[i] == A[i-1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}



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

typedef long long ll;

int main()
{

    //freopen("input.txt", "r", stdin);

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

    if (k == 0)
    {
        printf("%lld", n * 1ll * n);
        return 0;
    }

    ll ans = 0;
    for (int i = k + 1; i <= n; ++i)
    {
        ans += n / i * 1ll * (i - k);
        if (n % i >= k)
            ans += n % i - k + 1;
    }

    printf("%lld", ans);
}


Measured memory_bytes: 256
n, m, q = gets.split.map(&:to_i)

a = Array.new(n+2) {Array.new(n+2, 0)}
m.times do
    l, r = gets.split.map(&:to_i)
    a[l][r] += 1
end

n.downto(1) do |i|
    i.upto(n) do |j|
        a[i][j+1] += a[i][j]
        a[i][j] += a[i+1][j]
    end
end

q.times do
    x, y = gets.split.map(&:to_i)
    p a[x][y]
end

Measured memory_bytes: 4988
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	cin >> s;
	int n = s.length(), i, j, k, ct = 0;
	for (i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) ct++;
	}
	cout << ct << "\n";

	return 0;
}



Measured memory_bytes: 512
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        if(A-B >= 0) {
            System.out.println("delicious");
        }else if(B-A <= X) {
            System.out.println("safe");
        }else {
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    ll n, h; cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    ll a_max = a[n-1];
    
    int id = n-1;
    int ans = 0;
    while(1){
        if(0<=id && a_max<b[id]) { h -= b[id--]; ++ans; }
        else break;

        if(h<=0){
            cout << ans << '\n';
            return 0;
        }
    }

    ans += (h+a_max-1)/a_max;
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 1024
X = int(input())

ranking_class_q = X // 200

if ranking_class_q == 9:
    output = 1
elif ranking_class_q == 8:
    output = 2
elif ranking_class_q == 7:
    output = 3
elif ranking_class_q == 6:
    output = 4
elif ranking_class_q == 5:
    output = 5
elif ranking_class_q == 4:
    output = 6
elif ranking_class_q == 3:
    output = 7
elif ranking_class_q == 2:
    output = 8
    
print(output)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6;

ll n, m, k, t;

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    string s;
    cin >> s;
    cin >> k;
    n = s.length();
    bool f = 0;
    bool f1 = 0;
    ll cnt1 = 0, cnt2 = 0;
    ll dans = 0;
    ll cur = 1;
    for (q = 1; q < n; q++) {
        if (s[q] == s[q - 1]) {
            cur++;
        }
        else {
            if (!f) {
                f1 = cur % 2;
            }
            f = 1;
            dans += cur / 2;
            cur = 1;
        }
    }
    if (!f) {
        cout << n * k / 2;
        return 0;
    }
    dans += cur / 2;
    ll ans = dans * k;
    if (s[n - 1] == s[0] && cur % 2 == 1 && f1) {
        ans += k - 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    int n,k,c,i,j,l,m,p;
    cin >> n >> k >> c;
    string st;
    cin >> st;
    set<int> s;
    set<int , greater<int> > gs;
    vector<int> lf , rt;

    for(i = 0; i < n; i++){
        if(st[i] == 'o'){
            s.in(i);
            gs.in(i);
        }
    }

    if(s.size() == 0){
        return 0;
    }

    i = *(s.begin());
    p = 1;
    lf.pb(i);
    while(true){
        if(p == k)
            break;
        auto it = s.lb(i + c + 1);
        if(it == s.end())break;
        i = *it;
        lf.pb(i);
        p++;
    }

    if(p < k)return 0;

    i = *(gs.begin());
    p = 1;
    rt.pb(i);
    while(true){
        if(p == k)
            break;
        auto it = gs.lb(i - c - 1);
        if(it == gs.end())break;
        i = *it;
        rt.pb(i);
        p++;
    }

    if(p < k)return 0;
    reverse(all(rt));
    for(i = 0; i < k; i++){
        if(lf[i] == rt[i])cout << lf[i] + 1 << endc;
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> s(26,1);
  
  for(int i=0; i<n; i++){
    char c;
    cin>>c;
    s[c-97]++;
  }

  long long ans=1;
  for(int i=0; i<26; i++){
    ans*=s[i];
    ans%=1000000007;
  }

  cout<<ans-1<<endl;
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int a[100010];
bool used[100010];

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

  int k;
  cin >> k;

  deque<int> dq;
  dq.push_back(1);
  a[1] = 1;
  while (!dq.empty()) {
    int tp = dq.front();
    dq.pop_front();
    if (used[tp]) continue;
    used[tp] = 1;
    int x = (tp+1)%k;
    int y = (tp*10)%k;
    if (!used[x]) {
      a[x] = a[tp]+1;
      dq.push_back(x);
    }
    if (!used[y]) {
      a[y] = a[tp];
      dq.push_front(y);
    }
    /*
    if (x == 0) {
      cout << a[x] << endl;
      return 0;
    }
    if (y == 0) {
      cout << a[y] << endl;
      return 0;
    }
    */
  }
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
s = input()

if (s[0] == s[1]) and (s[2] == s[3]) and (s[0] != s[2]):
    print("Yes")
elif (s[0] == s[2]) and (s[1] == s[3]) and (s[0] != s[1]):
    print("Yes")
elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9060
S = input()
T = input()

converter = dict()

for s, t in zip(S, T):
    if converter.get(s) is not None:
        if converter[s] != t:
            print("No")
            break
    else:
        converter[s] = t
else:
    if len(converter.values()) != len(set(converter.values())):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3632
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K, S = mapint()
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0<=(S-i-j)<=K:
            cnt += 1

print(cnt)

Measured memory_bytes: 67580
a=[]

A=0
B=0
C=0
while True:
    N=int(input())
    if N==0:
        break
    else:
        for i in range (N+1):
            if i%2 != 0:
                pass
            else:
                while i!=0 and i%2==0 :
                    i=i//2
                    A+=1
        for i in range (N+1):
            if i%5 != 0:
                pass
            else:
                while i!=0 and i%5==0 :
                    i=i//5
                    B+=1        
    
        for i in range (N+1):
            if i%10 != 0:
                pass
            else:
                while i!=0 and i%10==0 :
                    i=i//10
                    C+=1
        D=A-C
        E=B-C
        if D<E:
            print(D+C)
        else:
            print(E+C)
        A=0
        B=0
        C=0


Measured memory_bytes: 5592
#include <vector>
#include <algorithm>
#include <iostream>
int main()
{
    std::size_t n;
    std::cin >> n;
    std::vector<std::uint32_t> v(n);
    for(auto&& i : v) std::cin >> i;
    std::sort(v.begin(), v.end());
    std::cout << ((v.end() == std::unique(v.begin(), v.end())) ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 1024
#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<ll, ll>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

void solve(long long S) {
    ll div = S / 3;
    combination comb = combination(int(1e6) + 5);

    mint ans = 0;
    for (int i = 1; i <= div; i++) {
        ll temp = S - 3 * i;
        ans += comb(temp + i - 1, temp);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long S;
    scanf("%lld", &S);
    solve(S);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int t;
        cin >> t;
        if(t%4==0){
            mp[2]++;
        }else if(t%2==0){
            mp[1]++;
        }else{
            mp[0]++;
        }
    }

    
    if(mp[1]==0){
        if(mp[2]+1>=mp[0]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(mp[2]>=mp[0]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int i1,i2,i3,i4;
    i1 = n / 1000;
    n = n % 1000;
    i2 = n / 100;
    n = n % 100;
    i3 = n / 10;
    i4 = n % 10;
    if(i2 == i3 && (i1 == i2 || i3 == i4)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>  
#include<vector>  
#include<algorithm>  
#include<string>  
  
using namespace std;  
int mas[1001][1001][3];  
int main(){  
  
  int M, N, K;  
  string tmp = "JOI";  
  
  cin >> M >> N;  
  cin >> K;  
  for(int i = 1 ; i <= M ; i++ ){  
    for(int j = 1 ; j <= N ; j++ ){  
      char c;  
      cin >> c;  
      for(int k = 0 ; k < 3 ; k++ ){  
        mas[i][j][k] = mas[i-1][j][k] + mas[i][j-1][k] - mas[i-1][j-1][k];  
      }  
      mas[i][j][tmp.find(c)]++;  
    }  
  }  
  for(int i = 0 ; i < K ; i++ ){  
    int a, b, c, d;  
    cin >> a >> b >> c >> d;  
    for(int j = 0 ; j < 3 ; j++ ){  
      cout << (j?" ":"") << mas[c][d][j] + mas[a-1][b-1][j] - mas[a-1][d][j] - mas[c][b-1][j];  
    }  
    cout << endl;  
  }  
}  

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

int main() {
  int l, a, b, c, d;
  cin >> l >> a >> b >> c >> d;
  cout << l - max( a / c + !!( a % c ), b / d + !! ( b % d ) ) << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 5;

vector<pll> prime_factorize(ll n) {
    vector<pll> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

void solve() {
    ll N; cin >> N;
    auto primes = prime_factorize(N);
    vector<ll> vec;
    for(auto it : primes){
        for(ll i = 1; i <= it.second; ++i){
            ll tmp = pow(it.first, i);
            vec.push_back(tmp);
        }
    }
    ll ans = 0;
    for(int i = 0; i < vec.size(); ++i){
        if(N%vec[i]==0){
            N /= vec[i];
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 4052
h,w = map(int,input().split())
lst = ["." * (w + 2)]
for _ in range(h):
  s = input()
  s = "." + s + "."
  lst.append(s)
lst.append("." * (w + 2))

flag = True

for x in range(1,h + 1):
  for y in range(1,w + 1):
    if lst[x][y] == "#":
      if lst[x - 1][y] == "." and lst[x + 1][y] == "." and lst[x][y + 1] == "." and lst[x][y - 1] == ".":
        flag = False
        break

if flag:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 25

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];
void Depth(int, int);
int Height(int);
int Sibling(int);

int main(){
  int i, id, l, r, root = 0, count = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].parent = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d%d",&id, &l, &r);
    T[id].left = l;
    T[id].right = r;
    if(l != -1) T[l].parent = id;
    if(r != -1) T[r].parent = id;
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == -1) root = i;
    Depth(root,0);
    Height(root);
  }

  for(i = 0; i < n; i++){
    count = 0;
    printf("node %d: parent = %d, sibling = %d, ",i, T[i].parent, Sibling(i));
    if(T[i].left != -1) count++;
    if(T[i].right != -1) count++;    
    printf("degree = %d, depth = %d, height = %d, ",count, D[i], H[i]);
    if(T[i].parent == -1) printf("root\n");
    else if(T[i].left == -1 && T[i].right == -1) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

void Depth(int r, int p){
  if(r == -1) return;
  D[r] = p;
  Depth(T[r].left, p+1);
  Depth(T[r].right, p+1);
}

int Height(int r){
  int hl = 0, hr = 0;
  if( T[r].left != -1) hl = Height(T[r].left)+1;
  if( T[r].right != -1) hr = Height(T[r].right)+1;
  if( hl > hr ){
    H[r] = hl;
    return H[r];
  }
  else{
    H[r] = hr;
    return H[r];
  }
}

int Sibling(int r){
  if(T[r].parent == -1) return -1;
  if(T[T[r].parent].left != r && T[T[r].parent].left != -1) return T[T[r].parent].left;
  if(T[T[r].parent].right != r && T[T[r].parent].right != -1) return T[T[r].parent].right;
  return -1;
}

Measured memory_bytes: 612
N, K = map(int, input().split())
import math
ans = 0
for i in range(1, N+1):
    if i >= K:
        ans += 1 / N
    else:
        tmp = math.ceil(math.log(K/i, 2))
        ans += (1 / N) * 0.5**tmp
print(ans)


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

int main ()
{
    int n;
    cin >> n;
    int x = n;
    int sum = 0;
    while(x > 0){
        sum += x % 10;
        x /= 10;
    }
    if(n % sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n), b;
    rep(i, n) cin >> a[i];
    
    rep(i, n) {
        if ((i & 1) != (n & 1)) {
            b.insert(b.begin(), a[i]);
        }
        else {
            b.push_back(a[i]);
        }
    }
    
    rep(i, n) {
        printf("%d%s", b[i], ((i == (n - 1)) ? "\n" : " "));
    }
    
    return 0;
}


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

int main() {

	string line;
	char c;

	getline(cin, line);
	for (int i = 0; i < (int) line.length(); ++i) {
		c = line.at(i);
		if (c >= 'A' && c <= 'Z') {
			cout << (char) tolower(c);
		} else if (c >= 'a' && c <= 'z') {
			cout << (char) toupper(c);
		} else {
			cout << c;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1176
# -*- coding: utf-8 -*-
n = int(input().strip())
a = list(map(lambda x: int(x), input().strip().split()))
min = 1000000
max = -1000000
sum = 0
for i in (range(n)):
    if(min > a[i]):
        min = a[i]
    if(max <  a[i]):
        max =  a[i]
    sum +=  a[i]
print("{0} {1} {2}".format(min, max, sum))

Measured memory_bytes: 8760
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};
// use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        r: usize,
        c: usize,
        k: usize,
        rcv: [(usize, usize, u64); k],
    }
    let mut items: Vec<Vec<u64>> = vec![vec![0; c]; r];
    for &(rr, cc, v) in &rcv {
        items[rr - 1][cc - 1] = v;
    }
    let mut dp: Vec<Vec<Vec<u64>>> = vec![vec![vec![0; 4]; c]; r];
    let mut ans = 0;
    for i in 1..=r {
        for j in 1..=c {
            for l in 0..=3 {
                if i == 1 && j == 1 {
                    if l == 0 {
                        dp[i - 1][j - 1][l] = 0;
                    } else if l == 1 {
                        dp[i - 1][j - 1][l] = items[i - 1][j - 1];
                    }
                    ans = ans.max(dp[i - 1][j - 1][l]);
                    continue;
                }
                if i > 1 {
                    for ll in 0..=3 {
                        dp[i - 1][j - 1][l] = dp[i - 1][j - 1][l].max(dp[i - 2][j - 1][ll]);
                        if l > 0 {
                            dp[i - 1][j - 1][l] =
                                dp[i - 1][j - 1][l].max(dp[i - 2][j - 1][ll] + items[i - 1][j - 1]);
                        }
                    }
                }
                if j > 1 {
                    dp[i - 1][j - 1][l] = dp[i - 1][j - 1][l].max(dp[i - 1][j - 2][l]);
                    if l > 0 {
                        dp[i - 1][j - 1][l] =
                            dp[i - 1][j - 1][l].max(dp[i - 1][j - 2][l - 1] + items[i - 1][j - 1]);
                    }
                }
                ans = ans.max(dp[i - 1][j - 1][l]);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 713056
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 = 100_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;
    foreach (i; iota(n).map!(x => x + 1).array())
    {
        ans += (i + i * (n / i)) * (n / i) / 2;
    }
    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: 80896
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>

using namespace std;
typedef tuple<int, int, int> tiii;
static const int INF = 1000000000;
static const int dx[] = { 1, 0, -1, 0 };
static const int dy[] = { 0, -1, 0, 1 };

inline bool between(int a, int b, int c){
	return a <= b && b < c;
}

int main(){
	ios_base::sync_with_stdio(false);
	int r, c;
	cin >> r >> c;
	vector<string> field(r);
	priority_queue<tiii, vector<tiii>, greater<tiii>> pq;
	vector<vector<int>> dist(r, vector<int>(c, INF));
	for(int i = 0; i < r; ++i){
		cin >> field[i];
		for(int j = 0; j < c; ++j){
			if(field[i][j] == 'S'){
				pq.emplace(0, i, j);
				dist[i][j] = 0;
			}
		}
	}
	int answer = INF;
	while(!pq.empty()){
		const auto t = pq.top();
		pq.pop();
		const int cost = get<0>(t);
		const int y = get<1>(t);
		const int x = get<2>(t);
		if(cost > dist[y][x]){ continue; }
		if(field[y][x] == 'G'){ answer = min(answer, cost); }
		for(int d = 0; d < 4; ++d){
			for(int i = 1; i <= 3; ++i){
				const int ny = y + dy[d] * i, nx = x + dx[d] * i;
				if(!between(0, ny, r) || !between(0, nx, c)){ break; }
				if(field[ny][nx] == '#'){ break; }
				int nc = cost + 2 + i;
				if(i == 1 && field[ny][nx] == 'o'){
					nc = cost + 1;
				}else if(i == 1 && field[ny][nx] != 'x'){
					nc = cost + 2;
				}
				if(nc < dist[ny][nx]){
					dist[ny][nx] = nc;
					pq.emplace(nc, ny, nx);
				}
			}
		}
	}
	cout << answer << endl;
	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int L;
int tw[22];
vint u, v, w;
signed main() {
    tw[0] = 1;
    for (int i = 1; i < 22; i++)tw[i] = tw[i - 1] * 2;
    cin >> L;

    int N = 1;
    for (int i = 0; i < 20; i++) {
        if (tw[i + 1] > L)break;

        N++;
        u.push_back(i);
        v.push_back(i + 1);
        w.push_back(tw[i]);

        u.push_back(i);
        v.push_back(i + 1);
        w.push_back(0);
    }
    int cur = tw[N - 1];
    L -= cur;

    for (int i = 0; i <= 20; i++) {
        if (L % 2 == 1) {
            u.push_back(i);
            v.push_back(N - 1);
            w.push_back(cur);
            cur += tw[i];
        }
        L /= 2;
    }

    cout << N << endl;
    cout << u.size() << endl;
    for (int i = 0; i < u.size(); i++) {
        cout << u[i] + 1 << " " << v[i] + 1 << " " << w[i] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int par[maxn],size[maxn],x[maxn],y[maxn],n,m;
long long now,ans[maxn];
int find(int x)
{
	if(par[x]==x)return x;
	else return par[x]=find(par[x]);
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
		size[i]=1;
	}
	for(int i=1;i<=m;i++)
	scanf("%d %d",&x[i],&y[i]);
	now=(long long)n*(n-1)/2;
	for(int i=m;i>=1;i--)
	{
		ans[i]=now;
		int X=x[i],Y=y[i];
		X=find(X);Y=find(Y);
		if(X==Y)continue;
		now-=size[X]*size[Y];
		par[X]=Y;
		size[Y]+=size[X];
	}
	for(int i=1;i<=m;i++)
	printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3712
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    if  n >= sum(A):
        print(n - sum(A))
    else:
        print(-1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10188
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >>n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
		cin >>arr[i];
	int lo = *min_element(arr.begin(), arr.end());
	int hi = *max_element(arr.begin(), arr.end());
	int ans = INT_MAX;
	for(int b = lo; b <= hi; b++) {
		int curr = 0;
		for(auto ele : arr) {
			curr += (abs(ele - b) * abs(ele - b));
		}
		ans = min(ans, curr);
	}
	cout <<ans;
	return 0;
}


Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


x, y = LI()
ans = 'No'
for i in range(x + 1):
    f = 2 * i + 4 * (x - i)
    if f == y:
        ans = 'Yes'
        break
print(ans)


Measured memory_bytes: 9196
#include <stdio.h>

int main(void)
{
	int i;
	double x, y, sum, a;
	
	while (scanf("%lf", &a) != EOF){
		
		sum = a;
		for (i = 0; i < 9; i++){
			if (i % 2 == 0){
				y = a * 2;
				sum += y;
			}
			else{
				a = y / 3;
				sum += a;
			}
		}
		printf("%f\n", sum);
	}
	return (0);
}

Measured memory_bytes: 648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, t[200005];

void inc(int x, int v) {
    t[x += n] = v;
    for (x >>= 1; x; x >>= 1) t[x] = min(t[x << 1], t[x << 1 | 1]);
}

int que(int l, int r) {
    int z = mod;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1) z = min(z, t[l++]);
        if (r & 1) z = min(z, t[--r]);
    }
    return z;
}

int main() {
    ios::sync_with_stdio(false);
    int m, d[100005] = {};
    string s;
    cin >> n >> m >> s;
    for (int i = 0; i < n; i++) d[i] = mod, inc(i, mod);
    for (int i = n - 1; i >= 0; i--) if (s[i] == '0') {
        if (i + m >= n) d[i] = 1;
        else d[i] = que(i + 1, i + m + 1) + 1;
        inc(i, d[i]);
    }
    if (d[0] >= mod) {
        cout << -1;
        return 0;
    }
    int c = 0;
    while (c < n) {
        for (int i = c; ; i++) if (d[c] == d[i] + 1) {
            cout << i - c << ' ';
            c = i;
            break;
        }
    }
}


Measured memory_bytes: 4888
#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
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;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,i,j;
    cin>>n>>m>>x;
    ll c[n],a[n][m];
    for(i=0;i<n;i++)
    {
    	cin>>c[i];
    	for(j=0;j<m;j++)
    	{
    		cin>>a[i][j];
		}
	}
	ll ans=INT_MAX;
	for(i=0;i<power(2,n);i++)
	{
		int b[m]={0};
		ll sum=0;
		for(j=0;j<n;j++)
		{
			if((i>>j)&1)
			{
				sum+=c[j];
				for(int k=0;k<m;k++)
				{
					b[k]+=a[j][k];
				}
				
			}
		}
		int flag=0;
		for(j=0;j<m;j++)
		{
			if(b[j]<x)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			ans=min(sum,ans);
		}
		
	}
	if(ans!=INT_MAX)
	cout<<ans;
	else
	cout<<-1;

}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int a, b;
  cin >> a >> b;
  bool flag = false;
  REPS(i,1,20000) {
    if(floor(i*0.08) == a && floor(i*0.1) == b) {
      cout << i << endl;
      
      return 0;
    }
  }
  cout << -1;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int X, t; cin >> X >> t;

	cout << max(0, X - t) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,flag=0;
	cin >> a;
	for(int i = a;i>0;i--){
		if(0<i&&i<10){flag++;}
		else if(99<i&&i<1000){flag++;}
		else if(9999<i&&i<100000){flag++;}
	}
	cout << flag << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
{
    FIO
    VI v;
    int start = 1;
    int n; cin>>n;
    int arr[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>arr[i];
    }
    for (int i = 0; i < n; ++i)
    {
        if (start == arr[i])
        {
            v.PB(start);
            start++;
        }
    }

    if (v.size() == 0)
    {
        cout<<-1;
    }
    else {
        cout<<n-v.size();
    }


    
    return 0;
}

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


int main() {
    int d, g;
    cin >> d >> g;
    vector<tuple<int, int, int>> problems;
    for (int i = 1; i <= d; i++) {
        int p, c;
        cin >> p >> c;
        problems.emplace_back(i * 100, p, c);
    }
    
    int ans = 1e9;
    do {
        int sum = 0, qs = 0;
        for (auto& e : problems) {
            int score = get<0>(e), number = get<1>(e), bonus = get<2>(e);
            if (sum + score * number < g) {
                sum += score * number;
                qs += number;
                if (sum + bonus < g) {
                    sum += bonus;
                } else {
                    ans = min(ans, qs);
                    break;
                }
            } else {
                for (int i = 1; i <= number; i++) {
                    if (sum + score * i >= g) {
                        ans = min(ans, qs + i);
                        break;
                    }
                }
                break;
            }
        }
    } while (next_permutation(begin(problems), end(problems)));
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import static java.lang.Math.floor;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();

    if ((int)floor(floor(n / 1.08) * 1.08) == n) {
      System.out.println((int) floor(n / 1.08));
    } else if (floor(floor(n / 1.08 + 1) * 1.08) == n) {
      System.out.println((int) floor(n / 1.08) + 1);
    } else {
      System.out.println(":(");
    }
  }

}

Measured memory_bytes: 21972
def amari(num):
    if num%10 ==0:
        return 10
    return num%10

if __name__ =="__main__":
    S = []
    for x in range(5):
        S.append(int(input()))
    max_num = min(S,key=amari)
    S.remove(max_num)
    total=0
    for x in S:
        if x%10 == 0:
            total += x
        else:
            total+=(int(x/10)+1)*10
    print(total+max_num)
    
    

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

int main()
{
  int64_t N,A,B;
  cin >> N>>A>>B;
  int64_t count,amari;
  count=N/(A+B);
  amari=N%(A+B);
  if(amari>=A)
  {
    amari=A;
  }
  cout << count*A+amari <<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

C = []
for i in range(M):
    p, y = map(int, input().split())
    C.append([i, p, y])
C.sort(key=lambda x: (x[1], x[2]))

ans = []
k = C[0][1]
n = 1
for i in range(M):
    city = C[i][1]
    if k != city:
        k = city
        n = 1
    number = f'{city:06}{n:06}'
    ans.append([C[i][0], number])
    n += 1
ans.sort(key=lambda x: x[0])
for i in range(M):
    print(ans[i][1])


Measured memory_bytes: 116824
s=int(input())
x=s//100
y=s-x*100




if x>0 and x<13:
  if y>0 and y<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
     
else:
  if y>0 and y<13:
    print("YYMM")
  else:
    print("NA")

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a==2 || b==2){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n) {
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n << ":" << endl;
	for (int i = 2; i <= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, m;
string s, t;
signed main() {
	cin >> n >> m >> s >> t;
	int siz = lcm(n, m);
	for (int i = 0; i < siz; i+=Min(siz/n,siz/m)) {
		if (i%(siz/n) == 0 && i % (siz/m) == 0) {
			if (s[i / (siz / n)] != t[i / (siz / m)]) {
				cout <<-1<< endl;
				end;
			}
		}
	}
	cout << siz << endl;
	end;
}


Measured memory_bytes: 512
D = int(input())
c = list(map(int, input().split()))
s = [[]]
for _ in range(D):
  s.append(list(map(int, input().split())))

lasts = [0 for i in range(len(c))]
ans = 0
for d in range(1, D+1):
  t = int(input()) - 1
  lasts[t] = d
  ans += s[d][t]
  for i in range(len(c)):
    ans -= c[i] * (d - lasts[i])
  print(ans)

Measured memory_bytes: 9352
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
  min_x = i
  for j in range(i, N):
    if A[j] < A[min_x]:
      min_x = j
  if (i != min_x):
    A[i], A[min_x] = A[min_x], A[i]
    cnt += 1

print(" ".join(map(str, A)))
print(cnt)


Measured memory_bytes: 5596
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int n;
int a[102];

int selection_sort() {
    int res=0;
    rep(i,n) {
        int min_idx=i;
        for(int j=i+1;j<n;j++) {
            if(a[j]<a[min_idx]) min_idx = j;
        }
        if(i!=min_idx) res++;
        swap(a[i],a[min_idx]);
    }
    return res;
}

int main() {
    cin>>n;
    rep(i,n) cin>>a[i];
    int ans=selection_sort();
    rep(i,n) cout<<(i==0?"":" ")<<a[i];
    cout<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		Queue<Number> que = new PriorityQueue<>();
		long sum = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			que.offer(new Number(num));
			sum += num;
		}
		for(int i = 0; i < m; i++) {
			int num = que.poll().num;
			int hangaku = num / 2;
			que.offer(new Number(hangaku));
			sum = sum - (num - hangaku);
		}
		out.println(sum);

		out.close();
	}
	static class Number implements Comparable<Number>{
		int num;
		Number(int n){
			this.num = n;
		}
		@Override
		public int compareTo(Number o) {

			return  - Integer.compare(this.num, o.num);
		}
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 28540
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	x := make([]int, N)
	y := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i], &y[i])
	}
	answer := N
	for i := 1; i < N; i++ {
		p := x[0] - x[i]
		q := y[0] - y[i]
		ai := N
		for j := 0; j < N; j++ {
			a := x[j]
			b := y[j]
			for k := 0; k < N; k++ {
				if k == j {
					continue
				}
				if a-p == x[k] && b-q == y[k] {
					ai--
					break
				}
			}
		}
		if ai < answer {
			answer = ai
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl

int main() {
    int l, r; cin >> l >> r;
    int ans = 1e9 + 7;
    //2019 = 3 * 673
    //673つの数を見れば必ず673の倍数の数があり、3の倍数の数もある
    rep3(i, l, min(r, l + 673)) rep3(j, i + 1, min(r, l + 673) + 1) {
        int sa = (ll)i * j % 2019;
        chmin(ans, sa);
    }
    out(ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  cout << ((A.size() == N) ? "YES" : "NO") << "\n";
}

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

using namespace std;

const int maxn = 200010;
unsigned long long int n = 2, ans = 0, s = 0, cnt = 0, a, b, m = 2;

int main()
{
    cin>>a;
    b = a;
    if(a & 1) {
        printf("0");
    }
    else {
        while(m <= a) {
            m *= 5;
            ans += a / m;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=[1000]
m=1000
k=0
for i,num in enumerate(a):
	m=k*num+m
	k=0
	ans.append(m)
	if i<n-1:
		if num<a[i+1]:
			k=m//num
			m=m-k*num
print(max(ans))

Measured memory_bytes: 9152