akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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){
  while(u!=NIL && k!=u->key){

  if(k < u->key) u=u->left;

  else u=u->right;
  }
  return u;
  
}

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

}

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;
  free(y);
}

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;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

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

  return 0;
}



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

#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)

constexpr int MAX = 3000;
int siz[MAX], par[MAX], Rank[MAX];

void init(int n) {
    REP(i, n) {
        par[i] = i;
        Rank[i] = 0;
        siz[i] = 1;
    }
}
int find(int x) {
    if (par[x] == x)
        return x;
    else {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
        siz[x] += siz[y];
        siz[y] = siz[x];
    } else {
        siz[y] += siz[x];
        siz[x] = siz[y];
        par[y] = x;
        if (Rank[x] == Rank[y]) Rank[x]++;
    }
}
bool same(int x, int y) { return find(x) == find(y); }

int X[2020], Y[2020], Z[2020];

vector<int> G[2020];

int N, K, S;

bool connected(int i, int j) {
    if (abs(X[i] - X[j]) < S && abs(Y[i] - Y[j]) < S && abs(Z[i] - Z[j]) < S)
        return true;
    else
        return false;
}

int over(int i, int j) {
    int dx = S - abs(X[i] - X[j]);
    int dy = S - abs(Y[i] - Y[j]);
    int dz = S - abs(Z[i] - Z[j]);
    return 2 * (dx * dy + dy * dz + dz * dx);
}

int dfs(int n, int pre, int s, int cnt, int res) {
    if (K == 1) {
        return 6 * S * S;
    }
    if (cnt == 0) {
        int ret = 1e18;
        for (auto v : G[n]) {
            ret = min(ret, dfs(v, n, n, cnt + 1, 2 * 6 * S * S - over(n, v)));
        }
        return ret;
    } else {
        int ret = 1e18;
        if (cnt == K) return res;
        if (cnt == K - 1) {
            if (siz[find(n)] > K || K <= 2)
                return res;
            else if (siz[find(n)] == K) {
                if (connected(n, s)) {
                    ret = min(ret, dfs(s, n, s, cnt + 1, res - over(n, s)));
                } else
                    ret = res;

                return ret;
            }
        } else {
            for (auto v : G[n]) {
                if (v == pre) continue;
                ret = min(ret, dfs(v, n, s, cnt + 1, res + 6 * S * S - over(n, v)));
            }
            return ret;
        }
    }
    return 1e18;
}

bool solve() {
    cin >> N >> K >> S;
    if (N == 0) return false;
    REP(i, N) {
        G[i].clear();
        cin >> X[i] >> Y[i] >> Z[i];
    }

    init(N);
    REP(i, N) FOR(j, i + 1, N) {
        if (connected(i, j)) {
            unite(i, j);
            G[i].push_back(j);
            G[j].push_back(i);
        }
    }
    int mx = 0;
    REP(i, N) { mx = max(mx, siz[find(i)]); }
    if (mx < K) {
        cout << -1 << endl;
        return true;
    }
    int ans = 1e18;
    REP(i, N) {
        if (siz[find(i)] >= K) {
            ans = min(ans, dfs(i, i, i, 0, 0));
        }
    }
    cout << ans << endl;
    return true;
}
signed main() {
    // init();
    while (solve())
        ;
}


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


