akhauriyash/Code-Regression huggingface dataset:
def main():
    n, x = map(int, input().split())
    l = list(map(int, input().split()))

    res = 0
    cnt = 1
    for i in l:
        res += i
        if res <= x:
            cnt += 1
        else:
            print(cnt)
            return
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39856
N = int(input())
S = list(input())
rli = []
gli = []
bli = []
for i in range(N):
    if S[i] == "R":
        rli.append(i+1)
    if S[i] == "G":
        gli.append(i+1)
    if S[i] == "B":
        bli.append(i+1)
ans = len(rli)*len(gli)*len(bli)
for i in range(N):
    for j in range(i+1, ((N-i)//2+(N-i)%2)+i):
        if S[i] != S[j] and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 68444
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq)
  val H = ls(0)(0)
  val W = ls(0)(1)
  val h = ls(1)(0)
  val w = ls(1)(1)
  val ret = (H-h)*(W-w)
  println(ret)
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vs words(N); REP(i, N) cin >> words[i];
    set<string> used;
    used.insert(words[0]);
    for(int i = 1; i < N; i++)
    {
        if(words[i-1][words[i-1].length()-1] != words[i][0] || used.find(words[i]) != used.end())
        {
            cout << "No" << endl;
            return;
        }
        used.insert(words[i]);
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

#define ll long long int
#define endl '\n'
#define inf 1e18

void testCase()
{
    
   // ll t; cin>>t; while(t--)
    {
        ll n;
        cin>>n;
        ll ar[n];
        for(int i=0;i<n;i++)
        cin>>ar[i];
        ll cnt=0;
        for(int i=0;i<n;i++)
        {
        for(int j=i+1;j<n;j++)
        {
        for(int k=j+1;k<n;k++)
        {
        if(ar[i]!=ar[j] and ar[j]!=ar[k] and ar[i]!=ar[k])
        {
                if(ar[i]+ar[j]>ar[k] and ar[i]+ar[k]>ar[j] and ar[j]+ar[k]>ar[i])
        cnt++;
        }
            
        }
        }
        }
        cout<<cnt;
    }       
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

long long N, w[1009], s[1009], v[1009], dp[1009][20009], mod = 1000000007;
vector<tuple<long long, long long, long long>>tup;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> s[i] >> v[i];
		tup.push_back(make_tuple(w[i] + s[i], w[i], v[i]));
	}
	sort(tup.begin(), tup.end());
	for (int i = 1; i <= N; i++) {
		s[i] = get<0>(tup[i - 1]) - get<1>(tup[i - 1]);
		w[i] = get<1>(tup[i - 1]);
		v[i] = get<2>(tup[i - 1]);
	}
	for (int i = 0; i <= 1000; i++) { for (int j = 0; j <= 20000; j++) dp[i][j] = -(1LL << 60); }

	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 20000; j++) {
			if (dp[i - 1][j] == -(1LL << 60)) continue;
			
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if (s[i] >= j) dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
		}
	}
	long long E = 0;
	for (int i = 0; i <= 20000; i++) E = max(E, dp[N][i]);
	cout << E << endl;
	return 0;
}

Measured memory_bytes: 158080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    deque<int> d;
    int n;

    while(~scanf("%d",&n))
    {
        d.clear();bool flag=0;
        for(int i=0;i<n;i++)
        {
            int t;
            scanf("%d",&t);
            if(flag)
                d.push_front(t);
            else
                d.push_back(t);
            flag=!flag;
        }
        if(n&1){
                //cout<<n<<endl;
            for(deque<int>::iterator i=d.end()-1;i!=d.begin()-1;i--)
            {
                cout<<*i<<' ';
            }
        }
        else{
            for(deque<int>::iterator i=d.begin();i!=d.end();i++)
            {
                cout<<*i<<' ';
            }
        }

        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>

#define N 500000 
void merge(int A[],int l,int m,int r);
void mergesort(int A[],int l,int r);
int n1,n2,c=0;

int a,b[N];

int main(){
  int i;
  scanf("%d",&a);
  for(i=0;i<a;i++)scanf("%d",&b[i]);
  mergesort(b,0,a);
  for(i=0;i<a;i++){
    printf("%d",b[i]);
    if(i==a-1)printf("\n");
    else printf(" ");
  }
  printf("%d\n",c);
}

void merge(int A[],int l,int m,int r){
  int i,j,k;
  n1=m-l;
  n2=r-m;
  int L[n1], R[n2];
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  //printf("%d ",L[0]);
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{ 
      A[k]=R[j];
      j++;
    }
    c++;
  }
}

