akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

template<class Type>
Type solve(Type res = Type()){
    ll N,S; cin >> N >> S;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    
    auto dp = make_v<ll>(N+1,S+1);
    dp[0][0] = 1;
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= S;j++){
            if(dp[i][j] == 0) continue;
            
            {// not
                (dp[i+1][j] += dp[i][j]*2)%=MOD;
            }
            if(j+A[i] <= S){
                (dp[i+1][j+A[i]] += dp[i][j])%=MOD;
            }
        }
    }
    // cout << dp << endl;
    res = dp[N][S];
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 73660
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    cin >> n;
    ll p = 1;
    ll pp = 2;
    ll c = 0;
    if (n == 1) {
        cout << p << endl;
        return 0;
    } else {
        FOR(i, 2, n) {
            c = p + pp;
            pp = p;
            p = c;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void LCSLength(char *,char *);

int main(){
  int q,i;
  char X[1000],Y[1000];

  scanf("%d",&q);
  if(q < 1 || q > 150)return 0;

  for(i = 0; i < q; i++){
    scanf("%s",X);
    scanf("%s",Y);
    LCSLength(X,Y);
  }
  return 0;
}

void LCSLength(char X[],char Y[]){
  int i,j,m,n,c[1001][1001];
  
  m = strlen(X);
  n = strlen(Y);
 
  for (i = 0;i < m+1;i++){
    c[i][0] = 0;
  }
 
  for (j = 0; j < n+1; j++){
    c[0][j] = 0;
  }
  
  for (i = 1; i < m+1; i++){
    for (j = 1; j < n+1;j++){
    if (X[i-1] == Y[j-1])c[i][j] = c[i-1][j-1] + 1;
    else if (c[i-1][j] >= c[i][j-1])c[i][j] = c[i-1][j];
    else c[i][j] = c[i][j-1];
    }
 }
  
  printf("%d\n",c[m][n]);
 
}



Measured memory_bytes: 5648
import queue
def main():
    n,m = map(int,input().split())
    ab = [[] for i in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        ab[a-1].append(b-1)
        ab[b-1].append(a-1)
    q =queue.Queue()
    q.put(0)
    ans = [-1] * n
    ans[0] = 0
    while not q.empty():
        now = q.get()
        for i, next in enumerate(ab[now]):
            if ans[next] == -1:
                ans[next] = now+1
                q.put(next)
        
    print('Yes')
    for i in range(1,n):
        print(ans[i])



if __name__=='__main__':
    main()


Measured memory_bytes: 37080
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll a;
    string s;
    cin >> a >> s;
    if (3200 <= a)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
    return 0;
}

Measured memory_bytes: 3028
L = int(input())
for i in range(21):
    if 2**i > L:
        r = i-1
        break
        
N = r+1
ans = []
for i in range(1, N):
    ans.append([str(i), str(i+1), str(2**(i-1))])
    ans.append([str(i), str(i+1), str(0)])

t = N-1
while t >= 1:
    if L-2**(t-1) >= 2**r:
        ans.append([str(t), str(N), str(L-2**(t-1))])
        L -= 2**(t-1)
    t -= 1
        
print(N, len(ans))
for i in range(len(ans)):
    print(" ".join(ans[i]))

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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 5e5 + 5;
int ans[MAXN];
P a[MAXN];
int n;
std::set<int> S;

int main(){
    scanf("%d",&n);
    FOR(i,1,n) scanf("%d",&a[i].fi),a[i].se = i;
    std::sort(a+1,a+n+1);
    FOR(i,1,n*n) S.insert(i);
    FOR(i,1,n){
        S.erase(a[i].fi);ans[a[i].fi] = a[i].se;
        FOR(j,2,a[i].se){
            if(*S.begin() > a[i].fi){
                puts("No");
                return 0;
            }
            ans[*S.begin()] = a[i].se;
            S.erase(S.begin());
        }
    }
    ROF(i,n,1){
        FOR(j,1,n-a[i].se){
            auto t = S.end();t--;
            if(*t < a[i].fi){
                puts("No");
                return 0;
            }
            ans[*t] = a[i].se;
            S.erase(t);
        }
    }
    puts("Yes");
    FOR(i,1,n*n) printf("%d ",ans[i]);puts("");
    return 0;
}


Measured memory_bytes: 15744
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		System.out.println(800*N-200*(N/15));
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int mod = 1000000000 + 7;
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String s = std.next();
        long[] appearCounts = new long[26];
        int index = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            for (int i = 0; i < n; i++) {
                char t = s.charAt(i);
                if (c == t) {
                    appearCounts[index]++;
                    appearCounts[index] = appearCounts[index] % mod;
                }
            }
            index++;
        }

        long ans = 1;
        for (long appearCount : appearCounts) {
            ans = ans % mod * (appearCount + 1);
        }

        ans = ans % mod - 1;

        System.out.println(ans);
    }
}


