akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
    int u,v;
    ll c;
    edge(){}
    edge(int uu,int vv,ll cc){
        u=uu;
        v=vv;
        c=cc;
    }

    bool operator<(const edge &e)const{
        return c<e.c;
    }
};

int cur=0;

struct uftree{
    int par[200005];
    priority_queue<int,vector<int>,greater<int> > que[200005];
    ll sum[200005];
    uftree(){
    }
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            while(que[i].size()){
                que[i].pop();
            }
            sum[i]=0;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }

    void insert(int x,ll y){
        x=find(x);
        //printf("ins %lld %lld\n",sum[x],y);
        if(sum[x]<y){
            que[x].push(y);
            cur++;
        }
    }

    void unite(int x,int y,ll c){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(que[x].size()<que[y].size()){
            par[x]=y;
            while(que[x].size()){
                que[y].push(que[x].top());
                que[x].pop();
            }
            sum[y]+=sum[x];
            que[y].push(c);
            cur++;
            if(sum[y]<c)return;
            while(que[y].size() && que[y].top()<=sum[y]){
                que[y].pop();
                cur--;
            }
        }else{
            par[y]=x;
            while(que[y].size()){
                que[x].push(que[y].top());
                que[y].pop();
            }
            sum[x]+=sum[y];
            que[x].push(c);
            cur++;
            if(sum[x]<c)return;
            while(que[x].size() && que[x].top()<=sum[x]){
                que[x].pop();
                cur--;
            }
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};


uftree uf;
int n,m;
ll x[100005];
edge e[100005];
vector<edge> ev;

int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%lld",&x[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d%d%lld",&e[i].u,&e[i].v,&e[i].c);
        e[i].u--;
        e[i].v--;
    }
    sort(e,e+m);
    int ans=0;
    uf.init(n);
    for(int i=0;i<n;i++){
        uf.sum[i]=x[i];
    }
    for(int i=0;i<m;i++){
        if(uf.same(e[i].u,e[i].v)){
            uf.insert(uf.find(e[i].u),e[i].c);
            ans=max(ans,i+1-cur);
            //printf("%d\n",ans);
            continue;
        }
        uf.unite(e[i].u,e[i].v,e[i].c);
        ans=max(ans,i+1-cur);
        //printf("%d %d\n",ans,cur);
    }
    printf("%d\n",m-ans);
    return 0;
}

Measured memory_bytes: 14080
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var a int
	var sum, max, min int
	sum = 0
	var i int
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if i == 0 {
			max = a
			min = a
		} else if a > max {
			max = a
		} else if a < min {
			min = a
		}
		sum += a

	}
	fmt.Println(min, max, sum)
}


