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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll x;
	cin >> x;

	ll ans = 1000 * (x / 500);
	x %= 500;
	ans += 5 * (x / 5);
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
  
fscanf(STDIN,"%d",$N);
$input = explode(" ",trim(fgets(STDIN)));
array_unshift($input,0);
array_push($input,0);
  
$distance = 0;
 
for($i=0;$i<=$N;$i++){
  $from = $input[$i];
  $to = $input[$i+1];
  $distance += abs((int)$to-(int)$from);
}
 
for($i=1;$i<=$N;$i++){
  $from = (int)$input[$i-1];
  $current = (int)$input[$i];
  $to = (int)$input[$i+1];
 
  $ans = $distance-(abs($current-$from)+abs($to-$current))+abs($to-$from);
 
  echo "$ans\n";
}

Measured memory_bytes: 23908
#include<cstdio>
#include<vector>
using namespace std;

int base, len;
vector<int> v;

void o() {
	for(int i=0;i<(int)v.size();i++) {
		if (v[i]==0) break;
		if (i) putchar(' ');
		printf("%d", v[i]);
	}
	puts("");
}

void dfs(int x) {
	// f[x] = prev(f[x+1])
	if (x==1) return;
	
	v.push_back(base/2+1);
	dfs(x-1);
	if (x%2==1) return;
	int it = (int)v.size()-1;
	while(v[it]==0) it--;
	v[it]--;
	while(v[it]>0 && it<len-1) {
		v[++it] = base;
	}
	//o();
}

int main() {
	scanf("%d%d", &base, &len);
	if (base==1) {
		v.clear();
		for(int i=0;i<(len+1)/2;i++) v.push_back(1);
		o();
		return 0;
	}
	if (base % 2 == 0) {
		printf("%d", base/2);
		for(int i=1;i<len;i++) printf(" %d", base);
		puts("");
		return 0;
	}
	
	v.clear();
	v.push_back(base/2+1);
	dfs(len);
	o();
	
	return 0;
}

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

