akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;

typedef long long int64;
const int64 MOD = 1e9 + 7;

int64 fast_pow(int64 x, int64 n) {
  if (n == 0)return 1;

  int64 ans = fast_pow(x, n >> 1);
  ans = (ans * ans) % MOD;
  if (n & 1)ans = (ans * x) % MOD;
  return ans;
}

class EMaxMinSums {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int n, k;
    in >> n >> k;
    vector<int64> v(n);
    forn(i, n) {
      in >> v[i];
      v[i] = v[i];
    }

    sort(all(v));

    int64 min = 0, max = 0;

    vector<int64> fact(n + 5, 1);
    fore(i, 1, n + 4)fact[i] = (fact[i - 1] * i) % MOD;

    for (int i = 0; i < n; ++i) {
      int remainder = n - i - 1;
      int kk = k - 1;
      if (remainder >= kk) {
        int64 deno = (fact[remainder - kk] * fact[kk]) % MOD;
        deno = (fast_pow(deno, MOD - 2) * fact[remainder]) % MOD;
        min += deno * v[i];
        min %= MOD;
      }

    }
    reverse(all(v));
    for (int i = 0; i < n; ++i) {
      int remainder = n - i - 1;
      int kk = k - 1;
      if (remainder >= kk) {
        int64 deno = (fact[remainder - kk] * fact[kk]) % MOD;
        deno = (fast_pow(deno, MOD - 2) * fact[remainder]) % MOD;
        max += deno * v[i];
        max %= MOD;
      }
    }
    out << (max - min + (10 * MOD)) % MOD << endl;

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  EMaxMinSums solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1920
// input macro start
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
// input macro end

fn main() {
    input! {
       n :u64 ,
    }

    let s: u64 = n.to_string().chars().map(|x| x as u64 - '0' as u64).sum();

    if n % s == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
const long double pi = 3.14159265358979323846264338327950288;
int main() {
	int n, b[26], c[26];
	string a;
	cin >> n;
	fill(b, b + 26, -1);
	for (int i = 0; i < n; i++) {
		cin >> a;
		fill(c, c + 26, 0);
		for (int j = 0; j < a.size(); j++) 
			c[(int)a[j] - 'a']++;
		for (int j = 0; j < 26; j++) {
			if (b[j] == -1)
				b[j] = c[j];
			b[j] = min(b[j], c[j]);
		}
	}
	string d = "";
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < b[i]; j++) {
			d += (char)i + 'a';
		}
	}
	cout << d << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main(){
  bool flg=false,bflg;
int i;
  while(!flg){
    /*行ループ*/
    string s;
    stack<char> box;
    char ch;
    getline(cin,s);

    if(s==".")flg=true;
    else {
      /*区画ループ*/
      bflg=true;
      box.push('s');

      for(i=0;i<s.size();i++){
        ch=s.at(i);
        if(ch=='('||ch=='[')box.push(ch);
        else if(ch==')'){
          if(box.top()=='(')box.pop();
          else{
            bflg=false;
            break;
          }
        }
        else if(ch==']'){
          if(box.top()=='[')box.pop();
          else{
            bflg=false;
            break;
          }
        }
        else if(ch=='.'){
          break;
        }
      }
      if(bflg==true && box.top()=='s')cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
int w,h;
int sx,sy;
int a[30][30];
string str[30];
queue<int> q;

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0){
			break;
		}

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				a[i][j] = 0;
			}
		}

		for(int i=0; i<h; i++){
			cin >> str[i];
		}

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(str[i][j] == '@'){
					sx = j;
					sy = i;
				}
			}
		}
		q.push(sy*30+sx);
		a[sy][sx] = 1;

		while(!q.empty()){
			int tmp = q.front();
			q.pop();

			for(int i=0; i<4; i++){
				int nx = tmp%30 + dx[i];
				int ny = tmp/30 + dy[i];

				if(ny <0 || nx <0 || ny >= h || nx >= w || str[ny][nx] == '#' || a[ny][nx] == 1){
					continue;
				}

				q.push(ny*30+nx);

				a[ny][nx] = 1;
			}
		}

		int count=0;

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(a[i][j] == 1){
					count++;
				}
			}
		}

		cout << count << endl;
	}


}