Measured memory_bytes: 1692
#include <stdio.h>
int main(void)
{
int H ,W;
int i, j;
while(1){
scanf("%d %d" ,&H ,&W);
if(H == 0 && W == 0) break;
for ( i = 0; i < H; i++ ){
for ( j = 0; j < W; j++ ){
if(j==0||j==W-1||i==0||i==H-1){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
puts("");
}
return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int s, sum = 0;
	while (cin >> s) {
		sum += s;
	}
	cout << sum / 60 % 60 << endl << sum % 60 << endl;

	return 0;
}

Measured memory_bytes: 3024
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int p[] = new int[N];
    for(int i = 0; i<N;i++){
      p[i] = Integer.parseInt(sc.next());   
    }
    Arrays.sort(p);
    int sum = 0;
    for(int i = 0; i<K;i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
}


// 1000000000000000001

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

using namespace std;

int main() {
	long long int N, T;
	cin >> N >> T;
	vector<long long int>A( N );
	long long int M = LLONG_MIN / 6, count = 0, mi = LLONG_MAX;
	for( size_t i = 0; i < N; i++ ) {
		cin >> A[i];
		if( A[i] - mi > M ) {
			M = A[i] - mi;
			count = 1;
		} else if( A[i] - mi == M ) {
			count++;
		}
		mi = min( A[i], mi );

	}
	//cout << M << endl;
	if( count == 0 || T < 2 ) {
		cout << 0 << endl;
	} else {
		cout << count << endl;
	}
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int a[20], b[20];

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    int N, M, K; cin >> N >> M >> K;

    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    int ma = 0;

    rep(bit, 1<<N) {
        int cnt = 0;
        vpii choice;
        rep(i, N) {
            if (bit >> i & 1) cnt += 1, choice.PB(pii(a[i], b[i]));
        }

        if  (cnt != K) continue;

        sort(all(choice), greater<pii>());

        int sum = 0;

        int m = M;

        rep(i, K) {
            sum += choice[i].fst * min(m, choice[i].scd);
            m -= min(m, choice[i].scd);
        }

        sum += m;

        chmax(ma, sum);
    }

    cout << ma << endl;
}

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


int main() {
int N, M;
int work[2000010];
cin >> N >> M;
for(int i = 0; i < M; i++){
    cin >> work[i];
    N -= work[i];
}
if(N < 0) N = -1;

cout << N << endl;


}



Measured memory_bytes: 3652
import itertools

ABCDE = [int(input()) for _ in range(5)]

def round_up_10(x):
    if x%10 == 0:
        return x
    else:
        return x - (x%10) + 10

# 総当り
ans = float("inf")
order = list(itertools.permutations(ABCDE))

for o in order:
    current_time = 0
    for i in range(5):
        current_time += o[i]
        if i == 4:
            break
        current_time = round_up_10(current_time)
    ans = min(ans, current_time)
    
print(ans)

Measured memory_bytes: 3064
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Array
import Data.Maybe
import Data.List

type S = Array Int Int

-- 下限境界 (Array 付き)
lowerBoundA :: Array Int Int -> (Int, Int) -> Int -> Int
lowerBoundA arr (from, to) target
    | from == to = from
    | mValue >= target = lowerBoundA arr (from, mid) target
    | mValue < target = lowerBoundA arr (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = arr ! mid

-- 上限境界 (Array 付き)
upperBoundA :: Array Int Int -> (Int, Int) -> Int -> Int
upperBoundA arr (from, to) target
    | from == to = from
    | mValue > target = upperBoundA arr (from, mid) target
    | mValue <= target = upperBoundA arr (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = arr ! mid

solve :: S -> S -> S -> Int -> Int -> Int 
solve xs ys zs n i
  | i >= n = 0
  | otherwise = res + solve xs ys zs n (i+1)
    where
      res = lb * (n - ub)
      y = ys ! i
      lb = lowerBoundA xs (0,n) y
      ub = upperBoundA zs (0,n) y

main = do
  n <- readLn :: IO Int
  xs <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  ys <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  zs <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  print $ solve xs ys zs n 0

Measured memory_bytes: 30076
#include <stdio.h>
#include <stdlib.h>

#define NIL NULL

struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node, int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);


int main() {
  int n, i, j, x, count=0, *state;
  char com[20];
  Node t;
  
  scanf( "%d" , &n );
  state = malloc(n * sizeof(int));

  for ( i=0; i<n; i++ ) {
    scanf( "%s" , com );
    
    if ( com[0] == 'f' ) {
      scanf( "%d" , &x );
      t = treeSearch(root, x);
      if ( t != NIL ) state[count] = 1;
      else state[count] = 0;
      count++;
    }
    
    else if ( com[0] == 'i' ) {
      scanf( "%d" , &x );
      insert(x);
    }
    
    else if ( com[0] == 'p' ) {
      for ( j=0; j<count; j++ ) {
	if ( state[j] == 1 ) printf( "yes\n" );
	else printf( "no\n" );
      }
      count = 0;
      inorder(root);
      printf( "\n" );
      preorder(root);
      printf( "\n" );
    }
    
    else if ( com[0] == 'd' ) {
      scanf( "%d" , &x );
      treeDelete(treeSearch(root, x));
    }
  }
  for ( j=0; j<count; j++ ) {
    if ( state[j] == 1 ) printf( "yes\n" );
    else printf( "no\n" );
  }
  
  return 0;
}


Node treeMinimum(Node x){
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while ( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if ( (u == NIL) || (k == u->key) ) return u;
  if ( k < u->key ) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if ( x->right != NIL ) return treeMinimum(x->right); // case 1
  y = x->parent;
  while ( (y != NIL) && (x == y->right) ) {
    x = y;
    y = y->parent;
  }
  return y; // case 2
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( (z->left == NIL) || (z->right == NIL) ) y = z;
  else y = treeSuccessor(z);

  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;
  
  if ( y->parent == NIL ) root = x;
  else if ( y == y->parent->left ) y->parent->left = x;
  else y->parent->right = x;
  
  if ( y != z ) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) x = x->left;
    else x = x->right;
    z->parent = y;
  }
  if ( y == NIL ) root = z; // Tree is empty
  else if ( z->key < y->key ) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if ( u != NIL ) {
    inorder(u->left);
    printf( " %d" , u->key );
    inorder(u->right);
  }
}

void preorder(Node u){
  if ( u != NIL ) {
    printf( " %d" , u->key );
    preorder(u->left);
    preorder(u->right);
  }
}



Measured memory_bytes: 20928
import java.util.*;
public class Main {

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

      Map<Integer, Integer> freq = new HashMap<>();
      for(int i = 0; i < n; i++) {
      	int num = sc.nextInt();
      	freq.put(num, freq.getOrDefault(num, 0) + 1);
      }

      int cnt = 0;
      loop:
      for(Map.Entry<Integer, Integer> entry : freq.entrySet()) {
      	if(entry.getValue() > 1) continue;
      	int num = entry.getKey();
      	for(int i = 1; i * i <= num && i <= num / i; i++) {
      		if(num % i == 0) {
      			int a = i;
      			int b = (num / i);
      			if(a != num && freq.containsKey(a) || b != num && freq.containsKey(b))
      				continue loop;
      		}
      	}
      	cnt++;
      }
      System.out.println(cnt);
      sc.close();
  }
}

Measured memory_bytes: 62816
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> G[100010];
bool used[100010];
int dp[2][100010];

int dfs(int x, bool free_c) {
    if (dp[free_c][x] != 0) return dp[free_c][x];
    int B = free_c;
    int W = 1;
    used[x] = true;
    for(auto next : G[x]) {
        if (used[next]) continue;
        if (free_c) 
            B = B * dfs(next, false) % mod;
        W = W * dfs(next, true) % mod;
    }
    used[x] = false;
    //cout << x << ":" << free_c << "->" << B << " " << W << endl;
    return dp[free_c][x] = (B + W) % mod;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    cout << dfs(0, true) << endl;
    //rep(i, N) cout << dp[0][i] << " " << dp[1][i] << endl; 
    return 0;
}


Measured memory_bytes: 15744
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
#from __future__ import print_function, division    #while using python2
# from itertools import accumulate
# from collections import defaultdict, Counter

def modinv(n,p):
    return pow(n,p-2,p)

def main():
    #sys.stdin = open('input.txt', 'r')
    # sys.stdout = open('output.txt', 'w')

    n, x, m = [int(x) for x in input().split()]
    series = []
    prev = set()
    repeat = []
    ans = 0
    y = x
    repeat_key = -1
    while True:
        if y not in prev:
            prev.add(y)
            series.append(y)
            y = (y * y) % m
        else:
            break

    repeat_key = y
    while True:
        repeat.append(y)
        y = (y * y) % m
        if y == repeat_key:
            break
    # print(series)
    # print(repeat)

    if n <= len(series):
        print(sum(series[:n]))
    else:
        n -= len(series)
        s1 = sum(series)
        s2 = sum(repeat) * (n//len(repeat))

        n %= len(repeat)
        print(s1 + s2 + sum(repeat[:n]))



#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

if __name__ == '__main__':
   main()


Measured memory_bytes: 81068
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i64; n],
    }

    let ans = solve(
        0,
        0,
        k,
        &h,
        &mut vec![vec![vec![None; k + 1]; n + 2]; n + 1],
    );

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

fn solve(
    cur: usize,
    prev: usize,
    k: usize,
    h: &[i64],
    tbl: &mut Vec<Vec<Vec<Option<i64>>>>,
) -> i64 {
    if cur == h.len() {
        return 0;
    }

    if let Some(ret) = tbl[cur][prev][k] {
        return ret;
    }

    let mut ret = solve(cur + 1, cur + 1, k, h, tbl)
        + max(0, h[cur] - if prev == 0 { 0 } else { h[prev - 1] });

    if k >= 1 {
        ret = min(ret, solve(cur + 1, prev, k - 1, h, tbl));
    }

    tbl[cur][prev][k] = Some(ret);
    ret
}


Measured memory_bytes: 471292
import sys
input = sys.stdin.readline

import heapq
N = int(input())
tasks = []
heapq.heapify(tasks)
broke = False
cum = 0
for i in range(N):
    A,B = (int(x) for x in input().split())
    if A > B:
        print('No')
        broke = True
        break
    else:
        heapq.heappush(tasks,(B,A))
if broke == False:
    for i in range(N):
        temp = heapq.heappop(tasks)
        cum += temp[1]
        if cum > temp[0]:
            print('No')
            broke = True
            break
    if broke == False:
        print('Yes')

Measured memory_bytes: 28776
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  ll ans = 0, last = 0;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (a < last) ans += last - a;
    last = max(last, a);
  }
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;
using namespace std;
#define X 256
int h,n;
bool d[10010][4];
int dp[100010][X];
int main(){
	cin>>h>>n;
	memset(d,0,sizeof(d));
	lol(i,n){
		int x,y;cin>>x>>y;
		d[y+1][x]=1;
	}
	lol(i,4)d[0][i]=1;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	lol(i,h+1){
		lol(j,X){
			if(dp[i][j]==-1)continue;
			int k=j*16%X;
			lol(r,4)if(d[i][r]==1)k+=(1<<r);
			Max(dp[i+1][k],dp[i][j]);
			bool t[8];
			lol(r,8)t[r]=(k%(2<<r)>=(1<<r));
			if(t[0]+t[1]+t[4]+t[5]==0){
				Max(dp[i+1][k+51],dp[i][j]+1);
			}
			if(t[1]+t[2]+t[5]+t[6]==0){
				Max(dp[i+1][k+102],dp[i][j]+1);
			}
			if(t[2]+t[3]+t[6]+t[7]==0){
				Max(dp[i+1][k+204],dp[i][j]+1);
			}
			if(k==0){
				Max(dp[i+1][255],dp[i][j]+2);
			}
		}
	}
	int ans=0;
	lol(i,X)Max(ans,dp[h+1][i]);
	cout<<ans<<endl;
	return 0;
}



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

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

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1272
import math

