akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>


using namespace std;

int main(){
    string str;
    int a, b;
    bool is = true;
    cin >> a >> b;
    cin >>str;
    if(str[a] != '-') is = false;
    for(int i = 0; i < a + b  + 1; i++)
        if(!isdigit(str[i]) && i != a) is = false;
    cout << (is ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int		main(void)
{
	int N, Y;
	int	i, j;

	scanf("%d%d", &N, &Y);
	for (i = 0; i <= N; i++)
	{
		for (j = 0; j <= N - i; j++)
		{
			if (10000 * i + 5000 * j + (N - i - j) * 1000 == Y)
			{
				printf("%d %d %d\n", i , j , N - i - j);
				return (0);
			}
		}
	}
	printf("%d %d %d\n", -1, -1, -1);
	return (0);
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int solve(vs a)
{
	int n=a.size();
	if(a==vs(n,string(n,'.')))
		return -1;
	int cnt=0;
	rep(i,n)
		cnt+=any_of(all(a),[&](const auto& row){return row[i]=='.';});
	int res=INF;
	rep(r,n){
		bool all_white=all_of(all(a),[&](const auto& row){return row[r]=='.';});
		int white=count(all(a[r]),'.');
		res=min<int>(res,cnt+all_white+white);
	}
	return res;
}

int main()
{
	for(int n;cin>>n&&n;){
		vs a(n);
		rep(i,n) cin>>a[i];
		cout<<solve(a)<<endl;
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int h, a;

int main() {
	scanf("%d %d", &h, &a);
	int ans = h / a;
	if(h % a) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]s = new string[7]{"SUN","MON","TUE","WED","THU","FRI","SAT"};
		string str = Console.ReadLine();
		int ans = -1;
		for(var i=0;i<7;i++){
			if(s[i]==str){
				ans = (7-i);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include<cstdio>
int main()
{
	 int a,b,c,d;
	 scanf("%d %d %d %d",&a, &b, &c, &d);
	 int num1 = a*b;
	 int num2 = c*d;
	 if(num1 > num2) printf("%d",num1);
	 	 else  printf("%d",num2);
	 
}

Measured memory_bytes: 128
# 2019-11-13 21:06:16(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    a, p = [int(x) for x in sys.stdin.readline().split()]
    pieces = a * 3 + p
    pies = pieces // 2
    print(pies)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL x,k,d;

int main()
{
	FIO;
	cin >> x >> k >> d;
	if(x < 0) x = -x;
	if(x/d >= k) {
		cout << x-k*d << endl;
		return 0;
	}
	k -= (x/d); 
	x = (x-(x/d)*d);
	if(k % 2) cout << d-x << endl;
	else cout << x << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll md = 1000000007;
#define rep(i, b) for(i = 0; i < b; i++)
#define fr first
#define sc second
using vl = vector<ll>;
using vvl = vector<vl>;
vl fac(2,1), ifac(2,1);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(int n, int r) {
    if(n < r || r < 0) return 0;
    return ml(fac[n], ml(ifac[r], ifac[n-r]));
}

ll PIE(ll n, ll k, ll e, ll s, ll mod = md) {
	if(e < 0 || k < 0 || n < 0) return 0;
	ll ans = 0;
	for(int i = 0; i <= n && (e+1) * i + (n-i)*s <= k; i++) {
		ans = ad(ans, (i&1 ? -1 : 1) * ml(C(n, i), C(n - 1 + k - (e+1) * i - (n - i) * s, n-1)));
	}
	return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    cachefact(1000000);
    int x, y;
    cin >> x >> y;
    if((x + y)%3 == 0) {
    	int n = (x + y)/3;
	    cout << PIE(n, x, 2, 1) << "\n";
	} else {
		cout << "0\n";
	}
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int calc(int x, int y, int z){
    return x*x + y*y + z*z +x*y + y*z + z*x;
}

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

    vector<int> count(n);
    rep(i,n) count[i] = 0;

    for(int x=1;x<sqrt(n);x++){
        for(int y=1;y<sqrt(n);y++){
            for(int z=1;z<sqrt(n);z++){
                if(calc(x,y,z)<=10000){
                    count[calc(x,y,z)-1]++;
                }
            }
        }
    }

    for(int i=1;i<=n;i++){
        cout << count[i-1] << '\n';
    }

    return 0;

}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := make([]bool, 1000000001)
	isPairWise := true
	for i := 0; i < n; i++ {
		var next int
		fmt.Scanf("%d", &next)
		if a[next] {
			isPairWise = false
		} else {
			a[next] = true
		}
	}
	if isPairWise {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1021440
#include <iostream>

using namespace std;

int main()
{
    long L = 0;
    long R = 0;
    cin >> L >> R;

    long final = 0;
    long result = 65535;

    for (long i=L; i<=L+2019; i++) {
        if (R <= i+1+2019) {
            final = R;
        } else {
            final = i+1+2019;
        }
        for (long j=i+1; j<=final; j++) {
            if (i*j%2019 < result) {
                result = i*j%2019;
                //cout << i << " " << j << " " << result << endl;
            } 
        }
    }

    cout << result;

    return 0;
}   


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    ll n,a,b;
    cin >> n >> a >> b;
    ll t=n/(a+b);
    n%=(a+b);
    ll ans=t*a;    
    ans+=(n>=a)?a:n;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3544
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn f(ab: &[(u32, i64)], k: u32) -> i64 {
    ab.iter().filter(|(a, _)| a | k == k).map(|(_, b)| b).sum()
}

fn main() {
    input! {
        n: usize,
        k: u32,
        ab: [(u32, i64); n],
    }
    let mut res = f(&ab, k);
    for i in 0..32 {
        let x = 1 << i;
        if k & x == 0 {
            continue;
        }
        res = std::cmp::max(res, f(&ab, k & (!x) | (x - 1)));
    }
    println!("{}", res);
}


Measured memory_bytes: 5480
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    static StringBuffer sb = new StringBuffer();
    public static void main(String args[]){
        HashMap<String,Integer> r=new HashMap<>();
        HashMap<String,Integer> b=new HashMap<>();
        int N=sc.nextInt(),res=0;
        for(int i=0;i<N;i++){
            String t=sc.next();
            if(!b.containsKey(t)) b.put(t,0);
            b.put(t,b.get(t)+1);
        }
        N=sc.nextInt();
        for(int i=0;i<N;i++){
            String t=sc.next();
            if(!r.containsKey(t)) r.put(t,0);
            r.put(t,r.get(t)+1);
        }
        for(String key:b.keySet()){
            if(r.containsKey(key)){
                res=Math.max(res,b.get(key)-r.get(key));
            }
            else{
                res=Math.max(res,b.get(key));
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 35768
_input = list(map(int, input().split(" ")))
a = _input[0]
b = _input[1]
c = _input[2]

check_limit = a * b
ratio = 1
remain_list = []

while (True):
  remain_list.append(a * ratio % b)
  ratio += 1

  if ratio > b:
    break

if c in remain_list:
  print("YES")
else:
  print("NO")



Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
K = [0] * 60
ans = 0
mod = 7 + 10**9
for i in A:
    for j in range(60):
        if (i >> j) & 1 == 1:
            K[j] += 1

for i, j in enumerate(K):
    ans += (2**i) * j * (N - j)
    ans %= mod

print(ans)




Measured memory_bytes: 122808
n,m= map(int,input().split())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l=sorted(l, key=lambda x: x[0])
x=0
ans = 0
for i in range(n):
  x = x + l[i][1]
  ans += l[i][0]*l[i][1]
  if x > m:
    ans = ans - l[i][0]*(x-m)
    break
print(ans)

Measured memory_bytes: 29792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}
int div2(int x) {
	if (x & 1) x += MOD;
	return x / 2;
}
 
const int N = 3030;
int a[N];
int xs[N];
int n, m, k;
int b[N][2];
int c[N], d[N];
int ans;
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		xs[i] = a[i];
	}
	sort(xs, xs + n);
	k = unique(xs, xs + n) - xs;
	for (int i = 0; i < n; i++)
		a[i] = lower_bound(xs, xs + k, a[i]) - xs;
	for (int i = 0; i < m; i++)
		for (int j = 0; j < 2; j++) {
			scanf("%d", &b[i][j]);
			b[i][j]--;
		}
	for (int it = k - 1; it >= 0; it--) {
		for (int i = 0; i < n; i++)
			c[i] = (int)(a[i] == it);
		for (int i = 0; i < m; i++) {
			int x = div2(add(c[b[i][0]], c[b[i][1]]));
			c[b[i][0]] = c[b[i][1]] = x;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			ans = add(ans, mult(sum, c[i]));
			ans = add(ans, div2(mult(c[i], d[i])));
			sum = add(sum, d[i]);
			d[i] = add(d[i], c[i]);
		}
	}
	for (int i = 0; i < m; i++) {
		ans = add(ans, ans);
	}
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll MOD = 1000000007;
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  ll sum = 0;
  rep(i,n){
    sum += a[i];
    sum %= MOD;
  }
  rep(i,n){
    sum = (sum - a[i] + MOD)%MOD;
    ans += a[i]*sum;
    ans %= MOD;
  }
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

ll dp[1005][1005], C[1005][1005];
ll f1[1005], f2[1005];
ll pw(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b%2 == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
int main(){
    C[0][0] = 1;
    f1[0] = f2[0] = 1;
    for(int i=1;i<=1000;i++){
        C[i][0] = C[i][i] = 1;
        f1[i] = f1[i-1]*1ll*i%mod;
        f2[i] = pw(f1[i], mod-2);
        for(int j=1;j<i;j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;
    }
    int n, a, b, c, d;
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    for(int j=a;j<=b;j++){
        dp[j-1][0] = 1;
        for(int i=n;i>=1;i--){
            dp[j][i] = (dp[j][i] + dp[j-1][i])%mod;
            int cnt = 0;
            ll inv = 1;
            for(int k=j;i+k-1<=n;k+=j){
                cnt++;
                inv = inv*f2[j]%mod;
                if(c <= cnt && cnt <= d){
                    ll res = dp[j-1][i-1]*1ll*C[n-i+1][k]%mod*f1[k]%mod*inv%mod*f2[cnt]%mod;
                    dp[j][i+k-1] = (dp[j][i+k-1] + res)%mod;
                }
            }
        }
    }
    printf("%d\n", dp[b][n]);
}

Measured memory_bytes: 18468
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=998244353;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,q,a[200111],pre[200111];
pair<int,int> p[200111];
int dp[200111];
int mn[800111];
#define ls p<<1
#define rs p<<1|1
void change(int x,int v,int l,int r,int p=1)
{
	if(l==r)
	{
		mn[p]=min(mn[p],v);
		return;
	}
	int m=l+r>>1;
	if(x<=m)change(x,v,l,m,ls);
	else change(x,v,m+1,r,rs);
	mn[p]=min(mn[ls],mn[rs]);
}
int query(int x,int y,int l,int r,int p=1)
{
	if(x<=l&&r<=y)return mn[p];
	int m=l+r>>1;
	if(x<=m&&m<y)return min(query(x,y,l,m,ls),query(x,y,m+1,r,rs));
	else if(x<=m)return query(x,y,l,m,ls);
	else return query(x,y,m+1,r,rs);
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+1-a[i];
	geti(q);
	for(int i=1;i<=q;i++)
	{
		getii(p[i].FF,p[i].SS);
	}
	memset(dp,31,sizeof(dp));
	memset(mn,31,sizeof(mn));
	sort(p+1,p+q+1);
	dp[0]=0;
	int it=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+a[i]);
		int l=it;
		while(it<=q&&p[it].FF==i)it++;
		int r=it;
		for(int j=l;j<r;j++)
		{
			int cur=dp[i-1]+pre[p[j].SS]-pre[i-1];
			cur=min(cur,query(p[j].FF,p[j].SS,1,n,1)+pre[p[j].SS]);
			change(p[j].SS,cur-pre[p[j].SS],1,n,1);
			dp[p[j].SS]=min(dp[p[j].SS],cur);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 7424
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> p;
  tools::read(p, N);

  std::partial_sort(p.begin(), p.begin() + K, p.end());
  std::cout << std::accumulate(p.begin(), p.begin() + K, static_cast<i64>(0)) << std::endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int A[1000010];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int maxi = 0;
	int k, n;
	cin >> k >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	A[n] = A[0];
	for(int i = 0; i < n; i++){
		if(A[i + 1] > A[i])
			maxi = max(maxi, A[i + 1] - A[i]);
		else 
			maxi = max(maxi, A[i + 1] + k - A[i]);
	}
	cout << k - maxi << '\n';


}

Measured memory_bytes: 1024
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

bmul = [0]*(n+1)
ci = 0

for bi in range(n):
    while ci != n and c[ci] <= b[bi]:
        ci += 1
    bmul[bi] = n-ci
for i in range(n):
    bmul[n-i-1] += bmul[n-i]
bi = 0
ai = 0
ret = 0
for ai in range(n):
    while bi != n and b[bi] <= a[ai]:
        bi += 1
    ret += bmul[bi]
print(ret)


Measured memory_bytes: 23124
#pragma once
#include <sstream>
#include <string>
#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 <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
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;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
int n;
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
int a[5];

void Solve() {

	ll k, a, b;
	cin >> k >> a >> b;
	ll res = k + 1;
	ll rem = k - (a - 1);
	ll sum = (rem / 2) * (b - a) + a;
	res = max(res, sum + (rem % 2));
	cout << res << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6016
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD



@mt
def slv(N, M, K):
    m = Mod(998244353)
    C = Combination(N, 998244353)

    ans = 0
    col = M
    for x in range(N-1, -1, -1):
        tmp = col
        tmp = m.mul(tmp, C(N-1, x))
        if x <= K:
            ans = m.add(ans, tmp)
        col = m.mul(col, M-1)
    return ans


def main():
    N, M, K = read_int_n()
    print(slv(N, M, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 120244
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	int n_t3 = n / 3;
	int n_t5 = n / 5;
	int n_t15 = n / 15;
	long long s_t3 = (3 + 3 + (n_t3 - 1) * 3) * 1LL * n_t3 / 2;
	long long s_t5 = (5 + 5 + (n_t5 - 1) * 5) * 1LL * n_t5 / 2;
	long long s_t15 = (15 + 15 + (n_t15 - 1) * 15) * 1LL * n_t15 / 2;
	long long tmp = (1 + n) * 1LL * n / 2;
	long long ans = tmp - s_t3 - s_t5 + s_t15;
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);//a<b
	if(a==1&&b==2)puts("Borys");
	else if((b-a)&1)puts("Borys");
	else puts("Alice");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <cstring>
#define ll long long

using namespace std;

int main()
{
    ll int i,j,n,k,count=0,sum=0,m;
    cin>>n>>k;
    ll int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++){
        k=k-a[i];
        if(k>=0)
            count++;
        else break;
    }
    if(k>0)
        count--;
    cout<<count<<endl;
    return 0;
}



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


int canSpace(int sx, int sy, int gx, int gy, const vector<vector<int>>& e){
    int high = 100000;
    for (int i = sx; i <= gx; ++i) {
        high = min(high, e[i][sy]);
        high = min(high, e[i][gy]);
    }
    for (int i = sy; i <= gy; ++i) {
        high = min(high, e[sx][i]);
        high = min(high, e[gx][i]);
    }
    int space = 0;
    for (int i = sx + 1; i < gx; ++i) {
        for (int j = sy + 1; j < gy; ++j) {
            int sp = high - e[i][j];
            if(sp <= 0) return 0;
            space += sp;
        }
    }
    return space;
}

int main() {
    int d, w;
    while(1) {
        cin >> d >> w;
        if(d == 0 && w == 0) break;
        vector<vector<int>> e(d, vector<int>(w));
        for (int i = 0; i < d; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> e[i][j];
            }
        }
        int maxSpace = 0;
        for (int sx = 0; sx < d; ++sx) {
            for (int sy = 0; sy < w; ++sy) {
                for (int gx = sx + 2; gx < d; ++gx) {
                    for (int gy = sy + 2; gy < w; ++gy) {
                        maxSpace = max(maxSpace, canSpace(sx, sy, gx, gy, e));
                    }
                }
            }
        }
        cout << maxSpace << '\n';
    }

}



Measured memory_bytes: 3152
n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]
for _ in range(q):
  q = list(map(int, input().split()))
  if q[0]==0:
    a[q[1]].append(q[2])
  elif q[0]==1:
    print(" ".join(map(str, a[q[1]])))
  elif q[0]==2:
    a[q[1]].clear()


Measured memory_bytes: 60472
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;
 
class Obj{
  public:
    int a;
    int c;
    Obj(int b, int d){
      a = b;
      c = d;
    }
    bool operator<(const Obj &o) const{
        if(a!=o.a){
            return a<o.a;
        }
      return c<o.c;
    }
};
 
typedef
tree<
  Obj,
  null_type,
  less<Obj>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
 
int main()
 {
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<Obj> li;;
    int n;
    cin >> n;
    for(int i = 0; i<n; i++){
        int x;
        cin >> x;
        li.push_back(Obj(x,i));
    }
    ordered_set X;
    for(int i = 0; i<n; i++){
        X.insert(li[i]);
    }
    for(int i = 0; i<n; i++){
        X.erase(X.find(li[i]));
        cout << (*X.find_by_order(n/2-1)).a << endl;
        X.insert(li[i]);
    }
    
}

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, n, t, u, s;
  in(n);
  vector<ll> c(n), e(n);
  rep(i, n)
    in(c[i]);
  sort(all(c));
  s = 1;
  vector<bool> d(n, false);
  d[n - 1] = true;
  a = n - 2;
  e[0] = c[0];
  rep(i, n - 1)
    e[i + 1] = c[i + 1] + e[i];
  rep(i, n - 1){
    if(e[n - 2 - i] * 2 >= c[n - i - 1])
      s++;
    else
      break;
  }
  out(s);
  memi;
}


Measured memory_bytes: 1792
n = int(input())
input_zahyo = []
goukei = 0
tairyoku = 0

input_zahyo = input().split()
zahyo = [int(s) for s in input_zahyo]


for i in range(n):
    goukei += zahyo[i]

ave = round(goukei/n)

for i in range(n):
    tairyoku += (zahyo[i]-ave)**2

print(tairyoku)

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


public class my
{
	struct Pond
    {
        public int pos;
        public int area;
 
        public Pond(int pos, int area)
        {
            this.pos = pos;	// pond's startline
            this.area = area;
        }
    }
	
	private static StringBuilder sb = new StringBuilder();
	
	public static void Main()
	{
		var s = Console.ReadLine();
		
		var stk = new Stack<int>();
		var pond = new Stack<Pond>();
		
		int sub = 0;
		int sum = 0;
		
		for(int i = 0; i < s.Length; i++) {
			if(s[i] == '\\' ) {
				stk.Push(i);
			} else if (s[i] == '/' && stk.Count > 0) {
				int j = stk.Pop();
				sub = i - j;
				sum += sub;
				
				// POND's KETUGOUSHYORI
				while(pond.Count >0 && pond.Peek().pos > j) {
					sub += pond.Peek().area;
					pond.Pop();
				}
				
				pond.Push(new Pond(j, sub));
			}
		}
		
		int k = pond.Count;
		Console.WriteLine(sum);
		Console.Write(k);
		
		for(int i = 0; i < k; i++ ) {
			sb.Insert(0, " " + pond.Pop().area);
		}
		Console.WriteLine(sb);
			
	}
	
	private static int CountChar(string s, char c)
	{
		return s.Length - s.Replace(c.ToString(), "").Length;
	}
	
	private static void Flush()
	{
		Console.Write(sb);
		sb.Length = 0;
	}
	
	private static void AppendLine(int v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(long v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(string[] v)
	{
		sb.AppendLine(string.Join(" ", v));
	}

	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 10392
#include<bits/stdc++.h>
using namespace std ;
#define int long long
int n , k  ;
const int N = 2e5 + 10 ;
int a[N] , sum[N] ;
map < int , int > mp ;
signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(nullptr) ;
  cout.tie(nullptr) ;
  cin >> n >> k ;
  sum[0] = 0 ; for(int i = 1 ; i <= n ; i ++) { cin >> a[i] ; }
  for(int i = 1 ; i <= n ; i ++) { sum[i] = (sum[i - 1] + a[i] - 1 + k) % k ; }
  int ans = 0 ; mp[0] = 1 ;
  for(int i = 1 ; i <= n ; i ++) {
    if(i >= k) { mp[sum[i - k]] -- ; }
    ans += mp[sum[i]] ++ ;
  }
  cout << ans << '\n' ;
  return 0 ;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    string S;
    map<string, int> prize;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> S;
        prize[S]++;
    }
    cout << prize.size() << endl;
    return 0;
}

Measured memory_bytes: 19176
/*
Author: Rishabh Agarwal
Nationality: Indian
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define MOD 1000000007
#define vpi vector<pair<int, int>>
#define ll long long int
#define inf 1000000000
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Cases int testCases; cin>>testCases; while(testCases--) 
#define MOD 1000000007
#define pb push_back
//---------------------------------------------------
int main() {
    FIO
    long double R;
    cin>>R;
    long double circum = 2*(3.14159265358979323846)*R;
    cout<<circum<<endl;
}



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

int main(){
  int x; cin >>x;
  for(int a = -120; a<=120; a++){
    for(int b = -120; b<=120; b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
const int INF = 1001001001;
int dp[1001][10001];

int main(){
  int h,n;cin>>h>>n;
  REP(i,h+1) dp[0][i]=INF;
  REP(i,n+1) dp[i][0]=0;
  REP(i,n){
    int a,b;cin>>a>>b;
    for(int j=1;j<=h;j++){
      dp[i+1][j]=min(dp[i][j],dp[i+1][max(j-a,0)]+b);
    }
  }
  cout<<dp[n][h];
}


Measured memory_bytes: 39424
#include <stdio.h>

int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);
  int i = 0;
  int a[n];
  int vote = 0;
  while (i < n)
  {
    scanf("%d", &a[i]);
    vote += a[i];
    i++;
  }
  
  i = 0;
  int cnt = 0;
  double tmp = vote;
  tmp = tmp / (4 * m);
  while (i < n)
  {
    if (a[i] >= tmp)
    {
      cnt++;
    }
    i++;
  }
  if (cnt >= m)
  {
    printf("Yes");
    return 0;
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

void dfs(vector<vector<int > > &map,int x,int y,int value){
	map[x][y] = 0;
	for(int i=0;i<4;i++){
	int nx = x+dx[i];
	int ny = y+dy[i];
	if(map[nx][ny]==value)dfs(map,nx,ny,value);
	}
	return;
}

int main(){
	int h,w;
	while(1){
		cin>>h>>w;
		if(h==0)break;
		vector<vector<int> > map(h+2,vector<int>(w+2,0) );
		char a;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
		cin>>a;
			if(a=='#'){
			map[i][j] = 1;
			}	
			if(a=='*'){
			map[i][j]=2;
			}
			if(a=='@'){
			map[i][j]=3;
			}
		}	
		int ans = 0;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
			if(map[i][j]!=0){
				dfs(map,i,j,map[i][j]);
				ans++;
			}
		}	

		cout<<ans<<endl;

	}
	return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, m;
    cin >> n >> m;
    VE a(n, 0), b(n, 0);
    REP(i, n) cin >> a[i] >> b[i];
    priority_queue<Pi, vector<Pi>, greater<Pi> > pq;
    REP(i, n) {
        pq.push(make_pair(a[i], b[i]));
    }
    ll cnt = m;
    ll ans = 0;
    while(!pq.empty()) {
        auto top = pq.top();
        pq.pop();
        ll value = top.first;
        ll num = top.second;
        if(num <= m) {
            ans += num * value;
            m -= num;
        } else {
            ans += m * value;
            break;
        }
    }
    print(ans);
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

pii A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>A[i].f>>A[i].s;

    sort(A,A+n);

    int R = 0;
    ll res = 0;

    for(int i=1;i<=m;i++){

        while(A[R].f<=i){
            pq.push(A[R].s);
            R++;
        }

        if(!pq.empty()){
            res+=pq.top();
            pq.pop();
        }
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	vector<vector<int>> map(h, vector<int>(w, -1));
	queue<pair<pair<int, int>, int>> q;
	q.push(make_pair(make_pair(0, 0), 1));
	while (!q.empty()) {
		int x = q.front().first.first;
		int y = q.front().first.second;

		if (map[x][y] != -1) {
			q.pop();
			continue;
		}
		map[x][y] = q.front().second;
		q.pop();

		int dx[] = { -1, 1, 0, 0 };
		int dy[] = { 0, 0, -1, 1 };
		for (int i = 0; i < 4; i++) {
			if (x + dx[i] < 0) continue;
			if (x + dx[i] >= h) continue;
			if (y + dy[i] < 0) continue;
			if (y + dy[i] >= w) continue;
			if (s[x + dx[i]][y + dy[i]] == '#') continue;
			q.push(make_pair(make_pair(x + dx[i], y + dy[i]), map[x][y] + 1));
		}
	}

	if (map[h - 1][w - 1] == -1) {
		cout << -1 << endl;
	} else {
		int num = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					num++;
				}
			}
		}
		cout << h * w - num - map[h - 1][w - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
 #include  <vector>
using namespace std;
int main()
{
	long long int n,max=0,arr,sum=0;
	cin>>n;
	long long int a[n];
	for(long long int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n,greater<long long int>());
	sum+=a[0];
	for(int i=1;i<n-1;i++)
	{
	sum+=a[(i+1)/2];
	}
	cout<<sum;
	/*
	vector <int> vec;
	for(int i=0;i<n;i++)
	{
		if(vec.empty())
		vec.insert(vec.begin,a[i]);
		else if(vec.length()==1)
		vec.insert(vec.begin,a[i]);
		else if(vec.length()==2)
		vec.insert(vec.begin,a[i]);
		else
		{
		for(int j=0;j<vec.length();j++)
		{
		    if(j=0&&(vec[j]<vec[j+1]||vec[j]<vec[vec.length()])
		    {
		    	{
				if(vec[j]>max)
				{
				max=vec[j];
				arr=j;
				}
			}
			}
			else if(vec[j]<vec[j+1]||vec[j]<vec[j-1])
			{
				if(vec[j]>max)
				{
				max=vec[j];
				arr=j;
				}
			}
			
		}
	    }
		
	}*/
	

}


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

const int N = 1e2 + 10;

int n;

struct card
{
    char str, value;
} c1[N], c2[N];

void bubble(struct card a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        for(int j = n - 1; j >= i + 1; j--)
        {
            if(a[j].value < a[j - 1].value) swap(a[j], a[j - 1]);
        }
    }
}

void selection(struct card a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        int minj = i;
        for(int j = i; j < n; j++)
        {
            if(a[minj].value > a[j].value) minj = j;
        }
        swap(a[i], a[minj]);
    }
}

bool isStable(struct card c1[], struct card c2[], int n)
{
    for(int i = 0; i < N; i++)
    {
        if(c1[i].str != c2[i].str) return false;
    }
    return true;
}

void print(struct card a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        if(i > 0) cout << " ";
        cout << a[i].str << a[i].value;
    }
    cout << endl;
}

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

    cin >> n;

    for(int i = 0; i < n; i++) cin >> c1[i].str >> c1[i].value;

    for(int i = 0; i < n; i++) c2[i] = c1[i];

    bubble(c1, n);
    selection(c2, n);

    print(c1, n);
    cout << "Stable" << endl;

    print(c2, n);
    if(isStable(c1, c2, n))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3180
N, K, C = list(map(int,input().split()))
s = list(str(input()))

L = []  # i+1日目に働くのはL[i]日目以降
R = []  # i+1日目に働くのはL[i]日目以前

for i in range(N):
    if len(L) >= K:
        break
    if s[i] == 'o' and (L == [] or (i + 1) - L[-1] > C):
        # 出勤可能('o') 且 (Lが空又はi日目時点の最終出勤からc日経過)
        # ならばLにi+1を追加
        L.append(i + 1)

for i in range(N - 1, -1, -1):
    if len(R) >= K:
        break
    if s[i] == 'o' and (R == [] or R[-1] - (i + 1) > C):
        R.append(i + 1)

R.reverse()
ans = []

for i in range(K):
    if L[i] == R[i]:
        print(L[i])

Measured memory_bytes: 22036
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int h,n,gokei=0;
    cin>>h>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        gokei+=a[i];
        //cout<<gokei<<endl;
    }
    if(gokei>=h){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main()
{
    int n;
    long long a;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>a;
        while(a%2==0)
        {
            a=a/2;
            sum++;
        }
    }
    cout<<sum;
    return 0;
}


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

int main() {
	int k;cin>>k;
//	vector<vector<int>> v(k);
	vector<int> list,next;
	int ans=1;
	int flag=0;
	int used[k];
	for(int i=0;i<k;i++){
		used[i]=0;
	}
	list.push_back(1);
	while(1){
		while(list.size()){
			int num=list.back();
//			cout<<num<<endl;
			if(num==0){
					flag=1;
					break;
			}
			list.pop_back();
			if(used[num]==0){
				used[num]=1;
				next.push_back((num+1)%k);
				list.push_back((num*10)%k);
			}

		}
		if(flag){
			break;
		}
		list=next;
		next.clear();
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}


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

typedef long long LL;

const int maxn=1e5+5;

int n,m;
char s[maxn],t[maxn];

int main()
{
	scanf("%d %d",&n,&m);
	scanf("%s",s+1);
	scanf("%s",t+1);
	if (n==m)
	{
		fo(i,1,n) if (s[i]!=t[i]) {puts("-1"); return 0;}
		printf("%d\n",n);
		return 0;
	} else if (n<m)
	{
		swap(n,m);
		swap(s,t);
	}
	
	LL len=(LL)n*m/__gcd(n,m), nblock=len/n, mblock=len/m;
	int x=0, y=0;
	fo(i,1,n)
	{
		LL now=(i-1)*nblock+1;
		if (now%mblock==1)
		{
			LL j=(now-1)/mblock+1;
			if (s[i]!=t[j]) {puts("-1"); return 0;}
		}
	}
	
	printf("%lld\n",len);
}

Measured memory_bytes: 384
import collections
import heapq

def dijkstra(graph, node, start):
    dist = [float("inf") for _ in range(node)]

    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while q:
        cost, cur_node = heapq.heappop(q)

        if dist[cur_node] < cost:
            continue

        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heapq.heappush(q, (dist[nex_node], nex_node))

    return dist



h, w = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
adj = [[] for _ in range(10)]
for i in range(10):
    for j in range(10):
        c_ = c[i][j]
        adj[i].append((c_, j))
a = []
for i in range(h):
    A = list(map(int, input().split()))
    for j in A:
        a.append(j)
ac = collections.Counter(a)
ans = 0
for i in ac:
    if i != -1:
        ans += dijkstra(adj, 10, i)[1] * ac[i]
print(ans)

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main()
{
    
    string s, c;
    int count = 0;
    cin >> s >> c;
    if(s[0] == c[0])
        count++;
    if(s[1] == c[1])
        count++;
    if(s[2] == c[2])
        count++;
    cout << count << endl;
    

    return 0;
}


Measured memory_bytes: 256
#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 n;
const int V=100005;
vector<int> to[100005];
vector<int> block[100005];
bool visited[100005];
int group[100005];
int group_idx=0;
int temp=0;
int indexy[100005];
int point[100005];


void dfs(int p){
    if(visited[p])return;
    visited[p]=1;
    group[p]=group_idx;
    temp++;
    for(int q:to[p]){
        dfs(q);
    }
    return;
}

int main(){
    int m,k;
    cin >> n>>m>>k;
    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
        point[a]++;
        point[b]++;
    }
    rep(i,k){
        int c,d;
        cin >> c>>d;
        c--;d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    rep(i,n){
        temp=0;
        dfs(i);
        indexy[i]=temp;
        group_idx++;
    }
    rep(i,n){
        for(int j:block[i]){
            if(group[i]==group[j]){
                point[i]++;
            }
        }
    }
    rep(i,n){
        int g=group[i];
        int ans=indexy[g]-point[i]-1;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 36864
S=int(input())
dp=[]#答えの方
assim=[]#累積和
mod=10**9+7

for i in range(2001):
    if i<3:
        dp.append(0)
    elif i==3:
        dp.append(1)
    else:
        dp.append((assim[-3])%mod)
    
    if i==0:
        assim.append(0)
    else:
        assim.append((assim[-1]+dp[-1])%mod)

print(assim[S])

Measured memory_bytes: 64288
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    vector<vector<int>> b(h, vector<int>(w));

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

        for (int j = 0; j < h; j++) {
            for (int k = 0; k < w; k++) {
                if ((a == 1 && k < x) || (a == 2 && k >= x) ||
                    (a == 3 && j < y) || (a == 4 && j >= y)) {
                    b[j][k] = 1;
                }
            }
        }
    }

    int cnt = 0;
    for (int j = 0; j < h; j++) {
        for (int k = 0; k < w; k++) {
            if(b[j][k] == 0){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>

using namespace std;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k-1] = tolower(s[k-1]);
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 256