int main(){
    int n; //宝石の数
    int k; //操作の最大回数
    cin >> n >> k;

    vector<int> v(n); //宝石を入れるdeque
    for(int i=0; i<n; i++) cin >> v[i];

    int ans = 0; //価値の最大値

    /* aは左から宝石をとる回数 */
    for(int a=0; a<=min(n,k); a++){

        /* bは宝石を右からとる回数 */
        for(int b=0; a+b<=min(n,k); b++){

            /* 宝石を捨て、価値の最大値を見つける */

            //獲得する宝石を別のdequeに格納する
            vector<int> hand(a+b);
            for(int i=0; i<a; i++) hand[i] = v[i];
            for(int i=0; i<b; i++) hand[i+a] = v[n-i-1];

            //sortする
            sort(hand.begin(),hand.end());

            int sum = accumulate(hand.begin(),hand.end(),0); //現時点での価値の合計

            //負の値を正にして加える（負の値の宝石を捨てる）
            for(int i=0; i<min(k-a-b,a+b); i++){
                if(hand[i] < 0) sum += abs(hand[i]);
                else break;
            }

            //価値を比べる
            if(ans < sum) ans = sum;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b;
  
  scanf("%d %d",&a,&b);

  if(a==b) printf("Draw");
  
  else if(a==1) printf("Alice");
  else if(b==1) printf("Bob");
  else if(a<b) printf("Bob");
  else printf("Alice");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  ll rate[2][3];
  ll samecnt = 0;
  ll bigger = 0;
  ll smaller = 0;
  rep(i,2){
      rep(j,3){
          cin >> rate[i][j];
          if(i==1){
              if(rate[0][j]>rate[1][j])smaller++;
              else if(rate[0][j]<rate[1][j])bigger++;
          }
      }
  }
  if(bigger==1){
      ll smi,sma;
      rep(i,3){
          if(rate[0][i]<rate[1][i]){
              smi = rate[0][i];
              sma = rate[1][i];
          }
      }
      n = n/smi*sma + n%smi;
  }else if(bigger == 2){
      ll mi1 = 0, ma1 = 0;
      ll mi2,ma2;
      rep(i,3){
          if(rate[0][i]<rate[1][i]){
              if(mi1==0){
                  mi1 = rate[0][i];
                  ma1 = rate[1][i];
              }else{
                  mi2 = rate[0][i];
                  ma2 = rate[1][i];
              }
          }
      }
      ll man = 0;
      rep(i,n/mi1+1){
          ll tmp = i * ma1 + (n-i*mi1)/mi2*ma2 + (n-i*mi1)%mi2;
          man = max(man,tmp);
      }
      n = man;
  }else if(bigger==3){
      ll mi1 = rate[0][0];ll ma1 = rate[1][0];
      ll mi2 = rate[0][1];ll ma2 = rate[1][1];
      ll man = 0;
      rep(i,n+1){
          rep(j,n+1){
              ll tmp = n-mi1*i-mi2*j;
              if(tmp<0)continue;
              man = max(man,i*ma1 + j*ma2 + tmp/rate[0][2]*rate[1][2] + tmp%rate[0][2]);
          }
      }
      n = man;
  }
  if(smaller==1){
   ll smi,sma;
      rep(i,3){
          if(rate[0][i]>rate[1][i]){
              smi = rate[1][i];
              sma = rate[0][i];
          }
      }
      n = n/smi*sma + n%smi;
  }else if(smaller==2){
      ll mi1 = 0, ma1 = 0;
      ll mi2,ma2;
      rep(i,3){
          if(rate[0][i]>rate[1][i]){
              if(mi1==0){
                  mi1 = rate[1][i];
                  ma1 = rate[0][i];
              }else{
                  mi2 = rate[1][i];
                  ma2 = rate[0][i];
              }
          }
      }
      ll man = 0;
      rep(i,n/mi1+1){
          ll tmp = i * ma1 + (n-i*mi1)/mi2*ma2 + (n-i*mi1)%mi2;
          man = max(man,tmp);
      }
      n = man;
  }else if(smaller==3){
      ll mi1 = rate[1][0];ll ma1 = rate[0][0];
      ll mi2 = rate[1][1];ll ma2 = rate[0][1];
      ll man = 0;
      rep(i,n+1){
          rep(j,n+1){
              ll tmp = n-mi1*i-mi2*j;
              if(tmp<0)continue;
              man = max(man,i*ma1 + j*ma2 + tmp/rate[1][2]*rate[0][2] + tmp%rate[1][2]);
          }
      }
      n = man;
  }
  cout << n << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

	
	public static void main(String[] args) {
		FastScanner scanner=new FastScanner();
		int n=scanner.nextInt();
		double a[]=new double[n];
		for(int i=0;i<n;i++) a[i]=scanner.nextDoubel();
		double dp[][]=new double[n+1][n+1];
		dp[0][0]=1;
		for(int i=1;i<=n;i++) {
			dp[i][0]=dp[i-1][0]*(1-a[i-1]);
		}
		
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=i;j++) {
				
				dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1]);
			}
		}
		double ans=0;
		for(int i=(n+1)/2;i<=n;i++)
			ans+=dp[n][i];
		
		System.out.println(ans);
		
		

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDoubel() {
			return Double.parseDouble(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}

}


Measured memory_bytes: 106540
n = int(input())
aDic = {}

for i in range(n):
  test = int(input())
  if not(test in aDic.keys()):
    aDic[test] = 1
  elif aDic[test] == 1:
    aDic[test] = 0
  else:
    aDic[test] = 1

print(sum(aDic.values()))




Measured memory_bytes: 15076
memo = {}
def down(d, last, c):
    result = 0
    if d in memo:
        return memo[d]
    for i in range(26):
        result += c[i] * (d - last[i])
    memo[d] = result
    return result


def calc_score_of_the_day(S, d, t, last, C):
    return S[d][t] - down(d+1, last, C) + C[t] * (d+1 - last[t])


def main():
    D = int(input())
    C = [int(c) for c in input().split()]

    S = [0] * D

    for d in range(D):
        S[d] = [int(s) for s in input().split()]

    last = [0] * 26

    result = 0
    T = [0] * D
    for d in range(D):
        next_t = 0
        score = float('-inf')
        for t in range(26):
            s = calc_score_of_the_day(S, d, t, last, C)
            if s > score:
                score = s
                next_t = t
        last[next_t] = d + 1
        result += score
        T[d] = next_t + 1

    for t in T:
        print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9480
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
//#include <bits/stdc++.h>で全部入る。

using namespace std;

template <class T>
class Stack{
  //メンバ関数
public:
  struct Node{
    Node* prev; //前のノードへのポインタ
    Node* next; //後のノードへのポインタ
    T value; //このノードに格納されているデータ
  };
private:
  Node* top;
  int max;
  int element_num;
public:
  Stack(int num);
  T pop();
  void push(T val);
  bool isEmpty();
  bool isFull();
};