Measured memory_bytes: 3120
#include <stdio.h>
int main(void){
    int N;
    
    scanf("%d", &N);
    
    if(N <= 111){
        printf("%d\n", 111);
    }else if(N >= 112 && N <= 222){
        printf("%d\n", 222);
    }else if(N >= 223 && N <= 333){
        printf("%d\n", 333);
    }else if(N >= 334 && N <= 444){
        printf("%d\n", 444);
    }else if(N >= 445 && N <= 555){
        printf("%d\n", 555);
    }else if(N >= 556 && N <= 666){
        printf("%d\n", 666);
    }else if(N >= 667 && N <= 777){
        printf("%d\n", 777);
    }else if(N >= 778 && N <= 888){
        printf("%d\n", 888);
    }else if(N >= 889 && N <= 999){
        printf("%d\n", 999);
    }
    
    
    
}


Measured memory_bytes: 1728
n=int(input())
a=list(map(int,input().split()))
ans=[]
anything=0
for i in range(n):
    if 1<=a[i]<=399:
        ans.append(1)
    elif 400<=a[i]<=799:
        ans.append(2)
    elif 800<=a[i]<=1199:
        ans.append(3)
    elif 1200<=a[i]<=1599:
        ans.append(4)
    elif 1600<=a[i]<=1999:
        ans.append(5)
    elif 2000<=a[i]<=2399:
        ans.append(6)
    elif 2400<=a[i]<=2799:
        ans.append(7)
    elif 2800<=a[i]<=3199:
        ans.append(8)
    elif 3200<=a[i]:
        anything+=1
ans_i=list(set(ans))
min_i=len(ans_i)
max_i=len(ans_i)+anything
if len(ans_i)==0 and 1<=anything:
    print(1,max_i)
else:
    print(min_i,max_i)

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int i = 0;
    while(b <= a){
        b *= 2;
        i++;
    }
    while(c <= b){
        c *= 2;
        i++;
    }
    if(i <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3636
S = str(input())
t = len(S)-1
a = []
for i in range(2**t):
    tasu = []
    for j in range(t):
        if ( (i >> j) & 1 ):
            tasu.append("+")
        else:
            tasu.append("")
    tasu.append("")
    a.append(tasu)

result = 0
for k in range(2**t):
    p = ""
    for (i,j) in zip(S,a[k]):
        p += i + j
    result += eval(p)
print(result)

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

int main()
{
    int n, m;cin>>n>>m;
    int a[n+1] = {};
    int pen = 0, acs = 0;
    for(int i=0;i<m;i++){
        string tr;
        int temp;
        cin>>temp>>tr;
        if(tr == "AC" && a[temp] != -1){
            acs++;
            pen+=a[temp];
            a[temp] = -1;
        }
        else if(tr == "WA" && a[temp] != -1)
            a[temp]++;
            
    }
    cout<<acs<<" "<<pen<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
  int no1,no2,no3;
  int t;
  scanf("%d",&no1);
  scanf("%d",&no2);
  scanf("%d",&no3);
  if (no1>no2){
    t=no1;
    no1=no2;
    no2=t;
  }
  if (no1>no3){
    t=no1;
    no1=no3;
    no3=t;
  }
  if (no2>no3){
    t=no2;
    no2=no3;
    no3=t;
  }
  printf("%d %d %d\n",no1,no2,no3);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define inf 1000050
using namespace std;
int top,ntop,a[inf+10],n,ll;
int add(int ll) {
	if (a[0]==1) return 0;
	if (ll<top) return 0;
	if (a[ll]==0) {
		a[ll]=1; if (ntop<ll) ntop=ll; return 1;
	}
	  int xx=ll;
	  while ((a[ll]==1)&&(ll>=1)) {
		a[ll]=0; ll--;
	} a[ll]=1; 
	if (a[0]==1) {
		if (xx<ntop) {
			a[0]=0;
			for (int i=1;i<=xx;i++)	a[i]=1;
			return 0;
		}
	}
	 return 1;
}
int check() {
	while (a[top+1]) top++;
	while (a[ntop]==0) ntop--;
}
int main (){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&ll);
		if (ll>inf) {
			printf("Yes\n"); continue;
		} 
		if (add(ll)) 
		printf("Yes\n"); 
		else printf("No\n");
		check();
	}
}