int main(void)
{
    int N;
    long long a[100];

    cin >> N;
    for(int i=0;i<N;++i) cin >> a[i];

    long long nawMax = 0;
    long long cash = 1000;
    long long kabu = 0;
    long long nawamax = a[0];
    long long uruhi = N+1;

    for(int i=0; i < N; ++i){
        nawamax = a[i];
        for(int j=i; j<N; ++j){
            if(nawamax <= a[j]){
                nawamax = a[j];
                uruhi = j;
            }else{
                break;
            }
        }
        if(uruhi < N){
            kabu = cash / a[i];
            cash = cash - kabu*a[i];
            
            cash = cash + kabu * a[uruhi];
            kabu = 0;

            i = uruhi;
        }
    }

    cout << cash << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static String swap(String str){
		String[] s = new String[(str.length()+1)/2];
		StringBuilder sb = new StringBuilder();
		s = str.split(" ");
		int[] p = new int[s.length];
		for(int i = 0; i < s.length; i++){
			p[i] = Integer.parseInt(s[i]);
		}
		int key = -1;
		for(int i = p.length-1; i >= 0; i--){
			if( p[i] != 1 ){
				key = i;
				break;
			}
		}
		StringBuilder replace = new StringBuilder();
		if( key == p.length-1 ){
			replace.append(String.valueOf(p[p.length-1]-1) + " 1");
		} else {
			int count = p.length-1-key;
			int x = count+1;
			if( p[key]-1 < x ){
				x = p[key]-1;
			}
			replace.append(String.valueOf(p[key]-1) + " ");
			for(int i = 0; i < (count+1)/x; i++){
				replace.append(String.valueOf(x) + " ");
			}
			if( (count+1)%x != 0 ){
				replace.append(String.valueOf((count+1)%x) + " ");
			}
		}
		for(int i = 0; i < key; i++){
			sb.append(String.valueOf(p[i]) + " ");
		}
		sb.append(replace.toString());
		String result = new String();
		result = sb.toString();
		if( result.charAt(result.length()-1) == ' ' ){
			sb.deleteCharAt(result.length()-1);
			result = sb.toString();
		}
		return result;
	}
			
		
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] n = new int[1000];
		int index = 0;
		
		for(int i = 0; i < 1000; i++){
			n[i] = stdIn.nextInt();
			if( n[i] == 0 ){
				break;
			}
			index++;
		}
		
		for(int i = 0; i < index; i++){
			String str = new String(String.valueOf(n[i]));
			System.out.println(str);
			if( str.equals("1") ){
				continue;
			}
			while( str.charAt(0) != '1' || str.charAt(1) != ' ' ){
				str = swap(str);
				System.out.println(str);
			/*	str = swap(str);
				System.out.println(str);
				str = swap(str);
				System.out.println(str);
				str = swap(str);
				System.out.println(str);
				str = swap(str);
				System.out.println(str);*/
		

			}
		
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    long long res = 0, sum = 0;
    for (int i = 0; i < N;) {
        int j = i;
        while (j < N && a[j]) sum += a[j++];
        res += sum / 2;
        sum = 0;
        i = j+1;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define Max 1000005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL a[Max];
int main()
{
    LL n;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    LL sum=0;
    for(int i=1;i<=n;i++){
        sum^=a[i];
    }
    if(sum==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static class LowerBoundComparator<T extends Comparable<? super T>>
      implements Comparator<T>
  {
    public int compare(T x, T y)
    {
      return (x.compareTo(y) >= 0) ? 1 : -1;
    }
  }


  public static class UpperBoundComparator<T extends Comparable<? super T>>
      implements Comparator<T>
  {
    public int compare(T x, T y)
    {
      return (x.compareTo(y) > 0) ? 1 : -1;
    }
  }

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final long MOD = 1000000007L;

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int[] a = new int[n];

    List<Integer> groups = new ArrayList<>();

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

    for (int i = 0; i < n; i++) {
//      int j = groups.size() - 1;
//      while (0 <= j && groups.get(j) <= a[j]) {
//        j--;
//      }
      int j = Collections.binarySearch(groups, a[i], new LowerBoundComparator<>());
//      if (0 <= j) {
//        groups.set(j, a[i]);
//      } else {
//        groups.add(0, a[i]);
//      }
      if (j == -1) {
        groups.add(0, a[i]);
      } else {
        groups.set(~j - 1, a[i]);
      }
    }

    os.println(groups.size());
  }
}

Measured memory_bytes: 54040
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <algorithm>

using namespace std;

template<class T> inline int chmax(T& a, T b){
    int ret = 1;
    if(a < b){
        a = b;
    }
    else{
        ret = 0;
    }

    return ret;
}

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N, 0);
    vector<int> v(N, 0);

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

    for(int i=0; i<N; i++){
        cin >> w[i] >> v[i];
    }

    dp[0][0] = 1;

    for(int i=1; i<N+1; i++){
        for(int j=0; j<W+1; j++){
            /* 新しい品物を取る */
            if((dp[i-1][j]>0) && ((j+w[i-1]) <= W)){
                /* i番目の品物を選ぶ */
                long long a = dp[i-1][j] + v[i-1];
                chmax(dp[i][j+w[i-1]], a);
            }

            else{
                /* 何もしない */
            }

            /* 新しい品物を取らない */
            chmax(dp[i][j], dp[i-1][j]);
        }

    }

    /* 出力時は-1する */
    long long max = *max_element(dp[N].begin(), dp[N].end());
    cout << (max -1) << endl;

    return 0;

}

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;

