akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

string S, T;

void _main() {
    cin >> S >> T;
    S += S;
    cout << (S.find(T) != string::npos ? "Yes" : "No") << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
<?php

	fscanf(STDIN, "%d",$N );

	if ($N === 1){
		echo "1\n";
		return;
	}

	$num1 = 2;
	$num2 = 1;
	$num3 = 3;
	for ($i = 2; $i < $N; $i++){
		$num3 += $num2;

		$wknum2 = $num2;
		$num2 += $num1;

		$num1 = $wknum2;
	}

	echo $num3."\n";

?>

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

int n, lim, a[1111];

int main(void) {
  cin >> n >> lim;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int lst = 0, cur = 0;
  vector<int> ans;
  for(int i = 1; i <= lim + 1; i++) {
    cur = lst == 1 ? 2 : 1;
    for(int j = 1; j <= n; j++) {
      if(j != lst && a[cur] > a[j]) {
        cur = j;
      }
    }
    for(int j = 1; j <= n; j++) {
      if(j != lst && j != cur) {
	a[j]--;
	ans.push_back(j);
      }
    }
    ans.push_back(cur);
    a[cur]--;
    for(int j = 1; j <= n; j++) {
      if(a[j] < 0) {
	return puts("-1"), 0;
      }
    }
    lst = cur;
  }
  cout << ans.size() << endl;
  for(int x : ans) {
    cout << x << " ";
  }
  return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split(' '))
A_ls = [0] + list(map(int, input().split(' ')))
for i in range(N):
    A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(M):
    B_ls[i + 1] += B_ls[i]

a_cnt, b_cnt, rst = 0, M, 0
for a_cnt in range(N + 1):
    if A_ls[a_cnt] > K:
        break
    while A_ls[a_cnt] + B_ls[b_cnt] > K and b_cnt > 0:
        b_cnt -= 1
    rst = max(rst, a_cnt + b_cnt)
print(rst)

Measured memory_bytes: 45084
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) rbegin(obj), rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}ll x,z,y,n,k,sum = 0,p,m; string s;
template<class Abel> struct UnionFind {
    vector<int> par, rank;
    vector<Abel> diff_weight;
    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }
    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int main() {
    cin >> n >> m;
    UnionFind<int> tree(n);
    rep(i, m) {
        cin >> x >> y >> z;
        x--; y--;
        if (tree.same(x, y)) {
            int di = tree.diff(x, y);
            if (di != z) {
                cout << "No" << endl;
                return 0;
            }
        }
        else  tree.merge(x, y, z);
    }cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  ll N,ans = 0; cin >> N;
  vector<int> vec(N);
  for (ll i = 0; i < N; ++i) cin >> vec[i];
  
  for (ll i = 0; i < N-2; ++i) {
    int a = vec[i];
    int b = vec[i+1];
    int c = vec[i+2];
    if (max({a,b,c})!=b && min({a,b,c})!=b) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 10'000;
int opt[N+1], pre[N+1], sticks[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    cin >> a;
    sort(a.begin(), a.end(), greater<int>());
    fill(opt, opt + n + 1, lim<int>::min());
    opt[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int x : a) {
            if(sticks[x] <= i and opt[i] < opt[i - sticks[x]] + 1) {
                opt[i] = opt[i - sticks[x]] + 1;
                pre[i] = x;
            }
        }
    }
    for(int i = n; i > 0; i -= sticks[pre[i]]) {
        cout << pre[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused_macros)]
macro_rules! maxs {
    ($x:expr, $($y:expr), *) => {{
        let mut ret = $x;
        $(
            ret = max(ret, $y);
        )*
        ret
    }};
}
fn main() {
    input!(x: usize);
    let mut ans = 0;
    if x == 0 {
        ans = 1;
    }

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


Measured memory_bytes: 2132
import java.util.*;

public class Main {
    private static final int MONEY = 1000;
    private static final int[] coins = {0, 1, 2, 3, 4, 1, 2, 3, 4, 5};

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                int cng = MONEY - n;
                System.out.println(coins[cng % 10] + coins[cng / 10 % 10] + coins[cng / 100 % 10]);
            }
        }
    }
}

