akhauriyash/Code-Regression huggingface dataset:
import Foundation
let main: () = {
    let N = nextInt()
    let A = listOfInt()
    var dp = [[Int]](repeating: [Int](repeating: 0, count: 2), count: N)
    dp[1][1] = A[1]
    dp[1][0] = A[0]
    for n in 2 ..< N {
        if (n.isEven) {
            if (n < 3) {
                dp[n][1] = A[n] + [dp[n - 2][1], dp[n - 2][0]].max()!
                dp[n][0] = [dp[n - 1][1], dp[n - 1][0]].max()!
            } else {
                dp[n][1] = A[n] + [dp[n - 3][1], dp[n - 3][0], dp[n - 2][1], dp[n - 2][0]].max()!
                dp[n][0] = [dp[n - 1][1], dp[n - 1][0], A[n - 2] + dp[n - 3][0]].max()!
            }
        } else {
            dp[n][1] = A[n] + [dp[n - 2][1], dp[n - 2][0], dp[n - 1][0]].max()!
            dp[n][0] = A[n - 1] + dp[n - 2][0]
        }
    }
    let ans = dp.last!.max()!
    print(ans)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
extension Int {
    var isEven: Bool { self.isMultiple(of: 2) }
}


Measured memory_bytes: 28780
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
  int t,n,k,x[100000+10],a[100000+10];

  cin >> t;

  for(int i=0;i<t;i++){
    cin >> n >> k;
    for(int j=0;j<n;j++) cin >> x[j];
    for(int j=0;j<n-1;j++) a[j] = x[j+1] - x[j]; 
    sort(a,a+n-1);
    
    int ans;
    if( k>=n ){
      cout << "0" << endl;
    }else{
      int sum=0;
      for(int l=0;l<k-1;l++) sum += a[ n-2 - l ];
      ans = x[n-1] - x[0] - sum;
      cout << ans << endl;
    }
  }
}
  

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  multiset<int64_t> ms;
  rep(i,n){
    auto itr = ms.lower_bound(a.at(i));//logn
    if(itr == ms.begin()){
      ms.insert(a.at(i));
      //printf("+%ld",a.at(i));
    }else{
      --itr;
      ms.erase(itr); 
      ms.insert(a.at(i));
    }
  }
  cout << ms.size() << endl;
  
      
      
    
  
  
  

  
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        if( i <= K){
            sum += X;
        }
        else{
            sum += Y;
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int q = sc.nextInt();
        int dir = 1;
        char[] l = new char[300000];
        char[] r = new char[300000];
        int lind = 0;
        int rind = 0;
        for (int i = 0 ; i < q ; i++) {
            int t = sc.nextInt();
            if (t == 1) {
                dir *= -1;
            } else {
                int f = sc.nextInt();
                char c = sc.next().toCharArray()[0];
                if (f == 2) {
                    if (dir == 1) {
                        l[lind] = c;
                        lind++;
                    } else {
                        r[rind] = c;
                        rind++;
                    }
                } else {
                    if (dir == 1) {
                        r[rind] = c;
                        rind++;
                    } else {
                        l[lind] = c;
                        lind++;
                    }
                }
            }
        }
        if (dir == 1) {
            for (int i = 0 ; i < rind ; i++) {
                System.out.print(r[rind - i - 1]);
            }
            System.out.print(s);
            for (int i = 0 ; i < lind ; i++) {
                System.out.print(l[i]);
            }
        } else {
            for (int i = 0 ; i < lind ; i++) {
                System.out.print(l[lind - i - 1]);
            }
            for (int i = 0 ; i < s.length() ; i++) {
                System.out.print(s.charAt(s.length()- i - 1));
            }
            for (int i = 0 ; i < rind ; i++) {
                System.out.print(r[i]);
            }
        }



    }

}

Measured memory_bytes: 152600
#include <cstdio>
#include <cstdint>
#include <algorithm>

#define fprintf(...) (void)0

