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

int main(){
  int A, B, K;
  cin >> A >> B >> K;

  for(int i=0; i<K; i++){
    //A,Bのどちらが操作するか決める
    if (i % 2 == 0){
      //Aの処理
      if(A % 2 == 1){
        A--;
      }
      B += A/2;
      A /= 2;
    }else{
      //Bの処理
      if(B % 2 == 1){
        B--;
      }
      A += B/2;
      B /= 2;
    }
  }
  cout << A << " " << B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll t,n,i,j,k,x,y,c=0,m;
     ll a[100007];
     cin>>n>>k;
     for(i=0;i<n;i++)
     {
         cin>>a[i];

     }
     ll mi;
     ll res[100007];
     res[0]=0;
     res[1]=abs(a[1]-a[0]);
     for(i=2;i<n;i++)
     {
         ll cnt=0;
         mi=INT_MAX;
         for(j=1;j<=k;j++)
         {
             if((i-j)<0)
             {
                 break;
             }
             mi=min(mi,res[i-j]+abs(a[i]-a[i-j]));
         }
      res[i]=mi;
     }
     cout<<res[n-1]<<"\n";
}


Measured memory_bytes: 1792
def choose(N, M, cakes, a1, a2, a3):
    return sum(sorted([b1 * a1 + b2 * a2 + b3 * a3 for b1, b2, b3 in cakes], reverse=True)[:M])

def solve(N, M, cakes):
    return max(
            choose(N, M, cakes, 1, 1, 1),
            choose(N, M, cakes, 1, 1, -1),
            choose(N, M, cakes, 1, -1, 1),
            choose(N, M, cakes, 1, -1, -1),
            choose(N, M, cakes, -1, 1, 1),
            choose(N, M, cakes, -1, 1, -1),
            choose(N, M, cakes, -1, -1, 1),
            choose(N, M, cakes, -1, -1, -1)
    )

N, M = map(int, input().split())
# M choose N
# 0 <= M <= N <= 1000

cakes = [0]*N
for i in range(N):
    cakes[i] = [int(x) for x in input().split()]

print(solve(N, M, cakes))




Measured memory_bytes: 3300
#include <stdio.h>
 
int main(void){
    int a,b;
   char op;
        while(1){
          scanf("%d %c %d",&a,&op,&b);
           if( op =='?')
               break;
           else if( op == '+')
               printf("%d\n",a+b);
           else if( op == '-')
               printf("%d\n",a-b);
           else if( op == '*')
               printf("%d\n",a*b);
           else if( op == '/')
               printf("%d\n",a/b);
           }
              return 0;
}
      


Measured memory_bytes: 2680
//recurive code hai 0/1 knapsack ka
#include<bits/stdc++.h>
#include <cstdlib>

using namespace std;
#define int long long
#define fastIO  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ip(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define op(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define MAX 100001

int dp[MAX][1002];

int knapsack(int wt[],int val[],int capacity,int n){
    if(n == 0 || capacity == 0) return 0;

    if(wt[n-1] <= capacity){
        return max(val[n-1] + knapsack(wt,val,capacity-wt[n-1],n-1) , knapsack(wt,val,capacity,n-1));
    }

    else return knapsack(wt,val,capacity,n-1);
}

int memoization(int wt[],int val[],int capacity,int n){
    if(n == 0 || capacity == 0) return 0;

    if(dp[capacity][n-1] != -1) return dp[capacity][n-1];

    if(wt[n-1] <= capacity){
        dp[capacity][n-1] = max( (val[n-1] + memoization(wt,val,capacity-wt[n-1],n-1) ) , memoization(wt,val,capacity,n-1));
        return dp[capacity][n-1];
    }

    else{
        dp[capacity][n-1] = memoization(wt,val,capacity,n-1);
        return dp[capacity][n-1];
    }
} 

int bottom_up(int wt[],int val[],int capacity,int n){

    for(int i=0;i<n;i++){
        dp[i][0] = 0;
        dp[0][i] = 0;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=capacity;j++){

            if(wt[i-1] <= j){
                dp[j][i] = max(val[i-1] + dp[j - wt[i-1]][i-1], dp[j][i-1]);
            }
            else{
                dp[j][i] = dp[j][i-1];
            }
        }
    }

    return dp[capacity][n];
}