template <class T>
Stack<T>::Stack(int num){
  top = 0;
  max = num;
  element_num = 0;
}

template <class T>
T Stack<T>::pop(){
  if(isEmpty()){
    printf("This Stack is empty.\n");
    return 0;
  }
  T out = top->value;
  top = top->next;
  if(element_num > 1){
    delete top->prev;
    top->prev = 0;
  }
  element_num--;
  return out;
}

template <class T>
void Stack<T>::push(T val){
  if(isFull()){
    printf("This Stack is full.\n");
    return;
  }
  Node* next_top = new Node;
  next_top->value = val;
  next_top->prev = 0;
  next_top->next = top;
  if(element_num > 0)
    top->prev = next_top;
  top = next_top;
  element_num++;
  return;
}

template <class T>
bool Stack<T>::isEmpty(){
  if(top == 0) return true;
  return false;
}

template <class T>
bool Stack<T>::isFull(){
  if(element_num == max) return true;
  return false;
}

int main(){
  Stack<int>* s = new Stack<int>(200);
  string c;
  while(cin >> c){
    if(c[0] == '+'){
      int op1 = s->pop();
      int op2 = s->pop();
      s->push(op2+op1);
      //fprintf(stderr,"%d+%d=%d\n",op2,op1,op2+op1);
      continue;
    }
    if(c[0] == '-'){
      int op1 = s->pop();
      int op2 = s->pop();
      s->push(op2-op1);
      //fprintf(stderr,"%d-%d=%d\n",op2,op1,op2-op1);
      continue;
    }
    if(c[0] == '*'){
      int op1 = s->pop();
      int op2 = s->pop();
      s->push(op2*op1);
      //fprintf(stderr,"%d*%d=%d\n",op2,op1,op2*op1);
      continue;
    }
    else{
      int num = 0;
      for(int i = 0;c[i] != '\0';i++){
        num = num*10 + (c[i]-'0');
      }
      //fprintf(stderr,"%d\n",num);
      s->push(num);
    }
  }
  int result = s->pop();
  printf("%d\n",result);
  delete s;
  return 0;
}



Measured memory_bytes: 3252
N = int(input())
As = [(A << 20) + i for i, A in enumerate(map(int, input().split()))]


def chmax(i, elem):
    global dp
    if dp[0][i] < elem:
        dp[1][i] = dp[0][i]
        dp[0][i] = elem
        return True
    elif dp[1][i] < elem < dp[0][i]:  # skip dp[0][i] == elem
        dp[1][i] = elem
        return True
    else:
        return False


dp = [[0] * len(As) for _ in range(2)]  # first largest and second largest
dp[0][0] = As[0]
ans = 0
for i in range(1, 2 ** N):
    for j in range(N):
        if i & (1 << j):
            if chmax(i, dp[0][i & ~(1 << j)]):
                chmax(i, dp[1][i & ~(1 << j)])
    chmax(i, As[i])
    ans = max(ans, (dp[0][i] + dp[1][i]) >> 20)
    print(ans)


Measured memory_bytes: 110132
n,m = map(int, input().split())
stu = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]

for x, y in stu:
    k = []
    for c, d in p:
        k.append(abs(x-c)+abs(y-d))
    print(k.index(min(k))+1)
        

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int h,w,num=0;
vector<string> s(100);
queue<pair<int,int>> q;
int vis[100][100]={};


void bfs(int ih,int iw){
    if(ih>=1){
        if(s[ih-1][iw]=='.'&&vis[ih-1][iw]==-1){
            vis[ih-1][iw]=vis[ih][iw]+1;
            q.push(MP(ih-1,iw));
        }
    }
    if(ih<h-1){
        if(s[ih+1][iw]=='.'&&vis[ih+1][iw]==-1){
            vis[ih+1][iw]=vis[ih][iw]+1;
            q.push(MP(ih+1,iw));
        }

    }
    if(iw>=1){
        if(s[ih][iw-1]=='.'&&vis[ih][iw-1]==-1){
            vis[ih][iw-1]=vis[ih][iw]+1;
            q.push(MP(ih,iw-1));
        }

    }
    if(iw<w-1){
        if(s[ih][iw+1]=='.'&&vis[ih][iw+1]==-1){
            vis[ih][iw+1]=vis[ih][iw]+1;
            q.push(MP(ih,iw+1));
        }

    }


    return;
}


