akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, K = li_input()

    ans = 0

    for p in range(1, N+1):
        t = 0
        while p < K:
            p *= 2
            t += 1
        
        ans += (0.5 ** t) / N
    
    print(ans)

main()


Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <random>
 
using namespace std;

typedef long long ll;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(s) (int)s.size()

mt19937 rnd(1337);

int main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int width, height, circle_x, circle_y, circle_r;
    scanf("%d %d %d %d %d", &width, &height, &circle_x, &circle_y, &circle_r);
    const int xmin = circle_r, xmax = width - circle_r;
    const int ymin = circle_r, ymax = height - circle_r;
    const int outofrange = !!(circle_x < xmin || circle_x > xmax || circle_y < ymin || circle_y > ymax);
    printf("%s\n", outofrange ? "No" : "Yes");
    return 0;
}



Measured memory_bytes: 2144
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

frag = 1
point = 0
while frag == 1:
    frag = 0
    for i in range(n-1,0,-1):
        if li[i] < li[i-1]:
            li[i],li[i-1] = li[i-1],li[i]
            frag = 1
            point += 1
print(' '.join(map(str, li)))
print(point)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll c1 = a*c;
  ll c2 = a*d;
  ll c3 = b*c;
  ll c4 = b*d;
  ll ans = max(max(c1, c2), max(c3, c4));
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3632
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
ans = 1
for i in range(1, n + 1):
    ans *= i
    ans %= mod
print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);
    static int N = sc.nextInt();
    static int A = sc.nextInt();
    static int B = sc.nextInt();
    static int C = sc.nextInt();
    static int L [] = new int [N];
    static int INF = 100000000;
    
	public static void main(String[] args) {    
	    for(int i = 0; i < N; i++){
	    	L[i]=sc.nextInt();
	    }
	    sc.close();
	    
	    System.out.println(dfs(0,0,0,0));	    
	}
	
	private static int dfs (int cur, int a, int b, int c){
		int ret0, ret1, ret2, ret3;
		if (cur == L.length) {
            if (a == 0 || b == 0 || c == 0) {
                return INF;
            }
            return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;
        }
			ret0 = dfs(cur + 1, a, b, c);
			ret1 = dfs(cur + 1, a + L[cur], b, c) + 10;
			ret2 = dfs(cur + 1, a, b + L[cur], c) + 10;
			ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10;
			
			return Math.min(Math.min(ret0, ret1), Math.min(ret2, ret3));
	}		
}



Measured memory_bytes: 23252
#include <iostream>
#include <queue>
#include <string>
#include <utility>  // std::pair
using namespace std;
using ll = long long;

/* キュー（待ち行列）の基礎：他のコンテナ型と同じ部分がある
queue.back()  -----------   queue.front()
queue.push()->   queue   -> queue.pop()
(enqueue)     -----------  (dequeue)

 * First In First Out: FIFO
・次に pop で取り出される（一番初めにキューに挿入された要素）：queue.front()
・要素を（一番後ろに）入れる：queue.push(num)
・要素を取り出す．：queue.pop(num)：戻り値は void
・直接構築でキューに要素を追加：stack.emplace()
stack.(), stack
*/

int test_queue() {
    // test queue.push()
    cout << "----- test queue.push() -----" << "\n";
    queue<int> que1;
    que1.push(3);
    que1.push(1);
    que1.emplace(4);
    
    while (!que1.empty()) {
        // queue.front() 次に dequeue で取り出される要素
        cout << que1.front() << "\n";
        que1.pop();
    }
    // test queue.emplace()
    cout << "----- test queue.emplace() -----" << "\n";
    queue<pair<int, string>> que2;
    que2.emplace(3, "aaa");
    que2.emplace(1, "bbb");
    que2.emplace(4, "ccc");
    
    while (!que2.empty()) {
        // queue.front() 次に dequeue で取り出される要素
        cout << que2.front().first << " " << que2.front().second << "\n";
        que2.pop();
    }
    return 0;
}

