akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 998244353
#define invp(a,p)pom(a,p-2,p)

ll fact[4010],invfact[4010];
ll factinit(ll n){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%MOD;
	invfact[n]=invp(fact[n],MOD);
	for(ll i=n;i>0;i--)invfact[i-1]=invfact[i]*i%MOD;
}
ll choose(ll n,ll r){
	if(n<0||r<0||n-r<0)return 0;
	return fact[n]*invfact[r]%MOD*invfact[n-r]%MOD;
}

ll ans[4010];
int main(){
	factinit(4005);
	ll n,k;
	scanf("%lld %lld\n",&k,&n);
	rep(x,2,k+2){
		ll t=0;
		if(x%2){
			//奇数のとき
			//はずすべきペアはx/2組ある
			ll p=x/2;
			rep(i,0,p+1){
				//p組のうちちょうどi組が(0,0)だとする。その組の選び方がchoose(p,i)
				//残りの(p-i)組に先に1個わりあてると、残りの(n-p+i)個を(k-2*p+p-i)組に振り分けるので
				//choose(k+n-2*p-1,n-p+i)通り
				//(p-i)組はどっちに割り振るか各2通りあるので2^(p-i)倍
				t=(t+choose(p,i)*choose(k+n-2*p-1,n-p+i)%MOD*pom(2,p-i,MOD))%MOD;
			}
		}else{
			//偶数のとき
			//はずすべきペアが(x/2-1)組と、0or1にすべきものが1つある
			ll p=x/2-1;
			rep(i,0,p+1){
				//p組のうちちょうどi組が(0,0)だとする
				//残りの(p-i)組に先に1個わりあてると、残りの(n-p+i)個を(k-2*p+p-i)組に振り分けるので
				//まんなかを0にしたときchoose(k+n-2*p-2,n-p+i)通り
				//まんなかを1にしたときchoose(k+n-2*p-3,n-p+i-1)通り
				//(p-i)組はどっちに割り振るか各2通りあるので2^(p-i)倍
				t=(t+choose(p,i)*(choose(k+n-2*p-2,n-p+i)+choose(k+n-2*p-3,n-p+i-1))%MOD*pom(2,p-i,MOD))%MOD;
			}
		}
		ans[x]=t;
	}
	rep(i,2,k+2)printf("%lld\n",ans[i]);
	rep(i,k+2,2*k+1)printf("%lld\n",ans[2*k+2-i]);
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] cin = Console.ReadLine().Split(' ');
                int n, x;
                n = int.Parse(cin[0]);
                x = int.Parse(cin[1]);
                if (n == 0 && x == 0) break;
                int ret = 0;
                int i, j;
                for (i = 1; i <= n; i++)
                {
                    for (j = i + 1; j <= n; j++)
                    {
                        if (x - (i + j) > j && x - (i + j) <= n)
                        {
                            ret++;
                            //Console.WriteLine("{0} {1} {2}",i,j,x-i-j);
                        }
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}



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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll a, b, k;
    cin >> a >> b >> k;

    for (int i = a; i <= b; ++i) {
        if (i <= a + k - 1 || i >= b - k + 1) MSG(i)
    }

    return 0;
}

Measured memory_bytes: 256
function Main(inputData) {
	init(inputData);
	
	var n = inI(),a = {};
	for(i=0;i<n;i++){
		var s = inS();
		a[s] = (s in a)? a[s]+1: 1;
	}

	var m = inI();
	for(i=0;i<m;i++){
		var s = inS();
		a[s] = (s in a)? a[s]-1: -1;
	}

	out(Math.max(0, values(a).max() ));
}


////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//prototype
Array.prototype.rsort = function(){
  return this.sort(function(a,b){return (a<b ? 1:-1);});
}

Array.prototype.max = function(){
  return Math.max.apply(null, this);
}

Array.prototype.min = function(){
  return Math.min.apply(null, this);
}