int testcase_ends() {
  intmax_t a, b, c, d, e;
  scanf("%jd%jd%jd%jd%jd", &a, &b, &c, &d, &e);

  if (a == 0)
    return 1;

  intmax_t na, nb, nc;
  scanf("%jd%jd%jd", &na, &nb, &nc);

  intmax_t res=na*a+nb*b+nc*c;
  if (d <= nc) {
    res = std::min(res, nc*e + na*a+nb*b);
    fprintf(stderr, "L%d: %jd\n", __LINE__, res);
  } else if (d*e < nc*c) {
    res = std::min(res, d*e + na*a+nb*b);
    fprintf(stderr, "L%d: %jd\n", __LINE__, res);
  }
  if (nb+nc >= d) {
    if (nc < d) {
      if ((d-nc)*b+nc*c > d*e) {
        res = std::min(res, d*e + na*a+(nb-(d-nc))*b);
        fprintf(stderr, "L%d: %jd\n", __LINE__, res);
      }
    }
  } else {
    if (d*e < nb*b+nc*c) {
      res = std::min(res, d*e + na*a);
      fprintf(stderr, "L%d: %jd\n", __LINE__, res);
    }
  }
  if (na+nb+nc >= d) {
    if (nb+nc < d) {
      if ((d-nc-nb)*a+nb*b+nc*c > d*e) {
        res = std::min(res, d*e + (na-(d-nc-nb))*a);
        fprintf(stderr, "L%d: %jd\n", __LINE__, res);
      }
    }
  } else {
    res = std::min(res, d*e);
    fprintf(stderr, "L%d: %jd\n", __LINE__, res);
  }
  // if (d <= nc) {
  //   res += nc*e;
  //   nc = 0;
  // } else if (d*e < nc*c) {
  //   res += nc*e;
  //   nc = 0;
  // } else {
  //   if (nb+nc >= d && (d*e < ((d-nc)*b+nc*c))) {
  //     res += d*e;
  //     nb -= d-nc;
  //     nc = 0;
  //   } else if (na+nb+nc >= d && (d*e < ((d-nc-nb)*a+nb*b+nc*c))) {
  //     res += d*e;
  //     na -= d-nc-nb;
  //     nb = nc = 0;
  //   }
  // }

  // intmax_t rem=na*a+nb*b+nc*c;
  // res += std::min<intmax_t>(rem, (na+nb+nc)*e);
  // if (na+nb+nc >= d) {
  //   res += std::min<intmax_t>(rem, (na+nb+nc)*e);
  // } else {
  //   res += rem;
  // }

  printf("%jd\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    int t,x,y;
    int bx=0,by=0,bt=0;
    bool flag=true;
    cin>>n;
    REP(i,n){
        cin>>t>>x>>y;
        int l=abs(x-bx)+abs(y-by);
        if(t-bt<l || (t-bt-l)%2){
            flag=false;
            break;
        }
    }
    Yes(flag);
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main(){
    let v = next_vec();
    let k = v[0];
    let t = v[1] as usize;
    let mut a = next_vec();

    a.sort();

    let mut left: usize = 0;
    let mut right: usize = t - 1;
    let mut cnt = 0;
    while left < right {
        a[left] -= 1;
        left = if a[left] == 0 {left + 1} else {left};
        a[right] -= 1;
        right = if a[right] == 0 {right - 1} else {right};
        cnt += 2;
    }
    cnt += if a[left] > 0 || a[right] > 0 {1} else {0};
    println!("{:?}", k - cnt);
}


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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N;
  int ans = 0;
    cin >> N;
    for(int i = 1; i <= N; i += 2){
      const auto &res = enum_divisors(i);
      if(res.size() == 8){
        ans++;
      }
    }
  cout << ans;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using vi = vector<int>;
using vvi = vector<vi>;

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

	int n; cin >> n; vi f(n), s(n + 1);
	string x; cin >> x;
	f[0] = 1;
	rep(i, 0, n - 1) {
		vi g(n);
		rep(i, 0, n) s[i + 1] = (s[i] + f[i]) % M;
		if (x[i] == '<')
			rep(j, 0, i + 2) g[j] = s[j];
		else
			rep(j, 0, i + 2) g[j] = (s[n] - s[j]) % M;
		swap(f, g);
	}
	int ans = 0;
	trav(z, f) (ans += z) %= M;
	if (ans < 0) ans += M;
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];
    LL ans = 0;
    LL num = 1;
    REP(i,n){
        if(a[i] == num){
            num++;
        }
        else{
            ans++;
        }
    }

    if(ans == n)ans = -1;
    PUTS(ans);
}