Measured memory_bytes: 24596
#include <stdio.h>

int main(void) {
    double juu;
    while(scanf("%lf",&juu)!=EOF){
        if(48>=juu){
            puts("light fly");
        }else if(juu<=51){
            puts("fly");
        }else if(juu<=54){
            puts("bantam");
        }else if(juu<=57){
            puts("feather");
        }else if(juu<=60){
            puts("light");
        }else if(juu<=64){
            puts("light welter");
        }else if(juu<=69){
            puts("welter");
        }else if(juu<=75){
            puts("light middle");
        }else if(juu<=81){
            puts("middle");
        }else if(juu<=91){
            puts("light heavy");
        }else{
            puts("heavy");
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 608
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

class UF
{
private:
    int         num;
    vector<int> par;
    vector<int> siz;
public:
    //vector<int> val;
public:
    UF(int n): num(n) {
        par.resize(n);
        siz.resize(n);
        //val.resize(n);
        int i;
        for(i=0; i<n; i++) {
            par[i]=i; siz[i]=1;
            //val[i]=0;
        }
    }
	
    int find(int x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(siz[x]<siz[y]) {
            par[x]=y;
            siz[y]=siz[x]+siz[y];
            //val[y]=val[x]+val[y];
        }
        else {
            par[y]=x;
            siz[x]=siz[x]+siz[y];
            //val[x]=val[x]+val[y];
        }
    }

    bool same(int x, int y) {
        return find(x)==find(y);
    }

    int size(int x) {
        return siz[find(x)];
    }

    int ngroup() {
    //int ngroup( int& ans ) {
        int count=0;
        int i;
        for(i=0; i<num; i++) {
            if(par[i]==i) {
                count++;
                //ans += (val[i]? siz[i]: siz[i]-1);
            }
        }
        return count;
    }
};


void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int i;
    UF uf(n);
    for (i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        uf.unite(a, b);
    }
    map<int, int> cnt;
    for (i = 0; i < n; i++) {
        int par = uf.find(i);
        cnt[par]++;
    }
    int ans = 0;
    auto it = cnt.begin();
    for (; it != cnt.end(); ++it) {
        ans = MAX(ans, it->second);
    }
    printf("%d\n", ans);

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 13656
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int MOD=998244353;
 
ll n;
ll a[312];
ll dp[91123];
ll ways[91123];
ll lim = 0;
 
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        lim += a[i];
    }
    ll lim2 = lim/2;
 
    dp[0] = 3;
    ways[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = lim2; j >= a[i]; j--) {
            int k = j - a[i];
            dp[j] = (dp[j] + dp[k]*2 % MOD) % MOD;
            ways[j] = (ways[j] + ways[k]) % MOD;
        }
    }
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= 3;
        ans %= MOD;
    }
    for (int i = 0; i <= lim2; i++) {
        //cout << i << ' ' << dp[i] << '\n';
        ans += MOD - dp[i];
        ans %= MOD;
        if (i*2 == lim) {
            ans = (ans + ways[i] * 3 % MOD) % MOD;
        }
    }
    cout << ans << '\n';
    return 0;
}



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