int32_t main(){

fastIO 
int n,capacity;
cin>>n>>capacity;

int wt[n],val[n];

for(int i=0;i<n;i++){
    cin>>wt[i];
    cin>>val[i];
}
// memset(dp,-1,sizeof(dp));
// cout<<knapsack(wt,val,capacity,n)<<endl;
// cout<<memoization(wt,val,capacity,n)<<endl;
memset(dp,0,sizeof(dp));
cout<<bottom_up(wt,val,capacity,n)<<endl;


}

Measured memory_bytes: 783104
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val ss = for (_ <- 1 to n) yield readLine

  def rec(s_list: List[String], c0: Int, c1: Int, c2: Int, c3: Int): List[Int] = s_list match {
    case Nil  => List(c0, c1, c2, c3)
    case list => list.head match {
      case "AC" => rec(list.tail, c0+1, c1, c2, c3)
      case "WA" => rec(list.tail, c0, c1+1, c2, c3)
      case "TLE" => rec(list.tail, c0, c1, c2+1, c3)
      case "RE" => rec(list.tail, c0, c1, c2, c3+1)
    }
  }
  val result = rec(ss.toList, 0, 0, 0, 0)
  println(s"AC x ${result(0)}")
  println(s"WA x ${result(1)}")
  println(s"TLE x ${result(2)}")
  println(s"RE x ${result(3)}")
}

Measured memory_bytes: 58696
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> student;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    student.push_back({a, b});
  }
  vector<pair<int, int>> point;
  REP(i, m) {
    int c, d;
    cin >> c >> d;
    point.push_back({c, d});
  }
  for (auto s: student) {
    int ans = 1;
    int distance_min = LINF;
    int idx = 1;
    for (auto p: point) {
      int distance = abs(s.first - p.first) + abs(s.second - p.second);
      if (distance < distance_min) {
        distance_min = distance;
        ans = idx;
      }
      ++idx;
    }
    cout << ans << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), S(N + 1, 0);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, N) S[i + 1] = S[i] + A[i];
    ll l = 0, h = 1e18;
    while (l + 1 < h) {
        ll m = (l + h) / 2, c = 0;
        rep(i, N) {
            c += A.end() - lower_bound(A.begin(), A.end(), m - A[i]);
            //cout << "m=" << m << " i=" << i << " c=" << c << "\n";
        }
        if (c >= M) l = m;
        else h = m;
    }
    //cout << "l=" << l << "\n";
    ll ans = 0, c = 0;
    rep(i, N) {
        int j = lower_bound(A.begin(), A.end(), l - A[i]) - A.begin();
        c += N - j;
        ans += S[N] - S[j] + A[i] * (N - j);
    }
    if (c > M) ans -= (c - M) * l;
    cout << ans << "\n";
    //rep(i, N + 1) cout << S[i] << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