Measured memory_bytes: 1792
#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) 998244353;
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 all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n;
    cin >> n;
    pii a[100010];

    rep(i, n) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }

    sort(a, a + n);

    rep(i, n) {
        cout << a[i].second << (i == n - 1 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 1664
def main():
    from math import gcd
    n, *a = map(int, open(0).read().split())
    m = 10 ** 6 + 1

    c = [0] * (m + 1)
    g = a[0]
    for i in a:
        g = gcd(g, i)
        c[i] = 1

    if g > 1:
        pre = "not"
    else:
        for i in range(2, 10 ** 6 + 1):
            if sum(c[i::i]) > 1:
                pre = "setwise"
                break
        else:
            pre = "pairwise"

    print(pre + " coprime")


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "A"
#define int long long

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;

int n, N, a[maxn];
int last[maxn];
ll f[maxn];
ll val[maxn];

signed main(void){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> n;
    while (n--){
        int x;
        cin >> x;
        if (x != a[N]){
            a[++N] = x;
        }
    }
    f[0] = 1;
    for (int i=1; i<=N; ++i){
        f[i] = f[i-1];
        if (last[a[i]] != 0){
            f[i] = (f[i] + val[last[a[i]]]) % mod;
            val[i] = (val[last[a[i]]] + f[i-1]) % mod;
        }
        else{
            val[i] = f[i-1];
        }
        last[a[i]] = i;
    }
    cout << f[N] << '\n';
}


Measured memory_bytes: 6528
#include<stdio.h>
#define N 200000

int main(){
  int i,j,max,min,n,k;
  int a[N];
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  min = a[0];
  max =a[1]-a[0];
  for(j=1; j<n; j++){
    k=a[j]-min;
      if(max < k)max = k;
      if(min > a[j])min=a[j];
  }
  printf("%d\n",max);
  return 0;
}



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

int main(){
  vector<int> a(3);
  for(int i = 0; i < 3; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int n = 2*a[2]-a[1]-a[0];
  if(n%2 == 0) cout << n/2 << endl;
  else cout << (n+3)/2 << endl;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, k, p[300000], ns[300000], pl[300000];
bool s[300000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  deque<int> d;
  int ls = 0;
  for (int i = n - 1; i >= 0; i--) {
    while (!d.empty() && p[d.front()] > p[i])
      d.pop_front();
    ns[i] = d.empty() ? n : d.front();
    ls = p[i] < p[i + 1] ? ls + 1 : 1;
    // cerr << i << " " << ns[i] << "\n";
    s[i] = ls >= k;
    d.push_front(i);
  }
  while (!d.empty())
    d.pop_front();
  for (int i = 0; i < n; i++) {
    while (!d.empty() && p[d.front()] < p[i])
      d.pop_front();
    pl[i] = d.empty() ? -1 : d.front();
    d.push_front(i);
  }
  int r = !s[0], rs = s[0];
  for (int i = 1; i <= n - k; i++) {
    rs += s[i];
    if (!(ns[i - 1] >= i + k && pl[i + k - 1] < i - 1) && !s[i])
      r++;
  }
  cout << r + (rs > 0) << "\n";
}


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

int main(){
    double r;
    cin >> r;
    double s, l;
    
    s = r * r * M_PI;
    l = 2 * r * M_PI;

    cout << fixed << setprecision(5) << s << " " << fixed << setprecision(5) << l << endl;
}


Measured memory_bytes: 3280
<?php

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

$ret = false;
while (true) {
  if ($N === 0 || $N % 500 === 0) {
    $ret = true;
    break;
  } elseif ($A === 0) {
    break;
  }
  $N--;
  $A--;
}

echo $ret ? 'Yes':'No';

?>

Measured memory_bytes: 4604
/**
 *   @FileName	e.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.13 21:23:12
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<pair<int,int>> p(n);
    set<int> st1,st2;
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
        st1.insert(p[i].first-p[i].second);
        st2.insert(p[i].first+p[i].second);
    }
    ll a = *st1.begin();
    ll b = *st1.rbegin();
    ll c = *st2.begin();
    ll d = *st2.rbegin();
    cout << max(abs(a-b),abs(c-d)) << endl;
    return 0;
}

Measured memory_bytes: 23536
// AOJ 1244
#include<iostream>
#include<string>
#include<map>
#include<sstream>
using namespace std;

typedef long long int integer;

int c;
string str;

/* 
 * Molecule -> [Atom | Atom Number | ( Molecule ) Number]*
 * Atom -> Capital | Capital Small
 * Number -> Digit | Digit Digit
 * Capital -> [A-Z]
 * Small -> [a-z]
 * Digit -> [0-9]
 */

integer Molecule();
integer Atom();
integer Number();

integer Z() {
  try {
    integer m = Molecule();
    return m;
  } catch (int e) {
    return -1;
  }
}

integer Molecule() {
  integer sum = 0;
  while (str[c] == '(' or ('A' <= str[c] and str[c] <= 'Z')) {
    if (str[c] == '(') {
      c++; // read (
      integer molecule = Molecule();
      c++; // read )
      integer number = Number();
      sum += molecule * number;
    } else {
      integer atom = Atom();
      if (isdigit(str[c])) {
        integer number = Number();
        atom *= number;
      }
      sum += atom;
    }
  }
  return sum;
}

map<string,integer> table;

integer Atom() {
  string name;
  name.push_back(str[c]);
  c++; // read[A-Z]
  if ('a' <= str[c] and str[c] <= 'z') {
    name.push_back(str[c]);
    c++; // read [a-z]
  }
  if (table.find(name) == table.end()) {
    throw -1;
  } else {
    return table[name];
  }
}

integer Number() {
  integer val = 0;
  while (isdigit(str[c])) {
    val = val * 10 + (str[c] - '0');
    c++; // read [0-9]
  }
  return val;
}

int main() {
  string line;
  while (cin >> line and line != "END_OF_FIRST_PART") {
    int mass;
    cin >> mass;
    table[line] = mass;
  }

  while (cin >> line and line != "0") {
    c = 0;
    str = line;
    integer ans = Z();
    if (ans == -1) {
      cout << "UNKNOWN" << endl;
    } else {
      cout << ans << endl;
    }
  }
}

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

typedef long long ll;
const int N = 200005;

ll a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	ll sum = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
		sum += x;
	}
	
	int q;
	cin>>q;
	while(q--){
		ll x,y;
		cin>>x>>y;
		sum -= x*a[x];
		sum += y*a[x];
		a[y] += a[x];
		a[x] = 0;
		cout<<sum<<endl;
	}
	
	return 0;
}


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

int main() {
  
  int N; cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  cout << vec[N / 2] - vec[N / 2 - 1] << endl;
  
}

Measured memory_bytes: 640
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] copy = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
            copy[i] = a[i];
        }
        Arrays.sort(copy);
        if (copy[n - 1] == copy[n - 2]) {
            for (int i = 0; i < a.length; i++)
                System.out.println(copy[n - 1]);
        } else {
            for (int i = 0; i < a.length; i++) {
                if (a[i] == copy[n - 1])
                    System.out.println(copy[n - 2]);
                else
                    System.out.println(copy[n - 1]);
            }
        }
    }
}

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