void mergesort(int A[],int left,int right){
  int mid;
  mid = (left + right)/2;
  if(left+1<right){
  mergesort(A, left, mid);
  mergesort(A, mid, right);
  merge(A, left, mid, right);
  }
}



Measured memory_bytes: 5672
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}

int main() 
{ 
    fastio;
    int n,k;
    cin>>n>>k;
    ld ans=0;
    int p[n];f(i,0,n)cin>>p[i];
    f(i,0,k){
        ans+=(p[i]+1.0)/2;
    }
    ld temp=ans;
    f(i,k,n){
        temp=temp+(p[i]+1.0)/2-(p[i-k]+1.0)/2;
        ans=max(ans,temp);
    }
    cout<<setprecision(13)<<ans<<"\n";
    return 0; 	
}


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

const int Maxn=100005;

vector<int> v[Maxn];
int n,f[Maxn],s[Maxn];


void dfs(int a,int p,int deep)
{
	f[a]=deep;
	for(int i=0;i<v[a].size();i++)
		if(v[a][i] != p)
			dfs(v[a][i],a,deep+1);
}
 

int main()
{
	int F=0,S=0;
	cin >> n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(n,0,0);
	for(int i=1;i <= n;i++)
		s[i]=f[i];
	dfs(1,0,0);
	for(int i=1;i <= n;i++)
		if(f[i] <= s[i])
			F++;
		else
			S++;
	if(F>S)
		puts("Fennec");
	else
		puts("Snuke");
	return 0;
}

Measured memory_bytes: 12800
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	while (cin >> N, N) {
		vector<string>s(N);
		for (auto &i : s)cin >> i;
		map<string,int>mp;
		vector<string>group(N);
		vector<vector<string>>member(N);
		for (int i = 0; i < N; i++) {
			string t;
			for (auto j : s[i]) {
				t.push_back(j);
				if (t.back() == ':') {
					t.pop_back();
					group[i] = t;
					mp[t] = i;
					t.clear();
				}
				else if(t.back() == ','|| t.back() == '.'){
					t.pop_back();
					member[i].push_back(t);
					t.clear();
				}
			}
		}
		set<string>ans;
		queue<int>Q;
		vector<int>used(N);
		used[0] = 1;
		Q.push(0);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto i : member[cn]) {
				if (mp.find(i) == mp.end()) {
					ans.insert(i);
				}
				else {
					if (!used[mp[i]]) {
						used[mp[i]] = 1;
						Q.push(mp[i]);
					}
				}
			}
		}
		cout << ans.size() << endl;
	}
}


Measured memory_bytes: 3360
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  vector<pair<int, pair<int,int> > > vec;
  int x,y;

  while(1){
    scanf("%d%d",&x,&y);
    if(x + y == 0) break;

    int ans_x,ans_y, t = INF;
    
    for(int i=1;i<=201;i++){
      for(int j=i+1;j<=202;j++){
        int q = i*i + j*j;
        if(((x*x + y*y == q && x < i) || x*x + y*y < q)
           && ( q < t || (q == t && i < ans_x))){
          ans_x = i;
          ans_y = j;
          t = i*i + j*j;
        }
      }
    }

    printf("%d %d\n",ans_x, ans_y);
    
  }
  
  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, m;
  cin >> n >> m;
  vi a(2 * m);
  rep(i,2*m){
    cin >> a[i];
  }
  for (ll i = 1; i <= n;i++){
    ll count = 0;
    rep(j,2*m){
      if(a[j]==i){
        count++;
      }
    }
    print(count);
  }
}