//function
function values(array) {
    var values = [];
    if(array)for(var key in array)values.push(array[key]);
    return values;
};

function keys(array) {
    var keys = [];
    if(array)for(var key in array)keys.push(key);
    return keys;
};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	ll k,a,b;
	cin >> k >> a >> b;
	if(a+2>=b) cout << 1+k << endl;
	else{
		//cout << "Yes" << endl;
		ll n = a - 1;
		//cout << (b-a)*(k-n)/2 << " " << n%2 << endl;
		cout << (b-a)*((k-n)/2) + (k-n)%2 + a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s = ">";
    string t;cin >> t;
    s = s + t + '<';
    ll n = t.size()+1;
    
    vector<ll> v(n, 0);
    // rep(i,n){
    //     if(s[i] == '>' && s[i+1] == '<')v[i] = 0; 
    // }
    rep(i,n){
        if(i > 0 && s[i] == '<')chmax(v[i], v[i-1] + 1);
    }
    debug(v);
    rrep(i,n){
        if(i-1 >= 0 && s[i] == '>')chmax(v[i-1], v[i] + 1);
    }
    debug(v);
    ll ans = 0;
    rep(i,n)ans += v[i];

    cout << ans << endl;
}

Measured memory_bytes: 5276
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        if(S.length()<=K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }
    }
}


Measured memory_bytes: 38672
n,t = map(int,input().split())
dishes = []
for i in range(n):
    a,b = map(int,input().split())
    dishes.append((a,b))
dp1 = [[0]*t for _ in range(n+2)]
dp2 = [[0]*t for _ in range(n+2)]
for i in range(n):
    a,b = dishes[i]
    for j in range(t):
        if j-a >= 0:
            dp1[i+1][j] = max(dp1[i][j],dp1[i][j-a]+b)
        else:
            dp1[i+1][j] = dp1[i][j]
for i in range(2,n+2)[::-1]:
    a,b = dishes[i-2]
    for j in range(t):
        if j-a >= 0:
            dp2[i-1][j] = max(dp2[i][j],dp2[i][j-a]+b)
        else:
            dp2[i-1][j] = dp2[i][j]
ans = 0
for i in range(n):
    a,b = dishes[i]
    for j in range(t):
        ans = max(ans,dp1[i][j]+dp2[i+2][t-1-j]+b)
print(ans)

Measured memory_bytes: 178436
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n-- > 0){
        char snake[256] = {0};
        int cnt = 0;
        int i;

        scanf("%s", snake);
        if (snake[0] == '>' && snake[1] == '\''){
            for (i = 2; snake[i] == '='; i++, cnt++);
            if (cnt && snake[i] == '#'){
                for (i++; snake[i] == '='; i++, cnt--);
                puts(snake[i] == '~' && !snake[i + 1] && !cnt ? "A" : "NA");
            }
            else {
                puts("NA");
            }
        }
        else if (snake[0] == '>' && snake[1] == '^'){
            for (i = 2; snake[i] == 'Q' && snake[i + 1] == '='; i += 2, cnt++);
            puts(snake[i] == '~' && snake[i + 1] == '~' && !snake[i + 2] && cnt ? "B" : "NA");
        }
        else {
            puts("NA");
        }
    }

    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll pr[mx],ar[mx],br[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    string s;
    cin>>s;
    int c=0;
    for(int i=0; i<4; i++){
        if(s[i]=='2')c++;
    }
    cout<<c<<endl;






    return 0;
}



Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();

    let mut x = vec![0; n];
    for i in 0..n {
        x[i] = read::<i64>();
    }

    let mut mini = std::i64::MAX;
    for i in 0..(n-k+1) {
        if x[i] < 0 && x[i+k-1] < 0 {
            mini = min(mini, x[i].abs());
        } else if x[i] >= 0 && x[i+k-1] >= 0 {
            mini = min(mini, x[i+k-1]);
        } else {
            if x[i].abs() > x[i+k-1] {
                mini = min(mini, 2*x[i+k-1] + x[i].abs());
            } else {
                mini = min(mini, 2*x[i].abs() + x[i+k-1]);
            }
        }

    }
    println!("{}", mini);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, a, b;