Measured memory_bytes: 5180
using System;
using System.Linq;

namespace AGC008
{
    class A
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long x = input[0];
            long y = input[1];

            if ((0 <= x && 0 <= y) || (x <= 0 && y <= 0))
            {
                if (x <= y)
                {
                    Console.WriteLine(Math.Abs(x - y));
                }
                else
                {
                    if (x != 0 && y != 0) { Console.WriteLine(Math.Abs(x - y) + 2); }
                    else { Console.WriteLine(Math.Abs(x - y) + 1); }
                }
            }
            else
            {
                Console.WriteLine(Math.Abs(Math.Abs(x) - Math.Abs(y)) + 1);
            }
        }
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()
def n():
    return int(input())
def d():
    return float(input())

def ls():
    return input().split()
def ln():
    return map(int, input().split())
def ld():
    return map(float, input().split())

def fs():
    return [input() for i in range(input())]
def fn():
    return [int(input()) for i in range(input())]
def fd():
    return [float(input()) for i in range(input())]

ABC = list(ln())
ABC = sorted(ABC)
ans1 = ABC[2]*10 + ABC[1] + ABC[0]
ans2 = ABC[2]*10 + ABC[0] + ABC[1]
print(max(ans1,ans2))


Measured memory_bytes: 5712
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

struct Data{
	char c;
	int n;
	Data(char c, int n) : c(c), n(n) {}
};

void parser(vector<Data>& a){
	char chr;
	int num;
	while(cin >> chr, chr != '$'){
		cin >> num;
		a.emplace_back(chr, num);
	}
}

vector<Data> a, b, c, ans;

bool canReplace(int idx){
	rep(i,b.size()){
		if(a[i + idx].c != b[i].c) return false;
		if(i == 0 or i == b.size() - 1){
			if(a[i + idx].n < b[i].n) return false;
		}else{
			if(a[i + idx].n != b[i].n) return false;
		}
	}
	return true;
}

signed main(){
	parser(a);
	parser(b);
	parser(c);

	rep(i,static_cast<int>(a.size()) - static_cast<int>(b.size()) + 1){
		if(canReplace(i)){
			rep(j,i) ans.emplace_back(a[j]);

			if(b.size() > 1){
				a[i].n -= b[0].n;
				if(a[i].n > 0) ans.emplace_back(a[i]);
			}
			rep(j,c.size()) ans.emplace_back(c[j]);

			a[i + b.size() - 1].n -= b.back().n;
			if(a[i + b.size() - 1].n > 0) ans.emplace_back(a[i + b.size() - 1]);
			range(j,i + b.size(), a.size()) ans.emplace_back(a[j]);
			break;
		}
	}

	if(ans.empty()) ans = a;

	rep(i,ans.size()){
		if(i + 1 < ans.size() and ans[i + 1].c == ans[i].c){
			ans[i + 1].n += ans[i].n;
		}else{
			cout << ans[i].c << ' ' << ans[i].n << ' ';
		}
	}
	cout << '$' << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int w, h, isl, v;
int a[2501];
deque<int> Q;
int main()
{
	while(cin >> w >> h && w>0)
	{
		for(int i=1; i<=w*h; i++)
		{
			cin >> a[i];
		}
		isl=0;
		for(int i=1; i<=w*h; i++)
		{
			if(a[i]==1)
			{
				isl++;
				Q.clear();
				Q.push_back(i);
				while(!Q.empty())
				{
					v=Q.front();
					Q.pop_front();
					if(v>w)
					{
						if(a[v-w]==1)
						{
							a[v-w]=0;
							Q.push_back(v-w);
						}
						if(v%w!=1)
						{
							if(a[v-w-1]==1)
							{
								a[v-w-1]=0;
								Q.push_back(v-w-1);
							}
						}
					}
					if(v%w!=1)
					{
						if(a[v-1]==1)
						{
							a[v-1]=0;
							Q.push_back(v-1);
						}
					}
					if(v%w!=0)
					{
						if(v>w)
						{
							if(a[v-w+1]==1)
							{
								a[v-w+1]=0;
								Q.push_back(v-w+1);
							}
						}
						if(a[v+1]==1)
						{
							a[v+1]=0;
							Q.push_back(v+1);
						}
						if(v+w<w*h)
						{
							if(a[v+w+1]==1)
							{
								a[v+w+1]=0;
								Q.push_back(v+w+1);
							}
						}
					}
					if(v+w<=w*h)
					{
						if(v%w!=1)
						{
							if(a[v+w-1]==1)
							{
								a[v+w-1]=0;
								Q.push_back(v+w-1);
							}
						}
						if(a[v+w]==1)
						{
							a[v+w]=0;
							Q.push_back(v+w);
						}
					}
				}
			}
		}
		cout << isl << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll h1,m1,h2,m2;
    cin>>h1>>m1>>h2>>m2;
    ll k;
    cin>>k;
    h1*=60;
    h1+=m1;
    h2*=60;
    h2+=m2;
    cout<<max(0ll,h2-h1-k);



}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e10+7;
double power(double a,int b)
{
    double ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;

    int a,b,n;
    cin>>a>>b>>n;

    map<int,int> mpp;
    int val=min(b-1,n);
    int maxx=a*(val%b)-(a*val)%b;
    maxx/=b;
    cout<<maxx<<endl;
}

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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, S);

    cout << ((S[0] == S[1] && S[1] == S[2]) ? "No" : "Yes") << "\n";

    return 0;
}


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