Measured memory_bytes: 26148
s = input()
n = len(s) - 1 #隙間の数

for i in range(2**3):
    tmp = s[0]
    for j in range(n):
        if (i >> j) & 1:
            tmp += "+"

        else:
            tmp += "-"

        tmp += s[j+1]

    list_tmp = [tmp[0], tmp[1:3], tmp[3:5], tmp[5:7]]

    res = 0
    for j in list_tmp:
        res += int(j)

    if res == 7:

        print(tmp + "=7")
        exit()

Measured memory_bytes: 3064
#include<cstdio>
int main(){
    char o[51],e[51];
    scanf("%s%s",o,e);
    for(int i=0;o[i]!='\0';i++){
        printf("%c",o[i]);
        if(e[i]!='\0')printf("%c",e[i]);
    }
    return 0;
}

Measured memory_bytes: 128
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main{
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            int[] arr=new int[n];
            for(int i=0;i<n;i++){
                arr[i]=scan.nextInt();
            }
            long[] pf=new long[n];
            pf[0]=0;
            long mod=(long)(1e9)+7;
            for(int i=1;i<n;i++){
                pf[i]=(pf[i-1]+arr[i-1])%mod;
            }
            long ans=0;
            for(int i=0;i<n;i++){
                ans=(ans+(pf[i]*arr[i])%mod)%mod;
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 35660
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on
string s;
int k;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> k;

  int n = s.length();
  set<string> S;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      string t = s.substr(i, j - i + 1);
      if ((ll)S.size() < k || t < *S.rbegin()) {
        S.insert(t);
      } else {
        break;
      }
      while ((ll)S.size() > k) {
        S.erase(prev(S.end()));
      }
    }
  }
  cout << *S.rbegin() << endl;

  return 0;
}


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

bool primeNumber(int n){
  if(n < 2) return false;
  else{
    for(int i = 2; i * i <= n; i++){
      if(n % i == 0) return false;
    }
    return true;
  }
}