int main() {
  string a;
  int n;
  cin >> a;
  n = a.size();
  
  string b = "abcdefghijklmnopqrstuvwxyz";
  
  vector<int> ans(26,0);
  rep(i,n){
    rep(j,26){
      if(a.substr(i,1)==b.substr(j,1)){ans[j]=1;break;}
    }
  }
  
  rep(i,26){
    if(ans[i]==0){cout<<b.substr(i,1)<<endl;return 0;}
  }
  
  cout << "None" << endl;
  
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) Scan() (ok bool) {
	ok = me.baseScanner.Scan()
	return
}
func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			panic(err)
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, fa)
		}
	}
	if n > 1 {
		facts = append(facts, factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func solve(stdin io.Reader, stdout io.Writer) {
	r := NewScannerEx(stdin)
	r.ScanAndSplit()
	n, k := r.nextInt(), r.nextInt()

	cnt := 0
	if n > 0 {
		cnt++
		n -= k
	}
	for n > 0 {
		cnt++
		n -= k - 1
	}

	fmt.Fprintln(stdout, cnt)

}



Measured memory_bytes: 640
//map_range_search
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    map<string, ll> M;
    string key, R, L;
    ll q, que, x;

    cin >> q;
    rep(i, q)
    {
        //cin >> que >> ((que == 3) ? L : key); //使えない??????
        cin >> que;

        switch (que)
        {
        case 0:
            cin >> key >> x;
            M.erase(key); //M[key] = x;
            M.insert({key, x});
            break;
        case 1:
            cin >> key;
            try
            {
                cout << M.at(key) << endl;
            }
            catch (out_of_range &)
            {
                cout << '0' << endl;
            }
            break;
        case 2:
            cin >> key;
            M.erase(key);
            break;
        case 3:
            cin >> L >> R;
            map<string, ll>::iterator begin_itr = M.lower_bound(L);
            map<string, ll>::iterator end_itr = M.upper_bound(R);
            for (auto itr = begin_itr; itr != end_itr; itr++)
                cout << itr->first << ' ' << itr->second << endl;
            break;
        }
    }
}


Measured memory_bytes: 27684
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  string A;
  cin >> A;

  ll c[26] = {};
  REP(i, A.size()) {
    c[A[i] - 'a']++;
  }

  ll total = A.size() * (A.size() - 1) / 2;
  REP(i, 26) {
    total -= c[i] * (c[i] - 1) / 2;
  }

  cout << total + 1 << endl;
  return 0;
}