#define EPS (1e-2)

double area(double xa, double ya, double xb, double yb, double xc, double yc){
  double s, a, b, c;
  a = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
  b = sqrt((xb - xc) * (xb - xc) + (yb - yc) * (yb - yc));
  c = sqrt((xc - xa) * (xc - xa) + (yc - ya) * (yc - ya));
  s = (a + b + c) / 2;
  return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main(void){
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    double abc, abp, bcp, cap;
    abc = area(x1, y1, x2, y2, x3, y3);
    abp = area(x1, y1, x2, y2, xp, yp);
    bcp = area(xp, yp, x2, y2, x3, y3);
    cap = area(x1, y1, xp, yp, x3, y3);
    if(fabs(abc - (abp + bcp + cap)) <= EPS){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

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

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
  cin >> s >> t;
  int len = s.size(), count = 0;
  for(int i = 0; i < len; i++)
    if(s[i] != t[i])
      count++;
  cout << count << endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <map>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,M;
    cin >> N >> M;
    vector<LL> A(N);
    REP(i,N)
    {
        cin >> A[i];
    }
    map<int,int> mp;
    mp[0] = 1;
    vector<LL> C(N+1);
    C[0] = 0;
    for(int i = 0; i < N; i++)
    {
        C[i+1] = (C[i] + A[i]) % M;
        mp[C[i+1]]++;
    }
    LL res = 0;
    for(auto m : mp)
    {
        res += (m.second - 1)* 1LL * m.second / 2;
    }
    cout << res << endl;

}


Measured memory_bytes: 4736
function Main(input){
    var inputs = input.split(' ');
    var A = parseInt(inputs[0],10);
    var B = parseInt(inputs[1],10);

    var garden = A * B;
    var road = 1 * A + 1 * B - 1;
    var w = garden - road;

    console.log(w);

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



Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    set<int> st;
    map<int, int> mp;
    cin >> n;
    imfor(i, n) {
        int a;
        cin >> a;
        st.insert(a);
        if (mp.find(a) == mp.end()) {
            mp[a] = 1;
        }
        else {
            mp[a]++;
        }
    }
    int ans = 0;
    for (int x : st) {
        if (x < mp[x]) {
            ans += (mp[x] - x);
        }
        else if (x > mp[x]) {
            ans += mp[x];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 0; i < n; ++i) cin >> q[i];
  vector<int> x(n);
  iota(x.begin(), x.end(), 1);

  int a;
  int b;
  int idx = 0;
  do {
    bool is_valid = true;
    for (int i = 0; i < n; ++i) {
      if (x[i] != p[i]) is_valid = false;
    }
    if (is_valid) {
      a = idx;
    }

    is_valid = true;
    for (int i = 0; i < n; ++i) {
      if (x[i] != q[i]) is_valid = false;
    }
    if (is_valid) {
      b = idx;
    }    
    idx++;
  } while (next_permutation(x.begin(), x.end()));
  int ans = abs(a - b);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
_n = gets
s = gets.split(" ").uniq.map(&:to_i)
_q = gets
t = gets.split(" ").uniq.map(&:to_i)

count = 0

def binarySearch?(arr, key)
  mid = arr.size / 2
  # print "key: #{key}, arr: #{arr} \n"
  if key == arr[mid]
    return true
  elsif arr.size <= 1
    return false
  elsif key > arr[mid]
    binarySearch?(arr[mid+1..-1], key)
  elsif key < arr[mid]
    binarySearch?(arr[0...mid], key)
  end
end

t.each do |i|
  count += 1 if binarySearch?(s, i)
end

puts count



Measured memory_bytes: 16928
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	ld a, b, h, m; scanf("%Lf%Lf%Lf%Lf", &a, &b, &h, &m);
	printf("%.30Lf\n", 
			sqrt(a * a + b * b - 2 * a * b * 
				cos(((h * 60 + m) * 0.5 - m * 6) * 3.14159265358979323846264338327950288L / 180)));
}


Measured memory_bytes: 4220
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n;
    long long int l[87];
    cin >> n;
    l[0] = 2; l[1] = 1;
    for(int i = 2;i <= n;i++)
    {
        l[i] = l[i - 2] + l[i - 1];
    }
    cout << l[n] << endl;
    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    ll n,k;
    cin>>n>>k;
    vll vec(n);
    rep(i,n) cin>>vec[i];
    sort(ALL(vec),greater<int>());
    ll sum=0;
    rep(i,n){
        if(i<k) continue;
        sum+=vec[i];
    }
    cout<<sum<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, W; cin >> N >> W;
    double ans = 0.0, cap = 0.0;
    vector< pair<int, int> > items;
    for(int i=0; i<N; i++) {
        int w, v; cin >> w >> v;
        if(w >= 0 and v <= 0) continue;
        else if(w <= 0 and v >= 0) {
            cap += w;
            ans += v;
        }
        else if(w <= 0 and v <= 0) {
            cap += w;
            ans += v;
            items.emplace_back(-w, -v);
        }
        else {
            items.emplace_back(w, v);
        }
    }

    sort(items.begin(), items.end(), [&](pii A, pii B) {
            return A.first * B.second < A.second * B.first;
        });

    for(auto e : items) {
        double rem = W - cap;
        int w, v; tie(w, v) = e;

        double ratio = min(1.0, rem / w);
        ans += ratio * v;
        cap += ratio * w;
    }
    printf("%.12f\n", ans);
    return 0;
}



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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int x[5];
	REP(i, 5) cin >> x[i];
	REP(i, 5){
		if(x[i] == 0){
			cout << i+1 << ln;
		}
	}
}

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

using ll = long long;

const ll MOD = 1e9 + 7;

ll modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

ll fac[500100] = {};

ll MUL(ll a, ll b) {
	return (a * b) % MOD;
}

ll DIV(ll a, ll b) {
	return MUL(a, modInverse(b, MOD));
}

ll choose(ll a, ll b) {
	return DIV(fac[a], MUL(fac[b], fac[a-b]));
}

ll add(ll a, ll b) {
	return ((a + b)%MOD + MOD) % MOD;
}

ll sub(ll a, ll b) {
	return ((a + b)%MOD + MOD) % MOD;
}

int main() {
	ll n, m;
	fac[0] = fac[1] = 1;
	for(int i=2;i<=500000;i++) {
		fac[i] = MUL(fac[i-1], i);
	}
	cin >> n >> m;

	ll ans = 0;
	ll cur = 1;
	for(ll i = 0;i<=n;i++) {
		ans = add(ans, MUL(cur, MUL(MUL(choose(n, i), choose(m-i, n-i)), fac[n-i])));
		cur = -cur;
	}
	
	cout << MUL(ans, MUL(choose(m, n), fac[n])) << endl;
}

Measured memory_bytes: 7548
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;
    int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
    int i,j,k;
    int n1 = mid-left;
    int n2 = right-mid;
    for(i=0;i<n1;i++) L[i] = A[left+i];
    for(i=0;i<n2;i++) R[i] = A[mid+i];
    L[n1].value = R[n2].value=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i].value<=R[j].value){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

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

}