int main(void) {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            vis[i][j]=-1;
        }
    }

    cin>>h>>w;

    for (int ih = 0; ih < h; ih++) {
        cin>>s[ih];
        for (int iw = 0; iw < w; iw++) {
            if(s[ih][iw]=='.')num++;
        }
    }

    vis[0][0]=1;
    bfs(0,0);
    while(!q.empty()){
        bfs(q.front().first,q.front().second);
        q.pop();
    }

    if(vis[h-1][w-1]==-1){
        cout<<-1<<"\n";
    }else{
        cout<<num-vis[h-1][w-1]<<"\n";
    }

    

    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
 
// ===============================================================
 
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
 
// ===============================================================
 
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}
 
	// 素数である
	return true;
}
//素数判定
 
// ===============================================================
 
int main() {
	ll n, m;
	cin >> n >> m;
	vl a(n);
	vl r(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			r[i] = a[i];
		}
		else r[i] = r[i - 1] + a[i];
	}
	ll ans = 0;
	ll count = 0;
	for (int i = 0; i < n - m+1; i++) {
		if (i != 0) {
			count = r[i + m - 1] - r[i - 1];
		}
		else {
			count = r[m - 1];
		}
		if (max(ans, count) == count) {
			ans = count;
		}
	}
	long double f = ans+m;
  cout << fixed << setprecision(10);
	cout<<f/2<<endl;
}

Measured memory_bytes: 6524
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
 
	long long ans = 0;
	int right = 0;
	int sum = 0; 
	for (int left = 0; left < n; ++left) {
		while (right < n && (sum ^ a[right]) == (sum + a[right])) {
			sum += a[right];
			++right;
		}
		ans += right - left;
		if (left == right) ++right;
		else sum -= a[left];
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    long long num,day,move,town=1,road[100000]={0},sum=0,i,j;
    scanf("%lld %lld",&num,&day);
    sum=0;
    for (i=0; i<num-1; i++) scanf("%lld",&road[i+1]);
    for (i=0; i<day; i++) {
        scanf("%lld",&move);
        if (move>0) {
            for (j=0; j<move; j++) sum+=road[town+j];
        } else {
            for (j=0; abs(j)<abs(move); j--) sum+=road[town+j-1];
        }
        sum%=100000;
        town+=move;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1384
package main

import "fmt"

// 答えを返す
func check(in []int) int {
	var cnt int
	for i := 1; i < len(in)-1; i++ {
		if (in[i-1] < in[i] && in[i] < in[i+1]) || (in[i+1] < in[i] && in[i] < in[i-1]) {
			cnt++
		}
	}
	return cnt
}

func main() {
	var n int
	var list []int

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var in int
		fmt.Scanf("%d", &in)
		list = append(list, in)
	}

	fmt.Println(check(list))
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 45
int fib(int,int *);

int main(){
  int n,F[MAX]={};
  scanf("%d",&n);
  printf("%d\n",fib(n,F));
  return 0;
}
int fib(int n,int F[]){
  if(n==0 || n==1) return F[n]=1;
  if(F[n]!=0) return F[n];
  return F[n]=fib(n-2,F)+fib(n-1,F);
}



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

int main(){
  int H, W, i, j, k, counter = 0;
  cin >> H >> W;

  string S[50];
  int d[8][2] = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}};

  for(i = 0; i < H; ++i) cin >> S[i];

  for(i = 0; i < H; ++i){
    for(j = 0; j < W; ++j){
      if(S[i][j] == '#') continue;

      for(k = 0; k < 8; ++k){
        int xi = i + d[k][0];
        int yj = j + d[k][1];

        if(xi < 0 or xi >= H) continue;
        if(yj < 0 or yj >= W) continue;
        if(S[xi][yj] == '#') counter++;
      }
      S[i][j] = char(counter + '0');
      counter = 0;

    }
  }

  for(i = 0; i < H; ++i) cout << S[i] << endl;

  return 0;
}

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

using namespace std;