void input(vector<auto>& a,int n);
int n;


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,10){
        REP(j,10){
            REP(k,10){
                int itr = 0;
                REP(l,n){
                    if(itr == 0){

                        if((int)s[l]-48 == i){
                            itr++;
                        }
                    }
                    else if(itr == 1){

                        if((int)s[l]-48 == j){
                            itr++;
                        }
                    }
                    else{
                        if((int)s[l]-48 == k){
                            ans++;
                            break;
                        }
                    }
                }
            }
        }
    }
    
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3676
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[1010000], P[1010000];
char p[1010000];
bool Odd(int K) {
	return P[n-1] == P[K] + P[n-1 - K];
}
int main() {
	int i;
	scanf("%d", &n);
	scanf("%s", p);
	P[0] = 0;
	for (i = 1; i <= n; i++) {
		int t = i;
		P[i] = P[i - 1];
		while (t % 2 == 0)t /= 2, P[i]++;
	}
	int chk = 0;
	for (i = 0; i < n; i++) {
		w[i] = p[i] - '1';
		if (w[i] == 1) {
			chk = 1;
		}
	}
	int ck = 0;
	for (i = 0; i < n; i++) {
		if (Odd(i))ck ^= w[i] % 2;
	}
	if (ck == 1) {
		puts("1");
		return 0;
	}
	if (chk) {
		puts("0");
		return 0;
	}
	for (i = 0; i < n; i++)w[i] /= 2;
	for (i = 0; i < n; i++) {
		if (Odd(i))ck ^= w[i];
	}
	if (ck == 1)puts("2");
	else puts("0");
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define start_routine int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define SPEED cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define endl '\n'
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int dp[500+1][500+1];
int ct[500+1][500+1];
int rec (int i, int j) {
  if (j < i) return 0;

  if (dp[i][j] < inf) return dp[i][j];
  if (i == j) return ct[i][j];
  dp[i][j] = ct[i][j] + rec(i + 1, j) + rec(i, j - 1) - rec(i + 1, j - 1);
  return dp[i][j];
}

signed main () {
  start_routine;
  // SPEED;
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif

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

  cout << a * b - a - b + 1;
  end_routine;
}


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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,k;

    cin>>n>>k;
    cout<<((int)(log10(n)/log10(k))+1)<<endl;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;

public class Main {

    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(st==null || !st.hasMoreElements()){
                try{
                    st=new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt(){
            return Integer.parseInt(next());
        }

        Long nextLong(){
            return Long.parseLong(next());
        }

        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str="";
            try{
                str=br.readLine();
            }
            catch(IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static String st(long sum,int a[],int m,int n){
        int b= (int) (sum/(4*m));
        if(sum%4!=0){
            b+=1;
        }
        int count=0;
        for(int i=0;i<n;i++){
            if(a[i]>=b){
                count++;
            }
        }
        if(count>=m){
           return "Yes";
        }else{
            return "No";
        }
    }
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n=in.nextInt();
        int m=in.nextInt();
        int sum=0;
        int a[]=new int [n];
        for(int i=0;i<n;i++){
            a[i]=in.nextInt();
            sum+=a[i];
        }
        System.out.println(st(sum,a,m,n));

    }
}



Measured memory_bytes: 22612
#include<stdio.h>
#include<math.h>
#define N 1000000
int prime[N];
int main(){
	int i,n,c,j;
	for(i=0;i<N;i++)prime[i]=1;
	prime[0] = prime[1] = 0;
	for(i=4;i<N;i+=2)prime[i]=0;
	for(i=3;i<N;i+=2){
		if(prime[i] == 0 )continue;
		for(j=i+i;j<N;j+=i)prime[j]=0;
	}
	for(;scanf("%d",&n)&&n;){
		c=0;
		for(i=0;i<=n/2;i++){
			if(prime[i]&&prime[n-i])c++;
		}
		printf("%d\n",c);
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> 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 issame(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.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];

	sort(all(a));
	sort(all(c));

	ll ans = 0;
	rep(i, n) {
		auto l = lower_bound(a.begin(), a.end(), b[i]);
		auto u = upper_bound(c.begin(), c.end(), b[i]);
		ans += (l - a.begin()) * (c.end() - u);
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long N = long.Parse(Console.ReadLine());
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long D = long.Parse(Console.ReadLine());
            long E = long.Parse(Console.ReadLine());
            

            long min = (long)(1e15+1);
            min = Math.Min(A,B);
            min = Math.Min(min,C);
            min = Math.Min(min,D);
            min = Math.Min(min,E);

            Console.WriteLine((long)Math.Ceiling((double)N/min)+4);

        }
    }
}


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

int main(){
  string S; cin>>S; int N;
  for(int i=0;i<3;i++){
    char c=S.at(i);
    if(c=='a'){
      N++;
    }else if(c=='b'){
      N+=10;
    }else
      N+=100;
  }
  if(N==111){
    cout <<"Yes";
  }else
    cout <<"No"<<endl;
}

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

int main(){
    ll N; cin>>N;
    vector<ll> A(N),a(N);
    ll sum=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
        sum%=mod;
    }
    ll ans=0;
    for(ll i=0;i<N-1;i++){
        sum -=A[i];
        if(sum<0)  sum+=mod;

        ans+=A[i]*sum;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6380
use std::io::{ stdin, BufRead };

fn itp1_1_d<R>(input: &mut R) -> String
  where R: BufRead
{
  let mut f = my::AsciiReader::new(input, 8);
  let mut sec = f.read_int_until_lf::<u32>();
  let mut min  = sec / 60;
  let hour = min / 60;
  sec %= 60;
  min %= 60;

  format!("{}:{}:{}\n", hour, min, sec)
}

fn main() {
  let stdin = stdin();
  print!("{}", itp1_1_d(&mut stdin.lock()));
}

mod my {
  use std::io::BufRead;
  use std::fmt::Debug;
  use std::ops::{ Add, Sub, Mul };

  const SP: u8 = b' ';
  const LF: u8 = b'\n';

  #[derive(Debug)]
  pub struct AsciiReader<R> {
    input : R,
    buf   : Vec<u8>,
  }

  impl<R> AsciiReader<R>
    where R: BufRead
  {
    #[allow(dead_code)]
    pub fn new(input: R, capa: usize) -> Self {
      AsciiReader {
        input : input,
        buf   : Vec::with_capacity(capa),
      }
    }

    fn read_until(&mut self, delim: u8) -> usize {
      self.buf.clear();
      self.input.read_until(delim, &mut self.buf).unwrap()
    }

    // ignore sign(+-) uint only
    fn parse_int<T>(&self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      let len = self.buf.len();
      let mut i = 0;
      let mut n = T::default();

      while i < len && b'0' <= self.buf[i] && self.buf[i] <= b'9' {
        n = (n * T::from(10)) + T::from(self.buf[i] - b'0');
        i += 1;
      }
      n
    }

    #[allow(dead_code)]
    pub fn read_int_until_delim<T>(&mut self, delim: u8) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_until(delim);
      self.parse_int()
    }

    // s -> n
    #[allow(dead_code)]
    pub fn read_int_until_lf<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_int_until_delim(LF)
    }

    // s -> n
    #[allow(dead_code)]
    pub fn read_int_until_sp<T>(&mut self) -> T
      where T: Add<Output=T> +
               Sub<Output=T> +
               Mul<Output=T> +
               Default +
               From<u8> +
               Debug
    {
      self.read_int_until_delim(SP)
    }
  }
}



Measured memory_bytes: 5016
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

h,w = map(int,input().split())
TRANS = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(h)]

#print(TRANS)
#print(A)

#warshall_floyd  kijの順番に注意!!
for k in range(10):  #kは中継
  for i in range(10):  # iは始点
    for j in range(10):  #jは目的地
      if (TRANS[i][k] != float('inf')) and (TRANS[i][k] != float('inf')):
        TRANS[i][j] = min(TRANS[i][j],TRANS[i][k] + TRANS[k][j])
#print(TRANS)

ans = 0
for i in range(h):
  for j in range(w):
    a = A[i][j]
    if a==-1:
      continue
    else:
      ans += TRANS[a][1]

print(ans)

Measured memory_bytes: 74568
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n,k;
  cin >>n>>k;
  vl h(n);
  rep(i,n) cin>>h[i];
  sort(all(h));
  ll ans = 0;
  rep(i,n-k) ans += h[i];
  cout <<ans<<endl;
  
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
char s[maxn];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s+1;
	int n=strlen(s+1);
	int flag=1;
	for(int i=1;i<=n;i+=2){
		if(s[i]!='h'||s[i+1]!='i') flag=0;
	}
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int cnt[100];
signed main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int a; scanf("%d", &a);
		a = min(a, 3200);
		cnt[a / 400]++;
	}
	int a = 0;
	rep(i, 8) {
		if (cnt[i])a++;
	}
	if (a) {
		printf("%d", a);
	}
	else if (cnt[8]) {
		printf("%d", 1);
	}
	else printf("0");
	printf(" %d\n", a + cnt[8]);
}

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