int partition(struct Card A[],int n,int p,int r){
    int i,j;
    struct Card t,x;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j].value <= x.value){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}

int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable=1;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s %d",S,&v);
        A[i].suit=B[i].suit=S[0];
        A[i].value=B[i].value=v;
    }
    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);
    
    for(i=0;i<n;i++){
        if(A[i].suit != B[i].suit) stable = 0;
    }
    
    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}



Measured memory_bytes: 4084
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,a,b;
    cin>> n >> a >> b;
    cout << min(n*a,b);

    return 0;
}

Measured memory_bytes: 3612
S = str(input())

f=int(S[:2])
b=int(S[2:])

if 1<=f<=12 and (b<=0 or b>=13):
    print('MMYY')
elif 1<=b<=12 and (f<=0 or f>=13):
    print('YYMM')
elif 1<=b<=12 and 1<=f<=12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n,k;
intl p[1000];

void input_var(){
    cin >> n >> k;
    rep(i,n)cin >> p[i];
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl cnt = 0;
    sort(p, p + n);
    rep(i,k)cnt += p[i];
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
int c[201000],val[201000],n,m,a[201000],cnt[201000];
void add(int x,int k){for(int i=x;i<=n;i+=i&-i)c[i]+=k;}
int query(int x){int ans=0;for(int i=x;i;i-=i&-i)ans+=c[i];return ans;} 
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);cnt[a[i]]++;
	} 
	for(int i=1;i<=n;i++)
		for(int j=i-cnt[i]+1;j<=i;j++)if(j>=1)val[j]++;
	for(int i=1;i<=n;i++)if(val[i]==0)add(i,1);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		if(a[x]-cnt[a[x]]+1>=1&&--val[a[x]-cnt[a[x]]+1]==0)add(a[x]-cnt[a[x]]+1,1);cnt[a[x]]--;a[x]=y;cnt[a[x]]++;
		if(a[x]-cnt[a[x]]+1>=1&&++val[a[x]-cnt[a[x]]+1]==1)add(a[x]-cnt[a[x]]+1,-1);printf("%d\n",query(n));
	}
	return 0;
 } //设x的出现次数为cnt，则可以看成覆盖[x-cnt+1,x]区间，ans=[1,n]中没有被覆盖的区间 

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