std::string S[3];
ll turn = 0;
ll p[3];

int main()
{
  rep( i, 3 )
    std::cin >> S[i];

  while( true )
  {
    if( p[turn] >= S[turn].size() )
    {
      std::cout << char('A'+turn) << std::endl;

      return 0;
    }

    ++p[turn];
    turn = S[turn][p[turn]-1]-'a';
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *C, key, bangou;
  int *B;
  int n, i, j;
  int count=0, max;

  scanf("%d", &n);
  if(n<1 || n>=MAX) exit(1);
  
  A = malloc(sizeof(int)*n);
  C = malloc(sizeof(int)*n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(A[i]<0 || A[i]>VMAX) exit(2);
  }
  
  max = A[0];
  for(i=1; i<n; i++) if(max < A[i]) max = A[i];
  B = malloc( (max+2)*sizeof(int) );

  /*for(i=0; i<=max; i++){
    for(j=0; j<n; j++){
      if(A[j] == i) count++;
    }
    B[i] = count;
    }*/
  
  for(i=0; i<n; i++) B[A[i]]++;
  for(i=0; i<=max+1; i++) B[i] = B[i] + B[i-1];
  //for(i=0; i<=max+1; i++) printf("%-2d",B[i]);

  //for(i=0; i<=max; i++) printf("%d ",B[i]);
  //printf("\n");

  for(i=n-1; i>=0; i--){
    C[B[A[i]]-1] = A[i];
    B[A[i]]--;
  }

  //for(i=0; i<=max+1; i++) printf("%-2d", B[i]);
  
  for(i=0; i<n; i++){
    printf("%d",C[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");

  return 0;
}




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

using namespace std;

char c;
void input();

void solve(){
    if(c>='A' && c<='Z'){
        cout<<"A"<<"\n";
    }
    else if(c>='a' && c<='z'){
        cout<<"a"<<"\n";
    }
}

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

}

void input(){
    cin>>c;
}


Measured memory_bytes: 3644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	cnt := make(map[int]int)

	for i := 0; i < n; i++ {
		x := nextInt()
		cnt[x]++
	}

	var xs []int = nil
	for x, _ := range cnt {
		xs = append(xs, x)
	}

	sort.Slice(xs, func(i, j int) bool { return xs[i] < xs[j] })

	ans := 0

	for i := 0; i < len(xs)-2; i++ {
		for j := i + 1; j < len(xs)-1; j++ {
			y := bisect(xs[i]+xs[j], xs, j+1, len(xs))
			for k := j + 1; k < y; k++ {
				ans += cnt[xs[i]] * cnt[xs[j]] * cnt[xs[k]]
			}
		}
	}

	fmt.Println(ans)
}

func bisect(x int, xs []int, first int, last int) int {
	for last-first > 0 {
		middle := (first + last) / 2
		if x <= xs[middle] {
			last = middle
		} else {
			first = middle + 1
		}
	}

	return first
}


Measured memory_bytes: 1864
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll arr[3] = {1, 2, 3};
ll A, B;

int main() {
	scanf("%lld %lld", &A, &B);
	for(int i = 0; i < 3; i++) {
		if(A != arr[i] && B != arr[i]) {
			cout << arr[i] << "\n";
		}
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
from sys import stdin
from collections import deque


class BFS():
    def __init__(self, grid_graph):
        # grid表現
        self.graph = grid_graph
        self.H = len(self.graph)
        self.W = len(self.graph[0])
        # 始点からの距離
        self.dist = [[-1]*self.W for i in range(self.H)]
        # キュー
        self.que = deque()

    def bfs(self, sv_arr):
        dx = [ 1, 0,-1, 0]
        dy = [ 0, 1, 0,-1]

        # 初期条件(0-indexed)
        for sv in sv_arr:
            self.dist[sv[0]][sv[1]] = 0
            self.que.append(sv)

        while self.que:
            v = self.que.popleft()
            for _dx, _dy in zip(dx,dy):
                nv = [v[0]+_dx,v[1]+_dy]
                if not 0<=nv[0]<self.H: continue 
                if not 0<=nv[1]<self.W: continue
                if self.dist[nv[0]][nv[1]] != -1: continue
                self.dist[nv[0]][nv[1]] = self.dist[v[0]][v[1]] + 1
                self.que.append(nv)


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    H, W = list(map(int,_in[0].split(' ')))  # type:list(int)
    graph = []
    for i in range(H):
        _ = list(_in[i+1])  # type:list(str)
        graph.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    bfs = BFS(graph)

    sv_arr = []
    for i in range(H):
        for j in range(W):
            if bfs.graph[i][j] == '#':
                sv_arr.append([i,j])

    bfs.bfs(sv_arr)
    cnt = max(max(_) for _ in bfs.dist)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 183264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    if(a % 2 == 1) continue;
    else{
      if(a % 3 != 0 and a % 5 != 0){
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout <<"APPROVED";
}
  

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int k = 2;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 1; j <= k && (i - j) >= 0; j++) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(a[i - j] - a[i]));
            }
        }
        out.println(dp[n-1]);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}