using namespace std;

int main()
{
  int n, l;
  
  cin >> n >> l;
  
  string s,t;
  
  /*vector<string> v;
  
  for(int i=0; i<n; i++)
  {
     cin >> s;
    
      v.push_back(s);
  }

  sort(v.begin(), v.end());
  
  for(auto i: v) cout << i << endl;*/
  
  multimap<string,int> mp;
  
  for(int i=0; i<n; i++)
  {
     cin >> s;
    
     mp.insert(multimap<string,int>::value_type(s, i));
  }
 
  for(auto i : mp) 
       t += i.first;
  
  cout << t << endl;
  
  
  return 0;
  
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


input_str = input()

length = 0
work = deque()
is_First = True

for i in range(len(input_str)):
    ch = input_str[i]
    if ch in [' ',',','.'] or i == len(input_str)-1: #区切り文字または最後の文字
        if length >= 3 and length <= 6:
            if is_First == False:
                print(" ",end="")

            while len(work) > 0:
                print("%s"%(work.popleft()),end="")
            is_First = False
        else:
            while len(work) > 0:
                work.popleft()
        length = 0
    else:
        work.append(ch)
        length += 1
print()


Measured memory_bytes: 6372
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    n,m,k = LI()
    ab = [LI_() for _ in range(m)]
    cd = [LI_() for _ in range(k)]
    e = collections.defaultdict(set)
    uf = UnionFind(n)
    for a,b in ab:
        e[a].add(b)
        e[b].add(a)
        uf.union(a,b)
    for c,d in cd:
        e[c].add(d)
        e[d].add(c)

    r = []
    for i in range(n):
        t = uf.find(i)
        s = -uf.table[t] - 1
        for j in e[i]:
            if uf.find(j) == t:
                s -= 1
        r.append(s)

    return JA(r, " ")


print(main())





Measured memory_bytes: 103340
import java.util.*;

class Cake{
	int s,w,d;

	Cake(int tw,int td){
		w = tw;
		d = td;
		s = w * d;
	}
}

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		while(true){
			int n = scan.nextInt();
			int w = scan.nextInt();
			int d = scan.nextInt();
			if(n==0 && w==0 && d==0) break;

			ArrayList<Cake> al = new ArrayList<Cake>();
			Cake cake = new Cake(w,d);

			al.add(cake);

			while(n-- > 0){
				int p = scan.nextInt();
				int s = scan.nextInt();
				Cake cut1,cut2;

				cake = al.remove(p-1);
				int cutPlace = s % (cake.w + cake.d);

				if(cutPlace > cake.w){
					cut1 = new Cake(cake.w, cutPlace - cake.w);
					cut2 = new Cake(cake.w, cake.d - cut1.d);
				}
				else{
					cut1 = new Cake(cutPlace, cake.d);
					cut2 = new Cake(cake.w - cutPlace, cake.d);
				}

				if(cut1.s < cut2.s){
					al.add(cut1);
					al.add(cut2);
				}
				else{
					al.add(cut2);
					al.add(cut1);
				}
			}

			int size = al.size();
			int s[] = new int[size];

			for(int i=0;i<size;i++) s[i] = al.get(i).s;
			Arrays.sort(s);

			for(int i=0;i<size;i++){
				if(i != 0) System.out.print(" ");
				System.out.print(s[i]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define INF (ll)1e18
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    int n,x,y,k;
    in(n,k,x,y);
    out(min(n,k)*x+max(n-k,0)*y);
}























Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

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

	int num = 0;

	for (int i = 0; i < N; i += 2) {
		if (a[i] % 2 == 1) num++;
	}

	cout << num << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> S(M), C(M);
	for (int i = 0; i < M; ++i) {
		cin >> S[i] >> C[i];
	}
	int ans = -1;
	for (int i = 0; i < 1000; ++i) {
		string s = to_string(i);
		if (s.size() != N) continue;
		bool valid = true;
		for (int j = 0; j < M; ++j) {
			if (s[S[j] - 1] - '0' != C[j]) {
				valid = false;
			}
		}
		if (valid) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations

def getval():
    n = int(input())
    f = [list(map(int,input().split())) for i in range(n)]
    p = [list(map(int,input().split())) for i in range(n)]
    return n,f,p

def main(n,f,p):
    ans = 0
    for i in range(n):
        temp = 0
        for j in f[i]:
            temp += j
        ans += p[i][temp]

    for i in range(1,10):
        for c in combinations(range(10),i):
            pro = 0
            for j in range(n):
                temp = 0
                for k in c:
                    temp += f[j][k]
                pro += p[j][temp]
            ans = max(ans,pro)

    print(ans)

if __name__=="__main__":
    n,f,p = getval()
    main(n,f,p)

Measured memory_bytes: 74104
N=int(input())
p=list(map(int,input().split()))
alis=[i for i  in range(1,N+1)]

newlist=[x-y for (x,y) in zip (p,alis)]


if sum(1 for x in newlist if x!=0)==2 or sum(1 for x in newlist if x!=0)==0 :
    print('YES')
else:
    print('NO')



Measured memory_bytes: 9176
//
//  abc114d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/12/02.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int prime[25]=
    {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    
    ll ans=0;
    int p3,p5,p15,p25,p75;
    p3=p5=p15=p25=p75=0;
    
    for(int i=0;i<25;i++)
    {
        int num=0;
        int p=prime[i];
        while(p<=n)
        {
            num+=(int)(n/p);
            p*=prime[i];
        }
        if(num>=2) p3++;
        if(num>=4) p5++;
        if(num>=14) p15++;
        if(num>=24) p25++;
        if(num>=74) p75++;
    }
    
    cout<<((p5*(p5-1))/2)*(p3-2)+p15*(p5-1)+p25*(p3-1)+p75<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  string S;
  cin>>S;
  if(S!="AAA" && S!="BBB") {
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}
    

Measured memory_bytes: 256
package main

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

type point struct {
	x float64
	y float64
}

var th = math.Pi * 60.0 / 180.0

func hoge(l point, r point, x int) {
	if x == 0 {
		fmt.Printf("%f %f\n", l.x, l.y)
	} else {
		p1 := point{
			x: (2.0*l.x + 1.0*r.x) / 3.0,
			y: (2.0*l.y + 1.0*r.y) / 3.0,
		}
		p2 := point{
			x: (1.0*l.x + 2.0*r.x) / 3.0,
			y: (1.0*l.y + 2.0*r.y) / 3.0,
		}
		m := point{
			x: (p2.x-p1.x)*math.Cos(th) - (p2.y-p1.y)*math.Sin(th) + p1.x,
			y: (p2.x-p1.x)*math.Sin(th) + (p2.y-p1.y)*math.Cos(th) + p1.y,
		}
		hoge(l, p1, x-1)
		hoge(p1, m, x-1)
		hoge(m, p2, x-1)
		hoge(p2, r, x-1)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	l := point{x: 0.0, y: 0.0}
	r := point{x: 100.0, y: 0.0}
	hoge(l, r, n)
	fmt.Printf("%f %f\n", r.x, r.y)
}



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

int z, o;
bool mp[105][105];

int main()
{
	scanf("%d%d",&z,&o);
	z--; o--;
	puts("98 49");
	for(int i=1;i<=49;i++) {
		for(int j=1;j<=49;j++) {
			mp[i][j] = 1;
		}
	}
	for(int i=2;i<=49&&z;i+=2) {
		for(int j=2;j<=49&&z;j+=2) {
			mp[i][j] = 0; z--;
		}
	}
	for(int i=51;i<=98&&o;i+=2) {
		for(int j=2;j<=49&&o;j+=2) {
			mp[i][j] = 1; o--;
		}
	}
	for(int i=1;i<=98;i++) {
		for(int j=1;j<=49;j++) {
			putchar(mp[i][j]?'#':'.');
		}
		puts("");
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int H,W;
	char C[105];
	scanf("%d%d\n",&H,&W);
	for(int i=0;i<H;i++)
	{
		scanf("%s",C);
		printf("%s\n%s\n",C,C);
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)


int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, x; cin >> n >> x;
	
	ll sum = n;
	n = n - x;
	while (x!=0) {
		ll num = n / x;
		sum += x * (num * 2 + (n%x==0 ? -1 : 0 ));
		ll x_new = n % x;
		ll n_new = x;
		x = x_new; n = n_new;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, x[111111], dm = INF;

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++)
    std::cin >> x[i];

  int a = std::lower_bound(x, x + N, 0) - x;

  for (int i = 0; i < N - K + 1; i ++) {
    int j = i + K - 1, s = x[i], t = x[j], d = std::min(std::abs(s), std::abs(t)) + t - s;

    dm = std::min(d, dm);
  }

  std::cout << dm << std::endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int width, point;
    cin >> width >> point;
      	
  	for(int i = 1; i <= width; i++)
    {
      	int ans1 = point-(width-i);
      	cout << ans1 << endl;
    }
  	
  	for(int i = 1; i <= width; i++)
    {	
      	if(width - i > 0){
    		int ans2 = point+i;
      		cout << ans2 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int dp[45];
int fibo(int);
int main(void)
{
	int n;
	scanf("%d", &n);
	printf("%d\n", fibo(n));
}
int fibo(int n)
{
	if (n == 0 || n == 1) return dp[n] = 1;
	if (dp[n]) return dp[n];
	else return dp[n] = (fibo(n - 1) + fibo(n - 2));
}


Measured memory_bytes: 2100
N, M, X = list(map(int, input().split()))

list = [list(map(int, input().split())) for i in range(N)]


def calc_cost(li):
    """
    与えられた部分リストが各アルゴリズムの条件を
    満たすか確認し、そのコストを計算。
    条件満たさないときは100000000を出力
    """

    # flag = True
    cost = 0
    for item in li:
        cost += item[0]

    for i in range(M):
        algo_sum = 0
        for item in li:
            algo_sum += item[i + 1]
        if algo_sum < X:
            return 100000000

    return cost


cost = 100000000
for i in range(2 ** N):
    in_list = []
    for j in range(N):
        if (i >> j) & 1:
            in_list.append(list[j])

    temp_cost = calc_cost(in_list)
    if temp_cost == -1:
        break
    cost = min(cost, temp_cost)

if cost == 100000000:
    cost = -1

print(cost)


Measured memory_bytes: 9176
import Data.Char  -- ord, chr
import Data.List  -- isInfixOf

decaesar cipher shift = map (charshift shift) cipher
charshift shift c
  | 'a' <= c && c <= 'z' = chr ((ord c - ord 'a' + shift) `mod` 26 + ord 'a')
  | otherwise            = c

containsKeyword str = or $ map (`isInfixOf` str)  ["the", "this", "that"]

decrypt cipher =
  head . filter containsKeyword . map (decaesar cipher) $ [1..26]

main = do
  s <- getContents
  putStr . unlines . map decrypt . lines $ s

Measured memory_bytes: 3968
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func rev(s []byte) string {
	N := len(s)
	for i := 0; i < N/2; i++ {
		s[i], s[N-1-i] = s[N-1-i], s[i]
	}
	return string(s)
}

func check(a, b string) bool {
	for _, e := range a {
		if byte(e) == b[0] {
			return true
		}
	}
	return false
}

type pair struct {
	pre  string
	post byte
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := make([]string, N)
	for i := 0; i < N; i++ {
		s[i] = rev([]byte(getString()))
	}
	sort.Slice(s, func(i, j int) bool {
		return len(s[i]) < len(s[j])
	})
	ans := 0
	mp := make(map[int]int)
	off := 100007
	for _, x := range s {
		hash := make([]int, len(x))
		hash[0] = int(x[0])
		for i := 1; i < len(x); i++ {
			hash[i] = hash[i-1]*off + int(x[i])
		}
		cnt := make([]int, 26)
		for i := 0; i < len(x); i++ {
			cnt[int(x[i]-'a')]++
		}
		for c := 0; c < 26; c++ {
			if cnt[c] == 0 {
				continue
			}
			h := c + 'a'
			ans += mp[h]
		}
		for i := 0; i < len(x)-1; i++ {
			h := hash[i] * off
			cnt[x[i]-'a']--
			for c := 0; c < 26; c++ {
				if cnt[c] == 0 {
					continue
				}
				h += c + 'a'
				ans += mp[h]
				h -= c + 'a'
			}
		}
		mp[hash[len(x)-1]]++
	}
	out(ans)
}


Measured memory_bytes: 19820
import numpy as np
N, x = map(int, input().split())
a = np.array(list(map(int, input().split())))

cs = np.sort(a).cumsum()

if cs[-1]<x:
    print(N-1)
elif cs[-1]==x:
    print(N)
else:
    print(np.where(cs<=x)[0].shape[0])

Measured memory_bytes: 12392
#include <iostream>
#include <math.h>
#include <stdio.h>

int main() {
	double x1, x2, y1, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%.8lf\n", sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
	return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();

		boolean beautiful = w.chars().boxed()
				.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
				.values().stream()
				.allMatch(v -> v % 2 == 0);

		System.out.println(beautiful ? "Yes" : "No");
	}
}


Measured memory_bytes: 16084
import collections
def main():

    N, W = map(int, input().split())
    goods = collections.defaultdict(list)
    for _ in range(N):
        w, v = map(int, input().split())
        goods[w].append(v)

    for w in goods:
        goods[w].sort(reverse = True)

    cur = dict()
    cur[0] = 0
    for w in goods:
        temp = cur.copy()
        for w1 in temp:
            w2, v2 = w1, temp[w1]
            for i in range(len(goods[w])):
                w2 += w
                v2 += goods[w][i]
                if w2 <= W:
                    if w2 not in cur:
                        cur[w2] = v2
                    else:
                        cur[w2] = max(cur[w2], v2)
    max_v = 0
    for w in cur:
        max_v = max(max_v, cur[w])
    return max_v

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll co = 0;
    ll ans;
    rp(i, 0, 222)
    {
        if (i % 2 == 0)
            c -= b;
        else
            a -= d;
        if (a <= 0 || c <= 0)
        {
            ans = i;
            break;
        }
    }
    if (ans % 2 == 0)
    {
        ce("Yes");
    }
    else
    {
        ce("No");
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define sz 100002
int a,b,test,i,j,ara[sz],c;

using namespace std;
int main()
{
    ll int sum=0,k=1;
    cin>>a>>b>>c;
    if(a!=b)k++;
    if(b!=c&&a!=c)k++;
    cout<<k<<endl;




}



Measured memory_bytes: 256
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "deque"
#include "cmath"
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= max(a, b); i++) {
		cout << min(a, b);
	}
	cout << endl;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<ll> x(n), y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  ll ans = 0;
  for (auto &x1 : x)
    for (auto &x2 : x)
      for (auto &y1 : y)
        for (auto &y2 : y) {
          if (x1 == x2 || y1 == y2) continue;
          int c = 0;
          ll l = min(x1, x2);
          ll r = max(x1, x2);
          ll u = min(y1, y2);
          ll d = max(y1, y2);
          for (int i = 0; i < n; i++) if (l <= x[i] && x[i] <= r && u <= y[i] && y[i] <= d) c++;
          if (c >= k) {
            if (ans == 0) ans = (r - l) * (d - u);
            ans = min(ans, (r - l) * (d - u));
          }
        }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
x,k,d=(map(int,input().split()))
a=abs(x)//d # bを実現するために必要な最小移動回数
b=abs(x)%d # 無限回移動できるとした時の最小の位置
if a<=k:
  if (k-a)%2==0:
    print(b)
  else:
    print(abs(b-d))
else:
  print(abs(x)-(k*d))
    

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<=n; i+=2)
    {
        if(a[i]%2!=0)
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main()
{
    string s; cin >> s;
    if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

from heapq import heappush, heappop
from collections import defaultdict, deque

def main():
  n, m = map(int, input().split())
  edges = [[] for _ in range(n)]
  cedges = defaultdict(lambda: [])
  for _ in range(m):
    p, q, c = map(int, input().split())
    edges[p-1].append((q-1, c))
    edges[q-1].append((p-1, c))
    cedges[p-1, c].append(q-1)
    cedges[q-1, c].append(p-1)

  ans = defaultdict(lambda: float('inf'))
  ans[0, -1] = 0  # ノード、路線
  que = deque([(0, 0, -1)])  # 距離、ノード、路線
  while len(que) > 0:
    d, u, c = que.popleft()
    if ans[u, c] < d:  # 更新しない
      continue
    if c < 0:
      for t, c2 in edges[u]:
        if d + 1 < ans[t, c2]:
          ans[t, c2] = d + 1
          que.append((d+1, t, c2))
    else:
      for t in cedges[u, c]:
        if d < ans[t, c]:
          ans[t, c] = d
          que.appendleft((d, t, c))
      if d < ans[u, -1]:
        ans[u, -1] = d
        que.appendleft((d, u, -1))
  try:
    print(min(d for (u, _), d in ans.items() if u == n-1))
  except ValueError:
    print(-1)


if __name__ == '__main__':
  main()


Measured memory_bytes: 218100
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  for D in range(len(pts)):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    priority_queue<int>que1;
    priority_queue<int,vector<int>,greater<int>>que2;
    int ad1=0,ad2=0;
    int val=0;

    int l,r;
    cin>>l>>r;
    que1.push(l);
    que2.push(l);
    int pre=r-l;

    for(int i=1;i<N;i++){
        cin>>l>>r;
        ad1-=r-l;
        ad2+=pre;

        pre=r-l;

        if(l<que1.top()+ad1){
            que1.push(l-ad1);
            que1.push(l-ad1);

            val+=que1.top();
            que2.push(que1.top()+ad1-ad2);
            que1.pop();
            val-=que1.top();

            val+=que1.top()+ad1-l;
        }
        else if(l<=que2.top()+ad2){
            que1.push(l-ad1);
            que2.push(l-ad2);
        }
        else{
            que2.push(l-ad2);
            que2.push(l-ad2);

            val-=que2.top();
            que1.push(que2.top()+ad2-ad1);
            que2.pop();
            val+=que2.top();

            val+=l-(que2.top()+ad2);
        }
    }
    cout<<val<<endl;
    return 0;
}


Measured memory_bytes: 2156
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int n;
    cin >> n;
    int x[n];
    int ans=INF;
    rep(i,n){
        cin >> x[i];
    }
    rep(p,105){
        int temp=0;
        rep(j,n){
            temp+=(x[j]-p)*(x[j]-p);
        }
        chmn(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
def check(P):
    lis = [[] for i in range(k)]
    su = [0 for i in range(k)]
    
    su.append(-10000)
    cur = 0
    for i, bag in enumerate(baggage):
        #cur = 0
        #print(su,cur,su[cur])
        while su[cur] + bag > P:
            cur += 1
        if cur == k:
            return False
        else:
            lis[cur].append(bag)
            su[cur] += bag
    #print(lis, su, P)
    return True

def main():
    min_P = 1000000000
    left = 1
    right = 1000000000
    mid = (left + right)//2
    while  left < right:
        '''if (left + right) % 2 == 0:
            mid = (left + right)//2
        else:
            mid = (left + right)//2 + 1
        #print(left, mid, right, end=" ")'''
        
        if check(mid):
            right = mid
            if min_P > mid:
                min_P = mid
        else:
            left = mid + 1
        mid = (left + right)//2
    #print(left,right)
    print(min_P)
if __name__ == '__main__':
    n, k = map(int, input().rstrip().split(" "))
    #n,k= 5,3
    baggage = [int(input()) for i in range(n)]
    #baggage = [8,1,7,3,9]
    
    main()





Measured memory_bytes: 17308
#include <stdio.h>

int main ()
{
	int a, b,hitung=0;
	scanf("%d %d", &a, &b);
	char inp[a+b+1];
	scanf("%s", inp);
	for (int i=0;i<a+b+1;i++)
	{
		if(i!=a)
		{
			if(inp[i]>='0' && inp[i]<='9')
			{
				hitung++;
			}
		}
			else if(inp[i]=='-')
			{
				hitung++;
			}
		
	}
	
	if(hitung==a+b+1)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	
	
	
	
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(i < 10) ans++;
        if(i >= 100 && i < 1000) ans++;
        if(i >= 10000 && i < 100000) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//道の数
int cost[10][10];//町iからjへのコスト
const int INF =10000000;
int a1,b1,c1;
int ans;
int minV;
int maxV;
int main()
{
  while(cin >>n,n){
  ans = INF;
  maxV =0;
  for(int i = 0;i <10;i++){
    for(int j = 0;j <10;j++){
      if(i!=j)
	cost[i][j] =INF;
      else
	cost[i][j] = 0;
    }
  }
  for(int i = 0;i < n;i++){
    cin >>a1>>b1>>c1;
    cost[a1][b1] = c1;
    cost[b1][a1] = c1;
    maxV =max(maxV,max(a1,b1));
  }
  for(int i = 0;i <=maxV;i++){
    for(int j = 0;j <=maxV;j++){
      for(int k = 0;k <=maxV;k++){
	cost[j][k] =min(cost[j][k],cost[j][i]+cost[i][k]);
      }
    }
  }
  for(int i = 0;i <=maxV;i++){
    int anstemp =0;
    for(int j = 0;j <=maxV;j++){
      anstemp +=cost[i][j];
    }
    if(ans >anstemp){
      ans = anstemp;
      minV = i;
    }
  }
  cout <<minV<<" "<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define m(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	IO
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;
	return 0;
}

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

int main(){
	string in;
	int a=0, b=0, o=0, ab=0;
	while( getline(cin, in), in.length() ){
		char blood[3] = "";
		int n;
		sscanf( in.c_str(), "%d,%s", &n, blood);
		if( blood[0] == 'A' && blood[1] == 'B' )	ab++;
		else if( blood[0] == 'B' )	b++;
		else if( blood[0] == 'O' )	o++;
		else if( blood[0] == 'A' )	a++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll v[4];

void solve(){
	ll n;
	REP(i, 0, 4) {
		cin >> v[i];
		if (i) {
			v[i] = min(v[i], v[i - 1] * 2);
		}
	}
	cin >> n;
	cout << (ll)n / 2 * v[3] + (n % 2) * v[2] << endl;
	
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  int n,k;
  cin >> n >> k;
  
  ll ans=0;

  vector<int> p(n);
  rep(i,n) {
    cin >> p[i];
  }

  sort(all(p));


  rep(i,k){
    ans+=p[i];
  }

  cout << ans << endl;       
}


Measured memory_bytes: 3592