int main(){
  int q,l[maxn],r[maxn],resulti[maxn];
  resulti[0]=0;
  resulti[1]=0;
  cin>>q;
  for(int i(0);i<q;i++){
    cin>>l[i]>>r[i];
  }
  for (int i(3);i<=maxn;i++){
    if (i%2==0){
      resulti[i-1]=0;
    }else{
      if(primeNumber(i)&&primeNumber((i+1)/2)){
        resulti[i-1]=1;
      }else{
        resulti[i-1]=0;
      }
    }
  }
  for (int i(1);i<maxn;i++){
    resulti[i]+=resulti[i-1];
  }
  for(int i(0);i<q;i++){
    if (l[i]!=1){
      cout << resulti[r[i]-1]-resulti[l[i]-2]<<endl;
    }else{
      cout << resulti[r[i]-1]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char S[205];

int main(){

	scanf("%s",S);

	int LEN;
	for(LEN = 0; S[LEN] != '\0'; LEN++);


	int ans = 0;

	for(int tail = 1; tail < LEN-1; tail += 2){
		bool FLG = true;

		int len = (tail+1)/2;

		for(int i = 0; i < len; i++){
			if(S[i] != S[len+i]){
				FLG = false;
				break;
			}
		}
		if(!FLG)continue;
		ans = (tail+1);
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3716
function main(input) {
    const reverse = (s) => {
        return s.split('').reverse().join('');
    };

    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    var index = 0;

    while(true) {
        var w = WORDS.find((w) => S.startsWith(w, index));
        if (!w) break;
        index += w.length;
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ans = p - 1;
  for (int i = n - 1, j = 0; j < p - 1; i--, j++)
  {
    a[i] += m;
  }

  ll csum[200010];
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + a[i];
  //[l, r)の和
  auto sum = [&](ll L, ll R) {
    return csum[R] - csum[L];
  };

  auto simulate = [&](ll si) {
    ll u = a[si] + m;
    ll cnt = m * (v - p);
    auto itr = upper_bound(all(a), u - m);
    ll r1 = distance(a.begin(), itr);
    itr = upper_bound(all(a), u);
    ll r2 = distance(a.begin(), itr);
    if (n - r2 >= p)
      return false;
    cnt -= r1 * m;
    cnt -= u * (r2 - r1) - sum(r1, r2);
    cnt += m; //最初に選んだ分を余計に引いたため
    return cnt <= 0;
  };

  rep(i, n - (p - 1))
  {
    if (simulate(i))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

    deque<int> b;
    vector<bool> seen(n, false);
    int cur = 0;
    while (true)
    {
        if (seen[cur])
        {
            while (b[0] != cur)
            {
                k--;
                b.pop_front();

                if (k == 0)
                {
                    cout << b[0] + 1 << endl;
                    return 0;
                }
            }
            break;
        }
        b.push_back(cur);
        seen[cur] = true;
        cur = a[cur];
    }

    cout << b[k % b.size()] + 1 << endl;

    return 0;
}

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

void fnInput(vector<vector<int>>& rvvnCandy)
{
  int nSize;
  cin >> nSize;

  rvvnCandy.resize(2, vector<int>(nSize, 0));
 
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < nSize; j++)
      cin >> rvvnCandy[i][j];
}

int fnCumlSum(const vector<vector<int>>& cnrvvnCandy)
{
  int nCumlSum = 0;
  int n1stSum  = 0;
  for (int i = 0; i < cnrvvnCandy[0].size(); i++)
  {
    n1stSum += cnrvvnCandy[0][i];
    int n2ndSum = 0;
    for (int j = i; j < cnrvvnCandy[1].size(); j++)
      n2ndSum += cnrvvnCandy[1][j];

    nCumlSum = max(nCumlSum, (n1stSum + n2ndSum));
  }
  return nCumlSum;
}
    
int main()
{
  vector<vector<int>> vvnCandy;
  
  fnInput(vvnCandy);
  cout << fnCumlSum(vvnCandy) << endl;

  return 0;
}

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

#define endl '\n'
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, j) for (int i = 0; i < j; i++)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

void solve() {
    int n;
  	cin >> n;
  	int x = n / 1000;
  	if(n % 1000)
      	x++;
  	else {
      	cout << 0 << endl;
      	return;
    }
  	cout << x * 1000 - n << endl;
  	return;
} 

int32_t main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
struct Line{
	LL k,b;
};
LL getval(Line A,LL B){
	return B*A.k+A.b;
}
bool bad(Line A,Line B,Line C){
	//B与A的交点的横坐标<C与A的交点的横坐标
	return (A.b-B.b)*(C.k-A.k) < (A.b-C.b)*(B.k-A.k); 
}
int N;
LL C,h[200000+2],f[200000+2]; 
int main(){
	fastio;
	deque<Line> q;
	cin>>N>>C;
	rb(i,1,N) cin>>h[i];
	f[1]=0;
	rb(i,2,N){
		Line tmp;
		tmp.k=-2ll*h[i-1];
		tmp.b=f[i-1]+h[i-1]*h[i-1]+C;
//		cout<<tmp.k<<" "<<tmp.b<<endl; 
		
		while(q.size()>1&&!bad(tmp,*(q.end()-2),q.back())){
			q.pop_back();
		}		
//		if(i==4){
//			cout<<(*(q.end()-2)).k<<"_"<<q.back().k<<endl;
//		}
		q.PB(tmp);
		while(q.size()>1&&getval(q.front(),h[i])>getval(*(q.begin()+1),h[i])){
//			cout<<"z"<<endl; 
			q.pop_front();
		}
//		cout<<f[i]<<endl;
		f[i]=getval(q.front(),h[i])+h[i]*h[i];
//		cout<<f[i]<<endl;
	}
	cout<<f[N]<<endl; 
	return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> s1(n+1), s2(n+1);
  s1[0] = 0; s2[0] = 0;
  int tmp = 0;
  FOR(i, 1, n+1) {
    cin >> tmp;
    s1[i] = s1[i-1] + tmp;
  }

  FOR(i, 1, n+1) {
    cin >> tmp;
    s2[i] = s2[i-1] + tmp;
  }

  int ma = 0;
  REP(i, n) {
    //cout << s1[i+1] + s2[n] - s2[i] << endl;
    ma = max (ma, s1[i+1] + s2[n] - s2[i]);
  }

  cout << ma << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> arr(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> arr[i];
	}

	sort(arr.begin(), arr.end());

	cout << arr[0] + 10 * arr[2] + arr[1];
}

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

int main() {
  int N, T, X;
  cin >> N >> T >> X;

  if ( N % T > 0 ) {
    cout << (N / T + 1) * X  << endl;
  }

  if ( N % T == 0 ) {
    cout << N / T * X << endl;
  }

}

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

long long n, s, sub, b = -1;

int main() {
  cin >> n >> s;
  sub = n - s;
  if(n == s) {
    cout << n + 1 << endl;
    return 0;
  }
  for(long long i = 2; i * i <= n; ++i) {
    long long now = n, sum = 0;
    while(now > 0) {
      sum += now % i;
      now /= i;
    }
    if(sum == s) {
      cout << i << endl;
      return 0;
    }
  }
  for(long long i = 1; i * i <= sub; ++i) {
    if(sub >= 0 && sub % i == 0) {
      long long x = sub / i + 1;
      if(x > (s - i) && i <= s && x * i + (s - i) == n) {
        if(b == -1) b = x;
        b = min(b, x);
      }
      x = i + 1;
      if(x * x > n && x > i && sub / i <= s &&
         x * (sub / i) + (s - (sub / i)) == n) {
        if(b == -1) b = x;
        b = min(b, x);
      }
    }
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for j in range(m)]
for i in range(n):
  dis=float('inf')
  ch=0
  for j in range(m):
    if dis>abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      ch=j
  print(ch+1)
  

Measured memory_bytes: 9208
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;

struct P{
	int t,x,y;
	P(){}
	P(int t,int x,int y):t(t),x(x),y(y){}
};
bool wall[128][128];
bool visited[128][128];

int main(){
	int t,n;
	while(cin>>t>>n,t||n){
		int x,y;
		memset(wall,false,sizeof(wall));
		memset(visited,false,sizeof(visited));
		while(n--){
			cin>>x>>y;
			wall[x+60][y+60]=true;
		}
		cin>>x>>y;
		queue<P> q;
		q.push(P(0,x+60,y+60));
		visited[x+60][y+60]=true;
		P a,b;
		int ans=1;
		while(!q.empty()){
			a=q.front();q.pop();
			for(int i=-1;i<=1;i++){
				for(int j=-1;j<=1;j++){
					if(i==-j)continue;
					b=P(a.t+1,a.x+i,a.y+j);
					if(!wall[b.x][b.y] && !visited[b.x][b.y]){
						visited[b.x][b.y]=true;
						if(b.t<t)q.push(b);
						ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1260
#include<stdio.h>

int main(){
 int a, b, c, i, x=0;

 scanf("%d %d %d", &a,&b,&c);
 for(int i = a; i <= b; i++){
 if( c%i ==0 ){
	x++;
 }
 }
 printf("%d\n", x);
}
 






Measured memory_bytes: 2048
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;

static const int N = 1000;

int max(int a, int b)
{
	if(a > b)
		return a;
	else 
		return b;
}
int lcs(string X, string Y)
{
	int c[N+1][N+1] = {0};
	int m = X.size();
	int n = Y.size();

	int max1 = 0;
	X = ' ' + X;
	Y = ' ' + Y;

	for(int i=1; i<=m; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(X[i] == Y[j])
				c[i][j] = c[i-1][j-1] + 1;
			else{
				c[i][j] = max(c[i-1][j],c[i][j-1]);
			}
			max1 = max(max1,c[i][j]);
		}
	}

	return max1;
}
int main()
{
	string a,b;
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		cin >> a >> b;
		printf("%d\n",lcs(a,b));
	}

	return 0;
}


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

typedef pair<int,int> pii;

char G[501][501];
int g[501][501];

int main(void){

    int h,w;
    while(cin >> h >> w,h|w){
        fill(g[0],g[501],0);
        for(int i=0;i<h;i++)cin >> G[i];

        for(int i=0;i<w;i++)g[0][i]=(G[0][i]=='.');
        for(int i=1;i<h;i++){
            for(int j=0;j<w;j++){
                if(G[i][j]=='.')g[i][j]=g[i-1][j]+1;
            }
        }

        int ans=0;
        for(int i=0;i<h;i++){
            stack<pii> st;
            for(int j=0;j<w;j++){
                if(st.empty() || st.top().first<g[i][j])st.push(pii(g[i][j],j));
                else if(st.top().first>g[i][j]){
                    int pos;
                    while(!st.empty() && st.top().first>=g[i][j]){
                        pos=st.top().second;
                        ans=max(ans,(j-st.top().second)*st.top().first);
                        st.pop();
                    }
                    st.push(pii(g[i][j],pos));
                }
            }

            while(!st.empty()){
                ans=max(ans,(w-st.top().second)*st.top().first);
                st.pop();
            }

        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4280
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int n,a[1000000];
ll sum,ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1]=0;a[0]=0;
	for(int i=0;i<=n;i++) sum+=abs(a[i+1]-a[i]);
	for(int i=1;i<=n;i++){
		ans=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
		printf("%lld\n",ans);
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> S;

}

bool isMM(string s){
    return (s>="01")&&(s<="12");
}

bool isYY(string s){
    return (s>="00")&&(s<="99");
}

bool isYYMM(string s){
    return isYY(s.substr(0,2))&&isMM(s.substr(2,4));
}

bool isMMYY(string s){
    return isMM(s.substr(0,2))&&isYY(s.substr(2,4));
}

bool isAMBIGUOUS(string s){
    return isYYMM(s)&&isMMYY(s);
}

void solve(){
    string ans;
    ans = "NA";
    if(isYYMM(S)) ans="YYMM";
    if(isMMYY(S)) ans="MMYY";
    if(isAMBIGUOUS(S)) ans="AMBIGUOUS";
    cout << ans << endl;
}

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll n, x, y;
    cin >> n >> x >> y;
    ll ans[n] = {0};
    sidha (i, 1, n+1) {
        sidha (j, i+1, n+1) {
            if (j <= x || i >= y)
                ans[j-i]++;
            else if (j >= y && i <= x)
                ans[j-y+x-i+1]++;
            else
                ans[min(j-i, abs(j-y)+abs(i-x)+1)]++;
        }
    }
    sidha (i, 1, n) cout << ans[i] << endl;
    
    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1; x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y = y>>1; x = (x*x) % mod; } 
    return res; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//nHk = n-1+kCn-1


bool comp(pair<int, pii> a, pair<int, pii> b) {
    if (a.S.F != b.S.F) return a.S.F < b.S.F;
    return a.S.S < b.S.S;
}
int main() {
    int n, m; cin >> n >> m;
    vector<int> p(m);
    vector<tuple<int, int, int> > v(m);
    rep(i, m) {
        cin >> p[i];
        int x; cin >> x;
        v[i] = make_tuple(p[i], x, i);
    }
    sort(all(v));
    
    vector<int> order(m);
    
    order[get<2>(v[0])] = 1;
    int cnt = 1;
    rep3(i, 1, m) {
        if (get<0>(v[i]) == get<0>(v[i - 1])) {
            cnt++;
            order[get<2>(v[i])] = cnt;
        } else {
            cnt = 1;
            order[get<2>(v[i])] = cnt;
        }
    }
    
    
    
    rep(i, m) {
        cout << setw(6) << setfill('0') << p[i];
        cout << setw(6) << setfill('0') << order[i] << endl;
        
    }
    
    
}


Measured memory_bytes: 3456
#include<stdio.h>
int main()
{
    int a,b,c,i,j;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b && a>c)
{
    if(b>c)
        printf("%d %d %d\n",c,b,a);
    else
        printf("%d %d %d\n",b,c,a);
}
else if(b>a && b>c)
{
    if(a>c)
        printf("%d %d %d\n",c,a,b);
    else
        printf("%d %d %d\n",a,c,b);
}
    else if(c>a && c>b)
    {
    if(a>b)
        printf("%d %d %d\n",b,a,c);
    else
        printf("%d %d %d\n",a,b,c);
    }

    return 0;
}

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

using namespace std;
using LL = long long;
const LL LINF = 1e18;
const LL MOD = 1e9+7;



int main(){
    int N,Q;cin >> N >> Q;
    string s;
    cin >> s;
    vector<int> ruiseki;
    ruiseki.push_back(0);
    for(int a = 1;a < N;a++){
        if(s.at(a) == 'C' && s.at(a-1) == 'A'){
            ruiseki.push_back(ruiseki.back()+1);
        }else{
            ruiseki.push_back(ruiseki.back());
        }
    }
    for(int a = 0;a < Q;a++){
        int b,c;cin >> b >> c;
        cout<<ruiseki.at(c-1)-ruiseki.at(b-1)<<endl;
    }
}


Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl

#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int main(){
	while(true){
		int H,W;cin >> H >> W;
		if(H==0 && W==0)break;
		vector<string> map=vector<string>(H);
		REP(i,H)cin >> map[i];
		vector<vector<bool>> passed=vector<vector<bool>>(H,vector<bool>(W));

		int px=0,py=0;
		while(true){
			if(map[py][px]=='.'){
				cout << px <<" "<<py <<endl;break;
			}
			if(passed[py][px]){
				cout <<"LOOP"<<endl;break;
			}
			passed[py][px]=true;
			switch(map[py][px]){
				case '>':px++;break;
				case '<':px--;break;
				case '^':py--;break;
				case 'v':py++;break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 
int main() {
    int n,m;
    cin >> n >> m;
    vector<int> X(m);
    for(int i = 0; i < m; i++)
    {
        cin >> X[i];
    }
    if (m<=1) {
        cout << 0 << endl;
    }
    else {
        vector<int> Y(m-1);
        sort(X.begin(),X.end());
        for(int i = 0; i < m-1; i++)
        {
            Y[i] = X[i+1] - X[i];
        }
        sort(Y.begin(),Y.end());
        ll sum=0;
        for(int i = 0; i < m-n; i++)
        {
            sum += Y[i];
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
s=[]
for i in range(N):
    s.append(str(input()))
t=[]
M=int(input())
for i in range(M):
    t.append(str(input()))
ans=0
for i in range(N):
    p=s.count(s[i])-t.count(s[i])
    ans=max(ans,p)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,M,a;
 int sum = 0;
   cin >> N >> M ;
 
  for (int i = 0; i < M; i++ ){
     cin >> a;
    sum += a;
  }
  
  if ( N -sum  < 0){
    cout << -1 << endl;
  }else{
    cout << N - sum << endl;
  }
  

 
}

Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        m[x]++;
    }
    vector<pair<int, int> > p;
    map<int, int> ::iterator it;
    for(it = m.begin(); it != m.end(); it++){
        p.pb(mp(it->second, it->first));
    }
    sort(rall(p));
    ll ans = 0;
    for(int i = k; i < p.size(); i++){
        ans+=p[i].first;
    }
    cout << ans;
}

Measured memory_bytes: 11768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
      
		//入力表示
		int A = sc.nextInt();
		int B = sc.nextInt();

		Boolean flag = false;
		
		for (int i = 1; i < 10000; i++) {
			if (Math.floor(i * 0.08) == A && Math.floor(i * 0.10) == B) {
				System.out.println(i);
				flag = true;
				break;
			}	
		}
	if (!flag) {
				System.out.println(-1);
			}
	}
}

Measured memory_bytes: 27328
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	map<int,int>a;
	int ans1=0;
	int ans2=0;
	cin >>n;
	int bef;
	rep(i,n){
		cin>>bef;
	//	clog<<bef/400<<endl;
		a[min(bef/400,8)]+=0;
		a[min(bef/400,8)]++;
	}
	ans1=a.size()-1;
	a[8]+=0;
	ans2=ans1;
	//ans2=ans1;
	if(a[8]==0){
		ans2++;
	}
		if(ans1==0 or a[8]==0){
			ans1++;
		}
	
	ans2+=a[8];
	printf("%d %d\n",ans1,ans2);
}

Measured memory_bytes: 256
#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;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int left=0;
    int right=0;
    int now = 0;
    rep(i,s.size()){
        if(s[i]=='('){
            now++;
        }else{
            if(now==0) left++;
            else now--;
        }

    }
    right = now;
    string ans ="";
    for(int i=0;i<left;i++) ans+="(";
    ans+=s;
    for(int i=0;i<right;i++) ans+=")";
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    if(x >= (a * a * b / 2)) {
        ans = atan(2 * (b - x / (a * a)) / a) / (2 * M_PI) * 360;
    } else {
        ans = (M_PI / 2 - (atan(2 * x / (a * b * b)))) / (2 * M_PI) * 360;
    }

    cout << std::setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
P = 10**9+7

def C(n, k):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % P
        b = b * (i+1) % P
    return a * pow(b, P-2, P) % P

print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

void printa_rf(int A[], int len) {
	for (int i = 0; i < len; i++)
		cout << A[i] << endl;
}

void printa_space(vector<int> A, int len) {
	cout << A[0];
	for (int i = 1; i < len; i++)
		cout << " " << A[i];
	cout << endl;
}

int insertionSort(int A[], int len, int g) {
	int cnt = 0;
	for (int i = g; i < len; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
	return cnt;
}

vector<int> makeG(int len) {
	vector<int> G;
	int h = 1;
	G.push_back(h);
	while ((h = 3 * h + 1) < len) {
		G.insert(G.begin(), h);
	}
	return G;
}

void shellSort(int A[], int len) {
	int cnt = 0;
	vector<int> G = makeG(len);
	int m = G.size();
	for (int i = 0; i < m; i++)
		cnt += insertionSort(A, len, G[i]);
	cout << m << endl;
	printa_space(G, m);
	cout << cnt << endl;
	printa_rf(A, len);
}

int main() {
	int n, *a;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	shellSort(a, n);
	delete[] a;
	return 0;
}

Measured memory_bytes: 4900
#include <stdio.h>

int main()
{
    int h, w;
        scanf("%d %d", &w, &h);
    while (!(h == 0 && w == 0))
    {
        for (int i = 1; i <= w; i++)
        {
            for (int j = 1; j <= h; j++)
            {
                if (j % 2 == 1)
                {
                    if (i % 2 == 1)
                    {
                        printf("#");
                    }
                    else
                    {
                        printf(".");
                    }
                }
                else
                {
                    if (i % 2 == 1)
                    {
                        printf(".");
                    }
                    else
                    {
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        scanf("%d %d", &w, &h);
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Scanner;

// *** ABC060 at 2018/02/19

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveB();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        String[] w = sc.nextLine().split(" ");
        String tmp = null;
        for (String c : w) {
            if (tmp == null) {
                tmp = c.substring(c.length() - 1, c.length());
            } else {
                if (tmp.equals(c.substring(0, 1))) {
                    tmp = c.substring(c.length() - 1, c.length());
                } else {
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int tmp = A;
        ArrayList<Integer> used = new ArrayList<>();
        while (true){
            if (tmp % B == C) {
                System.out.println("YES");
                return;
            } else {
                if (used.contains(tmp % B)) {
                    break;
                }
            }
            used.add(tmp % B);
            tmp += A;
        }
        System.out.println("NO");
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	cin >> a >> b >> c >> d;
	if (a <= c && a <= d && b <= c && b <= d) {
		cout << '0' << "\n";
	}
	else if (a <= c && a <= d && b >= c && b <= d) {
		cout << b - c << "\n";
	}
	else if (a <= c && a <= d && b >= c && b >= d) {
		cout << d - c << "\n";
	}
	else if (a >= c && a <= d && b >= c && b <= d) {
		cout << b - a << "\n";
	}
	else if (a >= c && a <= d && b >= c && b >= d) {
		cout << d - a << "\n";
	}
	else if (a >= c && a >= d && b >= c && b >= d) {
		cout << '0' << "\n";
	}
	std::cin >> e;
}

Measured memory_bytes: 256