Measured memory_bytes: 31588
H, W = map(int, input().split())
S = [input() for _ in range(H)]
for i in range(1,H-1):
    for j in range(1,W-1):
        if S[i][j] == '#':
            if S[i+1][j] == '#' or S[i][j+1] == '#' or S[i-1][j] == '#' or S[i][j-1] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')


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

int N, K, R, S, P;
string s;

bool flag[101010];
int dp[101010][3]; // r=0,s=1,p=2;

signed main() {
  cin >> N >> K >> R >> S >> P >> s;

  map<char, int> mp;
  map<int, int> p;

  mp['r'] = 2;
  mp['s'] = 0;
  mp['p'] = 1;

  p[0] = R;
  p[1] = S;
  p[2] = P;

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (flag[i]) {
      continue;
    }
    flag[i] = true;

    for (int j = 0; j < 3; j++) {
      dp[i][j] = 0;
    }
    dp[i][mp[s[i]]] = p[mp[s[i]]];

    int temp = i;
    for (int j = K; i + j < N; j += K) {
      temp = i + j;
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          if (l != k) {
            if (k == mp[s[i + j]]) {
              dp[i + j][k] = max(dp[i + j][k], dp[i + j - K][l] + p[k]);
            } else {
              dp[i + j][k] = max(dp[i + j][k], dp[i + j - K][l]);
            }
          }
        }
      }
      flag[i + j] = true;
    }

    int add = max({dp[temp][0], dp[temp][1], dp[temp][2]});
    ans += add;
  }

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

Measured memory_bytes: 2944
#include <stdio.h>
int main(void){
    int x, y, a, b;
    scanf("%d%d", &x,&y);
    if ((y - 2 * x)%2 == 1 || (4 * x - y) % 2 == 1 || y - 2 * x < 0 || 4 * x - y < 0)
    {
        printf("No");
        return(0);
    }
    printf("Yes");
    return(0);
}