int main()
{
	string N;

	cin >> N;

	int a = 0;

	for (int n = 1; n < 4; n++) {
		if (N[0] != N[n])break;
		if (n == 2)a = 1;
	}

	for (int n = 2; n < 4; n++) {
		if (N[1] != N[n])break;
		if (n == 3)a = 1;
	}

	if (a)cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace
{
const int MAX_N	= 100;
int d[ MAX_N + 5 ];
}

int main( int argc, char *argv[] )
{
int i;
int N;
int iCount;
int iChk;

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

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

	sort( d, d + N );

	iChk	= 0;
	iCount	= 0;
	for( i = 0; i < N; i++ )
	{
		if( iChk < d[ i ] )
		{
			iChk = d[ i ];
			iCount++;
		}
	}

	cout << iCount << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int hako[10][10]={};
  for(int i=0;i<10;i++){
    for(int j=i;j<10;j++){
      hako[i][j]=10;
    }
  }
  int a,x;
  cin>>a>>x;
  cout<<hako[x][a]<<endl;
  //for(int i=0;i<10;i++){
  //  for(int j=0;j<10;j++){
  //    cout<<hako[i][j];
  //  }
  //  cout<<endl;
  //}
}


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

int main() {
	int n;
	while (cin >> n) {
		if (!n)break;
		int _max = 0, _min = 1001, s, ans = 0, i = 0;
		for (i; i < n; ++i) {
			cin >> s;
			ans += s;
			_max = max(_max, s);
			_min = min(_min, s);

		}
		ans -= _max + _min;
		ans = int(ans / (n - 2));
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int N, num;
    cin >> N >> num;

    int number[103]={0};
    int now;
    for(int i=0; i<num; i++){
        cin >> now;
        number[now+1] = 1;
    }

    int width=0;
    int ans;
    while(true){
        if(num == 0){
            ans = N;
            break;
        }
        if(number[N-width+1] == 0){
            ans = N-width;
            break;
        }else if(number[N+width+1] == 0){
            ans = N+width;
            break;
        }

        width++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = mod * mod;


/* dp[i][j][k] i:上からの桁、j:下一桁、k:iとのさ*/
ll dp[62][3] = {};

int main(){
	ll n;
	
	cin >> n;
	dp[61][0] = 1;
	for (int i = 60; i >= 0; i--) {
		if ((n & (1LL << i) )== 0LL) {
			dp[i][0] = (dp[i + 1][0] + dp[i+1][1]) % mod;
			dp[i][1] = dp[i+1][1];
			dp[i][2] = (3*dp[i + 1][2] + dp[i + 1][1]) % mod;
		}
		else {
			dp[i][0] = dp[i + 1][0];
			dp[i][1] = (dp[i + 1][0] + dp[i + 1][1]) % mod;
			dp[i][2] = (3*dp[i + 1][2] + 2*dp[i + 1][1]) % mod;
		}
	}
	cout << (dp[0][0] + dp[0][01] + dp[0][2]) % mod << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,k,i,j,x,y,z;
    x=0;
    cin>>n>>k;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
	for (i=0;i<k;i++)
	{
		x+=arr[i];
	}
	cout<<x<<endl;
}

Measured memory_bytes: 3660
#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){
  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);

  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;

}

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: 20472
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
    int n;
    cin >> n;
    vector<int>a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    ll cnt = 0;
    rep(i,n){
        cnt+=min(a[i],b[i]);
        if(a[i]<b[i]){
            cnt+=min(a[i+1],b[i]-a[i]);
            a[i+1] = a[i+1] - min(a[i+1],b[i]-a[i]);
        }
    }
    cout << cnt <<endl;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int cost=A*X+B*Y;
  for (int k=1; k<=100000; k++) {
    cost=min(cost,2*C*k+max(X-k,0)*A+max(Y-k,0)*B);
  }
  cout<<cost<<endl;
  return 0;
}

Measured memory_bytes: 256
# 解説AC
N,K,C = map(int, input().split())
S = [""] + list(input())

# cnt1[i]: [1,i]での最大労働可能日数
cnt1 = [0] * (N + 2)
cnt, can = 0, 0
for i in range(1, len(S)):
    if S[i] == "o" and i >= can:
        cnt += 1
        can = i + (C + 1)
    cnt1[i] = cnt

# cnt2[i]: [i,N]での最大労働可能日数
cnt2 = [0] * (N + 2)
cnt, can = 0, N
for i in range(len(S) - 1, 0, -1):
    if S[i] == "o" and i <= can:
        cnt += 1
        can = i - (C + 1)
    cnt2[i] = cnt

ans = []
for i, s in enumerate(S[1:], 1):
    if s == "x": continue
    # i日目に働かないと、条件を満たさない場合
    if cnt1[i - 1] + cnt2[i + 1] < K:
        ans.append(i)

print(*ans, sep="\n")

Measured memory_bytes: 34268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		map<string,int>ma;
		vi in(n);
		rep(i,n){
			string s;int a,b;
			cin>>s>>a>>b;
			in[i]=(a*24*60)+(b/100*60+b%100)-6*60;
			ma[s]=i;
		}
		int m;
		cin>>m;
		int out=m;
		vi dp(7*24*60+100);
		bool h=true;
		rep(i,m){
			string s;
			cin>>s;
			int t=ma[s];
			loop(j,in[t],in[t]+30){
				if(dp[j])h=false;
				dp[j]=true;
			}
		}
		if(!h){
			cout<<-1<<endl;
			continue;
		}
		sort(all(in));
		int t=-1;
		rep(i,n){
			if(dp[in[i]]||dp[in[i]+29])continue;
			if(in[i]<t)continue;
			t=in[i]+30;
			out++;
		}
		cout<<out<<endl;
	}
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int h, w; cin >> h >> w;
    REP(i, 0, h){
        string s; cin >> s;
        cout << s << endl << s << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

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

string name;

int a, b, c, d;

int number[100005] = { 0 };

int h[100005] = { 0 };
int w[100005] = { 0 };

int max_count = 0;

void input(void) {
	CI N;
	
}
int main(void) {
	int cost = 0;
	int num = 0;
	int sum_c = 0;
	int sum_n = 0;
	int i = 0;
	
	while (scanf("%d,%d", &cost, &num) != EOF) {
		sum_c += cost * num;
		sum_n += num;
		i++;
	}

	CO sum_c E
	
	CO (int)((double)sum_n / (double)i + 0.5) E

	
	return 0;
}

Measured memory_bytes: 3164
use std::io;

fn main() {
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).ok();
        let mut iter = buf.split_whitespace();

        let x: i32 = iter.next().unwrap().parse().unwrap();
        let y: i32 = iter.next().unwrap().parse().unwrap();
        if x == 0 && y == 0 {
            break;
        }
        if x < y {
            println!("{} {}", x, y);
        } else {
            println!("{} {}", y, x);
        }
    }
}