Measured memory_bytes: 720
/************************************************************
	> File Name: d.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 22 Dec 2019 10:26:58 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int n,temp;
int main(void){
	IOS;
	cin >> n;
	int cnt = 1;
	for(int i = 1;i <= n;i++){
		cin >> temp;
		if(temp==cnt)
			cnt++;
	}
	if(cnt==1)
		cout << -1 << endl;
	else
		cout << n-cnt+1 << endl;
	return 0;
}

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

int main() {
	ll x;
	cin >> x;
	int count = 0;
	ll p = 100;
	bool a = true;
	while (a) {
		p += p / 100;
		count++;
		if (p >= x) {
			cout << count << endl;
			a = false;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int x, y, a, b, minxy, minab;
	scanf("%d %d %d %d", &x, &y, &a, &b);
	if(x<y)
	{
		minxy=x;
	}
	else if(y<x)
	{
		minxy=y;
	}
	if(a<b)
	{
		minab=a;
	}
	else if(b<a)
	{
		minab=b;
	}
	printf("%d\n", minab+minxy);
	return 0;
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, '%d %d', $n,$k);

$d = explode(' ', rtrim(fgets(STDIN),PHP_EOL));

//var_dump($d);exit;
//$flg = false;
for ($i=$n;$i<=100000;$i++) {

    $str = str_split($i);
//    $cnt = 0;

    foreach ($str as $word) {
        if (in_array($word, $d)){
            continue 2;
        }

//        $cnt += 1;
//
//        if($cnt == count($str)){
//            print($i);
//            exit;
//        }
    }

    echo $i.PHP_EOL;
    exit;

}

Measured memory_bytes: 4728
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] W = new String[N];
        String ans = "Yes";
        for(int i = 0; i < N; i++){
            W[i] = sc.next();
            for(int j = 0; j < i; j++){
                if(W[j].equals(W[i])){
                    ans = "No";
                }
            }
        }
        for(int i = 1; i < N; i++){
            if(W[i-1].charAt(W[i-1].length() - 1 ) != W[i].charAt(0)){
                ans = "No";
            }
        }
        System.out.println(ans);
        
    }
}


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


bool isso(long long int a) {
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
int main() {
	while (1) {
		int n; cin >> n;
		if (!n)break;
		int aa[100000];
		memset(aa, 0, sizeof(aa));
		for (int i = 0; i < n; ++i) {
			int t[2];
			for (int j = 0; j < 2; ++j) {
				int atime = 0;
				string st; cin >> st;
				atime += stoi(st.substr(0, 2)) * 3600;
				atime += stoi(st.substr(3, 2)) * 60;
				atime += stoi(st.substr(6, 2));
				t[j] = atime;
			}
			aa[t[0]] += 1;
			aa[t[1]] -= 1;
		}
		int now = 0;
		int amax = 0;
		for (int i = 0; i < 100000; ++i) {
			now += aa[i];
			amax = max(now, amax);
		}
		cout << amax << endl;
	}
	return 0;
}

Measured memory_bytes: 3540
#include <stdio.h>

int main() {
	int s, t;
	scanf("%d%d",&s,&t);
	if (s!=1&&t!=1) {
		printf("1");
	}
	else if(s != 2 && t != 2){
		printf("2");
	}
	else if(s != 3 && t != 3){
		printf("3");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String s1=sc.next();
		String s2=sc.next();
		int count=0;
		for(int i=0;i<s1.length();i++)
			
		{
			if(s1.charAt(i)!=s2.charAt(i))
			{
				count++;
			}
		}
		System.out.println(count);
	}


}

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

const int N_MAX=31;
int dp[N_MAX];

int rec(int n){
    int res;
    if(n<0)return 0;
    if(n==0)return 1;
    if(dp[n]>=0){
        return dp[n];
    }else{
        res=rec(n-1)+rec(n-2)+rec(n-3);
    }
    return dp[n]=res;
}

int main(){
    int n;
    while(cin>>n){
        memset(dp,-1,sizeof(dp));
        if(n==0)break;
        cout<<ceil(rec(n)/3650.0)<<endl;
    }
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}
}



Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}


int main(void){
  ll N, M, A, B, W, H, C, D, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  string s[N];
  rep(i, N) cin>>s[i];
  cin >> M;
  string t[M];
  rep(i, M) cin>>t[i];
  ans = 0;
  ll ans_count = 0;
  rep(i, N){
    ans_count = 0;
    rep(j, N){
      if (s[i] == s[j]) ans_count++;
    } 
    rep(j, M){
      if (s[i] == t[j]) ans_count--;
    }
    ans = max(ans, ans_count);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout<<c<<endl;
	}
	
	else if(a==c){
		cout<<b<<endl;
	}
	
	else if(b==c){
		cout<<a<<endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001
#define MOD 1000000007
typedef long long ll;

int H, W, A, B;
string s;



int main(){
    cin >> s;
    bool flag = false;
    pair<int, int> ans;
    for(int i = 0;i < s.length() - 1;i++){
        if(s[i] == s[i + 1]){
            flag = true;
            ans = {i + 1, i + 2};
        }
    }
    for(int i = 0;i < s.length() - 2;i++){
        if(s[i] == s[i + 2]){
            flag = true;
            ans = {i + 1, i + 3};
        }
    }

    if(flag) printf("%d %d\n", ans.first, ans.second);
    else printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 512
/*************************************************************************
  >         File: E.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 28 Aug 2016 08:42:27 PM CST
*************************************************************************/
#include <bits/stdc++.h>
const int N = 1e5 + 5;
int a[N], L, n;
int dp[N][20];