while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    z = 0
    while z <= e:
        z3 = z ** 3
        if z3 > e:
            break
        y = int(math.sqrt(e - z3))
        x = e - y ** 2 - z3
        m = min(m, x + y + z)
        z += 1
    print(m)



Measured memory_bytes: 5672
n = int(input())
a = list(map(int, input().split()))

if n == 1:
    if a[0] == 0:
        print('1')
    else:
        print('0')
    exit()

ans = 0
b = [0 for _  in range(n)]
b[0] = a[0]
for i in range(1, n):
    b[i] = a[i] + b[i - 1]

b = sorted(b)

i = 0
while i < n:
    x = 1
    i += 1
    while i < n:
        if b[i] != b[i - 1]:
            break
        else:
            x += 1
            i += 1
    if b[i - 1] == 0:
        ans += (x + 1) * x // 2
    else:
        ans += x * (x - 1) // 2

print(ans)


Measured memory_bytes: 25976
import math
n,m = map(int,input().split())

A = [int(input()) for i in range(n)]
B = [int(input()) for i in range(m)]
v = [0 for i in range(n)]

for i in range(m):
    for j in range(n):
        if B[i] >= A[j]:
            v[j] += 1
            break

print(v.index(max(v))+1)


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

int main(){
  string s;
  cin >> s;
  for (int i=0;i<3;++i){
    if (s.at(i)==s.at(i+1)) goto b;}
  cout << "Good" << endl;
  return 0;
  b: cout << "Bad" << endl;
}

