akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N-1; i++) {
        cin >> C[i];
    }
    int v = B[A[0]];
    int p = A[0];
    for (int i = 1; i < N; i++) {
        v += B[A[i]];
        if (p == A[i]-1) v += C[p];
        p = A[i];
    }
    cout << v << endl;
    return 0;
}



Measured memory_bytes: 256
import Data.List
import Data.Char

main = interact $ show' . solve . read'
  where
    show' x = (show x) ++ "\n"
    solve (word, words) = count word words 0
    count word [] acc = acc
    count word (x:xs) acc | word == x = count word xs (acc + 1)
                          | otherwise = count word xs acc
      where l = length word
    read' = f . lines
      where f (x:xs) = ([toLower c | c <- x], words [toLower c | c <- (unlines xs)])



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr char sp = ' ';

int N, K, C, L[222222], R[222222];
string S;

int main() {
	cin >> N >> K >> C >> S;
	int lim = 0;
	for (int i = 1; i <= N; i++) {
		L[i] = L[i - 1];
		if (S[i - 1] == 'o'&&lim < i) {
			L[i]++;
			lim = i + C;
		}
	}
	lim = 0xE869120;
	for (int i = N; i >= 1; i--) {
		R[i] = R[i + 1];
		if (S[i - 1] == 'o'&&i < lim) {
			R[i]++;
			lim = i - C;
		}
	}
	for (int i = 1; i <= N; i++) {
		if (L[i - 1] + R[i + 1] < K) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 3332
a, b, x = gets.split.map(&:to_i)

s = x.to_f / a

rad = if b / 2.0 < s / a
  h = 2.0 * (a * b - s) / a
  Math.atan2(h, a)
else
  w = 2 * s / b
  Math.atan2(b, w)
end

puts rad / (2 * Math::PI) * 360


Measured memory_bytes: 1788
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [x, y] = nextIntArray()
    let ans = Math.abs(Math.abs(x) - Math.abs(y))
    if (x * y < 0) {
        ans += 1
    } else if ((x > 0 && y == 0) || x == 0 && y < 0) {
        ans += 1
    } else if (x > y) {
        ans += 2
    }
    console.log(ans)
}
Main()





Measured memory_bytes: 29556
use std::io;
use std::io::{BufRead, Write};

fn ceiling_div(lhs: usize, rhs: usize) -> usize {
    if lhs % rhs == 0 {
        lhs / rhs
    } else {
        lhs / rhs + 1
    }
}

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (n, k): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        )
    };
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let mut a = buf.split_whitespace().map(|x| x.parse().unwrap());
    let pos = a.position(|x: usize| x == 1).unwrap();
    let result = ceiling_div(n-1, k-1);
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "4 3
2 3 1 4
",
            "2\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "3 3
1 2 3
",
            "1\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "8 3