int main(void){
    cin >> n >> a >> b;
    vector<lli> x(n);
    rep(i, n) cin >> x[i];
    lli ans = 0;
    for(int i = 1; i < n; i++){
        lli dx = x[i]-x[i-1];
        if(dx*a > b) ans+=b;
        else ans+=dx*a;
    }
    cout << ans << endl;

    return 0;
}


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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

#define MAX_V 10
struct edge {
	int to;
	int cost;
};
vector<edge> G[MAX_V];
int d[MAX_V];

ll n, m;
ll ans = 0;

void dfs(ll now, ll bit) {
	bit |= 1LL << (now - 1LL);

	if (bit == (1LL << n) - 1LL) {
		ans++;
	}

	for (auto e : G[now]) {
		if ((bit >> (e.to - 1) & 1) == 0) {
			dfs(e.to, bit);
		}
	}
}

void solve_abc_c() {
	//ll n, m;
	ll a, b;
	//ll ans = 0;
	//double ans = 0;
	
	cin >> n >> m;

	edge e;
	rep(i, m) {
		cin >> a >> b;
		e.cost = 1;
		e.to = a;
		G[b].push_back(e);
		e.to = b;
		G[a].push_back(e);
	}

	dfs(1, 0);

	cout << ans << "\n";
}

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

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int a[3];

void sort(int i, int j)
{
	if(a[i] > a[j]) {
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}
}

int main()
{
	scanf("%d%d%d", &a[0], &a[1], &a[2]);

	sort(0, 1);
	sort(1, 2);
	sort(0, 1);

	printf("%d %d %d\n", a[0], a[1], a[2]);

	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    vector<ll> vec;
    rep(i,0,n){
        ll a;
        cin >> a;
        vec.push_back(a);
    }
    vector<ll> ans;
    rep(i,0,n){
        rep(j,0,vec.size()){
            ll k = vec.size()-j-1;
            if(k+1 == vec[k]){
                ans.push_back(vec[k]);
                vec.erase(vec.begin()+k);
                break;
            }
        }
    }
    
    if(ans.size() != n) cout << -1 << endl;
    else{
        rep(i,0,ans.size()){
            ll k = ans.size()-i-1;
            cout << ans[k] << endl;
        }
    }
    return 0;
}


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

int main(){
    int N;
    int i;
    int min;
    int res = 0;
    cin >> N;
    vector<int> vec(N+1);
    
    for(i=0;i<N;i++){
        cin >> vec.at(i);
    }
    min = vec.at(0);
    for(i=0;i<N;i++){
        if(min >= vec.at(i)){
            min = vec.at(i);
            res++;
        }
    }
    cout << res;
}

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


int main(){

  int A, B;
  cin >> A >> B;

  int x = 0;

  for(int i=0; i<1012; i++){
      if(((i * 8 / 100) == A) && ((i * 10 / 100) == B)){
         cout << i << endl;
         break;
      }

      x++;
  }

    if(x == 1012){
      cout << "-1" << endl;
    }
}

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

int main(void){
  double x;
  int q;

  while(1){
    scanf("%d",&q);
    if(q<0)break;


    x = (double)q / 2.0;
    while(1){
      if(fabs(x*x*x-q) < 0.00001 * q)break;
      
      x = x - ((x*x*x)-q)/(3*x*x);
    }

    printf("%lf\n",x);
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

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

    ld a, b ;
    cin >> a >> b ;
    cout << (ll)(a*b) <<endl ;
    

    return 0;
}



Measured memory_bytes: 3748
import java.util.Scanner;

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

		for (int i = 0; i < M; i++) {
			N = N - scan.nextInt();
		}

		if (N >= 0) {
			System.out.println(N);
		} else {
			System.out.println("-1");
		}
		scan.close();
	}
}


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