Measured memory_bytes: 256
/*input 
2000000000 0 0 2000000000
*/


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

 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))

#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll n,i,j,k,m, c=0;
int a[20][20];
stack <int> sol;

void solve() 
{ int a,b,c;
 cin>>a>>b>>c>>k;
   
   int ans=0;
   if(k>a)
    {ans+=a;
        k=k-a;
    }
    else {cout<<k;
        return;
    }
    if(k>b)
    {
        k=k-b;
    }
    else {
        cout<<ans;
        return;

    }
   
   if(k<c)
   {
    ans=ans-k;
   }
   else ans=ans-c;

   cout<<ans;

} 
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;
int h=T;
    while(T--){
//cout<<"Case #"<<(h-T)<<": ";
        solve();
cout<<endl;
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 3664
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<u64> = sc.read_vec(n);

    let mut sum = vec![0; n + 1];
    let mut xor = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
        xor[i + 1] = xor[i] ^ a[i];
    }

    let mut ans = 0;
    for from in 0..n {
        let mut ok = from;
        let mut ng = n;
        while ng - ok > 1 {
            let m = (ok + ng) / 2;

            let sum = sum[m + 1] - sum[from];
            let xor = xor[m + 1] ^ xor[from];
            if sum == xor {
                ok = m;
            } else {
                ng = m;
            }
        }

        ans += ok - from + 1;
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 10492
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int n,m;cin>>n>>m;
  if(n==m) p("Yes");
  else p("No");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
 
  int n;
  double t,a;
  cin >> n >> t >> a;
  
  double near = 100000;
  
  vector<int> p(n);
  rep(i,n) {
  cin >> p[i];
  near = min(near,abs(t-p[i]*0.006-a));
  }
  
  rep(i,n) {
    if(near==abs(t-p[i]*0.006-a)) {
    cout << i+1 << endl;
    }  
  }

}

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

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

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::Ordering;
use std::cmp::{max, min};