int s[10010];

int main(){
  int N; cin >> N;
  for( int i = 0; i < N; i++ ){
    cin >> s[i];
  }
  int ans = 0;
  int q; cin >> q;
  for( int i = 0; i < q; i++ ){
    int t; cin >> t;
    for( int j = 0; j < N; j++ ){
      if( t == s[j] ){
	ans++;
	break;
      }
    }
  }

  cout << ans << endl;
}



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

int n, l, r, A[4000];

signed main(){
  
  while(1){
    
    cin>>n>>l>>r;
    if( !n && !l && !r ) break;
    
    for(int i=1;i<=n;i++) cin>>A[i];
    
    int ans = 0;
    
    for(int num=l;num<=r;num++){
      
      int idx = 0;
      
      for(int i=1;i<=n;i++){
	
	if( num % A[i] == 0 ){
	  idx = i;
	  break;
	}
	
      }
      
      if( idx ) ans += idx % 2;
      else ans += n % 2 == 0;
      
    }
    
    cout<<ans<<endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define N 300050
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
int n,m,ar[N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n, abs(n-k));
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int W, H, N; cin >> W >> H >> N;
    int x1 = 0, x2 = W, y1 = 0, y2 = H;
    for(int i = 0, x, y, a; i < N; i++) {
        cin >> x >> y >> a;
        if(a == 1) x1 = max(x1, x);
        else if(a == 2) x2 = min(x2, x);
        else if(a == 3) y1 = max(y1, y);
        else if(a == 4) y2 = min(y2, y);
        if(x2 < x1 || y2 < y1) {
            cout << 0;
            return 0;
        }
    }
    cout << (x2 - x1) * (y2 - y1);
}

Measured memory_bytes: 256
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (100006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,A[MAXN],ans;
vector<ll>sumf[MAXN],sumb[MAXN];
void addf(ll c) {
	if(sumf[c].size())return;
	ll sum=0;
	for(ll i=0;i<n;i+=c){
		sum+=A[i];sumf[c].pb(sum);
	}
	return;
}
void addb(ll c) {
	if(sumb[c].size())return;
	ll sum=0;
	for(ll i=n-1;i>=0;i-=c){
		sum+=A[i];sumb[c].pb(sum);
	}
	return;
}
void solve(ll a, ll b, ll k) {
	if(b>=a||b<=0)return; 
	ll C=a-b; if((a%C==0&&a/C<=k))return;
	addf(C); // k
	addb(C); // k
	// cerr<<k<<'\n';// cerr<<sumf[C][k-1]<<' '<<sumb[C][k]<<'\n';
	ans=max(ans,sumf[C][k]+sumb[C][k]);
	return;
}
int main()
{	
	FAST
	cin>>n;
	FOR(i,0,n)cin>>A[i];assert(A[0]==0&&A[n-1]==0);
	FOR(a,1,n+1){
		for(ll k=1;k*k<=(n-1-a);++k){
			if((n-1-a)%k)continue;
			solve(a,a-(n-1-a)/k,k);
			solve(a,a-(n-1-a)/((n-1-a)/k),((n-1-a)/k));
		}
	}
	cout<<ans;
}


Measured memory_bytes: 30196
N = int(input())
H = list(map(int, input().split()))

for i in range(len(H))[-2::-1]:
    if H[i]>H[i+1]:
        H[i]-=1

result=True
for i in range(len(H)-1):
    if H[i]>H[i+1]:
        result=False

print('Yes' if result==True else 'No')

Measured memory_bytes: 14396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> taro(n);
    vector<string> hanako(n);
    int taro_point = 0;
    int hanako_point = 0;
    for (int i = 0; i < n; i++) {
        cin >> taro[i] >> hanako[i];
    }
    for(int i = 0; i < n; i++) {
        if(taro[i] == hanako[i]) {
            taro_point++;
            hanako_point++;
        } else if(taro[i] > hanako[i]) {
            taro_point += 3;
        } else {
            hanako_point += 3;
        }
    }
    cout << taro_point << " "  << hanako_point << endl;    
    return 0;
}


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

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

int main() {
	int n, x, t; cin >> n >> x >> t;
	cout << (n + x  - 1) / x * t << endl;
	return 0;
}


Measured memory_bytes: 3632
def find(x):
    global set_list
    if set_list[x] == x:
        return x
    result = set_list[x] = find(set_list[x])
    return result


n, q = map(int, input().split())
set_list = list(range(n))

while q:
    op, x, y = map(int, input().split())
    if op:
        print(1 if find(x) == find(y) else 0)
    else:
        set_list[find(y)] = find(x)
    q -= 1

Measured memory_bytes: 8012
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    s = set()
    for i in range(N):
        s.add(A[i])

    if N == len(s):
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,c,k,ans=0;
	deque<ll> d;
	cin >> n >> c >> k;
	vll t(n);
	rep(i,n) cin >> t[i];
	sort(all(t));
	rep(i,n) d.pb(t[i]);
	while(!d.empty()){
		ll tmp=d.front();
		ll cnt=1;
		d.pop_front();
		while(d.front()<=tmp+k && !d.empty() && cnt<c){
			cnt++;
			d.pop_front();
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
const int MAXN=1010;
char m[MAXN][MAXN];
int dp[MAXN][MAXN];
int ddp(int i,int j){
	if(dp[i][j]!=-1) return dp[i][j];
	return dp[i][j]=(ddp(i+1,j)+ddp(i,j+1))%1000000007;
}
int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='.') dp[i][j]=-1;
			if(c=='#') dp[i][j]=0;
		}
	}
	dp[h][w]=1;
	int resp=ddp(1,1);
	printf("%d",resp);
}

Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
        long long N;
        cin >> N;
        long long min = 9999999999999;
        for(long long i = sqrt(N);i > 0;i--){
            if(N % i == 0 && N / i + i < min){min = N / i + i;}
        }
        
        cout << min - 2;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<cstdint>