using namespace std;

#define ll long long

ll a[12];
int n;

int solve(int idx,ll mul) {
    if(idx==n) {
        if(mul%2==0) return 1;
        return 0;
    }
    return solve(idx+1,a[idx]*mul)+solve(idx+1,(a[idx]-1)*mul)+solve(idx+1,(a[idx]+1)*mul);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S; cin >> S;
  int digit[4]; for(int i = 0; i < 4; i++) digit[i] = int(S[i]) - 48;
  int dp, tot;
  for(dp = 0; dp < 8; dp++){
    tot = digit[0];
    for(int i = 0; i < 3; i++){
      if(dp & (1 << i)) tot += digit[i + 1];
      else tot -= digit[i + 1];
    }
    if(tot == 7){
      cout << digit[0];
      for(int j = 0; j < 3; j++){
        if(dp & (1 << j)) cout << "+";
        else cout << "-";
        cout << digit[j + 1];
      }
      cout << "=7";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int, in){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1;
	range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using V = vector<int>;

int main() {
	for (int n, m; n = in(), m = in();) {
		V v(n);
		for (int &a: v)
			a = in();
		sort(v.begin(), v.end());
		int r{0};
		for (auto i{v.begin()}, e{v.end() - 1}; i != e && r < m; i++) {
			while (*i + *e > m && i != e)
				e--;
			if (i == e)
				break;
			r = max(r, *i + *e);
		}
		if (r)
			outl(r);
		else
			outl("NONE");
	}
}


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

using namespace std;

typedef long long ll;

int n, m;
bool arr[102][102];
int DP[102][102];

int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            char c;
            scanf(" %c", &c);
            if(c == '#') arr[i][j] = 1;
        }
    }
    if(arr[1][1]) DP[1][1] = 1;
    for(int i=2; i<=n; i++){
        DP[i][1] = DP[i-1][1] + (arr[i][1] != arr[i-1][1]);
    }
    for(int i=2; i<=m; i++){
        DP[1][i] = DP[1][i-1] + (arr[1][i] != arr[1][i-1]);
    }
    for(int i=2; i<=n; i++){
        for(int j=2; j<=m; j++){
            DP[i][j] = min(DP[i-1][j] + (arr[i-1][j] != arr[i][j]), DP[i][j-1] + (arr[i][j-1] != arr[i][j]));
        }
    }
    printf("%d", (DP[n][m]+1)/2);
}


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

using namespace std;

bool pr[110];
vector<int> prime;