7 3 1 8 4 6 2 5
",
            "4\n",
        );
    }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  int cur = 0, ans = 0;
  while (cur < n) {
    while (cur < n - 1 && va[cur + 1] == va.front()) {
      cur++;
    }

    bool diff = false;
    for (int i = cur; i < cur + k && i < va.size(); ++i) {
      if (va[i] != va.front()) {
        va[i] = va.front();
        diff = true;
      }
    }

    if (diff) {
      ans++;
    }

    cur = min(cur + k - 1, n);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3668
<?php
/*
    Problem URL : http://abc060.contest.atcoder.jp/tasks/abc060_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

list($A, $B, $C) = explode(" ", trim(fgets(STDIN)));

$Alast = substr($A, -1, 1);
$Bfirst = substr($B, 0, 1);
$Blast = substr($B, -1, 1);
$Cfirst = substr($C, 0, 1);

if (($Alast == $Bfirst) && ($Blast == $Cfirst)) {
    echo "YES\n";
} else {
    echo "NO\n";
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b) { if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b) { if(b < a) { a = b; return true; } else { return false; } }

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

    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> pv(A), qv(B), rv(C);
    REP(i, A) {
        cin >> pv[i];
    }
    REP(i, B) {
        cin >> qv[i];
    }
    REP(i, C) {
        cin >> rv[i];
    }

    RSORT(pv);
    RSORT(qv);

    REP(i, X) {
        rv.push_back(pv[i]);
    }
    REP(i, Y) {
        rv.push_back(qv[i]);
    }

    RSORT(rv);
    cout << accumulate(rv.begin(), rv.begin() + X + Y, 0LL) << endl;

    return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 1e5 + 10;
int n, a[maxn], ans = 0;
typedef pair<int,int> pii;
vector<pair<int,int> > v;

int getMin(int x)
{
    return min(abs(x - a[n - 1] / 2), abs(x - (a[n - 1] + 1) / 2));
}

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int pos = lower_bound(a, a + n, a[n - 1] / 2) - a;

    for(int i = pos; i < pos + 5 && i < n; i ++)
        v.push_back(pii(getMin(a[i]), a[i]));
    for(int i = pos; i > pos - 5 && i >= 0; i --)
        v.push_back(pii(getMin(a[i]), a[i]));

    pos = lower_bound(a, a + n, (a[n - 1] + 1) / 2) - a;
    for(int i = pos; i < pos + 5 && i < n; i ++)
        v.push_back(pii(getMin(a[i]), a[i]));
    for(int i = pos; i > pos - 5 && i >= 0; i --)
        v.push_back(pii(getMin(a[i]), a[i]));

    sort(v.begin(), v.end());
    printf("%d %d", a[n - 1], v[0].second);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> x >> y;

		if (y % 2 == 0)
		{
			maxx = (y / 2);
			minn = (y / 4) + ((y % 4)) / 2;



			if (x <= maxx && x >= minn)
				cout << "Yes";
			else
				cout << "No";
		}
		else
			cout << "No";



		ln
	}
	return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner entrada = new Scanner(System.in);
       int A = entrada.nextInt();
       if(A==0){
           System.out.println("No");
       }else if(A>0){
           Boolean x = false;
           for(int i=1;i<=9;i++){
               for(int c=1;c<=9;c++){
                   if(A == i*c){
                        x = true;
                   }
               }
           }if(x==true){
               System.out.println("Yes");
           }else{
               System.out.println("No");
           }
       }
       
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007

signed main() {
	int n, p;
	cin >> n >> p;
	map<int, int>mp;
	int a = 2;
	while (a*a <= p) {
		if (p%a == 0) {
			mp[a]++;
			p /= a;
		}
		else {
			a++;
		}
	}
	mp[p]++;
	int ans = 1;
	for (auto itr = mp.begin(); itr != mp.end();itr++) {
		int x = itr->second;
		for (int i = 0; i < x / n; i++) {
			ans *= itr->first;
		}
	}
	cout << ans << endl;

	END;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int max =s[0]-'0';
	int sum = 0;
	for (int i = 1; i < s.size(); i++)
	{
		if ((s[i]-'0')== max)
		{
			sum++;	
			if (s[i] == '0')
				s[i] = '1';
			else
				s[i] = '0';
		}
		max = s[i]-'0';
	}
	cout << sum<< endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

mod = 10**9 + 7

N = int(input())
ad = [[] for _ in range(N)]
for _ in range(N-1):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ad[x].append(y)
    ad[y].append(x)

dp = [[1]*2 for _ in range(N)]

def rec(v=0,pv=-1):
    for cv in ad[v]:
        if cv == pv:
            continue
        rec(cv,v)
        dp[v][0] *= (dp[cv][0] + dp[cv][1]) % mod
        dp[v][1] *= dp[cv][0] % mod

rec()
ans = (dp[0][0] + dp[0][1]) % mod
print(ans)

Measured memory_bytes: 126768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define REP(i, a, n) for(int i= a; i<n; i++)

int main() {
	int N;
	string S;
	cin >> N >> S;

	int l = 0, r = 0;
	REP(i, 0, N) {
		if (S[i] == '(') l++;
		else {
			if (l > 0) l--;
			else r++;
		}
	}
	REP(i, 0, l) S = S + ')';
	REP(i, 0, r) S = '(' + S;

	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {

unsigned long long int k;
cin>>k;
if (k==0) {
	cout<<2<<endl;
	cout<<1<<" "<<1<<endl;
	return 0;
}
if (k==1) {
	cout<<2<<endl;
	cout<<0<<" "<<2<<endl;
	return 0;
}

if (k>1 && k<50) {
	cout<<k<<endl;
	for (int j=0; j<k; j++) {
		cout<<j+1<<" ";
	}
	cout<<endl;
	return 0;
}

cout<<50<<endl;
unsigned long long int br=k%50;
for (int j=0; j<50-br; j++) {
	cout<<j+(k/50)<<" ";
}
for (int j=50-br; j<50; j++) {
	cout<<j+(k/50)+1<<" ";
}
cout<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 60;
ll dp[MAX_N][MAX_N][MAX_N * MAX_N + MAX_N];
ll arr[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, a;
    cin >> n >> a;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i ++) {
        int curr = i;
        for(int j = 0; j < n; j ++) {
            for(int k = 0; k < MAX_N * MAX_N; k ++) {
                if(dp[curr][j][k] == 0) {continue;}
                dp[curr + 1][j][k] += dp[curr][j][k];
                dp[curr + 1][j + 1][k + arr[i]] += dp[curr][j][k];
            }
        }
    }
    ll cnt = 0;
    for(int i = 1; i <= n; i ++) {
        cnt += dp[n][i][i * a];
    }
    cout << cnt << endl;
    return 0;
}




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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


modint dp0[2003][2003];
modint dp1[2003][2003];

void solve() {
    int n, m; cin >> n >> m;
    vec s(n+1), t(m+1);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    dp0[0][0] = 1;
    rep(i, n+1){
        rep(j, m+1){
            dp0[i+1][j] += dp0[i][j];
            dp1[i][j] += dp0[i][j];
            dp1[i][j+1] += dp1[i][j];
            if(s[i] == t[j]){
                dp0[i+1][j+1] += dp1[i][j];
            }
        }
    }
    cout << dp1[n][m].n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 70448
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct Edge {
    int to, id;
    Edge(int to, int id): to(to), id(id) {}
};

vector<Edge> graph[55];
vector<int> es;

bool dfs(int cur, int goal, int pa = -1) {
    if (cur == goal) return true;
    for (Edge p : graph[cur]) {
        int next = p.to;
        if (next == pa) continue;
        if (dfs(next, goal, cur)) {
            es.push_back(p.id);
            return true;
        }
    }
    return false;
}

int main() {
    // 包除原理、M個の制約で辺のidの集合をbitで持つ
    int N;
    cin >> N;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }
    int M;
    cin >> M;
    vector<ll> eset(M);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        es = vector<int>();
        dfs(u, v);
        for (int a : es) {
            eset[i] |= 1ll << a;
        }
    }
    ll ans = 0;
    for (int i = 0; i < 1<<M; i++) {
        // M個の辺のbit全探索
        ll mask = 0;
        for (int j = 0; j < M; j++) {
            if (i>>j & 1) mask |= eset[j];
        }
        int white = __builtin_popcountll(mask);
        ll temp = 1ll << (N-1-white);
        if (__builtin_popcountll(i)%2 == 0) ans += temp;
        else ans -= temp;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <complex>

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

#define int i64

signed main() {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if(u == s) cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int n, k;
    cin >> n >> k;

    vector<bool> C(n + 1, false);

    while (k--)
    {
        int d, x;
        cin >> d;

        while (d--)
        {
            cin >> x;
            C[x] = true;
        }
    }

    int sol = 0;
    for (int i = 1; i <= n; ++i)
        if (C[i] == false)
            sol += 1;

    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,k);
    vector<ll> vec(n);
    vector<ll> rinsetu(n-1);
    in(vec);
    for(int i=0;i<n-1;i++){
        rinsetu[i]=vec[i]+vec[i+1];
    }
    ll ans=0;
    for(int i=0;i<n-1;i++){
        if(rinsetu[i]>k){
            ans+=rinsetu[i]-k;
            rinsetu[i+1]-=min(rinsetu[i]-k,vec[i+1]);
            rinsetu[i]=k;
        }
    }
    out(ans);
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int dp[11][100009];
int c[100009];
vector<int> adj[100009];

int main(){
	DRII(n,m);
	REP(i,m){
		DRII(a,b);a--;b--;
		adj[a].PB(b);adj[b].PB(a);
	}
	MS1(dp);
	DRI(q);
	REP(i,q){
		//printf("HI");
		DRII(v,d);RI(c[i]);v--;
		dp[d][v]=i;
	}
	for(int i=10;i>=1;i--){
		REP(j,n){
			if(dp[i][j]==-1)continue;
			dp[i-1][j]=max(dp[i-1][j],dp[i][j]);
			for(int k:adj[j]){
				dp[i-1][k]=max(dp[i-1][k],dp[i][j]);
			}
		}
	}
	REP(i,n){
		if(dp[0][i]==-1)printf("0\n");
		else printf("%d\n",c[dp[0][i]]);
	}
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int a, b; cin >> a >> b;
    cout << a + b/2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7760
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>N;
    vector<pair<ll,ll> > v(N);
    rep(i,0,N){
        cin>>A>>B;
        v[i]=make_pair(B,A);
    }
    sort(v.begin(),v.end());
    ll num=0;
    rep(i,0,N){
        num += v[i].second;
        if(num > v[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

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

    int a[10010];
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> a[i];
    int s = 0;
    for(int i = 0; i < m; i++)
        s += a[i];
    if(s > n)
        cout << "-1";
    else
        cout << n - s;

    cout << "\n";
    return 0;
}


Measured memory_bytes: 3624
n= int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
    a[i],b[i],c[i]=map(int, input().split())

dp = [[0] * 3 for _ in range(n)]

dp[0] = [a[0], b[0], c[0]]

for i in range(1,n):
    dp[i][0]=max(a[i]+dp[i-1][1],a[i]+dp[i-1][2])
    dp[i][1]=max(b[i]+dp[i-1][0],b[i]+dp[i-1][2])
    dp[i][2]=max(c[i]+dp[i-1][0],c[i]+dp[i-1][1])
print(max(dp[-1]))

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

int main() {
  int N, A;
  cin >> N >> A;
  int x = N % 500;

  if(x > A) {
    cout << "No" << endl;
  }
  else if (x <= A) {
   	cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var n,min,max int
  fmt.Scanf("%d %d %d", &n, &min, &max)
  
  var sum int
  for i :=1 ; i<=n ; i++ {
    tmp:=i
    var remainder int
    for tmp > 0 {
      remainder += tmp%10
      tmp /= 10
    }
    
    if remainder >= min && remainder <= max {
    	sum += i
    }    
  }
 
  fmt.Println(sum)
}



Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int
 
int main(){
    vector<ll> n(3);
    in_arr(ll, n, 3);
    sort(n.begin(), n.end());
    if(any_of(n.begin(), n.end(), [](ll a){return a % 2 == 0; })){
        cout << 0 << endl;
    }else{
        cout << n[1] * n[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> p(n);
	int key = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] != i+1) {
			key++;
		}
	}
	if (key > 2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define INF 1000000007
int dp[2000][2000];
int main(void)
{
	string total,jumon;
	int i,j,k;
	cin>>total>>jumon;
	for(i=0;i<total.size();i++) {
		for(j=0;j<=jumon.size();j++) {
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(i=0;i<total.size();i++) {
		for(j=0;j<=jumon.size();j++) {
		  dp[i+1][j]=(dp[i+1][j]+dp[i][j])%INF;
		  if(j!=jumon.size()&&total[i]==jumon[j]) dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%INF;
		}
	}
	cout<<dp[total.size()][jumon.size()]<<endl;
}

Measured memory_bytes: 10916
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int array[] = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        Set<Integer> set = new HashSet<Integer>();

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            if(array[a] > array[b]){
                set.add(b);
            } else if (array[b] > array[a]){
                set.add(a);
            } else {
                set.add(a);
                set.add(b);
            }
        }

        System.out.println(n - set.size());

        sc.close();
    }

}

Measured memory_bytes: 63532
#include <stdio.h>

int getGCD(int a,int b){
        int r;
        while(1){
                r = a % b;
                if(r <= 0){return b;}
                a = b;
                b = r;
        }

}

int main(void){
	int a,b;
	while(scanf("%d%d",&a,&b) != EOF){
		printf("%d\n",getGCD(a,b));
	}
	return 0;
}

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

int dp[20001][256];

int main(){

  int n,m,c[16],x[20000];

  while(cin>>n>>m,n){

    for(int i=0;i<m;i++)cin>>c[i];
  
    for(int i=0;i<n;i++)cin>>x[i];
  
    for(int i=0;i<20001;i++)
      for(int j=0;j<256;j++)dp[i][j]=1e9;

    dp[0][128]=0;

    for(int i=0;i<n;i++)
      for(int j=0;j<256;j++)
	for(int k=0;k<m;k++){
	  int y=min(255,max(0,j+c[k]));
	  dp[i+1][y]=min(dp[i][j]+(y-x[i])*(y-x[i]),dp[i+1][y]);
	}
  
    int ans=1e9;
    for(int i=0;i<256;i++)ans=min(ans,dp[n][i]);

    cout<<ans<<endl;
  
  }
  return 0;
}

Measured memory_bytes: 23144
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, X;
  cin >> N >> X;
  vll A(N);
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }
  sort(A.begin(), A.end(), less<>());

  ll x = X;
  ll count = 0;
  REP(i, 0, N - 1) {
    if (x >= A[i]) {
      count++;
      x -= A[i];
    }
  }
  if (A[N-1] == x) {
    count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
void swap(int* a,int s,int v){
int c;
c=a[s];
a[s]=a[v];
a[v]=c;
return;
}
int main(){
int w,n;
int ans[100];
int sw[2];
scanf("%d %d",&w,&n);
int i;
for(i=1;i<=w;i++){
ans[i]=i;
}
for(i=0;i<n;i++){
sw[1]=sw[0]=0;
scanf("%d,%d",&sw[0],&sw[1]);
swap(ans,sw[0],sw[1]);
}
for(i=1;i<=w;i++){
printf("%d\n",ans[i]);
}
return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int stack[1000000];
int pos = 0;
int pop() {
  pos--;
  return stack[pos];
}

void push(int x) {
  stack[pos] = x;
  pos++;
}

void print() {
  for (int i = 0; i < pos; i++) {
    cout << stack[i] << " ";
  }
  cout << endl;
}

int main() {
  char c;
  bool conti = false;
  int n, m;
  while (scanf("%c", &c), c != '\n') {
    if (c == ' ') {
      conti = false;
    } else if (c == '+') {
      n = pop();
      m = pop();
      push(m+n);
      conti = false;
    } else if (c == '-') {
      n = pop();
      m = pop();
      push(m-n);
      conti = false;
    } else if (c == '*') {
      n = pop();
      m = pop();
      push(m*n);
      conti = false;
    } else {
      if (conti) {
        push(pop()*10+(c-'0')); 
      }else{
        push(c-'0');
        conti = true;
      }
    }
    //print();
  }
  cout << pop() << endl;
}




Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N;  
	cin >> N; 
	int A[114] = {}; 
	for(int i = 2; i <= N; i++){
                int k = i; 
		for(int j = 2; j <= N; j++){
			while(k % j == 0){
				A[j] ++; 
				k /= j; 
			}
		}
	}
	sort(A, A+100); 
	int N74 = 100 - (lower_bound(A, A+100, 74) - A); 
	int N24 = 100 - (lower_bound(A, A+100, 24) - A); 
	int N14 = 100 - (lower_bound(A, A+100, 14) - A); 
	int N4 = 100 - (lower_bound(A, A+100, 4) - A); 
	int N2 = 100 - (lower_bound(A, A+100, 2) - A); 
	int typeA = N74; 
	int typeB = N24 * (N2 - 1); 
	int typeC = (N4 * (N4 - 1))/2 * (N2 - 2); 
	int typeD = N14 * (N4 - 1); 
	cout << typeA + typeB + typeC + typeD << endl; 
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N,K; cin >> N >> K;

    int ans = N - K + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Sugoroku
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			int[] a = new int[n+1];
			for(int i=1;i<=n;i++)a[i]=sc.nextInt();
			int[] d = new int[m];
			for(int i=0;i<m;i++)d[i]=sc.nextInt();
			int p = 1;
			for(int i=0;i<m;i++){
				p += d[i];
				if(p>=n){
					System.out.println(++i);break;
				}
				p += a[p];
				if(p<0)p = 0;
				if(p>=n){
					System.out.println(++i);break;
				}
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
int main()
{
	int n,l;
	cin>>n>>l;
    string s[100];
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++)
	 cout<<s[i];
     cout<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//最終的に全部売る。
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), P(N);
    rep(i,N){
        cin >> A[i];
    }
    //ll id = -1;//id以降は売買しない。
    rep(i,N-1){
        if(A[i] < A[i+1]){
            P[i] = 1;
        }else{
            P[i] = 0;
            //id = i;
        }
    }
    ll cuc = 1000;
    ll ns = 0;
    ll sum = 0;
    /*if(id == -1){
        cout << cuc << endl;
        return 0;
    }*/
    rep(i,N){
        if(i == N-1){
            cuc += ns*A[i];
            ns = 0;
            break;
        }
        if(P[i]){
            ns += ll(cuc/A[i]);
            cuc -= ll(cuc/A[i])*A[i];
        }else{
            cuc += ns*A[i];
            ns = 0;
        }
        //cout << i <<" " <<cuc << endl;
    }
    cout << cuc << endl;
}


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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli n;
	cin >> n;
	
	vcL dp( 200, 0 );
	
	for (int i = 0; i <= 100; i += 4 ) dp[i] = true;
	
	for (int i = 7; i <= 100; ++i) {
		dp[i] |= dp[ i-7 ];
	}
	
	if ( dp[n] ) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