fn main() {
    let n = read();
    let k = read();
    let p: Vec<u32> = read_n(n);

    let mut tmp = 0;
    for i in 0..k {
        tmp += p[i];
    }

    let mut sum = tmp;

    for i in k..n {
        tmp = tmp + p[i] - p[i - k];
        if tmp > sum {
            sum = tmp;
        }
    }

    let ans = ((sum + k as u32) as f64 ) / 2.0;
    println!("{}", ans);
}


Measured memory_bytes: 54268
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

ll Ap,Bp;

ll binary(ll l, ll r,ll a,ll b,ll sum){
    if (r - l == 1){
        if (sum <= a*l + b*l && Ap <= a*l && Bp <= b*l) {
            return l;
        }else{
            return r;
        }
    }
    ll mid = (l+r)/2;
    
    if (Ap > a*mid || Bp > b*mid) {
        return binary(mid,r,a,b,sum);
    }else{
        return binary(l,mid,a,b,sum);
    }
}

ll rec(ll A, ll B, ll sum){
    ll maxk1 = 1000000000000000000/B + 1;
    ll maxk2 = 1000000000000000000/A + 1;
    ll maxk = min(maxk1,maxk2);

    ll k = binary(1,maxk,A,B,sum);
    Ap = A*k;
    Bp = B*k;
    
    return Ap + Bp;
}