void sieve(){
	memset(pr, true, sizeof(pr));
	pr[0] = pr[1] = false;
	for(int i = 2; i * i <= 110; i++){
		if(pr[i]){
			for(int j = 2 * i; j <= 110; j += i) pr[j] = false;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int M, D;
	cin >> M >> D;

	sieve();
	int cnt = 0;
	for(int i = 1; i <= M; i++){
		if(pr[i]) continue;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0){
				if(j > 9 || j < 2 || i / j > 9 || i / j < 2) continue;
				int num1 = j;
				int num2 = i / j;
				if(num1 * 10 + num2 <= D) cnt++;
				if(num1 == num2) continue;
				if(num2 * 10 + num1 <= D) cnt++;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ul>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;    cin>>n>>k;
   ll ans = 0;
   ll left = 0,right = 0;
   for(int i = 1;i<=n+1;i++)
   {
       left += (i-1);  left %= MOD;
       right += (n-i+1);  right%=MOD;
       if(i >= k)
       {
           ans += (right-left+1+MOD);
           ans %= MOD;
       }}
    cout << ans ;

}
    


Measured memory_bytes: 3616
using System;

namespace C___Sentou
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var t = int.Parse (input[1]);
            var a = new int[n];
            var ans = t;
            input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse (input[i]);
            }
            for (var i = 1; i < a.Length; i++)
            {
                if (a[i] - a[i - 1] >= t)
                {
                    ans += t;
                }
                else
                {
                    ans += a[i] - a[i - 1];
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 28164
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll d;
    cin >> d;
    
    if (d == 3 || d == 5 || d == 7)cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC81 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
c = list(Counter(a).items())
c.sort(key = itemgetter(1))
m = len(c)
ans = 0
for i,j in c[:m-k]:
    ans += j
print(ans)


Measured memory_bytes: 97864
#include <iostream>
#include <string>
#include <queue>
#define N 100000

using namespace std;

void process(pair <string,int> p[N], int n, int q){
	
	queue <pair <string,int> > proc;
	int time = 0;
	
	for(int i = 0; i < n; i++){
		proc.push(p[i]);
	}
	while(!proc.empty()){
		if( proc.front().second <= q ){
			time += proc.front().second;
			cout << proc.front().first << ' ' << time << endl;
			proc.pop();
		} else {
			time += q;
			proc.front().second -= q;
			proc.push(proc.front());
			proc.pop();
		}
	}
}

int main(){
	
	int n,q;
	pair <string, int> p[N];
	
	cin >> n >> q;
	for(int i = 0; i < n; i++){
		cin >> p[i].first >> p[i].second;
	}
	
	process(p,n,q);
	
	return 0;
	
}


Measured memory_bytes: 7684
K, S = map(int, input().split())
count = 0
x_min = max(0, S-K*2)
x_max = min(K, S)
for x in range(x_min, x_max+1):
	rest = S-x
	if rest<K:
		count = count+rest+1
	else:
		count = count+K*2-rest+1
print(count)

Measured memory_bytes: 3192
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll a, b;

int main() {
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        if ((x + y) % 3 != 0) {
            System.out.println(0);
            return;
        }
        int n = (x + y) / 3;
        long ans = comb(x - n + y - n, x - n > y - n ? x - n : y - n);
        System.out.println(ans);

    }

    // 繰り返し２乗法
    private static long modPow(long n, int p) {
        long res = 1;
        long a = n;
        for (a %= MOD; p > 0; a = a * a % MOD, p >>= 1) {
            if ((p & 1) > 0) {
                res = res * a % MOD;
            }
        }
        return res;
    }

    // 逆元
    private static long modInv(long a) {
        return modPow(a, MOD - 2);
    }

    // 二項係数
    private static long comb(long n, long r) {
        long ret = 1;
        for (long i = 0; i < r; i++) {
            ret *= n - i;
            ret %= MOD;
            ret *= modInv(i + 1);
            ret %= MOD;
        }
        return ret;
    }
}

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)
N = int(input())
adj = [[0]*N for _ in range(N)]
searched = {n: 0 for n in range(N)}
edge = {}

for n in range(N):
    inp = list(map(int, input().split()))
    edge[n] = inp[1]
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

time = 1
stack = []
unsearch = set(range(N))
uncomplete = set(range(N))
result = {n:{"found": 0, "finish": 0} for n in range(N)}

def DFS(i):
    global time
    global unsearch
    
    itr = sorted(unsearch)
    
    for j in itr:
        if adj[i][j] == 1 and j in unsearch:
            result[j]["found"] = time
            time += 1
            unsearch.remove(j)
            DFS(j)
    result[i]["finish"] = time
    time += 1
    
while len(unsearch):
    i = min(unsearch)
    unsearch.remove(i)
    result[i]["found"] = time
    time += 1
    DFS(i)

for n in range(N):
    print("{} {} {}".format(n+1, result[n]["found"], result[n]["finish"])) 

Measured memory_bytes: 7832
def main():
    #input
    N=int(input())
    A=list(map(int,input().strip().split()))

    A.sort()

    l=[True for _ in range(A[-1]+1)]
    
    cnt=0
    for n in range(N-1):
        if l[A[n]]==True:
            if A[n]==A[n+1]:
                l[A[n]]=False
            else:
                l[A[n]]=False
                cnt+=1
            i=1
            while i*A[n]<=A[-1]:
                l[A[n]*i]=False
                i+=1
    if l[A[N-1]]==True:
        cnt+=1
        l[A[N-1]]=False
    return cnt

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

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

int main(void){
   int N;
   cin>>N;
   vector<char> c(N);
   for(int i=0;i<N;i++){
      cin>>c[i];
   }
   int Red=0;
   for(int i=0;i<N;i++){
      if(c[i]=='R') Red++;
   }
   int ans=0;
   for(int i=0;i<Red;i++){
      if(c[i]=='W') ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3632
#![allow(non_snake_case)]

#[allow(unused_macros)]
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        n: usize,
        t: f64,
        a: f64,
        hs:[f64;n],
    }
    let mut temp = std::f64::MAX;
    let mut ans = 0;
    for (i, h) in hs.iter().enumerate() {
        if (t - h * 0.006 - a).abs() < temp {
            temp = (t - h * 0.006 - a).abs();
            ans = i;
        }
    }

    println!("{}", ans + 1);
}

Measured memory_bytes: 4476
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define fi first
#define se second
using namespace std;
short n,k;
int64_t dp[303][303],ans;
int a[303];
const int64_t vc=int64_t(1e17);
int main(){
    scanf("%hd%hd",&n,&k);
    for (short i=1;i<=n;++i) scanf("%d",&a[i]);
    k=n-k;
    if (k==0){printf("0");return 0;}
    for (short i=0;i<=n;++i)
    for (short j=0;j<=k;++j)
        dp[i][j]=vc;
    dp[0][0]=0;
    ans=vc;
    for (short i=1;i<=n;++i){
        for (short j=1,jj=min(i,k);j<=jj;++j){
            for (short z=0;z<i;++z)
                dp[i][j]=min(dp[i][j],dp[z][j-1]+max(0,a[i]-a[z]));
        }
        ans=min(ans,dp[i][k]);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1024
// Cakes and Donuts
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    bool CanBuy = false;
    for (int i = 0; i < (N/4+1); ++i) {
        for (int j = 0; j < (N/7+1); ++j) {
            int total = 4 * i + 7 * j;
            if (total == N) {
                CanBuy = true;
                break;
            }
        }
    }
    if (CanBuy) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }



void solve() {
    string S;
    cin >> S;
    ll N = S.size();
    ll ans = 0;
    ll sum;
    ll tmp;
    rep(i,pow(2,N-1)){
        sum = 0;
        tmp = S[0] - '0'; 
        rep(j,N-1){
            if(i>>j&1){
                sum+=tmp;
                tmp = S[j+1]-'0';
            }else{
                tmp = 10*tmp + (S[j+1]-'0');
            }
        }
        sum += tmp;
        ans += sum;
    }
    print(ans);
}   
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main(){
  int n,x,t;
  cin >> n;
  cin >> x;
  cin >> t;

  if(n % x == 0){
    cout << (n / x) * t;
  }else{
    cout << ((n / x) + 1 ) * t;
  }
  return 0;
}


Measured memory_bytes: 3152
a, b = gets.chomp.split(&:to_i)
c = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if c.index(a.to_i) > c.index(b.to_i)
  puts "Alice"
elsif c.index(a.to_i) < c.index(b.to_i)
  puts "Bob"
else
  puts "Draw"
end


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

typedef long long ll;
const ll INF = 1LL << 60;

string s;
ll dp[10000000 + 100][2];

int main() {
    cin >> s;
    // 桁から数える
    reverse(s.begin(), s.end());
    s += '0';

    int n = s.size();

    // i: 何桁め
    rep(i, n + 1)rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, n)rep(j, 2) {
        int x = s[i] - '0';
        x += j;

        rep(a, 10) {
            int ni = i + 1, nj = 0;
            int b = a - x;
            if (b < 0) {
                nj = 1;
                b += 10;
            }

            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
        }
    }

    int ans = dp[n][0];
    cout << ans << endl;
}

Measured memory_bytes: 17796
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  int N, u, v;
  cin >> N >> u >> v;

  vector<set<int> > connect(N + 1);
  long A, B;

  rep(i, N - 1){
    cin >> A >> B;
    connect[A].insert(B);
    connect[B].insert(A);
  }

  // from u
  queue<int> que;
  vi visited1(N + 1, 0);
  vi fromu(N + 1, 0);
  que.push(u);
  visited1[0] = visited1[u] = 1;
  fromu[0] = fromu[u] = 0;

  while(!que.empty()){
    int w = que.front();

    for(auto x = connect[w].begin(); x != connect[w].end(); x++){
      if(visited1[(*x)] == 0){
	que.push((*x));
	fromu[(*x)] = fromu[w] + 1;
	visited1[(*x)] = 1;
      }
    }

    que.pop();
  }

  vi visited2(N + 1, 0);
  vi fromv(N + 1, 0);
  que.push(v);
  visited2[0] = visited2[v] = 1;
  fromv[0] = fromv[v] = 0;

  while(!que.empty()){
    int w = que.front();

    for(auto x = connect[w].begin(); x != connect[w].end(); x++){
      if(visited2[(*x)] == 0){
	que.push((*x));
	fromv[(*x)] = fromv[w] + 1;
	visited2[(*x)] = 1;
      }
    }

    que.pop();
  }

  vi cands;

  rep2(i, 1, N + 1){
    if((fromu[i] < fromv[i]) && (connect[i].size() == 1)){
      cands.push_back(fromv[i]);
    }
  }

  stable_sort(cands.begin(), cands.end(), greater<int>());

  cout << cands[0] - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 16288
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=110;
int tot,a[N],n;

int main(){
	scanf("%d",&n); tot=n;
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,2,n){
		if (a[i]==a[i-1]) a[i]=++tot;
	}
	printf("%d\n",tot-n);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a[5], ans=0, tmp=10, j;
	for(int i=0; i<5; i++){
		cin >> a[i];
		if(a[i]%10!=0){
			if(tmp>a[i]%10){
				tmp=a[i]%10;
				j=i;
			}
		}
	}
	for(int i=0; i<5; i++){
		if(j!=i){
			ans+=(a[i]+9)/10*10;
		}
	}
	cout << ans+a[j] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod  1000000007
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);i++)
    