void Init() {
  for (int i = 0; i < n; i++) {
    dp[i][0] = std::upper_bound(a + i, a + n, a[i] + L) - a - 1;
  }
  for (int step = 1; step < 20; step++) {
    for (int start = 0; start < n; start++) {
      dp[start][step] = dp[dp[start][step - 1]][step - 1];
    }
  }
}

int main() {
  std::ios::sync_with_stdio(0);
  std::cin >> n;
  for (int i = 0; i < n; i++) std::cin >> a[i];
  std::cin >> L;
  Init();
  //for (int i = 0; i < n; i++) {
  //  std::cerr << "i: " << i << std::endl;
  //  for (int j = 0; j < 4; j++) {
  //    std::cerr << dp[i][j] << ' ';
  //  }
  //  std::cerr << std::endl;
  //}
  int q;
  std::cin >> q;
  while (q--) {
    int a, b;
    std::cin >> a >> b;
    a--, b--;
    if (a > b) std::swap(a, b);
    int lo = 0, hi = b - a;
    while (lo + 1 < hi) {
      int mid = (lo + hi) >> 1;
      int now = a;
      for (int step = 0; step < 20; step++) {
        if (mid & (1 << step)) {
          now = dp[now][step];
        }
      }
      if (now >= b) hi = mid;
      else lo = mid;
    }
    std::cout << hi << std::endl;
  }
  return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>

int count;

void def(int n){
  int i,j,a[4],l,s,k;

  if(n==6174){

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

  }else{

    count++;

    a[3]=n/1000;
    a[2]=(n/100)%10;
    a[1]=(n/10)%10;
    a[0]=n%10;

    for(i=0;i<3;i++){
      for(j=0;j<3-i;j++){
        if(a[j]<a[j+1]){
          k=a[j];
          a[j]=a[j+1];
          a[j+1]=k;
        }
      }
    }

    l=a[0]*1000 + a[1]*100 + a[2]*10 + a[3];
    s=a[3]*1000 + a[2]*100 + a[1]*10 + a[0];

    def(l-s);
  }
}
int main(){
  int num,ans;
  while(scanf("%d",&num),num){

    count=0;
    if(num%1111==0){
      printf("NA\n");
    }else{
      def(num);
    }
  }

  return 0;
}

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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n = sc.nextInt();
	static int m = sc.nextInt();
	static int[] cost = new int[n];
	static int[] standard = new int[m];
	static ArrayList<Integer> vote = new ArrayList<Integer>();

	public static void main(String[] args) {
		inputData();
		voting();
	}

	private static void inputData() {
		for (int i = 0; i < n; i++) {
			cost[i] = sc.nextInt();
		}

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

		for (int i = 0; i < n; i++) {
			vote.add(i, 0);
		}
	}

	private static void voting() {
		int max = -1;

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {

				if (standard[i] >= cost[j]) {
					vote.set(j, vote.get(j) + 1);
					break;
				}

			}
		}

		for (int i = 0; i < n; i++) {
			max = Math.max(max, vote.get(i));
		}
/*
		for (int i = 0; i < n; i++) {
			System.out.print(vote.get(i) + " ");
		}System.out.println();


		System.out.printf("max = %d\n",max);
*/

		System.out.println(vote.indexOf(max) + 1);
	}

}