// verified AOJ: ALDS1_3_B
int ALDS1_3_B() {
    // input
    int n, q;
    cin >> n >> q;
    int t;
    string process;
    queue< pair<string, int> > que;
    for (ll i = 0; i < n; ++i) {
        cin >> process >> t;
        que.emplace(process, t);
    }
    
    // calculation
    int time = 0;
    pair<string, int> tmp;
    while (!que.empty()) {
        tmp = que.front();
        que.pop();
        if (tmp.second > q) {
            tmp.second -= q;
            time += q;
            que.push(tmp);
        } else {
            time += tmp.second;
            cout << tmp.first << " " << time << "\n";
        }
    }
    
    return 0;
}

int main() {
    // test_queue();
    ALDS1_3_B();
    
    return 0;
}



Measured memory_bytes: 6356
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <vector>
using namespace std;


int main(){
	int n;
	long long count = 0;
	cin >> n;

	for (int i=1; i<=n; ++i){
		if (i%3 == 0){
			continue;
		}
		else if(i%5 == 0){
			continue;
		}
		else{
			count += i;
		}
	}

	cout << count << endl;

	return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int a,b;
    cin>>a>>b;
    int c=min(a,b);
    int d=max(a,b);
    if(c==d)
    {
    	cout<<1;
    }
    else
    {
    	int k=(c+d)/2;
    	if(2*k==c+d)
    	{
    		cout<<k;
    	}
    	else
    		cout<<"IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
using ll = long long;

int main() {
    int N, M;
    std::cin >> N;
    std::map<std::string, int> s;
    for (int i = 0; i < N; i++) {
        std::string input;
        std::cin >> input;
        s[input]++;
    }
    std::cin >> M;
    std::map<std::string, int> t;
    for (int i = 0; i < M; i++) {
        std::string input;
        std::cin >> input;
        t[input]++;
    }

    int ans = 0;
    for (auto&& str : s) {
        ans = std::max(ans, str.second - t[str.first]);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        String s2;
        int a,b;
        while(k-->0){
            s1=s.next();
            s2=s.next();
            s2+=s1;
            System.out.println(s2);
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 26952
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = a % b;
		String ans = "NO";
		for (int i = 1; i <= b; i++) {
			
			if ((d * i) % b == c) {
				ans = "YES";
				break;
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int result = INT_MAX;
    for (int lb: A) {
        vector<int> v;
        int first = 0;
        int last;
        while (first < N) {
            while (first < N && A[first] < lb) {
                ++first;
            }
            last = first;
            while (last < N && A[last] >= lb) {
                ++last;
            }
            if (last - first >= K) {
                vector<int> temp(A.begin() + first, A.begin() + last);
                sort(all(temp));
                REP(i, last - first - K + 1) {
                    v.push_back(temp[i]);
                }
            }
            first = last + 1;
        }
        if (v.size() >= Q) {
            sort(all(v));
            result = min(result, v[Q - 1] - v[0]);
        }
    }
    cout << result << endl;
    return 0;
}

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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	ll ans=0;
	for(int i=0; i<s.size(); ++i)
		ans+=s[i]-'0';
	cout << (ans%9==0?"Yes":"No");
}


Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int c = 700;
	
	char s;
	
	REP(i,3){
		cin >> s;
		
		if (s == 'o') c += 100;
	}
	
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

ll modpow(ll x, ll n) {
    if(n==0){
        return 1;
    }else if(n%2==0){
        ll h = modpow(x,n/2);
        return h * h % MOD;
    } else {
        return x * modpow(x,n-1) % MOD;
    }
}

int main() {
  // std::cout<<std::fixed<<std::setprecision(12);
  ll n, m;
  cin >> n >> m;

  cout << (1900*m+100*(n-m))*pow(2,m) << endl;

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define MAX 10

int main() {
	int N, L[MAX]; scanf("%d", &N);
	int M; int sum = 0;

	FOR(i, 0, N) { 
		int l; scanf("%d", &l);
		if (i == 0) M = l;
		else if (M < l) M = l;
		sum += l;
	}

	if (M < sum - M) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define SIZ 1400
int A[SIZ][SIZ],m[SIZ][SIZ];
int main(){
	int i,j,k,x,y,r,M=0;
	scanf("%d%d",&y,&x);
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t;
		scanf("%d",&t);
		r=t==0?r+1:0;
	}
	for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=x,k=j;k<y;k++){
		if(M>m[k][i])M=m[k][i];
		int z=k-j+1;
		if(M<z)break;
		if(r<z)r=z;
	}
	printf("%d\n",r*r);
	return 0;
}

Measured memory_bytes: 9768
def c(n,r)
  res = 1
  r.times{|i|
    res *= (n-i) 
    res /= (i+1)
  }
  res
end

N,P = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

a_od = 0
a_ev = 0

a.each{|t|
  a_od += 1 if t%2==1
  a_ev += 1 if t%2 == 0
}

o = 0
e = 0

if P == 0 then
  (0..(a_od/2)).each{|i|
    o += c(a_od, i*2)
  }
  (a_ev+1).times{|i|
    e += c(a_ev, i)
    #puts "aou",a_ev,i,c(a_ev, i)
  }
else
  (a_od/2.0).ceil.times{|i|
    o += c(a_od, i*2+1)
  }
  (a_ev+1).times{|i|
    e += c(a_ev, i)
  }
end

puts o*e


Measured memory_bytes: 1788
fun main(args: Array<String>) {

    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    val destinationList = readLine()!!.split(" ").map {Math.abs(it.toInt()-x)}
    destinationList.sorted()
    var ans = destinationList.first()
    destinationList.drop(1)
    destinationList.forEach {
       ans = euclidean(ans, it)
    }
    println(ans)
}

fun euclidean(divisor: Int, dividend: Int): Int {
    val r = divisor % dividend
    if (r == 0) {
        return dividend
    }
    return euclidean(dividend, r)
}

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

int main() {
  int n;
  cin >>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int hi=0,ans=0;
  for(int i=0;i<n;i++) {
    if(h[i]>=hi){
      ans++;
      hi= max(hi,h[i]);
    }
  }
  cout<<ans<<endl;

  }


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  int mini=INF;
  REP(i,n){
    a[i]=l+i;
    if(abs(a[i])<=abs(mini)){
      mini=a[i];
    }
  }
  int pre=n*(n-1)/2+n*l;
  cout<<pre-mini<<endl;
  return 0;
}


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

const int MAXN = 11;

int main() {
  int w, d;
  int h1[MAXN], h2[MAXN];
  while(cin >> w >> d && (w|d)) {
    for(int i = 0; i < w; ++i) {
      cin >> h1[i];
    }
    for(int i = 0; i < d; ++i) {
      cin >> h2[i];
    }
    bool used1[MAXN], used2[MAXN];
    fill(used1, used1+MAXN, false);
    fill(used2, used2+MAXN, false);

    int res = 0;
    for(int i = 0; i < w; ++i) {
      for(int j = 0; j < d; ++j) {
	if(used2[j]) continue;
	if(h1[i] == h2[j]) {
	  used1[i] = used2[j] = true;
	  res += h1[i];
	  break;
	}
      }
    }
    for(int i = 0; i < w; ++i) {
      if(!used1[i]) res += h1[i];
    }
    for(int i = 0; i < d; ++i) {
      if(!used2[i]) res += h2[i];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i > 0; i++)
const int MOD =1e9+7;
using ll=long long;

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

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()

    can_move = False
    for i in range(1, len(S) - 1):
        if S[i - 1] != S[i + 1]:
            can_move = True
    if not can_move:
        print("Second")
        return

    N = len(S)
    if S[0] != S[-1]:
        if N % 2 == 1:
            print("First")
        else:
            print("Second")
    else:
        if N % 2 == 1:
            print("Second")
        else:
            print("First")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  string s; cin >> s;

  stack<int> q1; stack<P> q2;
  int A = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '\\') {
      q1.push(i);
    } else if (s[i] == '/' && !q1.empty()) {
      int p = q1.top(); q1.pop();
      int l = i - p;
      A += l;
      while (!q2.empty() && q2.top().first > p) {
        l += q2.top().second; q2.pop();
      }
      q2.push({p, l});
    }
  }

  vector<int> L(q2.size());
  for (int i = q2.size() - 1; i >= 0; --i) {
    L[i] = q2.top().second; q2.pop();
  }

  cout << A << endl;
  cout << L.size();
  for (int i = 0; i < L.size(); ++i) {
    cout << ' ' << L[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;


int min3(int a,int b,int c){
	return min(min(a,b),c);
}

int main(){
    ofstream out("output.txt");
    			
    string a,b;
    cin>>a>>b;
    int res = 0;
    for(int i =0;i<3;i++){
    	if(a[i] == b[i]) res++;	 
    }
    cout<<res<<endl;

    return 0;
}

 
 







Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
int main(){
	int n,m;
	long long int a[50],b[50],c[50],d[50];
	long long int md[50];
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%lld %lld",&c[i],&d[i]);
	}
	
	// i番目の生徒に対してすべてのチェックポイントjへのマンハッタン距離を求める
	for(int i=0;i<n;i++){
		long long int min_md = 1000000000;
		int nearest_cp;
		for(int j=0;j<m;j++){
			md[j] = llabs(a[i] - c[j]) + llabs(b[i] - d[j]);
			if(min_md > md[j]) {
				min_md = md[j];
				nearest_cp = j+1;
			}
		}
		printf("%d\n",nearest_cp);
	}
	return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

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

	a = n / 500;
	n = n - (500 * a);
	b = n / 5;

	cout << a * 1000 + b * 5;
}

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

if (n % 10 == 3):
    print('bon')
elif (n % 10 == 0) or (n % 10 == 1) or (n % 10 == 6) or (n % 10 == 8):
    print('pon')
elif(n % 10 == 2) or (n % 10 == 4) or (n % 10 == 5) or (n % 10 == 7) or (n % 10 == 9):
    print('hon')

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> dp(n+10, 0);
    dp[2] = 1;
    for(int i = 3; i < n+1; i++){
        const auto &res = prime_factorize(i-1);
        int num= 1;
        for(auto p: res){
            num *= (p.second+1);
        }
        dp[i] = dp[i-1] + num;
    }
    cout << dp[n] << endl;
    return 0;
}

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

using namespace std;


int main(){

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

    int n,k;

    cin >> n >> k ;

    long long int ans = 1;

    for(int i=1;i<n;i++)
        ans = ans * (k-1);

    cout << ans * k << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int insertionSort(int *A, int n, int g){
    int count = 0;
    for(int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            count++;
        }
        A[j+g] = v;
    }
    return count;
}

void shellSort(int *A, int n){
    int i, count = 0;
    int m = 100;
    int G[m];
    G[0] = 1;
    for(i = 1; i < m; i++){
        G[i] = 3 * G[i-1] + 1;
        if(G[i] > n) break;
    }
    m = i;
    for(int h = 0, i = m-1; i >= 0; i--){
        G[i] = 3 * h + 1;
        h = 3 * h + 1;
    }
    for(i = 0; i < m; i++) count += insertionSort(A, n, G[i]);

    cout << m << endl;
    for(i = 0; i < m - 1; i++) cout << G[i] << " ";
    cout << G[i] << endl;
    cout << count << endl;
}

int main(){
    int n, i;
    cin >> n;
    int A[n];
    for(i = 0; i < n; i++) cin >> A[i];
    shellSort(A, n);
    for(i = 0; i < n-1; i++) cout << A[i] << endl;
    cout << A[i] << endl;
    return 0;
}


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

int main(){
  int a,b,c,d;
  int e,f,g;
  scanf("%d %d %d %d" ,&a,&b,&c,&d);
  e=a-c;
  f=a-b;
  g=b-c;
  e=abs(e);
  f=abs(f);
  g=abs(g);
  if(e<=d){
    printf("Yes\n");
  }
  else if(f<=d && g<=d){
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int maxn = 90;
const int mod = 1e9 + 7;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
LL fib[maxn], n, m;
vector<pair<LL, LL>> pool[maxn];
 
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
 
    fib[0] = fib[1] = 1;
    for(int i = 2; i < maxn; i++) fib[i] = fib[i-1] + fib[i-2];
 
    pool[1].eb(1, 2);
    pool[1].eb(1, 3);
    for(int i = 2; i+2 < maxn; i++) 
        for(const auto& it : pool[i-1]) 
            for(LL y = it.fst + it.snd; y <= fib[i+2] + fib[i]; y += it.snd) 
                pool[i].eb(it.snd, y);
 
    for(int q = read<int>(); q; --q) {
        n = read<LL>();
        m = read<LL>();
        if(n > m) swap(n, m);
 
        if(n == 1) printf("1 %lld\n", m % mod); 
        else if(n == 2 && m == 2) printf("1 4\n");
        else {
            int k = 1, ans = 0;
            while(fib[k+1] <= n && fib[k+2] <= m) ++k;
            printf("%d ", k);
            for(const auto& it : pool[k-1]) {
                if(it.snd <= n) ans = (ans + (m - it.fst) / it.snd) % mod;
                if(it.snd <= m) ans = (ans + (n - it.fst) / it.snd) % mod;
            }
            printf("%d\n", ans);
        }
    }
 
    return 0;
}

Measured memory_bytes: 4224
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		if (N >= (K - 1) * 2 + 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cout<<setprecision(10);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define gcj cout<<"Case #"<<tc<<": "
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val,n) foo(i,0,n+5) x[i]=val;
#define mset2(x,val,n,m) foo(i,0,n+5) foo(j,0,n+5) x[i][j]=val;
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll>
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6 + 8;

int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#define UMAP unordered_map<ll,ll,custom_hash>

ll t = 1; randomINIT;
//<<-----Declare Variable Here------->>//
ll d, dp[10006][2][100];
string S;

//<<-----Implement Functions Here---->>//
ll solve(ll index, bool smaller, ll rem) {
    if (index == S.size())
        return (rem == 0);

    if (dp[index][smaller][rem] != -1)
        return dp[index][smaller][rem];

    ll cnt = 0;
    ll limit = smaller ? limit = S[index] - '0' : 9;
    foo(i, 0, limit) {
        bool ns = (i < S[index] - '0') ? 0 : smaller;
        cnt = (cnt + solve(index + 1, ns, (rem + i) % d) % mod);
    }

    return dp[index][smaller][rem] = cnt;
}

//<<-----Start of Main--------------->>//
void MAIN(ll tc) {
    cin >> S >> d;
    memset(dp, -1, sizeof(dp));
    ll a2 = (solve(0, 1, 0) - 1 + mod) % mod;
    cout << a2 << "\n";
}

int main() {
    fastio;
    // cin>>t;
    foo(i, 1, t) {
        MAIN(i);
    }
}

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

using namespace std;
string s;
int main(){
	int n, a=0, b=0, c=0, d=0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s;
		if(s == "AC")
			a++;
		if(s == "WA")
			b++;
		if(s == "TLE")
			c++;
		if(s == "RE")
			d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string ans;
int a[4];

void dfs(int pos, string str, int sum) {
    if (pos == 4) {
        if (sum == 7) {
            ans = str;
        }
        return;
    }
    dfs(pos + 1, str + '+', sum + a[pos]);
    dfs(pos + 1, str + '-', sum - a[pos]);
};

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        a[i] = s[i] - '0';
    }
    dfs(1, "", a[0]);

    for (int i = 0; i < 3; ++i) {
        cout << s[i] << ans[i];
    }
    cout << s[3] << "=7" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
A,B,C,D=[],[],[],[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(m):
    c,d=map(int,input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    ans,x=1000000000000,0
    for j in range(m):
        if ans>abs(A[i]-C[j])+abs(B[i]-D[j]):
            ans=abs(A[i]-C[j])+abs(B[i]-D[j])
            x=j
    print(x+1)




Measured memory_bytes: 3064
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string str, snd;
    cin>>str>>snd;
    int ans = 0;
    for(int i = 0; i < str.length(); i++)
        ans += str[i]!=snd[i];
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3860
#include<stdio.h>
 
 
int main(void)
{
    int a,b,c,d,e=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  
    if(a==0){printf("1");}
  　else if(b==0){printf("2");}
  　else if(c==0){printf("3");}
  　else if(d==0){printf("4");}
  　else if(e==0){printf("5");}
    
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

ll BinarySearch(vector <ll> &A, ll K)
{
    ll N=A.size();
    ll low=1, high=(*max_element(A.begin(), A.end()));
    while (high-low > 1)
    {
        ll mid=(low+high)/2;
        ll cuts=0;
        loop(i,0,N)
        {
            cuts += (A[i]/mid);
            if (A[i]%mid==0) {
                cuts--;
            }
        }
        if (cuts<=K) {
            high=mid;
        }
        else low=mid+1;
    }
    ll cuts=0;
    loop(i,0,N)
    {
        cuts += (A[i]/low);
        if (A[i]%low==0) {
            cuts--;
        }
    }
    if (cuts<=K) {
        return low;
    }
    return high;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,K; cin >> N >> K;
    vector <ll> A(N);
    loop(i,0,N)
    {
        cin >> A[i];
    }
    cout << BinarySearch(A,K) << "\n";
    return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h> 
using namespace std; 
int main(){
  int N;
  cin >> N;
  int M = N % 10;
  
  if (M == 2 || M == 4 || M == 5 || M == 7 || M == 9){
    cout << "hon" << endl;
  }
  
  else if ( M == 0 || M ==  1 || M == 6 || M == 8 ){
    cout << "pon" << endl;
    
  }
  
  else {
    cout << "bon" << endl;
    
  }
  
}


Measured memory_bytes: 3560
using System;
using System.Linq;
using System.Collections.Generic;

public class MainProgram
{
    public static void Main(string[] args)
    {
        new SRC71C().Start();
    }

}
//複数個に対応できていない
public class SRC71C
{
    public void Start()
    {
        Solve();
    }

    public void Solve()
    {
        int num = int.Parse(Console.ReadLine().Trim());
        var words = new List<string>();
        var min = int.MaxValue;
        var minWord = "";
        for(int i = 0;i < num;i++){
            string word = Console.ReadLine().Trim();
            words.Add(word);
            if(word.Length < min){
                minWord = word;
                min = word.Length;
            }
        }

        string result = FindStringSet(words,minWord);

        Console.WriteLine(result);

    }

    string FindStringSet(List<String> words,string minWord)
    {
        char[] minWordChars =Utility.GetAlphabet().ToArray();//minWord.ToCharArray();
        var resultChars = new List<char>();
        for(int i= 0,l = minWordChars.Length;i<l;i++){
            char ch =minWordChars[i];
            if(IsExistInAllWord(words,ch))
            {
                for(int j = 0,jl = FindMinNum(words,ch);j<jl;j++){
                    resultChars.Add(ch);
                }
            }
        }

        return new String(resultChars.ToArray());

    }

    int FindMinNum(List<String> words,char word)
    {
        int min = int.MaxValue;
        for(int all = 0,allLength = words.Count;all<allLength;all++){
            min = Math.Min(min,Utility.CountChar(words[all],word));
        }

        return min;
    }

    bool IsExistInAllWord(List<String> words,char word)
    {
        for(int all = 0,allLength = words.Count;all<allLength;all++){
            if(!words[all].Contains(word.ToString()))
            {
                return false;
            }
        }
        return true;
    }

public static class Utility
{
    public static void OutPutResult(List<string> resultLines)
    {
        for (int i = 0, l = resultLines.Count; i < l; i++)
        {
            Console.WriteLine(resultLines[i]);
        }
    }

    public static List<char> GetAlphabet()
    {
        List<char> result = new List<char>();
        const int Size = 'z'-'a';
        char alpha = 'a'; 
        for(int i = 0;i<=Size;i++){
            result.Add(alpha++);
        }

        return result;
    }

    public static int CountCharIgnoreCase(string s, char c) {
        return s.ToLower().Where(c1 => c1==char.ToLower(c)).Count();
    }

    public static int CountChar(string s, char c) {
        return s.Where(c1 => c1==c).Count();
    }

    public static void SortStringArray(string[] stringArray)
    {
        StringComparer cmp = StringComparer.OrdinalIgnoreCase;
        Array.Sort(stringArray, cmp);
    }

    public static void SortArray<T>(T[] target)
    {
        StringComparer cmp = StringComparer.OrdinalIgnoreCase;
        Array.Sort(target, cmp);
    }
}

}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
   int N;
   int H=-1;
   bool flag=false;
   
   cin >> N ;
   int *x = new int[ N+1 ];
   int *y = new int[ N+1 ];
   int *h = new int[ N+1 ];
   int *HH = new int[N+1];
   
   x[0]=-1;
   y[0]=-1;
   h[0]=-1;
   
   for(int i=1 ; i<=N  ;i++){
       cin >> x[i] >> y[i] >> h[i];
     
   } 
 
   if(N!=1){
          for (int j = 0;j<=100;j++){//  for (int j = x[xMin];j<=x[xMax];j++){
             
              for (int k=0;k<=100;k++){//for (int k=y[yMin];k<=y[yMax];k++){
                 
                 int lcnt=0;
                 for(int l=1;l<=N;l++){
                  
                     if(h[l]==0 ){
                          
                       HH[lcnt]=l;
                       lcnt+=1;
                                 }
                                 
         
                     else{
                     if(H==-1){
                         H=h[l]+abs(x[l]-j)+abs(y[l]-k); 
                     }else if(H!=h[l]+abs(x[l]-j)+abs(y[l]-k)){

                         flag=true;
                                       }
                   
                     }
                    
                }
     
                if(lcnt>0){
                    for(int l=0 ;l<lcnt;l++){
                 
                       if(H>h[HH[l]]+abs(x[HH[l]]-j)+abs(y[HH[l]]-k)){
                          
                           flag=true;
                       }
                    
                    }
                }
                
                if(flag==false){
                      x[0]=j;
                      y[0]=k;
                      h[0]=H;}
                flag=false;
                H=-1;
            
                      
              }
              
              
          } 
          
           
   }else{
                      x[0]=x[1];
                      y[0]=y[1];
                      h[0]=h[1];}
   
   
       cout << x[0] << " " << y[0] << " " << h[0] << endl; 
       
   
   
   
   
   delete[] x;
   delete[] y;
   delete[] h;
   delete[] HH;
  
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

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

    ll ans = 0;
    for(ll i=1;i<=n;++i){
        ll y = n/i;
        ans += y*(y+1) * i / 2;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

string func(string a, string b) {
    assert(a.length() == b.length());
    string res = "";
    int n1 = atoi(a.c_str()), n2 = atoi(b.c_str());
    int n = n2 - n1;
    while (n) res += (n % 10) + '0', n /= 10;
    REVERSE(res);
    return res;
}

void solve(string a0, int L) {
    map<string, int> mp;
    int cnt = 0;
    if (a0.length() < L) {
        a0 = string(L - a0.length(), '0') + a0;
    }
    while (!FIND(mp, a0)) {
        mp[a0] = cnt++;
        auto a0ma = a0, a0mi = a0;
        SORT(a0mi);RSORT(a0ma);
        a0 = func(a0mi, a0ma);
        if (a0.length() < L) {
            a0 = string(L - a0.length(), '0') + a0;
        }
    }
    string ans = a0;
    REVERSE(ans);
    while ((*--ans.end()) == '0') ans.pop_back();
    REVERSE(ans);
    cout << mp[a0] << " " << (ans.length() == 0 ? "0" : ans) << " " << cnt - mp[a0] << endl;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    while (cin >> s >> m, m) {
        solve(s, m);
        //return 0;
    }
}

Measured memory_bytes: 3208
"""
B-Popular Vote
"""

import sys
input = sys.stdin.readline
from collections import Counter, deque


INF = float('inf')


def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)

    total = sum(A)
    counter = 0
    for a in A:
        if total <= a * (4 * M):
            counter += 1

    print('Yes' if counter >= M else 'No')


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 2e6 + 100;

int a[5], k;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 0; i < 5; i++)
		cin >> a[i];
	sort(a, a + 5);
	cin >> k;
	cout << (a[4] - a[0] > k? ":(": "Yay!");
	return 0;
}

Measured memory_bytes: 256