int mx[210][210];
bool mxflag[210][210];
int mi[210][210];
bool miflag[210][210];
int n;
string s;

int mxdfs(int l,int r);
int midfs(int l,int r);

int mxdfs(int l,int r){
    if(s[l]=='('||s[r]==')'){
        int c = 0;
        for(int i=l;i<=r;i++){
            if(isdigit(s[i]))c++;
        }
        if(c==1){
            return -inf;
        }
    }
    if(s[l]=='(')return mxdfs(l+1,r); 
    if(s[r]==')')return mxdfs(l,r-1);
    if(mxflag[l][r])return mx[l][r];
    if(l==r){
        return s[l]-'0';
    }
    if(s[r-1]=='(')return -inf;
    int res = -inf;
    for(int i=l;i<=r;i++){
        if(s[i]=='-'){
            res = max(mxdfs(l,i-1)-midfs(i+1,r),res);
        }else if(s[i]=='+'){
            res = max(mxdfs(l,i-1)+mxdfs(i+1,r),res);
        
        }
    }
    mxflag[l][r] = 1;
    return mx[l][r] = res;
}
int midfs(int l,int r){
    if(s[l]=='('||s[r]==')'){
        int c = 0;
        for(int i=l;i<=r;i++){
            if(isdigit(s[i]))c++;
        }
        if(c==1){
            return inf;
        }
    }
    if(s[l]=='(')return midfs(l+1,r); 
    if(s[r]==')')return midfs(l,r-1);
    if(miflag[l][r])return mi[l][r];
    if(l==r){
        return s[l]-'0';
    }
    if(s[l+1]==')')return inf;
    int res = inf;
    for(int i=l;i<=r;i++){
        if(s[i]=='-'){
            res = min(midfs(l,i-1)-mxdfs(i+1,r),res);
        }else if(s[i]=='+'){
            res = min(midfs(l,i-1)+midfs(i+1,r),res);
        
        }
    }
    miflag[l][r] = 1;
    return mi[l][r] = res;
}