#include<cstddef>
#include<algorithm>
#include<vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<int, int>;
int n, m;
vector<vector<int>> dist(100, vector<int>(100, 1e9));

void warshall_froyd() {
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >> n >> m;
    rep(i, n) {
        rep(j, n) {
            if (i == j)dist[i][j] = 0;
        }
    }
        vector<int> a(m),b(m),c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        dist[a[i]][b[i]] = min(c[i],dist[a[i]][b[i]]);
        dist[b[i]][a[i]] = min(c[i],dist[a[i]][b[i]]);

    }
    warshall_froyd();
    int ans = 0;
    rep(i,m){
      if(c[i] > dist[a[i]][b[i]])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3704
package main

import "fmt"

func main() {
  var n, m, c int
  fmt.Scan(&n, &m, &c)
  b := make([]int, m)
  for i := 0; i < m; i++ {
    fmt.Scan(&b[i])
  }
  a := make([]int, m)
  count := 0
  for i := 0; i < n; i++ {
    sum := c
    for j := 0; j < m; j++ {
      fmt.Scan(&a[j])
      sum += a[j] * b[j]
    }
    if sum > 0 {
      count++
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type runes []rune

func (rs runes) Len() int           { return len(rs) }
func (rs runes) Swap(i, j int)      { rs[i], rs[j] = rs[j], rs[i] }
func (rs runes) Less(i, j int) bool { return rs[i] < rs[j] }

func solve() {
	n := getInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		s := getRunes()
		sort.Sort(runes(s))
		m[string(s)]++
	}

	ans := 0
	for _, num := range m {
		ans += (num - 1) * num / 2
	}
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,w=1;
	cin>>n;
	for(int i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)
		{
			int x=i,y=n/i;
	     	while(y>=10)
     	    {
	    	    y/=10;
	    	    w++;
    	    }
	        cout<<w<<endl;
	        break;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int k,n;cin>>k>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  vector<int> sub(n);
  sub[0]=k+a[0]-a[n-1];
  rep1(i,n-1){
    sub[i]=a[i]-a[i-1];
  }
  sort(sub.begin(),sub.end());
  int res=k-sub[n-1];
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int,int>pii;
//typedef long long ll;
ll n,x,mn=(1LL<<62);
int main(){
	cin>>n;
	for(ll i=1;i<6;i++)cin>>x,mn=min(mn,x);
	if(n%mn==0)n/=mn;
	else n=n/mn+1;
	cout<<n+4<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, A = Z(), ZZ()
    if 0 in A:
        print(0)
        return
    output = 1
    for a in A:
        output *= a
        if output > 10 ** 18:
            print(-1)
            break
    else: print(output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 21700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  ll n;
  cin>>n;
  ll ans=0;
  while(n>=2){
    ans+=min(q*8,min(h*4,min(s*2,d)));
    n-=2;
  }
  while(n>0){
    ans+=min(q*4,min(h*2,s));
    n-=1;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
require 'set'

N, M = STDIN.gets.chomp.split(' ').map(&:to_i)
H = STDIN.gets.chomp.split(' ').map(&:to_i)
A, B = (1..M).map {|i| STDIN.gets.split.map(&:to_i) }.transpose

o = Set.new
(1..N).each { |i| o.add(i) }

0.upto(M - 1) do |i|
  case
  when H[A[i] - 1] > H[B[i] - 1]
    o.delete(B[i])
  when H[A[i] - 1] < H[B[i] - 1]
    o.delete(A[i])
  else
    o.delete(A[i])
    o.delete(B[i])
  end
end

print o.size


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n[3];
	REP(i,3){
		cin >> n[i];
	}
	SSORT(n,3);
	cout << n[0]*10+n[1]+n[2] << endl;
	
}

Measured memory_bytes: 764
def main():
  n = int(input())
  arr = list(map(int, input().split()))
  
  
  if 0 in arr:
    print(0)
    return 0
  res = arr[0]
  for a in arr[1:]:
    res *= a
    if res > 1000000000000000000:
      print("-1")
      return 0

  print(res)

main()

Measured memory_bytes: 84648
S=str(input())
if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
      print("Yes")
elif S[0]==S[2] and S[0]!=S[1] and S[1]==S[3]:
     print("Yes")
elif S[0]==S[3] and S[0]!=S[1] and S[1]==S[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader rd = new Reader();        
        int[] a = rd.ii();
      	int N = a[0],
      		Q = a[1];
      	String S = rd.s();
      	int[] l = new int[Q],
      	      r = new int[Q];
      	for(int i = 0; i < Q; i++){
        	a = rd.ii();
          	l[i] = a[0];
          	r[i] = a[1];
        }
      	char[] letter = S.toCharArray();
        int[] ac = new int[N+1];
        ac[0] = 0;
        for(int i = 1; i < N; i++){
            ac[i] = ac[i-1];
            if(letter[i-1] == 'A' && letter[i] == 'C') ac[i]++;
        }
      	for(int i = 0; i < Q; i++){
            print(ac[r[i]-1] - ac[l[i]-1]);
        }
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static int max(int[] ii){
        int max = ii[0];
        for(int i : ii) if(max < i) max = i;
        return max;
    }
    static int min(int[] ii){
        int min = ii[0];
        for(int i : ii) if(i < min) min = i;
        return min;
    }
    static long max(long[] ll){
        long max = ll[0];
        for(long l : ll) if(max < l) max = l;     
        return max;
    }
    static long min(long[] ll){
        long min = ll[0];
        for(long l : ll) if(l < min) min = l;
        return min;
    }
    static double max(double[] dd){
        double max = dd[0];
        for(double d : dd) if(max < d) max = d;
        return max;
    }
    static double min(double[] dd){
        double min = dd[0];
        for(double d : dd) if(d < min) min = d;
        return min;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int j = 0; j < N; j++) ii[j] = i();
            return ii;
        }
        long l() throws IOException{
            return Long.parseLong(readLine());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int j = 0; j < N; j++) ll[j] = i();            
            return ll;
        }
    }
}

Measured memory_bytes: 59168
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  ll N, C;
  cin >> N >> C;
  vector<ll> x(N + 2), v(N + 2);
  for (ll i = 1; i <= N; i++) {
    cin >> x[i] >> v[i];
  }
  x[0] = 0;
  x[N + 1] = C;
  
  vector<vector<ll>> dp(2, vector<ll>(100010, 0));
  ll cal = 0;
  for (ll i = 1; i <= N; i++) {
    cal -= x[i] - x[i - 1];
    cal += v[i];
    dp[0][i] = max(dp[0][i - 1], cal);
  }
  cal = 0;
  for (ll i = N; i >= 1; i--) {
    cal -= x[i + 1] - x[i];
    cal += v[i];
    dp[1][i] = max(dp[1][i + 1], cal);
  }
  
  ll maxcal = 0;
  for (int i = 0; i <= N; i++) {
    cal = dp[0][i] + dp[1][i + 1] - x[i];
    maxcal = max(maxcal, cal);
    
    cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
    maxcal = max(maxcal, cal);
  }
  cout << maxcal << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> colors(n);
    int sum = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
        colors[i] = (int)(s[i] - '0');
    }
    for (int i = 0; i < n; i++)
    {
        if (i == 0)
        {
            continue;
        }
        if (colors[i - 1] != colors[i])
        {
            colors.erase(colors.begin() + i);
            colors.erase(colors.begin() + i - 1);
            i = 0;
            n -= 2;
            ans += 2;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void solve(ll N, ll A, ll B, ll C, ll D, ll E) {
  ll bn = min({A, B, C, D, E}); // bottle neck
  cout << ((N - 1) / bn + 5) << endl;
}

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

  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;

  solve(N, A, B, C, D, E);

  return 0;
}


Measured memory_bytes: 3540
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var INF = 1e9;

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = Array(m);
  var c = Array(m);
  for(var i = 0; i < m; i++){
    a[i] = o.a();
    var b = o.a(), t = 0;
    for(var j = 0; j < b; j++){
      var ci = o.a();
      t += 1 << ci-1;
    }
    c[i] = t;
  }
  var dp = xArray(INF,1<<n);
  dp[0] = 0;
  for(var i = 0; i < 1<<n; i++){
    if(dp[i] === INF)continue;
    for(var j = 0; j < m; j++){
      var t = i | c[j];
      if(dp[i] + a[j] < dp[t])dp[t] = dp[i] + a[j];
    }
  }
  return dp[(1<<n)-1] === INF ? -1 : dp[(1<<n)-1];
}

Measured memory_bytes: 7836
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 2000005;
const int MOD = 998244353 ;




void solve(){
    int a[10] = {0};
    f(i,5){
        int k;
        cin>>k;
        a[k] = 1;
    }
    ff(i,5){
        if(a[i] == 0){cout<<i;return ;}
    }
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

using namespace std;

using int64 = long long;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}
template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int64 a, b;
  cin >> a >> b;
  int64 ans = INT64_MAX;
  if (a <= b) {
    UpdateMin(ans, b - a);
  }
  if (a <= -b) {
    UpdateMin(ans, -b - a + 1);
  }
  if (-a <= b) {
    UpdateMin(ans, b - (-a) + 1);
  }
  if (-a <= -b) {
    UpdateMin(ans, -b - (-a) + 2);
  }
  cout << ans << endl;
}

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

int main()
{
	int dice1[6], dice2[6];
	int n;
	for (n = 0; n < 6; n++)
	{
		scanf("%d", &dice1[n]);
	}
	for (n = 0; n < 6; n++)
	{
		scanf("%d", &dice2[n]);
	}
	int i = 18, tmp, j = 4;
	while (i--)
	{
		if (dice1[0] == dice2[0]
			&& dice1[1] == dice2[1]
			&& dice1[2] == dice2[2]
			&& dice1[3] == dice2[3]
			&& dice1[4] == dice2[4]
			&& dice1[5] == dice2[5])
		{
			printf("Yes\n");
			return 0;
		}
		while (j--)
		{
			tmp = dice1[1];
			dice1[1] = dice1[2];
			dice1[2] = dice1[4];
			dice1[4] = dice1[3];
			dice1[3] = tmp;
			if (dice1[0] == dice2[0]
				&& dice1[1] == dice2[1]
				&& dice1[2] == dice2[2]
				&& dice1[3] == dice2[3]
				&& dice1[4] == dice2[4]
				&& dice1[5] == dice2[5])
			{
				printf("Yes\n");
				return 0;
			}
		}
		j = 4;
		if (i % 2 == 0)
		{
			tmp = dice1[0];
			dice1[0] = dice1[1];
			dice1[1] = dice1[5];
			dice1[5] = dice1[4];
			dice1[4] = tmp;
			if (dice1[0] == dice2[0]
				&& dice1[1] == dice2[1]
				&& dice1[2] == dice2[2]
				&& dice1[3] == dice2[3]
				&& dice1[4] == dice2[4]
				&& dice1[5] == dice2[5])
			{
				printf("Yes\n");
				return 0;
			}
		}
		if (i % 2 == 1)
		{
			tmp = dice1[0];
			dice1[0] = dice1[2];
			dice1[2] = dice1[5];
			dice1[5] = dice1[3];
			dice1[3] = tmp;
			if (dice1[0] == dice2[0]
				&& dice1[1] == dice2[1]
				&& dice1[2] == dice2[2]
				&& dice1[3] == dice2[3]
				&& dice1[4] == dice2[4]
				&& dice1[5] == dice2[5])
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2700