Measured memory_bytes: 1736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main()
{
	int N;
	cin >> N;
	vector<long long int>d(N);
	long long int ans=0;
	for (int i = 0; i < N; i++)cin >> d[i];
	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			ans += d[i] * d[j];
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

const double PI = acos(-1);

int main(){
	int a, b, h, m;
	std::cin >> a >> b >> h >> m;

	// 針の座標を求める
	double th = double(h*60+m)/720 *2*PI;
	double tm = double(m)/60 *2*PI;
	double xh, yh, xm, ym;
	xh = a*cos(th);
	yh = a*sin(th);
	xm = b*cos(tm);
	ym = b*sin(tm);

	// 距離を求める
	double dx, dy;
	dx = xh - xm;
	dy = yh - ym;
	printf("%.10f\n", sqrt(dx*dx + dy*dy));
	return 0;
}

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

int main(){
  int N;cin>>N;
  int A[110];
  int mina=1000000005;
  int maxa=0;
  
  for (int i=0;i<N;++i){
    cin>>A[i];
    if (mina>A[i])mina=A[i];
    if (maxa<A[i])maxa=A[i];
  }

  int sa=maxa-mina;
  
  cout<<sa<<endl;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  int ans = a*x+b*y;
  {
    int cc = min(x,y);
    int ans2 = cc*2*c + (cc==x ? (y-cc)*b : (x-cc)*a);
    int ans3 = max(x,y)*2*c;
    ans = min(ans, min(ans2, ans3));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <cstdlib>
#include <ctime>
#include <queue>
using namespace std;

const int N = 100010;
int dp[N];
bool vis[N];

int solve(int n) {
	queue<int> q;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i < 10; i++) {
		if (dp[i % n] == -1) {
			dp[i % n] = i;
			q.push(i % n);
		    vis[i % n] = true;
		}
	}

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		vis[u] = false;
		for (int i = 0; i < 10; i++) {
			int x = (10 * u + i) % n;
			if (dp[x] == -1 || dp[x] > dp[u] + i) {
				dp[x] = dp[u] + i;
				if (!vis[x]) {
					vis[x] = true;
					q.push(x);
				}
			}
		}
	}
	return dp[0];
}

int main()
{
	int n;
	scanf("%d", &n);
	
	cout << solve(n) << endl;
	return 0;
}

Measured memory_bytes: 1152
n=int(input())
a=list(map(int,input().split()))
p=[1,-1]
j=[-1,1]
c=0
l=0
d=0
e=0
for i in range(n):
    s=i%2
    c+=a[i]
    l+=a[i]
    if p[s]*c<=0:
        d+=abs(c-p[s])
        c=p[s]
    if j[s]*l<=0:
        e+=abs(l-j[s])
        l=j[s] 
print(min(e,d))

Measured memory_bytes: 14332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int n, k;
char c[10];
bool b[10];
int ma = 1000000007;
void dfs(string s) {
	if (s.size()>0) {
		if (stoi(s) >= n) {
			if (ma > stoi(s)) {
				ma = stoi(s);
			}
			return;
		}
		if (s.size() > 10) {
			return;
		}
	}
	for (int i = 0; i < 10; i++) {
		if (b[i] == true) {
			dfs(string(s + c[i]));
		}
	}
}
int main() {
	cin >> n >> k;
	for (int i = 0; i < 10; i++) {
		c[i] = char('0' + i);
		b[i] = true;
	}
	for (int i = 0; i < k; i++) {
		char c1;
		cin >> c1;
		for (int j = 0; j < 10; j++) {
			if (c1 == c[j]) {
				b[j] = false;
			}
		}
	}
	string st = "";
	dfs(st);
	cout << ma << endl;
	return 0;
}



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


void solve(long long H, long long A){
    cout << ceil((float)H / A) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int,int> c[2];
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++c[i&1][x];
  }
  vector<pair<int,int>> pq[2];
  pq[0] = pq[1] = {{0,-1}};
  for (int i = 0; i < 2; ++i) {
    for (auto p : c[i])
      pq[i].push_back({p.second,p.first});
    sort(rbegin(pq[i]),rend(pq[i]));
    pq[i].resize(2);
  }
  int ans;
  if (pq[0][0].second != pq[1][0].second)
    ans = pq[0][0].first + pq[1][0].first;
  else
    ans = max(pq[0][0].first + pq[1][1].first,pq[0][1].first + pq[1][0].first);
  cout << n-ans << endl;
}