Measured memory_bytes: 256
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n,k) = (v[0],v[1]);
    let mut ans = 0;
    let a = n-k;
    for i in k+1..n+1 {
        let b = n-i+1;
        let mut r = b/i;
        let mut c = (r+1)*i;
        ans += r*(c-b)+i-k;
        loop {
            if c>a {
                ans-=r*(c-a-1);
                break;
            }
            r+=1;
            ans += r*i;
            c+=i;
        }
    }
    if k==0 {
        ans -= n;
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int maxn = 105;

int main()
{
    char str[maxn];
    int num[maxn];
    while(scanf("%s",str) != EOF)
    {
        int flag = 1;
        memset(num,0,sizeof(num));
        for(int i = 0;str[i] != '\0';i++)
        {
            int x = str[i] - 'a';
            num[x]++;
        }
        for(int i = 0;i < 26;i++)
        {
            if(num[i] % 2 != 0)
            {
                flag = 0;
                break;
            }
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int z=s.size();
  int val=0;
  
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      int ok1=0;
      int ok2=0;
      int ok=0;
      int a[10];
      for(int l=0;l<=9;l++){
        a[l]=0;}
      for(int k=0; k<=z-1;k++){
       
   int q=(int)s[k];
        q-=48;
           if(q==j &&ok1==1){
          ok2=1;}
        if(q==i){
      
          ok1=1;}
     
        if(ok1==1 && ok2==1 && ok==0){
ok=1;
        continue;}
        if(ok==1){
        if(a[q]==0){
          a[q]=1;}
        }
      }
      
      for(int l=0;l<=9;l++){
        if(a[l]==1)val++;
     }
   
    }
  }
  
  cout<<val<<endl;
  return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  int64_t ansA=0,ansB=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    ansA+=A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
    ansB+=B[i];
  }
  int64_t dis=0;int cnt=0;
  if(ansB>ansA){cout<<-1<<endl;}
  else{
    vector<int64_t>d;
    for(int i=0;i<N;i++){
      if(A[i]>B[i]){d.push_back(A[i]-B[i]);}
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    for(int i=0;i<N;i++){
     if(A[i]<B[i]){cnt++;dis=dis+B[i]-A[i];}
    }
    if(cnt==0){cout<<0<<endl;return 0;}
    for(int i=0;i<d.size();i++){
     if(d[i]>=dis){cnt++;break;}
     else{cnt++;dis-=d[i];}
    }
    cout<<cnt<<endl;return 0;
    }
  return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<string.h>
/*
Dictionary (Hash)
2019. 4/30
*/

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// char to int
int getChar(char ch) {
    switch (ch) {
        case 'A':
            return 1;
            break;
        case 'C':
            return 2;
            break;
        case 'G':
            return 3;
            break;
        case 'T':
            return 4;
            break;
        default:
            return 0;
    }
}

// char to int, generate 'key'
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for ( i =  0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < M; i++) H[i][0] = '\0'; /* NULL文字 */
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);

        if(com[0] == 'i'){
            insert(str);
        } else {
            if(find(str)){
                printf("yes\n");
            } else{
                printf("no\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 16032
n = int(input())
aoaka = set()
s = []
t = []
for i in range(n):
    new = input()
    s.append(new)
    aoaka.add(new)
m = int(input())
for i in range(m):
    new = input()
    t.append(new)
    aoaka.add(new)
saidai = 0
for i in aoaka:
    cnt = 0
    cnt = cnt + s.count(i) - t.count(i)
    saidai = max(saidai,cnt)
print(saidai)

Measured memory_bytes: 3064
import bisect
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)]
c = deque()
c.append(A[0])
for i in range(1, N):
    j = bisect.bisect_left(c, A[i])
    if j == 0:
        c.appendleft(A[i])
    else:
        c[j-1] = A[i]
print(len(c))


Measured memory_bytes: 53720
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a==0){
        if(1867<b&&b<1912){cout<<"M"<<b-1867<<endl;}
        if(1911<b&&b<1926){cout<<"T"<<b-1911<<endl;}
        if(1925<b&&b<1989){cout<<"S"<<b-1925<<endl;}
        if(1988<b&&b<2017){cout<<"H"<<b-1988<<endl;}
    }
    if(a==1){cout<<1867+b<<endl;}
    if(a==2){cout<<1911+b<<endl;}
    if(a==3){cout<<1925+b<<endl;}
    if(a==4){cout<<1988+b<<endl;}
}



Measured memory_bytes: 3100
#include <iostream>

int digitsSum(int n)
{
  int total = 0;

  while(n > 0)
  {
    total += (n % 10);
    n /= 10;
  }
  return total;
}