INF = 2**62-1


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


# @mt
def slv(N, Q, A, X):

    from itertools import accumulate
    sa = [0] + list(accumulate(A))
    sea = [0] + list(accumulate(a if i % 2 == 0 else 0 for i, a in enumerate(A)))
    soa = [0] + list(accumulate(a if i % 2 == 1 else 0 for i, a in enumerate(A)))

    for x in X:
        def f(n):
            if 2*n-1 > N:
                return 1
            t = abs(x-A[-n])
            a = max(abs(x-A[-n-1]), abs(x-A[-2*n+1]))
            if a <= t:
                return 0
            return 1
        n = Bisect(f).bisect_left(1, 1, N) - 1
        ans = sa[N] - sa[N-n]
        r  = max(0, N - 2*n)
        if r % 2 == 0:
            ans += soa[r] - soa[0]
        else:
            ans += sea[r] - sea[0]
        print(ans)

def main():
    N, Q = read_int_n()
    A = read_int_n()
    X = [read_int() for _ in range(Q)]
    slv(N, Q, A, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 97860
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b;
	if(b<10) b+=a*10;
	else if(b<100) b+=a*100;
	else b+=a*1000;
	for(c=0;c*c<b;c++){}
	if(c*c==b) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int n,p,q,i,j,k,a,b,aa,bb,ans[101]={0},juni[101]={0},c=1,d=0;
    scanf("%d",&n);
    p=n*(n-1)/2;
    q=(n-1)*3;
    for(i=0;i<p;i++){
        scanf(" %d %d %d %d",&a,&b,&aa,&bb);
        if(aa>bb)ans[a]=ans[a]+3;
        else if(bb>aa)ans[b]=ans[b]+3;
        else if(aa==bb){
            ans[a]=ans[a]+1;
            ans[b]=ans[b]+1;
        }
    }
    for(j=q;j>0;j--){
        for(k=1;k<=n;k++){
            if(ans[k]==j){
                juni[k]=c;
                d++;
            }
        }
        for(k=0;k<d;k++){
            c++;
        }
        d=0;
    }
    for(j=1;j<=n;j++){
        printf("%d\n",juni[j]);
    }
return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin >>n;
  int ans =0;
  for(int i=1;i<=n;i+=2){
      int check =0;
      for(int j=1;j<=i;j++){
          if(i%j==0){
              check++;
          }
          if(check==8){
              ans++;
          }
      }
  }
  cout << ans << endl;
}

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

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

    int N,K;
    cin >> N >> K;

    vector<long long> height(N+1);
    for(int i=1;i<=N;i++) cin >> height[i];

    vector<long long> dp(N+1,0);

    for(int i=2;i<=N;i++) {
        dp[i] = (1LL<<59);

        for(int j=1;j<=K;j++) {
            if(i-j>=1) {
                dp[i] = min(dp[i],dp[i-j]+abs(height[i-j]-height[i]));
            } else break;
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.nextIntArray(n);

            Map<Integer, Integer> map = new TreeMap<>();
            for (int x : a) {
                map.merge(x, 1, Integer::sum);
            }

            int cnt = map.size();
            List<Integer> list = new ArrayList<>();
            list.addAll(map.values());

            Collections.sort(list);
            int ans = 0;
            for (int i = 0; i < cnt - k; i++) {
                ans += list.get(i);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 56080