int main(){
    cin >> s;
    n = s.size();
    cout << mxdfs(0,n-1) << endl;
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
string s;
cin>>s;
if(s == "SUN"){
  cout<<7;
}
else if(s == "MON"){
  cout<<6;
}
else if(s == "TUE"){
  cout<<5;
}
else if(s == "WED"){
  cout<<4;
}
else if(s == "THU"){
  cout<<3;
}
else if(s == "FRI"){
  cout<<2;
}
else if(s == "SAT"){
  cout<<1;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main() 
{
    IOS;
    int n;
    cin>>n;
    int arr[n];
    int xorr=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        xorr^=arr[i];
    }
    for(int i=0;i<n;i++)
        cout<<(xorr^arr[i])<<" ";
}   









Measured memory_bytes: 5228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
int n,m,k,a[20][20],sum[15],c[15],ans=0x3f3f3f3f,g;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++){
	scanf("%d",&c[i]);	
	for(int j=0;j<m;j++) scanf("%d",&a[i][j]); 
	}
	for(int i=1;i<(1<<n);i++){
	  memset(sum,0,sizeof(sum)); g=0;
	 for(int j=0;j<n;j++){
	  if(!(i&(1<<j))) continue;
	  for(int l=0;l<m;l++) sum[l]+=a[j][l];
	  g+=c[j];
	 }
	bool flag=0;
	for(int j=0;j<m;j++) {
	 if(sum[j]<k) {
	 	flag=1;
	 	break;
	 }
	}
	if(!flag) ans=min(ans,g);
	}
	printf("%d\n",ans==0x3f3f3f3f? -1:ans);
 } 

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n;
    cin>>n;
    int ans=0;
    vector<int> st(n);
    rep(i,n){
    int score;
    cin>>score;
    st[i]=score;
    ans+=score;
        
    }  
    sort(st.begin(),st.end());

    if(ans%10!=0){
        cout<<ans<<endl;
    }
    else{
        bool find=false;
        rep(i,n){
            if((st[i]%10)!=0){
                ans-=st[i];
                find=true;
                break;
            }
        }
        if(find){
            cout<<ans<<endl;
        }
        else{
            cout<<"0"<<endl;
        }
    }
    return 0;

}
/*


*/


Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
pp=[]
su=0
for i in range(n):#累積和
    if i<k:
        su+=p[i]
    else:
        pp.append(su)
        su=su-p[i-k]+p[i]
pp.append(su)
ans=0.0
for i in range(len(pp)):
    j=(pp[i]+k)/2
    if ans<j:
        ans=j
print(ans)

Measured memory_bytes: 24808
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

vi ans;
vector<vp> g;
void dfs(int now, int par){
    rep(i,g[now].size()){
        int ne = g[now][i].first;
        if(ne == par)continue;
        int d = g[now][i].second;
        if(d%2) ans[ne] = 1 - ans[now];
        else ans[ne] = ans[now];
        dfs(ne,now);
    }
}

signed main(void) {
    int n;
    cin >> n;
    g = vector<vp>(n);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        g[a].push_back(pii(b,c));
        g[b].push_back(pii(a,c));
    }
    ans = vi(n);
    ans[0] = 1;
    dfs(0,-1);
    rep(i,n)cout << ans[i] << endl;
}


Measured memory_bytes: 10752