Measured memory_bytes: 5024
import java.io.*;
import java.io.BufferedReader;

public class Main{
    public static String replaceS(String s, int begin, int end){
        String newString = s.substring(0,begin) + s.substring(end);
        return newString;
    }
    public static void main(String[] args){
        String s1,s2;

        //final String FILENAME  = "btest.txt";
        BufferedReader br = null;
        try{
            br = new BufferedReader(new InputStreamReader(System.in));
            String curr;
            while(!(curr=br.readLine()).equals(".")){
                s1 = curr;
                //System.out.println(s1+" and \""+s1.indexOf('\"'));
                curr = br.readLine();
                s2 = curr;
                //System.out.println(s2);
                if (s1.equals(s2)){
                    System.out.println("IDENTICAL");
                }else{
                    int[] list1 = new int[100];
                    int[] list2 = new int[100];
                    int x = 0;
                    int y = 0;
                    for (int i = 0; i < s1.length(); i++){
                        if (s1.charAt(i) == '\"'){
                            list1[x] = i;
                            //System.out.println("list1["+x+"]:"+i);
                            x++;     
                        }
                    }
                    for (int i = 0; i < s2.length(); i++){
                        if (s2.charAt(i) == '\"'){
                            list2[y] = i;
                            //System.out.println("list2["+y+"]:"+i);
                            y++;     
                        }
                    }

                    if (list1.length != list2.length){
                        System.out.println("DIFFERENT");
                    }else {
                        int check = 0;
                        for (int i = 0; i < list1.length;i+=2){
                            String temp1 = replaceS(s1,list1[i],list1[i+1]);
                            String temp2 = replaceS(s2,list2[i],list2[i+1]);
                            //System.out.println("temp1:"+temp1);
                            //System.out.println("temp2:"+temp2);
                            if (temp1.equals(temp2)){
                                check = 1;
                                break;
                            }
                        }
                        if (check == 1){
                            System.out.println("CLOSE");
                        }else{
                            System.out.println("DIFFERENT");
                        }
                    }
                }
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 30680
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  vector<ll> idx(n);
  rep(i,n) idx.at(A[i]-1)=i;

  ll ans=0;
  multiset<ll> s{-1,-1,n,n};
  rep(k,n,0,-1){
    ll i=idx[k-1];
    auto itl=s.insert(i);
    auto itr=itl;
    vector<ll> l(2),r(2);
    rep(i,2){
      l[i]=*(--itl);
      r[i]=*(++itr);
    }
    ans+=k*((i-l[0])*(r[1]-r[0])+(l[0]-l[1])*(r[0]-i));
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 6528
n = int(input())
s = list(input())
e = s.count("E")
w = s.count("W")
res = 10**7
for i in range(n):
    if s[i] == "E":
        tmp = e - 1
    else:
        tmp = e
    if s[i] == "W":
        e += 1
    else:
        e -= 1
    res = min(res, tmp)
print(res)


Measured memory_bytes: 5796
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N = int(input())
cood = []
ans = 0
r = 0
for i in range(N):
    A= [float(i) for i in input().split()]
    cood.append(A)
for j in range(N):
    for k in range(N):
        for i in range(N):
            if i == k or i == j or j == k:
                continue
            else:
                a = cood[j][0]
                b = cood[j][1]
                c = cood[k][0]
                d = cood[k][1]
                e = cood[i][0]
                f = cood[i][1]

                aa = a * a
                bb = b * b
                cc = c * c
                dd = d * d
                ee = e * e
                ff = f * f
                if ((a-c) * (a-e) + (b-d) * (b-f)) > 0 and ((c-a) * (c-e) + (d-b) * (d-f)) > 0 and ((e-a)* (e-c) + (f-b) * (f-d)) > 0:
                    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

                    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
                        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

                    r = math.hypot(px - a, py - b)
                else:
                    r = max(((a-c)**2+(b-d)**2)**(1/2),((a-e)**2+(b-f)**2)**(1/2),((e-c)**2+(f-d)**2)**(1/2))
                    r /= 2
                if r > ans:
                    ans = r
if N == 2:
    ans = ((cood[1][0]-cood[0][0])**2+(cood[1][1]-cood[0][1])**2)**(1/2)/2
print(ans)


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  rep(i,0,4){
    int a,b;
    cin>>a>>b;
    if(a == 1){
      cout<<b*6000<<'\n';
    }else if(a == 2){
      cout<<b*4000<<'\n';
    }else if(a == 3){
      cout<<b*3000<<'\n';
    }else{
      cout<<b*2000<<'\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

/*
  階乗計算（MODで割った余りで返す）
*/

class Factorial {
    private:
        vector<ll> fac;
    public:
        Factorial();
        Factorial(ll n_max);
        void initialization(ll n_max);
        ll getFactorial(ll n);
};

Factorial::Factorial() {}
Factorial::Factorial(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
void Factorial::initialization(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
ll Factorial::getFactorial(ll n) {
    return fac[n];
}

/*
  MOD計算
*/
// 割り算のための逆元を求める（mod m での a の逆元）
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u % m;
}

/*
    順列と組み合わせ (P, C, H)
*/

class PCH {
    private:
        Factorial fact;
    
    public:
        PCH(ll n_max);
        ll P(ll n, ll r);
        ll C(ll n, ll r);
        ll H(ll n, ll r);
};
PCH::PCH(ll n_max) {
    fact.initialization(n_max);
}
ll PCH::P(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::C(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::H(ll n, ll r) {
    return C(n - 1 + r, r);
}

int main() {
  
  ll S;
  cin >> S;

  ll ans = 0;
  PCH pch(S);

  for (ll i = 1; i * 3 <= S; i++) {
    ll sum = S - 3 * i;
    ans += pch.H(i, sum);
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayDeque
import java.util._
import java.io._
import scala.collection.mutable.Set
import scala.io.StdIn._
 
object Main {
    def main(args: Array[String]): Unit = {
     var n = readInt
     var set = Set[String]()
     var list = readLine.split(" ").map(_.toString)
     for(i <- 0 until n){
       set.add(list(i))
     }
     n = readInt
     val temp = readLine.split(" ")
     var count = 0
     for(i <- 0 until n){
       if(set.contains(temp(i)))count += 1
     }
     println(count)
     
     
    }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	string s;
	cin >> s;
	//000から999が成り立つかを見ていく。
	int ans = 0 ;
	rep(i,1000){
		string search = to_string(i); 
		if(search.size() == 0) {
			search = "000" ;
		} 
		if(search.size() == 1){
			search = "00"+to_string(i);
		}
		if(search.size() == 2){
			search = "0" + to_string(i);
		}
		//searchが行けるか。
		int k = 0 ;
		char now_search = search[k++] ;
		rep(j,n){
			if(s[j] == now_search ) {
				now_search =search[k++] ;
				if(k==4){
					 ans ++ ;
					 break;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if M % 2 == 1:
        print(-1)
        return 0

    G = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)

    heap = []
    dist = [N] * (N+1)
    dist[1] = 0
    d = 0
    q = deque()
    q.append(1)
    while len(q) > 0:
        d += 1
        q_ = deque()
        while len(q) > 0:
            a = q.popleft()
            for b in G[a]:
                if dist[b] > d:
                    dist[b] = d
                    q_.append(b)
                    heappush(heap, (-d, b))
        q = q_

    cnt = [0] * (N+1)
    visited = [False] * (N+1)
    ans = []
    while len(heap) > 0:
        _, a = heappop(heap)
        visited[a] = True
        for b in G[a]:
            if visited[b]:
                continue

            if cnt[a] % 2 == 1:
                ans.append((a, b))
                cnt[a] += 1
            else:
                ans.append((b, a))
                cnt[b] += 1

    for a, b in ans:
        print('{} {}'.format(a, b))
    exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 37072
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
	int n,m;
	int a[1000][100];
	for(;;){
		cin >> n >> m;
		if(n==0&&m==0)return 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin >> a[i][j];
			}
		}

		int b[1000];
		for(int i=0;i<m;i++)b[i]=0;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(a[j][i])b[i]++;
			}
		}

		//for(int i=0;i<m;i++)printf("%d\n",b[i]);

		int ans[100];
		for(int i=0;i<m;i++)ans[i]=i+1;
		for(int i=0;i<m;i++){
			for(int j=i+1;j<m;j++){
				if(b[i]<b[j]){
					swap(b[i],b[j]);
					swap(ans[i],ans[j]);
				}
			}
		}
		for(int i=0;i<m;i++){
			for(int j=i+1;j<m;j++){
				if(b[i]==b[j]&&ans[i]>ans[j]){
					swap(ans[i],ans[j]);
				}
			}
		}
		for(int i=0;i<m;i++){
			if(i==m-1)printf("%d\n",ans[i]);
			else printf("%d ",ans[i]);
		}
	}
    return 0;
}

Measured memory_bytes: 1536
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map {it.toInt()}
    val ps = ArrayList<Pair<Int, Int>>()

    for (i in 1 .. M) {
        val (a, b) = readLine()!!.split(" ").map {it.toInt()}
        ps.add(Pair(a, i))
        ps.add(Pair(b, -i))
    }

    ps.sortWith(Comparator { a, b -> if (a.first == b.first) a.second - b.second else a.first - b.first })

    var res = 0
    var st = TreeSet<Int>()

    for (p in ps) {
        if (p.second > 0) {
            st.add(p.second)
        } else if (st.contains(-p.second)) {
            st.clear()
            res++
        }
    }

    println(res)
}


Measured memory_bytes: 74796
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	int c[100];
	string s;
	int i, index;
	for(i = 0; i < 100; i++) c[i] = 0;
	while(1) {
		getline(cin, s);
		if(s == "\0") break;
		for(i = 0; i < s.size(); i++) {
			if(('a' <= s[i] && s[i] <= 'z') || ('A' <= s[i] && s[i] <= 'Z')) {
				s[i] = tolower(s[i]);
				index = s[i] - 'a';
				c[index]++;
			}
		}
	}
	for(i = 0; i <= 'z' - 'a'; i++) {
		printf("%c : %d\n", 'a' + i, c[i]);
	}
	return 0;
}

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

int main(){
	ll n;
	cin>>n;
	vector<ll> pots(12,1);
	for(int i=1;i<=12;i++){
		pots[i]=pots[i-1]*26*1ll;
	}
	int id=0;
	ll sum=0;
	while(sum<=n){
		sum+=pots[id];
		id++;
	}
	id--;
	sum-=pots[id];
	n-=sum;
	vector<char>ans(id,'a');

	for(int i=0;i<id;i++){
		ll val=0;
		char c='a';
		while(val<=n){
			val+=pots[id-i-1];
			c++;
		}
		val-=pots[id-i-1];
		n-=val;
		c--;

		ans[id]=c;
		cout<<ans[id];

	}
	cout<<'\n';


	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N, D;
	cin >> N >> D;

	ll ans = (N + 2 * D) / (2 * D + 1);


	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256