Measured memory_bytes: 34704
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {

    int N;
    cin >> N;

    int M;
    cin >> M;

    vector<int> v;

    for (int i = 0; i < N; i++) {
        v.push_back(0);
    }

    for (int i = 0; i < M; i++) {

        int a, b;
        cin >> a >> b;
        v[a - 1] += 1;
        v[b - 1] += 1;
    }

    for (int i = 0; i < N; i++) {
        cout << v[i] << "\n";
    }

    return 0;

}

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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;

int n,m,ans=inf;
pi a[20];

int main()
{
#ifdef local
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>a[i].f>>a[i].s;
    int t=1<<n;
    for(int i=1; i<t; i++)
    {
        int sum=m,cnt=0;
        for(int j=n-1; ~j; j--)
        {
            if((1<<j)&i)
            {
                int tt=a[j].f*(j+1)*100;
                if(tt>=sum)
                {
                    cnt+=(sum+100*(j+1)-1)/(100*(j+1));
                    sum=0;
                }
                else
                {
                    cnt+=a[j].f;
                    sum-=tt+a[j].s;
                }
                if(sum<=0) break;
            }
        }
        if(sum<=0) ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}


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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') cout << 9;
        if (s[i] == '9') cout << 1; 
    }
    cout << endl;
}

Measured memory_bytes: 3600
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