Measured memory_bytes: 6140
#include<bits/stdc++.h>
using  namespace std;
long long dp[105][1000005];
int N,W,w[105],v[105];
int main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>w[i]>>v[i];
    for(int i=1;i<=W;i++){
        for(int j=1;j<=N;j++){
             dp[j][i]=max(dp[j-1][i],dp[j][i]);
            if(i-w[j]>=0)
                dp[j][i]=max(dp[j-1][i],max(dp[j][i],dp[j-1][i-w[j]]+v[j]));

        }
    }
    int ans=0;


    cout<<dp[N][W]<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N;
  string S;
  cin >> N >> S;

  string AZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (auto c : S) {
    for (ll i = 0; i < AZ.length(); i++) {
      if (c == AZ[i]) {
        cout << AZ[i + N];
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	string s, t;
	cin >> s >> t;
	if (s == t.substr(0, t.length() - 1))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3628
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from collections import Counter
c = Counter(MAP())
print(len(c.keys()))


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

int main() {
  int n ,q;
  cin >> n;
  vector<int> S(n);
  for(int i = 0; i < n; i++) {
    cin >> S.at(i);
  }
  cin >> q;
  vector<int> T(n);
  for(int i = 0; i < q; i++) {
    cin >> T.at(i);
  }
  int count = 0;
  for(int i = 0; i < q; i++) {
    int x = T[i];
    int ok = n;
    int ng = -1;
    while(abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;
      //cout << i << ":" << mid << endl;
      if((S[mid] - x) > 0) {
        ok = mid;
      }
      else {
        ng = mid;
      }
    }
    if(S[ng] == x) {
      //cout << ng << " " << x << endl;
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3456
n=int(input())
score=[[]for i in range(n)]
for i in range(n):
    x,y,z=map(int,input().split())
    score[i]=(x,y,z)
dp=[[0]*3 for i in range(n)]
for i in range(3):
    dp[0][i]=score[0][i]
#dp[i][j] i日目にjを選ぶ時ありうる最大のスコア
for i in range(1,n):
    for j in range(3):
        for k in range(3):
            if j!=k:
                dp[i][j]=max(dp[i][j],dp[i-1][k]+score[i][j])
print(max(dp[-1]))


Measured memory_bytes: 71456
#include <stdio.h>
#define N 2000001
int main()
{
  int n,A[N],i,j,B[N],count,C[N],D[N],a,max=0;
  FILE *fp;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
      if(max<A[i])
	max=A[i];
    }
  for(i=0;i<=max;i++)
    {
      C[i]=0;
    }
  for(j=1;j<=n;j++)
    C[A[j]]++;
  for(i=0;i<=max;i++)
    {
      C[i]=C[i-1]+C[i];
    }
  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
  for(i=1;i<=n;i++)
    {
      printf("%d",B[i]);
      if(i!=n)
	printf(" ");
    }
  printf("\n");
  return 0;
}



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

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> TA(N);
    rep(i, N)cin >> TA[i].first >> TA[i].second;
    ll tmin, amin;
    tie(tmin, amin) = TA.front();
    REP(i, 1, N) {
        ll T, A;
        tie(T, A) = TA[i];
        //ll safe = max(ceil(1.*T / tmin), ceil(1.*A / amin));
        ll out = 0, safe = 3e18 / max(T, A);
        while (abs(safe - out) > 1) {
            ll mid = (safe + out) / 2;
            ll tt = T * mid;
            ll ta = A * mid;
            (tt >= tmin && ta >= amin ? safe : out) = mid;
        }
        tmin = T * safe;
        amin = A * safe;
        //cout << tmin << " " << amin << endl;
    }
    cout << tmin + amin;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    string S;
    cin >> S;
    int N = stoi(S);
    int ans = 0;
    int p = 1;
    for (int i = 0; i < S.size() / 2; i++) {
        ans += 9 * p;
        p *= 100;
    }
    if(S.size() % 2 == 1) {
        ans += N - p + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		sc.close();

		long result1 = Math.max(0, a - k);
		long result2 = Math.max(0, Math.min(a + b - k, b));
		System.out.println(String.format("%d %d", result1, result2));
	}
}


Measured memory_bytes: 21972
#include <cstdio>
#include <climits>
#include <cmath>

int main() {
    int n, T, a;
    scanf("%d %d %d", &n, &T, &a);

    int ans = -1, min = INT_MAX;
    for (int i = 1, h; i <= n; i++) {
        scanf("%d", &h);
        int diff = std::abs(1000 * T - 6 * h - a * 1000);
        if (diff < min) {
            min = diff;
            ans = i;
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

int fn(int A,int B,int C)
{
  return abs(A-B) + abs(B-C) + abs(C-A);
}

void solve(void)
{
  int N;
  cin>>N;
  if((N/10 ==9) || (N -N/10*10 == 9))
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int h1=readI(),m1=readI(),h2=readI(),m2=readI(),k=readI();
    if(h1>h2||(h1==h2&&m1>m2)){
      h2+=24;
    }
    int t = (h2-h1)*60+(m2-m1)-k;
    pl(t+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return Long.parseLong(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var cnt = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                if (cnt.ContainsKey(A[i])) cnt[A[i]]++;
                else cnt.Add(A[i], 1);
            }
            var sortedC = cnt.OrderByDescending(i => i.Key).ToArray();
            long ans1 = 0, ans2 = 0;
            foreach (var i in sortedC)
            {
                if (i.Value >= 4)
                {
                    if (ans1 == 0) { ans1 = i.Key; ans2 = i.Key; break; }
                    else { ans2 = i.Key; break; }
                }
                else if (i.Value >= 2)
                {
                    if (ans1 == 0) ans1 = i.Key;
                    else { ans2 = i.Key; break; }
                }
            }

            Console.WriteLine(ans2 != 0 ? ans1 * ans2 : 0);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 26592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp66 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int X = st[0];
            int Y = st[1];
            int Z = st[2];

            Console.WriteLine((X - Z) / (Y + Z));

        }
    }
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

//////////////////////////////////////////


int n;

int factorial(int n)
{
    if (n == 0)
    return 1;
    return n * factorial(n - 1);
}

void Input() {

    cin >> n;
    int a[n];
    vector< pair<double, double> > v;

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

        double x, y;
        cin >> x >> y;
        a[i] = i;
        v.push_back(make_pair(x, y));
    }

    long double ans = 0.0;
    do {

        for(int i = 0; i < n-1; i++) {

            ans += (double) sqrt(pow((v[a[i]].first - v[a[i+1]].first), 2) + pow((v[a[i]].second - v[a[i+1]].second), 2));
        }

    }while(next_permutation(a, a+n));



    cout << setprecision(15) << ans / factorial(n) << endl;
}



void Solve() {




}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
s = int(input())
a = [s]
i = 1
t = 0
while t == 0:
  if s%2 == 0:
    s = s//2
  else:
    s = 3*s + 1
  a.append(s)
  i += 1
  for j in a:
    if a.count(j) == 2:
      t += 1
print(i)

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

const ll mod = 1e9 + 7;
ll n, a, b, c, d;
ll dp[1010][1010];
ll fact[1010], fact_inv[1010], inv[1010];

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
}

long long combination(long long n, long long k){
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main(){
    cin >> n >> a >> b >> c >> d;
    
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < 1010; i++) dp[i][0] = 1;

    fact[0] = fact_inv[0] = 1;
    for(int i = 1; i < 1010; i++){
        inv[i] = mod_pow(i, mod - 2);
        fact[i] = fact[i - 1] * i % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }

    for(int i = a; i <= b; i++){
        for(int j = 1; j <= n; j++){
            ll p = 1;
            dp[i][j] += dp[i - 1][j];
            for(int k = 1; k <= d; k++){
                if(j - i * k < 0) break;
                p = p * combination(n - j + i * k, i) % mod * inv[k] % mod;
                if(c <= k && k <= d){
                    (dp[i][j] += (dp[i - 1][j - i * k]) * p % mod) %= mod;
                }
            }
        }
    }
    cout << dp[b][n] << endl;
}

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

int main()
{
	int N,M,total=0;
	cin >> N >> M;
	int A[M];
	for(int i=0;i<M;i++)
	{
		cin >> A[i];
		total += A[i];
	}

	if((N-total)<0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << N-total << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long a[] = new long[N];
		
		for(int i=0;i<N;i++) {
			a[i] = sc.nextLong();
		}

		
		Arrays.parallelSort(a);		
		for(int j=0;j<N-1;j++) {
			if(a[j]-a[j+1]==0) {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
//		for(int i=0;i<N-1;i++) {
//			for(int j=i+1; j<N; j++) {
//	//			System.out.println("ai:"+a[i]);
//	//			System.out.println("aj:"+a[j]);
//
//				if(a[i]==a[j]) {
//					System.out.println("NO");
//					return;
//				}
//			}
//		
//		}
//		System.out.println("YES");
		

	}	
}

Measured memory_bytes: 62180
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
    
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;
    
     
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  char s[32];
    
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
      
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a];
      A[a] = b;
      if(small[curr] >= b) {
        small[curr] = b;
      } else if(update) {
        small[curr] = INF;
        for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        if(ret > small[begin - 1]) for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        if(ret > small[end]) for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
int s[10007];
int t[507];
int main(){
	int n;
	int q;
	cin >> n;
	
	int i;
	for(i = 0; i < n; i++){
		cin >> s[i];
	}
	
	cin >> q;
	for(i = 0; i < q; i++){
		cin >> t[i];
	}
	
	int j;
	int count = 0;
	for(i = 0; i<q;i++){
		for(j = 0; j<n;j++){
			if(s[j]==t[i]){
				count++;
				break;
			}
		} 
	}
	cout << count << endl;
	return 0;
} 


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n,m;
  cin>>n>>m;

  int ans=m;

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

    int x;
    cin>>x;

    if(x <= m) ans--;

  }

  cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	int x = 0;
	int y = n;
	while(n%10 != 0){
		x += n%10;
		n /= 10;
	}
	cout << (y%x == 0? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void solve(string& s, int n)
{
    int m = s.size();
    if(m == n){
        cout << s << endl;
        return;
    }

    for(char c='a'; ; ++c){
        s += c;
        solve(s, n);
        s.pop_back();
        if(s.find(c) == string::npos)
            break;
    }
}

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

    string s = "";
    solve(s, n);

    return 0;
}


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

using namespace std;

long long a[200005];
long long sum[200005];
int main()
{
    long long n;
    cin>>n;
    for(long long i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sum[0]=a[0];
    for(long long i=1;i<n;i++)
        sum[i]=sum[i-1]+a[i];
    long long ans=20000000000000005;
    for(long long i=0;i<n-1;i++)
        ans=min(ans,abs(sum[n-1]-2*sum[i]));
    cout<<ans<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int n, m;
int a[220000];
bool p[220000];

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  
  for (int i = n; i > 0; i--) {
    int sm = 0;
    for (int j = i; j <= n; j += i) {
      if (p[j]) sm++;
    }
    sm %= 2;
    if (a[i] != sm) {
      p[i] = true;
      m++;
    }
  }
  
  cout << m << endl;
  for (int i = 1; i <= n; i++) {
    if (p[i]) {
      cout << i << " ";
    }
  }
  return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int n, D;
string s;
int memo[10005][105][2];

int dp(int i, int o, bool m) {
	if (i==n) {
		if (o) return 0;
		return 1;
	}
	if (memo[i][o][m] != -1) return memo[i][o][m];
	int mxd = m?9:s[i]-'0';
	int uk = 0;
	for (int d=0 ; d<=mxd ; d++) {
		uk = (uk + dp(i+1, (o+d)%D, m|(d<s[i]-'0'))) % MOD;
	}
	return memo[i][o][m] = uk;
}

int main() {
	memset(memo, -1, sizeof memo);
	cin >>s;
	scanf("%d", &D);
	n = s.size();
	printf("%d\n", (MOD+dp(0, 0, 0)-1)%MOD);
	return 0;
}

Measured memory_bytes: 12784
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    string s; cin >> s;
    if ((s[6] == '1' && s[5] == '0') || (s[6] == '2' && s[5] == '0') || s[6] == '3' || s[6] == '4') {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b,w,d;
    scanf("%d%d%d",&w,&a,&b);
    if(a<b)
    {
        if((a+w)<b)
            d=b-(a+w);
        else
            d=0;
    }
    else if(a>b)
        if((b+w)<a)
            d=a-(b+w);
        else
            d=0;
    printf("%d",d);
}


Measured memory_bytes: 256