int main(){

    int w,x,y,z;
    while(cin >> w >> x >> y >> z){
       if(w>=x){
            int first_days = x ,last_days =  w - x ;
            cout << (y*first_days)+(z*last_days) << endl;
       }
       else{
            cout <<(w*y) <<endl;
       }
    }
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N), P(N), B(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  P[0] = A[0];
  B[N-1] = A[N-1];
  for(int i = 1; i < N; ++i) P[i] = __gcd(A[i],P[i-1]);
  for(int i = N-2; i >= 0; --i) B[i] = __gcd(A[i],B[i+1]);
  int ans = max(B[1],P[N-2]);
  for(int i = 1; i < N-1; ++i) ans = max(ans,__gcd(P[i-1],B[i+1]));
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define INF (ll)(1e18)
#define MAXN 410

ll  f[MAXN][MAXN];
ll  s[MAXN];
int n;

int main() {
    scanf("%i", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &s[i]);
        s[i] += s[i - 1];
    }



    for(int l = 2; l <= n; ++l) {
        for(int i = 1; i + l - 1 <= n; ++i) {
            int j = i + l - 1;
            f[i][j] = INF;
            for(int z = i + 1; z <= j; ++z) {
                ll tmp = (s[j] - s[i - 1]) + f[i][z - 1] + f[z][j];
                f[i][j] = min(tmp, f[i][j]);
            }
        }
    }

    printf("%lld\n", f[1][n]);
    return 0;
}