apples=[]
for i in range(a):
    apples.append([p[i],0])
for i in range(b):
    apples.append([q[i],1])
for i in range(c):
    apples.append([r[i],2])

apples.sort(reverse=True)

mx_cnt=[x,y,float('inf')]
cnt=[0,0,0]
ans=0
for app in apples:
    deli=app[0]
    clr = app[1]

    if cnt[clr] < mx_cnt[clr]:
        ans+=deli
        cnt[clr]+=1

    if sum(cnt)>=x+y:
        break
print(ans)

Measured memory_bytes: 128100
//
//  antiadjacency.cpp
//  
//
//  Created by Òscar Balcells on 09/02/2019.
//

#include <iostream>

using namespace std;

int main() {
    
    int n, k;
    scanf("%d %d", &n, &k);
    
    if((n+1) / 2 >= k) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int k = in.nextInt();
            long[] arr = IntStream.range(0, k).mapToLong(i -> in.nextLong()).toArray();
            long l = 2, r = 2;
            boolean flag = true;
            for (int i = k - 1; i >= 0; i--) {
                long tl = l / arr[i] * arr[i];
                if (tl < l) tl += arr[i];
                long tr = r / arr[i] * arr[i];
                if (tl < l || tl > r || tr < l || tr > r) {
                    flag = false;
                    break;
                }
                l = tl;
                r = tr + arr[i] - 1;
            }
            if (flag) {
                out.print(l + " ");
                out.println(r);
            } else {
                out.println(-1);
            }
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(nextString());
        }

    }
}



Measured memory_bytes: 43604
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a[4], b, c, i, j;
  scanf("%d", &b);
  for(i = 0; i < 4; i++){
    a[3-i] = b % 10;
    b /= 10;
  }
  for(i = 0; i < 1<<3; i++){
    c = a[0];
    for(j = 0; j < 3; j++){
      if(i&(1<<j)) c += a[j+1];
      else c -= a[j+1];
    }
    if(c == 7){
      printf("%d", a[0]);
      for(j = 0; j < 3; j++){
        printf("%s%d", (i&(1<<j) ? "+" : "-"), a[j+1]);
      }
      printf("=7\n");
      return 0;
    }
  }
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

		List<Long> snackNumList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			snackNumList.add(sc.nextLong());
		}

		Map<Long, Long> snackMap = new HashMap<>();
		snackMap.put(0L, 1L);
		long remain = 0;
		long counter = 0;

		for (int i = 0; i < snackNumList.size(); i++) {
			remain = (remain + snackNumList.get(i)) % M;
			counter += snackMap.getOrDefault(remain, 0L);
			snackMap.put(remain, snackMap.getOrDefault(remain, 0L) + 1L);
		}

		System.out.println(counter);
		sc.close();
	}
}


Measured memory_bytes: 62944