int main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  if (n%digitsSum(n) == 0) std::cout << "Yes\n";
  else std::cout << "No\n";
  
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b=100,c=0,d,e,f;cin>>a>>b>>c>>d>>e;
  f=min({a*4,b*2,c});
  cout<<min(f*e,e/2*d+e%2*f);
}


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

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PRINT(str) printf(#str "\n")
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define v_pri(val) printf("%d\n",val);
#define s_pri(str) printf("%s\n",str);
#define v_sca(x) scanf("%d",&x);
#define s_sca(x) scanf("%s",x);

typedef long long int ll;


/*
puts("コメント");
//*/

int main(void) {
	
	int a, b;
	v_sca(a);
	v_sca(b);
	if (a + b == 15) {
		s_pri("+");
	}
	else if (a*b == 15) {
		s_pri("*");
	}
	else {
		s_pri("x");
	}

	return 0;
}

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

#define ll long long int
#define li int64_t

int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(d<= t*s)
	{
		cout<<"Yes\n";
	}	
	else
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;

// * XY座標
#define X real()
#define Y imag()

// * 点の表現
typedef complex<double> P;

// * 許容する誤差ε
const double EPS = 1e-10;
// * Infinity
const double INF = 1e12;
// * 円周率
const double PI = acos(-1.0);
// * 
const P INF_P(INF,INF);

// * complex<double> の順序を定義する
namespace std {
	bool operator < (const P& a, const P& b) {
		return (real(a) != real(b))? real(a) < real(b) : imag(a) < imag(b);
	}
}

// * 点座標のデバッグ出力
void print(P p) {
	cout << "point" << p << ";" << endl;
}

// * 2乗する
double sq(double x) {
	return x * x;
}

// * 2点間の距離
double dist(P p1, P p2) {
	return abs(p1 - p2);
}

// * 2つのスカラーが等しいかどうか
bool equal(double a, double b) {
	return ( fabs( a - b ) < EPS );
}
// * 2つのベクトルが等しいかどうか
bool eq_v(P a, P b) {
	return ( equal( a.X, b.X ) && equal( a.Y, b.Y ) );
}

// * 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b) {
	return real( conj(a) * b );
}

// * 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
	return imag( conj(a) * b ) ;
}

// ベクトル a の単位法線ベクトルを求める
vector<P> normal_unit(P a) {
	vector<P> vp;
	vp.push_back( (a * P(0,  1)) / abs(a) );
	vp.push_back( (a * P(0, -1)) / abs(a) ) ;
	return vp;
}

// 原点を軸に点 p を角度 a (ラジアン)だけ回転させた点を返す
P rot(P p, double a){
	double x = p.X * cos(a) - p.Y * sin(a);
	double y = p.X * sin(a) + p.Y * cos(a);
	return P(x,y);
}