Measured memory_bytes: 1536
program slimes
  implicit none
  integer :: n
  character(:),allocatable :: S
  character,allocatable :: a(:)
  integer :: i,count

  read(*,*) n
  allocate(character(n)::S)
  allocate(a(n))


  read(*,*) S
  
  do i =1,n
     read(S(i:i),*) a(i)
  end do 
  
  count = 1
  do i = 2,n
     if(a(i).ne.a(i-1))then
        count = count +1
     end if
!     print*,a(i),count
  end do
  write(*,*) count
  
end program slimes


Measured memory_bytes: 1152
import sys

def left(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def count(x, y, z):
    uniq_num = len(set([x, y, z]))
    if uniq_num == 3:
        return 6  # 3!
    elif uniq_num == 2:
        return 3  # 3C1
    else:
        return 1

def show_result(ans):
    for n,fn in enumerate(ans[1:]):
        print(fn)

N = int(input())

ans = [0]*(N+1)
x = y = z = 1
while x <= N-3 and left(x, y, z) <= N:
    while y <= N-3 and left(x, y, z) <= N:
        while z <= N-3 and left(x, y, z) <= N:
            l = left(x, y, z)
            ans[l] += count(x, y, z)
            z += 1
        y += 1
        z = y
    x += 1
    y = z = x
show_result(ans)

Measured memory_bytes: 69556
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

std::string S;
int nums[3] = {};

int main(int argc, char **argv) {
    std::cin >> S;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'a') {
            nums[0]++;
        } else if (S[i] == 'b') {
            nums[1]++;
        } else {
            nums[2]++;
        }
    }

    int min = std::min(nums[0], std::min(nums[1], nums[2]));

    for (int i = 0; i < 3; i++) {
        if (min + 1 < nums[i]) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;

    return 0;
}

Measured memory_bytes: 512
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int X;
	cin >> X;
	int p = X / 200;
	cout << 10 - p << "\n";
	return 0;
}

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

int main() {
  double n,m,tot=0;
  cin>>n>>m;
  vector<int> a;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    a.emplace_back(tmp);
    tot+=tmp;
  }
  double x;
  x=tot/(4*m);
  
  sort(a.begin(),a.end(),greater<int>());

  rep(i,0,m){
    if(a[i]<x){cout<<"No"<<endl;return 0;}
  };
  
  cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>  // next_permutation(順列)
#include <numeric>
using namespace std;

bool G[10][10];   // グラフを隣接行列で管理

int main() {
  int N, M;
  cin >> N >> M;
  for ( int i = 0; i < M; i++ ) {
    int a, b;
    cin >> a >> b;
    G[a-1][b-1] = true;
    G[b-1][a-1] = true;
  }
  
  // 順列
  vector<int> ord(N);
  for ( int i = 0; i < N; i++ ) ord[i] = i;
  
  int ans = 0;
  do {
    if ( ord[0] != 0 ) break;   //始点は1である必要あり
    
    bool ok = true;
    for ( int i = 0; i + 1 < N; i++ ) {
      int from = ord[i];
      int to = ord[i+1];
      if ( !G[from][to] ) ok = false;
    }
    if ( ok ) ans++;
  } while ( next_permutation(ord.begin(), ord.end()) );   //next_permutationを利用するには昇順に並び替えておく必要あり

  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));
  $d = explode(" ", trim(fgets(STDIN)));

  $b = false;
  $ans = $n-1;
  while(!($n <= $ans && $b)) {
    $ans++;
    $b = true;
    for ($i=0; $i<$k; $i++) {
      if(strpos($ans, $d[$i]) !== false){
        $b = false; 
      }
    }
//    echo $ans.PHP_EOL;
  }
  echo $ans;

Measured memory_bytes: 16104