int main(){
    INT(N);
    ll A,B;
    scanf("%lld %lld",&A,&B);
    Ap = A;
    Bp = B;
    ll sum = A + B;
    REP1(i,N-1){
        ll a,b;
        scanf("%lld %lld",&a,&b);
        sum = rec(a,b,sum);
        //cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long grid[2000][2000] = {};
int main(){
    int n;
    cin >> n;
    REP(i,n){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        grid[a][b]++;
        grid[c][b]--;
        grid[a][d]--;
        grid[c][d]++;
    }
    long long ans = 0;
    for(int i = 0;i <= 1000;++i){
        for(int q = 1;q <= 1000;++q){
            grid[i][q] += grid[i][q-1];
        }
    }
    for(int i = 0;i <= 1000;++i){
        for(int q = 1;q <= 1000;++q){
            grid[q][i] += grid[q-1][i];
        }
    }
    for(int i = 0;i <= 1000;++i){
        for(int q = 0;q <= 1000;++q){
            ans = max(ans,grid[i][q]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   string s;
   cin >> s;
   for(int i='a';i<='z';i++){
      if(count(s.begin(),s.end(),i) == 0){
         cout << (char)i << endl;
         return 0;
      }
   }
   cout << "None" << endl;
   return 0;
}


Measured memory_bytes: 512
MAX_A = 10**6 + 1
is_prim = [True] * (MAX_A//2)
is_prim[0] = is_prim[1] = False
for i in range(2, MAX_A//2):
    if not is_prim[i]: continue
    for j in range(i+i, MAX_A//2, i): is_prim[j] = False

def solve():
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    for p in [i for i in range(MAX_A//2) if is_prim[i]]:
        if sum(C[p::p]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'

n = int(input())
A = [*map(int, input().split())]
print(solve(), 'coprime')


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

int main(){
  string str;
  cin >> str;
  if (str == "Sunny")
    cout << "Cloudy";
  else if (str == "Cloudy")
    cout << "Rainy";
  else 
    cout << "Sunny";
  cout << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    int main(){
                    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif 
 
        fast;
        int t=1; 
        // cin>>t; 
        while(t--){
            int a,b,c,k;
            cin>>a>>b>>c>>k;
            if(k<=a) cout<<k;
            else if(k<=a+b) cout<<a;
            else cout<<a-(k-a-b);
        } 
        return 0;   
    }       


    //keep it simple stupid 

Measured memory_bytes: 3560
N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)
 
V[0] = 1
for i in range(N):
    V[i+1] = (V[i]*2 - A[i+1])
    if V[i+1] < 0 :
        flug = 1
    Lsum = Lsum - A[i+1]
    if V[i+1] > Lsum :
        V[i+1] = Lsum
 
ans = sum(V)+sum(A)
if A[0] != 0 or A[N] == 0:
    ans = -1
if flug == 1:
   ans = -1
if N == 0 and A[0] != 1:
    ans = -1
elif N == 0 and A[0] == 1:
    ans = 1
 
print(ans)

Measured memory_bytes: 645420
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main(){
	int a;
	double ans = 0;
	cin >> a;
	vector<int> s(a);
	rep(i, a)cin >> s[i];
	sort(s);
	ll int  x = pow(2, a - 1);
	rep(i, a) {
		if (i < 2)ans += s[i];
		else {
			ans += pow(2, i - 1) * s[i];
		}
	}
	double abc = ans / x;
	cout << abc << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int n=max(max(a,b),c);
  int m=a+b+c-n;
  rep(i,k){
    n*=2;
  }
  cout << m+n << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
$numbers = fgets(STDIN);
$exploded_numbers = explode(' ', trim($numbers));

$counted_nums = array_count_values($exploded_numbers);
rsort($counted_nums);

if ($counted_nums[0] > 1) {
  echo 'NO';
} else {
  echo 'YES';
}

Measured memory_bytes: 39408
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define pb              push_back
#define fi              first
#define se              second
#define mod             1000000007  //998244353// 1e9 + 7
#define inf             1000000007 // 1e9 + 7
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL
#define MAXN            200064
#define mt              make_tuple
#define eps             1e-6
#define endl            '\n'
#define test            int _o_; cin>>_o_; while(_o_--)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #define tree            tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
// int fact[1000007]={0};
// int spf[(int)(1e7) + 20];
// bool prime[(int)((1e7) + 20)];
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
// void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int xyp(int x,int y){int res=1;while(y>0){if(y%2==1) res=(res*x)%mod;x=(x*x)%mod;y/=2;}return res%mod;}
// int inv(int x){return xyp(x,mod - 2);}
// int inv_euclid(int a, int m = mod){int m0 = m;int y = 0, x = 1;if (m == 1)return 0;while (a > 1){int q = a / m;int t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
// void init() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[r],mod-2)))%mod; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res; }
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
// int add(int a, int b){return (a%mod + b%mod + ((MAX)/mod)*mod)%mod;}
// int sub(int a, int b){return (a%mod - b%mod + ((MAX)/mod)*mod)%mod;}
// int mul(int a, int b){return ((a%mod)*(b%mod) + ((MAX)/mod)*mod)%mod;}
// #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// int dx[] = {+1, -1, 0, 0};
// int dy[] = {0, 0, +1, -1};
signed main()
{
	fast_io
	int n;
	cin >> n;
	if(n % 1000)
	cout << 1000 - n % 1000 << '\n';
	else cout << 0 << endl;
}

Measured memory_bytes: 3564
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll res=0;
    rep3(i,1,n+1){
        if(i%3!=0&&i%5!=0){
            res+=i;
        }
    }
    cout<<res<<endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  
  if(a%2==0 || b%2==0 || c%2==0){
    cout << 0 << endl;
  }
  else{
    ll d[] = {a, b, c};
    sort(d, d+3);
    cout << d[0]*d[1] << endl;
  }
}


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

int main() {
        const string P = "Positive";
        const string N = "Negative";
        const string Z = "Zero";
        int a, b;
        cin >> a >> b;
        if (a <= 0 && 0 <= b) {
                cout << Z << endl;
        } else if (a < 0 && b < 0) {
                cout << (((b - a) % 2 == 1) ? P : N) << endl;
        } else if (a < 0 && 0 < b) {
                cout << (((-a) % 2 == 0) ? P : N) << endl;
        } else {
                cout << P << endl;
        }
        return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
ary = []
M.times do
  s, c = gets.split.map(&:to_i)
  ary << [s-1, c.to_s]
end

for i in 0..999
	str = i.to_s
    next if str.length != N
	is_find = true
  	
  	ary.each do |s,c|
       is_find = false if str[s].to_i != c.to_i
    end
      
  	if is_find
       puts str
       exit
    end
end

puts '-1'


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,A,B;
  cin>>N>>A>>B;
  ll ans=0;
  ans=A*(N/(A+B))+min(A,N%(A+B));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

bool CheckString(string s) {
	int l = s.length();
	for (int i = 0; i < l / 2; i++) {
		if (s[i] != s[l - 1 - i]) {
			return false;
		}
	}
	return true;
}

void Main()
{
	string s;
	cin >> s;

	if (!CheckString(s)) {
		cout << "No" << endl;
		return;
	}

	string s1 = s.substr(0, (s.length() - 1) / 2);
	if (!CheckString(s1)) {
		cout << "No" << endl;
		return;
	}

	s1 = s.substr((s.length() + 3) / 2 - 1);
	if (!CheckString(s1)) {
		cout << "No" << endl;
		return;
	}

	cout << "Yes" << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
from collections import defaultdict

N=int(input())
v=list(map(int,input().split()))

dda= defaultdict(int)
ddb= defaultdict(int)


for i in range(N):
    if i%2==0:
        dda[v[i]]+=1
    else:
        ddb[v[i]]+=1

La=[]
Lb=[]

for k,v in dda.items():
    La.append((v,k))
    
for k,v in ddb.items():
    Lb.append((v,k))
        
La.sort()
Lb.sort()

ma=La[-1][0]
mb=Lb[-1][0]
ans=ma+mb

if La[-1][1]==Lb[-1][1]:
    if len(La)!=1:
        m2a=La[-2][0]
    else:
        m2a=0
    if len(Lb)!=1:
        m2b=Lb[-2][0]
    else:
        m2b=0
    ans=ma+max(m2a,m2b)
    
print(N-ans)

Measured memory_bytes: 63724