int main(){
	int n;
	while( cin >> n , n ){
		vector<P> v;
		int ans=1;
		for(int i=0 ; i < n ; i++ ){
			double x, y;
			scanf("%lf %lf", &x, &y);
			v.push_back( P(x,y) );
		}
		for(int i=0 ; i < v.size() ; i++ ){
			for(int j=i+1 ; j < v.size() ; j++ ){
				if( i == j ) continue;
				P p1 = v[i];
				P p2 = v[j];
				double d = dist(p1,p2);
				if( d >= 2.0 ) continue;
				
				double angle = atan2( p2.Y-p1.Y , p2.X-p1.X );
				P mid = rot( p2-p1 , -angle ) / 2.0;
				double h = sqrt(1.0 - sq(d/2.0));
				P p3 = P( mid.X , h );
				P p4 = P( mid.X , -h );
				int cnt1=0, cnt2=0;
				for(int k=0 ; k < v.size() ; k++ ){
					P p = rot( v[k]-p1 , -angle );
					if( dist(p3,p) <= 1.0 ) cnt1++;
					if( dist(p4,p) <= 1.0 ) cnt2++;
				}
				ans = max( ans , max(cnt1,cnt2) );
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    ll n;
        string s;
    cin>>n;
    while(n>0)
    {
        if(n%26)
        {
            s+=char('a'+n%26-1);
            n/=26;
        }
        else
        {
            s+='z';
            n=(n-26)/26;
        }
    }
    for(int i=s.size()-1;i>=0;i--)
    cout<<s[i];
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    
    sort(l.begin(), l.end());
    
    int res = 0;
    for(int i = n-1; i >= 2; i--){
        for(int j = i-1; j >= 1; j--){
            int left = -1;
            int right = j;
            while(right - left > 1){
                int mid = (left + right)/2;
                if(l[mid] <= l[i]-l[j]){
                    left = mid;
                }else{
                    right = mid;
                }
            }
            //cout << left << ", " << right << endl;
            if(l[right] > l[i]-l[j]) res += j - right;
        }
    }
    
    cout << res << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int l,r,d; cin >> l >> r >> d;
    int out = 0;
    for(int i=l;i<=r;i++){
        if(i%d==0) out ++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3624
N, K = list(map(int, input().split()))

hito = [1]*N
A = []
for num in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for num1 in range(d):
        idx = A[num1] - 1
        hito[idx] = 0

ans = sum(hito)
print(ans)

Measured memory_bytes: 9192
#include <stdio.h>
#include <math.h>

int main(){
  float n, sum;
  float s[1000];
  float a, a2, m, sigma;
  int i;

  while(1){
    scanf("%f", &n);
    if(n==0){
      break;
    }
    sum=0;
    for(i=0; i<n; i++){
      scanf("%f", &s[i]);
      sum=sum+s[i];
    }
    m=sum/n;

    sigma=0;
    for(i=0; i<n; i++){
      sigma=sigma+(s[i]-m)*(s[i]-m);
    }
    a2=sigma/n;
    a=sqrt(a2);

    printf("%.9f\n", a);
  }
    return 0;
  }

Measured memory_bytes: 652
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll n;
cin>>n;
ll cnt=0;
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j*i<n;j++)
	{
		cnt++;
	}
}
cout<<cnt<<endl;
}



 

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	long double a, b, ans;
    cin >> a >> b;
    ans = a*b;
    cout << (long long int)ans << endl;
    system("pause");
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
//#include "../dump.hpp"

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;

vvi g;
vi d;

void bfs(int s){ // sを根としてbfs
  queue<int> q;
  d[s] = 0;
  q.push(s);
  
  while(!q.empty()){
    int next = q.front();
    q.pop();
    
    rep(i, g[next].size()){
      int c = g[next][i];
      
      if(d[c] == -1){
	d[c] = d[next] + 1;
	q.push(c);
      }
    }
  }
}

signed main(){
  int n, m, k; cin >> n >> m >> k;
  vector<int> dar(m);
  rep(i,m){
    cin >> dar[i];
    dar[i]--;
  }
  //dump(dar);
  vvi v(n,vi(k));
  rep(i,n) rep(j,k){
    cin >> v[i][j];
    v[i][j]--;
  }
  //dump(v);
  g.resize(1<<m);
  d.resize(1<<m,-1);
  rep(i,1<<m){
    rep(j,k){
      //dump(i);
      // 集合iからj番目の遷移を使った時に集合がどうなるか
      int next = 0;
      rep(x,m){ // x番目の部屋
	if((i>>x)&1){ // x番目の部屋に人がいて
	  //dump(x,v[dar[x]][j]);
	  auto itr = find(all(dar),v[dar[x]][j]); // 部屋xからj番目の遷移先が
	  if(itr != dar.end()){ // 暗い部屋なら
	    //dump(itr-dar.begin());
	    next |= 1<<(itr-dar.begin()); // 遷移先に増やす
	  }
	}
      }
      //dump(next);
      g[i].push_back(next);
    }
  }
  //dump(g);
  bfs((1<<m)-1);
  //dump(d);
  cout << d[0] << endl;
}


Measured memory_bytes: 38776
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

using namespace std;

int main()
{

    long long N;
    long long A;
    long long B;

    cin >> N;
    cin >> A;
    cin >> B;

    long long AB;
    AB = A+B;

    long long amari;
    amari = N - (N/AB)*AB;

    if(amari > A){
        cout << ((N/AB)*A+A) << endl;
    }

    if(A >= amari){
        cout << ((N/AB)*A+amari) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if(A>=13) cout << B << endl;
  else if(A<=13&&A>=6) cout << B/2 << endl;
  else cout << 0 << endl;
  return 0;
}

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

// double mathdist(double, double, double, double);

int main()
{
    /* 始めからdouble型で読み込むべし */
    /* 読み込み時のキャストは危険 */
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    // cout << mathdist(x1, x2, y1, y2) << endl;
    cout << fixed << setprecision(cout.precision()) << sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2)) << endl;
    return 0;
}

// double mathdist(double x1, double x2, double y1, double y2)
// {
//     double dxsq, dysq, res;

//     constexpr double EPS = numeric_limits<double>::epsilon();
//     if (abs(x1 - x2) <= EPS)
//     {
//         dxsq = 0.0;
//     }
//     else
//     {
//         dxsq = pow(abs(x1 - x2), 2);
//     }
//     if (abs(y1 - y2) <= EPS)
//     {
//         dysq = 0.0;
//     }
//     else
//     {
//         dysq = pow(abs(y1 - y2), 2);
//     }

//     return res = sqrt(dxsq + dysq);
// }


Measured memory_bytes: 3280
#include <stdio.h>

int main()
{
	int w, w1, w2, w3, k, k1, k2, k3;
	w1 = w2 = w3 = 0;
	k1 = k2 = k3 = 0;
	int i;
	for (i = 0;i < 10;i++) {
		scanf("%d", &w);
		if (w >= w1) { w3 = w2;w2=w1;w1=w; }
		else if (w >= w2) { w3 = w2;w2 = w; }
		else if (w >= w3) { w3 = w;   }
	}
	for(i=0;i<10;i++){
		scanf("%d",& k);
		if (k >= k1) { k3 = k2;k2 = k1;k1 = k;  }
		else if (k >=k2) { k3 = k2;k2 = k; }
		else if (k>=k3) { k3 = k; }
	}
	printf("%d %d\n", w1 + w2 + w3, k1 + k2 + k3);

	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/function.hpp>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define repr(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n)
    {
        rep(i, n) par[i] = i;
    }

    int root(int x)
    {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    int n, m; cin >> n >> m;
    priority_queue<long, vector<long>, greater<long>> as;
    long sum = 0;
    rep(i, n)
    {
        long a; cin >> a;
        as.push(a);
        sum += a;
    }
    priority_queue<pair<long, long>> bs;
    priority_queue<long> cs;
    rep(i, m)
    {
        long b, c; cin >> b >> c;
        bs.emplace(c, b);
    }
    long count = 0;
    while (!bs.empty() && count <= n)
    {
        auto p = bs.top();
        rep(j, p.second)
        {
            count++;
            cs.push(p.first);
            if (count > n) break;
        }
        bs.pop();
    }
    rep(i, n)
    {
        if (cs.empty()) break;
        long a = as.top();
        long c = cs.top();
        if (c <= a) break;
        sum += c - a;
        as.pop();
        cs.pop();
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k;
    cin>>n>>k;
    if(n==1||k==1) cout<<'1';
    else if((n*k)%2==0)  cout<<(n*k)/2;
    else cout<<(n*k/2)+1;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

def solve():
    n, x = map(int, input().split())
    l = list(map(int, input().split()))

    ans = []
    for i in l:
        ans.append(abs(x-i))

    return gcd_list(ans)
    

print(solve())


Measured memory_bytes: 16308
#include<stdio.h>
int main(){
int a,b,i,c,d,y,z,x,e;
while(scanf("%d %d",&a,&b)!=EOF){
 if(a>=b) x=a,y=b;
 else x=b,y=a;
while(y!=0) {
 z=x%y; x=y; y=z;
 }
c=a/x;
d=b/x;
e=c*d*x;
printf("%d %d\n",x,e);
 }
return 0;}

Measured memory_bytes: 592
n,m=gets.split.map(&:to_i)
l=[nil]*(n+1)
m.times do |i|
  s,c=gets.split.map(&:to_i)
  if l[s]==nil
    l[s]=c
  elsif l[s]!=c
    puts "-1"
    exit
  end
end
if n==1&&(l[1]==0||l[1]==nil)
  puts 0
  exit
end
if l[1]==0
  puts "-1"
  exit
end
l.delete_at(0)
if l[0]==nil
  print 1
else
  print l[0]
end
l.delete_at(0)
l.each do |ll|
  if ll==nil
    print 0
  else
    print ll
  end
end



Measured memory_bytes: 3836
/*-Produced by Aman Vashistha-*/
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mods 1000000007
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
    fio;
    int x;
    cin>>x;
    if(x==0) cout<<"1";
    else cout<<"0";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    double n, m, d;
    cin >> n >> m >> d;
    double res;
    if(d == 0) res = (m - 1) / (double) n;
    else res = 2 * (n - d) / (double) n * (m - 1) / (double) n;
    printf("%.10lf\n", res);
    return 0;
}

Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
const ll N=2019;
ll freq[2019];
int32_t main()
{   
     IOS;
     
     string s;
     ll n,m,i,j,k;
     cin>>s;
     n=s.length();
     ll mul=1;
     ll pre=0;
     for(i=n-1;i>=0;i--)
     {
       ll x=(mul*(s[i]-'0')+pre)%N;
       // cout<<x<<endl;
       freq[x]++;
       pre=x;
       mul*=10;
       pre%=N;
       mul%=N;
     }
     ll ans=0;
     ans+=(freq[0]*(freq[0]+1))/2;
     for(i=1;i<N;i++)
     {
      // if(freq[i]>=2)
      // cout<<freq[i]<<" "<<i<<endl;
      ans+=(freq[i]*(freq[i]-1))/2;
    }
    cout<<ans;

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 4004
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=505;

int n,a[N][N],x,y;

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

bool check(int x,int y)
{
	return !a[x][y]&&!a[x][y-1]&&!a[x-1][y]&&!a[x-1][y-1];
}

int main()
{
	x=read();y=read();n=99;
	x--;if (x) y--;
	for (int i=2;i<=n;i++)
		for (int j=2;j<=n;j++)
		{
			if (!x) break;
			if (check(i,j)) a[i][j]=a[i][j-1]=a[i-1][j]=1,x--;
		}
	for (int i=2;i<=n;i++)
		for (int j=2;j<=n;j++)
		{
			if (!y) break;
			if (check(i,j)) a[i][j]=1,y--;
		}
	printf("%d %d\n",n,n);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++) putchar(!a[i][j]?'.':'#');
		puts("");
	}
	return 0;
}

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

namespace ARC091D
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0];
            int K = line[1];

            long ans = 0;
            for(int b = K + 1; b <= N; b++)
            {
                int ta = 0;
                if (K == 0) { ans += N; continue; }
                if (N % b == 0)
                {
                    ans += N / b * (b - K);
                    continue;
                }
                if (N % b >= K)
                {
                    ta = N % b - K + 1;
                }
                int tb = N / b * (b - K);
                ans += ta + tb;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, k, l[n];
  cin >> n >> k;
  rep(i, n) cin >> l[i];
  sort(l, l + n, greater<int>());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  string s;cin>>s;
  ll ans=0;
  rep(i,n-1) if(s[i]==s[i+1]) ans++;
  ans+=2*k;
  print(min(n-1,ans));
  return 0;
}

Measured memory_bytes: 512
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void solv() {
	
	int n;
	cin >> n;
	ll a[100010];
	int p[1000010];
	memset(p, 0, sizeof(p));
	int fp = 0;
	int pos = 0;

	for (size_t i = 0; i < n + 1; i++)
	{
		cin >> a[i];
		p[a[i]]++;
		if (p[a[i]] == 2) pos = i;
	}
	for (size_t i = 0; i < n; i++)
	{
		if (p[a[i]] == 2) { fp = i; 
		break;
		}
	}
	ll rem = n - pos;
	rem += fp;
	for (size_t i = 1; i <= n + 1; i++)
	{
		ll v = COM(n + 1, i);
		if ((i - 1) <= rem) {
			v += INF;
			v -= COM(rem, i - 1);
			v %= INF;
		}
		cout << v << endl;
	}
}

int main() {
	COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 10880
import sys
input = sys.stdin.buffer.readline

mod = 10**9+7
N = int(input())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

seq = []
st = [1]
seen = [0] * (N+1)
seen[1] = 1
child = [[] for _ in range(N+1)]
while st:
    v = st.pop()
    seq.append(v)
    for u in adj[v]:
        if seen[u] == 0:
            seen[u] = 1
            st.append(u)
            child[v].append(u)

seq.reverse()
dp0 = [1] * (N+1)
dp1 = [1] * (N+1)
for v in seq:
    for u in child[v]:
        dp0[v] = (dp0[v] * ((dp0[u] + dp1[u])%mod)) % mod
        dp1[v] = (dp1[v] * dp0[u]) % mod

print((dp0[1] + dp1[1]) % mod)


Measured memory_bytes: 71344
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N; cin >> N;
  vector<string> S(N);
  map<string, long long> M;

  string tmp;
  for(int i=0; i<N; ++i) {
    cin >> tmp;
    sort(tmp.begin(), tmp.end());
    M[tmp]++;
  }

  long long ret=0;
  for(auto& itr: M) {
    if (itr.second == 1) {
      continue;
    }
    ret += ( (itr.second-1)*(itr.second)/2 );

  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ez(i,x) for(int i = h[x]; i; i = e[i].next)
using namespace std;
const int N = 2005;
int h[N], dis[N], vis[N];
int fa[N];
int n, cnt, k;
int ans;
struct edge{
	int from,to, next;
}e[N<<1];

void add(int u, int v) {
	e[++cnt] = (edge){u, v, h[u]}; h[u] = cnt;
	e[++cnt] = (edge){v, u, h[v]}; h[v] = cnt;
}

void dfs(int x){
	ez(i,x) {
		int v = e[i].to;
		if (dis[v]) continue;
		dis[v] = dis[x] + 1;
		dfs(v);
	}
}
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		add(u, v);
	}
	ans = 0x7fffffff;
	if (k & 1){
		for (int i = 1; i <= n; i += 2) {
			int u = e[i].from, v = e[i].to;
			memset(dis, 0, sizeof(dis));
			dis[v] = 1; dis[u] = 1;
			dfs(v); dfs(u);
			cnt = 0;
			for (int i = 1; i <= n; i++) if (dis[i] > (k + 1) / 2) ++cnt;
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 1; i <= n; i++) {
			memset(dis, 0, sizeof(dis));
			dis[i] = 1;
			dfs(i);
			cnt = 0;
			for (int i = 1; i <= n; i++) if (dis[i] > k / 2 + 1) ++cnt ;
			ans = min(ans, cnt);
		}

	}
	cout << ans << endl;


}


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

int main() {
    int h,n;
    cin>>h>>n;
    int weapon[n];
    for(int i=0; i<n; i++) cin>>weapon[i];

    int sum = 0;
    for(int i=0; i<n; i++) sum+=weapon[i];

    if(sum>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 640
function main(input) {
  const args = input.split(' ');
  const K = parseInt(args[0], 10);
  const S = parseInt(args[1], 10);
  
  let count = 0;
  
  for (let x = 0; x <= K; x++) {
    for (let y = 0; y <= K; y++) {
      z = S - x - y;
      if (0 <= z && z <= K) { count++; }
    }
  }
  
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32200
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	int i;
	int zero=0;
	int one=0;
	int sLen=S.size();
	for (i=0;i<sLen;i++){
		if (S[i]=='0'){
			zero++;
		}else{
			one++;
		}
	}
	int Min=min(zero,one);
	cout<<sLen-(sLen-2*Min)<<endl;
	return 0;
}

Measured memory_bytes: 512
package main
import(
  "fmt"
  "sort"
)
 func main(){
   var n, l, i int 
   var ans string
   fmt.Scan(&n, &l)
   s:=make([]string, n)
   for i=0;i<n;i++{
     fmt.Scan(&s[i])
   }
   sort.Sort(sort.StringSlice(s))
   for i=0;i<n;i++{
     ans+=s[i]
   }
   fmt.Println(ans)
 }

Measured memory_bytes: 1280
until (n = $<.gets.to_i).zero?
  data = n.times.map {$<.gets.split}.map {|a, *b| [a] + b.map(&:to_i)}
  selected = []
  all = [*0...n]
  solve = ->(left, order) {
    return if data[order.last][2] < (all - order).map {|i| data[i][1]}.sum
    if left.empty?
      selected << order
    else
      left.each {|i| solve.(left - [i], order + [i])}
    end
  }
  all.each {|i| solve.(all - [i], [i])}
  result = selected.sort_by do |order|
    w = order.map {|i| data[i][1]}
    [*1..order.size].zip(w).map {|a, b| a * b}.sum / w.sum.to_f
  end.first
  puts result.map {|i| data[i][0]}
end


Measured memory_bytes: 55876
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int __x = 2e5 + 5;
const int N = 1e6+5;
vector<int> arr(N,1), v(N,0);
void sieve(){
    for(int i=2;i<=N;i++)
    {
        if(!v[i])
        {
            arr[i] = i;
            v[i] = 1;
            for(int j=i*i;j<=N;j+=i)
            {
                arr[j]=i;
                v[j]=1;
            }
        }
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int __x_tests=1; 
    //cin >> __x_tests;
    while(__x_tests-->0){
    vector<int> visited(1e6+5,0);
    int n;
    cin >> n;
    vector<int> a(n);
    sieve();
    FOR(i,0,n) cin>>a[i];
    bool f=1;
    int gcd = a[0];
    FOR(i,1,n) gcd = __gcd(gcd ,a[i]);

    FOR(i,0,n)
    {
        int __x = a[i]; set<int> s;
        while(__x>1)
        { 
            s.insert(arr[__x]);
            if(visited[arr[__x]]) {f=0;}
            __x /= arr[__x];

        }

        for(auto j:s)
        {
            visited[j]=1;
        }

        if(!f) break;


    }


    if(f) cout << "pairwise coprime" ;
    else if(gcd == 1) cout << "setwise coprime" ;
    else cout << "not coprime" ;
    

    }    
}

Measured memory_bytes: 34596