akhauriyash/Code-Regression huggingface dataset:
//***Faithless is he that says farewell when the road darkens***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0) cout<<"1";
	if(b==0) cout<<"2";
	if(c==0) cout<<"3";
	if(d==0) cout<<"4";
	if(e==0) cout<<"5";
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
    int stack[100],i=0,j=0,temp,ans[100]={0};
    while(scanf("%d",&temp)!=EOF) {
        if(temp!=0){
            stack[i]=temp;
            i++;
        } else {
            ans[j]=stack[i-1];
            j++;
            i--;
        }
    }
    for(i=0;i<j;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <tuple>

using namespace std;

bool compare( tuple<int, int, int> t1, tuple<int, int, int> t2 ) {
  if ( get<0>( t1 ) != get<0>( t2 ) ) {
    return get<0>( t1 ) > get<0>( t2 );
  } else if ( get<1>( t1 ) != get<1>( t2 ) ) {
    return get<1>( t1 ) < get<1>( t2 );
  } else {
    return get<2>( t1 ) < get<2>( t2 );
  }
}

int main() {
  while( true ) {
    int t, p, r;
    cin >> t >> p >> r;
    if ( t == 0 and p == 0 and r == 0 ) break;

    vector<int> pen( t + 1 );
    vector<int> cor( t + 1 );
    vector<vector<int>> wrong( t + 1, vector<int>( p + 1 ) );
    fill( pen.begin(), pen.end(), 0 );
    fill( cor.begin(), cor.end(), 0 );
    for ( auto ar : wrong ) {
      fill( ar.begin(), ar.end(), 0 );
    }
    
    for ( int i = 0; i < r; i++ ) {
      int tid, pid, time;
      string m;
      cin >> tid >> pid >> time >> m;
      if ( m == "WRONG" ) {
	wrong[ tid ][ pid ]++;
      } else {
	pen[ tid ] += 1200 * wrong[ tid ][ pid ] + time;
	cor[ tid ]++;
      }
    }
    vector<tuple<int, int, int>> ans( t );
    for ( int i = 1; i <= t; i++ ) {
      ans[ i - 1 ] = make_tuple( cor[ i ], pen[ i ], i );
    }
    sort( ans.begin(), ans.end(), compare );
    
    for ( auto t : ans ) {
      cout << get<2>( t ) << " " << get<0>( t ) << " " << get<1>( t ) << endl;
    }
  }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 2e5 + 10;
int remin[maxn],n,k;

int main(){
   cin>>n>>k;
   for(int i = 1; i <= n; i++){
       remin[i % k]++;
   } 

   long long ans = 0;
   ans += 1ll *remin[0] * remin[0] * remin[0];
   if(k % 2 == 0) ans += 1ll * remin[k / 2] * remin[k/ 2] * remin[k / 2];
   cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = input()
l = [0,1,2,3,4,5,6,7,8,9]
ans = 0
for i in l:
    for j in l:
        for k in l:
            a,b,c = i,j,k
            # print(a,b,c)
            for m in s:
                # print(m)
                if a==int(m):
                    # print(i)
                    a = -1
                elif a==-1 and b==int(m):
                    b = -1
                elif b==-1 and c==int(m):
                    ans+=1
                    # print(i,j,k)
                    break
print(ans)

Measured memory_bytes: 73004
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll h,n,x=0,y;
	cin>>h>>n;
	for(int a=0;a<n;a++)
	{
		cin>>y;
		x=x+y;	
	}
	if(x>=h)
	cout<<"Yes";
	else 
	cout<<"No";
	return 0;
}



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

int main(){
    int N, D, A;
    std::cin >> N >> D >> A;
    std::vector< std::pair< int, long long > > XH(N);
    for(int i=0; i<N; i++){
        std::cin >> XH[i].first >> XH[i].second;
        XH[i].second = XH[i].second / A + (int)(XH[i].second % A != 0);
    }
    
    std::sort(XH.begin(), XH.end());

    long long cnt = 0;
    std::deque< int > bomb_end;
    std::deque< int > bomb_num;
    int cur_bomb_total = 0;
    for(int i=0; i<N; i++){
        while(!bomb_end.empty()){
            if(bomb_end[0] < XH[i].first){
                cur_bomb_total -= bomb_num[0];
                bomb_end.pop_front();
                bomb_num.pop_front();
            }else{
                break;
            }
        }
        if(XH[i].second <= cur_bomb_total){
            continue;
        }
        bomb_end.push_back(XH[i].first + 2 * D);
        bomb_num.push_back(XH[i].second - cur_bomb_total);
        cnt += XH[i].second - cur_bomb_total;
        cur_bomb_total = XH[i].second;

    }

    std::cout << cnt << std::endl;
    return 0;
}



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

using namespace std;

struct state {
  double begin;
  double end;
  double v;
  state() {}
  state(double b, double e, double v): begin(b), end(e), v(v) {}
};

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

  vector<int> t(n + 2, 0), v(n + 2, 0);
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }

  vector<state> vs(n + 2);
  vs[0] = state(0, 0, 0);
  for (int i = 1; i <= n + 1; i++) {
    state s = vs[i - 1];
    vs[i] = state(s.end, s.end + t[i], v[i]);
  }

  const double eps = 1e-10;
  int T = 2 * (int)vs[n + 1].end;
  vector<double> p(T + 1, 101.0);
  for (int i = 0; i <= T; i++) {
    double t = i / 2.0;
    for (int j = 0; j < n + 2; j++) {
      if (vs[j].begin - t > eps) {
        p[i] = min(p[i], vs[j].begin - t + vs[j].v);
      } else if (t - vs[j].end > eps) {
        p[i] = min(p[i], t - vs[j].end + vs[j].v);
      } else {
        p[i] = min(p[i], vs[j].v);
      }
    }
  }

  double ans = 0.0;
  for (int i = 0; i < T; i++) {
    ans += p[i] + p[i + 1];
  }
  printf("%.10f\n", ans / 4.0);

  return 0;
}

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

public class Main {
  private static String solve(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;;
    int x4 = x3 - dx;
    int y4 = y3 - dy;
    return String.format("%d %d %d %d", x3, y3, x4, y4);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x1 = reader.nextInt();
    int y1 = reader.nextInt();
    int x2 = reader.nextInt();
    int y2 = reader.nextInt();
    out.println(solve(x1, y1, x2, y2));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  rep(i, N) {
    std::cin >> S[i];
  }

  std::sort(S.begin(), S.end());

  std::map<std::string, int> cnt;
  int max_cnt = 0;
  rep(i, N) {
    max_cnt = std::max(max_cnt, ++cnt[S[i]]);
  }

  auto end = std::unique(S.begin(), S.end());
  for(auto it = S.begin(); it != end; ++it) {
    std::string s = *it;
    if(cnt[s] == max_cnt) {
      std::cout << s << '\n';
    }
  }
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    string s; cin >> s;
	bool poss = true;
	if(s[0] == 'A'){
		for(auto i : s)
			if(i != 'A' && i != 'C'){
				if(islower(i))
					continue;
				poss = false;
				break;
			}
		int cnt = 0;
		for(int i = 2; i <= s.length() - 2; i++)
			if(s[i] == 'C')
				cnt++;
		if(cnt != 1)
			poss = false;
	}else
	{
		poss = false;
	}
	if(poss)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int a[10000];
    int G[105][105];
    long i,j,n,h,w;
    cin >> h >> w;
    cin >> n;
    for(i=1;i<=n;++i)
    cin>>a[i];
    long ans=1;
    for(int i=1;i<=h;++i)
    {
        if(i&1)
        {
            for(int j=1;j<=w;++j)
            {
                if(a[ans]>0) {G[i][j]=ans;a[ans]--;}
                else if(a[ans]==0) {ans++;G[i][j]=ans;a[ans]--;}
            }
        }
        else
        {
            for(int j=w;j>=1;j--)
            {
                if(a[ans]>0) {G[i][j]=ans;a[ans]--;}
                else if(a[ans]==0) {ans++;G[i][j]=ans;a[ans]--;}
            }
        }
    }
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(j!=w) cout<<G[i][j]<<" ";
            else cout<<G[i][j]<<endl;
        }
    }
return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;


	int s;

	int sum,ave;

	int i;

	while(1){
		vector<int> v;
		sum = 0;

		cin >> n;
		if (n==0) break;

		for(i=0;i<n;i++){
			cin >> s;
			v.push_back(s);
		}

		
		sort(v.begin(),v.end());

		for(i=1;i<v.size()-1;i++){
			sum += v[i];
		}

		ave = sum/(v.size()-2);

		cout << ave << endl;

	}
	return 0;
}

Measured memory_bytes: 1220
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    A = list(map(int, input().split()))
    def Chk(a, pos):
        cnt = 0
        tmp = 0

        for a in A:
            tmp += a

            if pos and tmp < 1:
                cnt += 1 - tmp
                tmp = 1
            elif not pos and tmp > -1:
                cnt += 1 + tmp
                tmp = -1

            pos = not pos
        return cnt

    print(min(Chk(A, True), Chk(A, False)))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 14204
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	if (B / A >= C)
	{
		cout << C;
	}
	else
	{
		cout << B / A;
	}

	return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c;
    cin>>n;
    map<ll,ll>mp;
    c=0;
    for(i=0;i<n;i++)
    {
        cin>>k;
        if(mp[k]==0)
        {
            c++;
        }
        mp[k]++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int d, c[365], s[365][26], t[365], last[26], u;

void input(){
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d){
    rep(j, 26){
      cin >> s[i][j];
    }
  }
  rep(i, d){
    int k;
    cin >> k;
    k--;
    t[i] = k;
  }
  fill(last, last+26, 0);
}

int test(int k, int i){
  ll res = 0;
  rep(j, 26){
    if(j == k) continue;
    res -= c[j] * last[j];
  }
  
  return res + s[i][k];
}

void greedy(){
  rep(i, d){
    rep(i, 26) last[i]++;
    int res = -INF;
    rep(k, 26){
      if(res < test(k, i)){
        u = k;
        res = test(k, i);
      }
    }
    last[u] = 0;
    t[i] = u;
  }
}

int p_calc(){
  ll res = 0;
  int last[26];
  fill(last, last+26, 0);
  rep(i, d){
    res += s[i][t[i]];
    rep(i, 26) last[i]++;
    last[t[i]] = 0;
    rep(j, 26){
      res -= c[j]*last[j];
    }
  }
    
  return res;
}
  


  
int main(){
  input();
  greedy();
  ll ans = p_calc();

  
  for(int i = 364; i >= 0; i--){
    int p = i;
    int tmp = t[i];
    for(int j = 0; j < 26; j++){
      if(j == t[i]) continue;
      t[i] = j;
      if(ans > p_calc()) t[i] = tmp;
    }
  }
  rep(i, d) cout << t[i]+1 <<endl;
}

  

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A):
    return reduce(lambda x, y: x + y*(y-1)//2, Counter(accumulate([0]+A, lambda x, y: (x+y) % M)).values(), 0)


def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99768
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int notice;
	int rooms[4][3][10];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 10; k++)
				rooms[i][j][k] = 0;

	cin >> notice;
	for (int i = 0; i < notice; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		rooms[b - 1][f - 1][r -1] += v;
		if (rooms[b - 1][f - 1][r -1] < 0) {
			rooms[b - 1][f - 1][r -1] = 0;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++)
				cout << " " << rooms[i][j][k];
			cout << endl;
		}
		if (i != 3) {
			for (int l = 0; l < 20; l++) cout << "#";
			cout << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3084
package main

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

//const (
//	MaxIntValue = int(^uint(0) >> 1)
//)

func main() {
	X := readLineInt()[0]
	Result := 0

	for {
		if X-500 >= 0 {
			Result += 1000
			X -= 500
		} else if X-5 >= 0 {
			Result += 5
			X -= 5
		} else {
			break
		}
	}

	fmt.Println(Result)
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	//scanner.Split(bufio.ScanWords)
}
func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		r, _ := strconv.Atoi(v)
		result = append(result, r)
	}
	return result
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;


    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    map<int, int> mp;

    rep(i, n){
        if (mp.find(a[i]-i) == mp.end()){
            mp.insert({a[i]-i, 1});
        } else {
            mp[a[i]-i]++;
        }
    }

    ll ans = 0;
    rep(i, n){
        mp[a[i]-i]--;

        int key = -a[i]-i;
        ans += mp[key];
    }
    cout << ans << endl;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n + 1, 0);
    map<int, int> wa;
    int cwa = 0, cac = 0;
    for (int i = 0; i < m; i++)
    {
        int t;
        string s;
        cin >> t >> s;
        if (!ac[t] && s == "AC")
        {
            ac[t] = 1;
            cac++;
        }
        else if (!ac[t])
            wa[t]++;
    }
    for (auto x : wa)
    {
        if (ac[x.first])
            cwa += x.second;
    }
    cout << cac << " " << cwa << endl;
}


Measured memory_bytes: 6480
/*
<問題文>
額面がc1, c2,..., cm　円の　m　種類のコインを使って、 n 円を支払うときの、
コインの最小の枚数を求めて下さい。各額面のコインは何度でも使用することができます。
<入力>
n m
c1 c2 ... cm
１行目に整数 n と整数 m が１つの空白区切りで１行に与えられます。
２行目に各コインの額面が１つの空白区切りで１行に与えられます。
<制約>
1 ≤ n ≤ 50,000
1 ≤ m ≤ 20
1 ≤ 額面 ≤ 10,000
額面はすべて異なり、必ず1を含む。
*/
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	int  n,m,c[25];
	int dp[200010];
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>c[i];
	}
	for(int i=0;i<=n;i++){
		dp[i]=200010;
	}
	sort(c,c+m);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			dp[i+c[j]]=min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(c+b-a>0){
    cout << c+b-a;
  }
  else{
    cout << "0";
  }
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
    int n,i;
    int max = 0;
    int sum = 0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        sum += a[i];
        if(a[i]>max){
            max = a[i];
        }
    }
    printf("%d",sum-(max/2));
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

i64 p = 1000000007LL;

i64 powmod(i64 x, i64 y)
{
    if (y == 1)
        return x % p;
    if (y % 2 == 1)
        return (x * powmod(x, y - 1)) % p;

    i64 pwmd = powmod(x, y / 2) % p;
    return (pwmd * pwmd) % p;
}

i64 bicomod(int n, int a)
{
    if (n == a)
        return 1;
    if (a > n / 2)
        return bicomod(n, n - a);
    i64 anom = 1;
    i64 adom = 1;
    for (int i = 1; i <= a; i++)
        anom = anom * i % p;
    for (int i = n - a + 1; i <= n; i++)
        adom = adom * i % p;

    return (adom * powmod(anom, p - 2)) % p;
}

int main()
{
    i64 x, y;
    cin >> x >> y;

    if ((x + y) % 3LL != 0LL)
    {
        cout << 0 << endl;
        return 0;
    }

    // m, n >= 0 が必要
    i64 m = (2LL * y - x) / 3LL;
    i64 k = (x + y) / 3LL;

    if ((m < 0) || (m > k))
    {
        cout << 0 << endl;
        return 0;
    }

    // 答えは(m+n)Cm
    i64 ans = bicomod(k, m);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
  
  for (int i = 0; i < N; ++i) {
    for (int sum_w = 0; sum_w <= W; ++sum_w) {
      
      if (sum_w - weight[i] >= 0) {
        chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
        }
      chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  
  cout << dp[N][W] << endl;
}
      

Measured memory_bytes: 79360
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
void solve(){
	ll n,m;cin>>n>>m;
	vll c(m);
	rep(i,0,m)cin>>c[i];
	vll dp(n+1,MOD);
	dp[0]=0;
	rep(i,1,n+1){
		rep(j,0,m){
			if(i>=c[j])dp[i]=min(dp[i],dp[i-c[j]]+1);
		}
	}
	cout<<dp[n]<<kai;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int mod = 1e5+5;

main(){
    int n;cin>>n;
    ll a[n];
    ll allxor=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        allxor^= a[i];
    }
    for(int i=0;i<n;i++){
        ll val = allxor^a[i];
        cout<<val<<" ";
    }
}

Measured memory_bytes: 5140
package main

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

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

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

					`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	ans := 0
	for i := 2; ; i++ {
		if n%i == 0 {
			w := 0
			for n%i == 0 {
				n /= i
				w++
			}
			ans += int(math.Floor((-1 + math.Sqrt(1+8*float64(w))) / 2))
		}
		if n == 1 {
			break
		}
		if n < i*i {
			ans++
			break
		}
	}

	//fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
func floor(x int) int {
	return int(math.Floor(float64(x)))
}


Measured memory_bytes: 1812
#include<stdio.h>
int main(){
  int x,y,z;

  scanf("%d%d",&x,&y);
  
  z = x % y ;
  while(z> 0){
    z = x % y;
    x = y;
    y = z;

  }
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int A,B,T;

int main(){
    cin>>A>>B>>T;
    out(B*(T/A));
}


Measured memory_bytes: 256
import collections
N = int(input())
s = []
for _ in range(N):
    s.append(input())
word_nums = collections.OrderedDict(sorted(collections.Counter(s).items(), key=lambda x: x[1], reverse=True))
max_num = max(list(word_nums.values()))
output = []
for i, j in word_nums.items():
    if max_num == j:
        output.append(i)
    else:
        break
for i in sorted(output):
    print(i)
    

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
int main() {
    int n;
    cin>>n;
    int t,a,t1,a1;
    long long num;
    cin>>t>>a;
    long long tot=t+a;
    long long num1=1;
    rep(i,n-1){
        cin>>t1>>a1;
        num=max(((num1*t-1)/t1)+1,((num1*a-1)/a1)+1);
        tot=num*(a1+t1);
        num1=num;
        a=a1;
        t=t1;
    }
    cout<<tot<<endl;
    

    return 0;}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  bool change = true;
  cin >> a >> b >> c >> d;
  while(a > 0 && c > 0){
    if(change){
      c -= b;
      change = false;
    }
    else{
      a -= d;
      change = true;
    }
  }
  if(a <= 0){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	bool flag = true;

	std::cin >> n;

	for (long long i = 0; i < n; i++)
	{
		long long a;

		std::cin >> a;
		if (a % 2 == 0) {
			if (a % 3 == 0 || a % 5 == 0) {

			}
			else {
				flag = false;
			}
		}
	}

	if (flag) {
		std::cout << "APPROVED" << std::endl;
	}
	else {
		std::cout << "DENIED" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    string s[N];
    for(int i=0; i<N; i++){
        cin >> s[i];
    }
    int a=0, b=0, common=0;
    int ans=0;
    for(int i=0; i<N; i++){
        int cnt=0;
        if(s[i][0]=='B') b++;

        if(s[i][s[i].size()-1]=='A') a++;

        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') common++;

        int flag=0;
        for(int size=0; size<s[i].size(); size++){
            if(s[i][size]=='A'){
                flag=1;
            }else if(s[i][size]=='B' && flag==1){
                cnt++;
                flag=0;
            }else{
                flag=0;
            }
        }
        ans+=cnt;
    }

    if(a==b && a==common){
        a--;
        if(a<0) a=0;
    }
    int tmp=min(a,b);
    
    ans+=min(tmp, N-1);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

vector<ll> g0(ll K, ll x) {
    x %= 2 * K;
    vector<ll> v(4);
    v[0] = -x;
    v[1] = K - x;
    v[2] = 2 * K - x;
    v[3] = 3 * K - x;

    return v;
}

vector<ll> g1(ll K, ll x) {
    x %= 2 * K;
    vector<ll> v(4);
    v[0] = K - x;
    v[1] = 2 * K - x;
    v[2] = 3 * K - x;
    v[3] = 4 * K - x;
    return v;
}

void setRect(vector<vector<int>>& s, vector<ll> x, vector<ll> y, ll K) {
    rep(i, x.size()) x[i] += 2 * K;
    rep(i, y.size()) y[i] += 2 * K;

    s[y[0]][x[0]]++;
    s[y[0]][x[1]]--;
    s[y[0]][x[2]]++;
    s[y[0]][x[3]]--;

    s[y[1]][x[0]]--;
    s[y[1]][x[1]]++;
    s[y[1]][x[2]]--;
    s[y[1]][x[3]]++;

    s[y[2]][x[0]]++;
    s[y[2]][x[1]]--;
    s[y[2]][x[2]]++;
    s[y[2]][x[3]]--;

    s[y[3]][x[0]]--;
    s[y[3]][x[1]]++;
    s[y[3]][x[2]]--;
    s[y[3]][x[3]]++;
}

void Main()
{
    ll n, K;
    cin >> n >> K;

    vector<ll> x(n), y(n);
    vector<char> c(n);
    rep(i, n) cin >> x[i] >> y[i] >> c[i];

    vector<vector<int> > s(6 * K + 1, vector<int>(6 * K + 1));

    // 有効なdx,dyの範囲を(0 ~ 2K)^2の範囲で各点について求めて、すぬけ法で集計する
    // 重複の最大値が答え
    rep(i, n) {
        if (c[i] == 'W') {
            auto xs = g0(K, x[i]);
            auto ys = g0(K, y[i]);
            setRect(s, xs, ys, K);

            xs = g1(K, x[i]);
            ys = g1(K, y[i]);
            setRect(s, xs, ys, K);
        }
        else {
            auto xs = g0(K, x[i]);
            auto ys = g1(K, y[i]);
            setRect(s, xs, ys, K);

            xs = g1(K, x[i]);
            ys = g0(K, y[i]);
            setRect(s, xs, ys, K);
        }
    }

    rep(y, s.size()) {
        repi(x, s.size()) {
            s[y][x] = s[y][x-1] + s[y][x];
        }
    }

    rep(x, s.size()) {
        repi(y, s.size()) {
            s[y][x] = s[y-1][x] + s[y][x];
        }
    }

    int res = 0;
    rep(x, s.size()) {
        rep(y, s.size()) {
            res = max(res, s[y][x]);
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 145828
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    int a[2];
    scanf("%d%d", &a[0], &a[1]);

    if(a[0] % 3 == 0 || a[1] % 3==0 || (a[0]+a[1]) % 3 == 0){
        printf("Possible");
    }else{
        printf("Impossible");
    }

    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std;

class State{
public:
  int x, y, cost;

  State(int x, int y, int cost) :
    x(x), y(y), cost(cost) {}
};

int w, h;
char t[102][102];
bool closed[102][102];

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

void solve(){
  queue<State> open;
  open.push(State(0, 0, 1));
  memset(closed, 0, sizeof(closed));
  closed[0][0] = true;

  while(!open.empty()){
    State st = open.front();
    open.pop();

    if(st.x == w - 1 && st.y == h - 1){
      cout << st.cost << endl;
      return;
    }

    for(int i = 0; i < 4; i++){
      int nx1 = st.x + dx[i];
      int ny1 = st.y + dy[i];
      int nx2 = st.x + 2 * dx[i];
      int ny2 = st.y + 2 * dy[i];

      if(nx2 < 0 || w <= nx2 || ny2 < 0 || h <= ny2) continue;
      if(t[ny1][nx1] != '0' || t[ny2][nx2] != '0') continue;
      if(closed[ny2][nx2]) continue;

      closed[ny2][nx2] = true;
      open.push(State(nx2, ny2, st.cost + 1));
    }
  }

  cout << 0 << endl;
}

int main(){
  while(cin >> w >> h, w || h){
    char buff[102];
    fgets(buff, 102, stdin);

    h = 2 * h - 1;
    w = 2 * w - 1;

    for(int i = 0; i < h; i++){
      fgets(t[i], 102, stdin);
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(t[i][j] == '0' || t[i][j] == '1') continue;
        t[i][j] = '0';
      }
    }

    solve();
  }
}

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


// 有向グラフの接続行列 B に対し，線形方程式 Bx = c を (必要なら mod 2 で) 解くライブラリ
template<typename T>
struct LinearSystemIncidence {
  struct Edge {
    int id, to; bool fwd;
    Edge(int i, int t, bool f) : id(i), to(t), fwd(f) {}
  };

  int n, m;
  bool mod2;
  vector<T> x;
  vector<bool> seen;
  vector<vector<Edge>> G;
  
  LinearSystemIncidence(int n, vector<P> &E, bool mod2=false) : n(n), m(E.size()), G(n), mod2(mod2) {
    rep(i, m) {
      G[E[i].first].emplace_back(i, E[i].second, true);
      G[E[i].second].emplace_back(i, E[i].first, false);
    }
  }

  T dfs(vector<T> &b, int u) {
    seen[u] = true;
    T res = b[u];
    for (Edge e : G[u]) {
      if (seen[e.to]) continue;
      T tmp = dfs(b, e.to);
      if (e.fwd) x[e.id] = tmp;
      else x[e.id] = -tmp;
      res += tmp;
      if (mod2) {
        x[e.id] %= 2;
        if (x[e.id] < 0) x[e.id] += 2;
      }
    }
    if (mod2) res %= 2;
    return res;
  }

  pair<bool, vector<T>> solve(vector<T> &b) {
    x.assign(m, 0);
    seen.assign(n, false);
    rep(u, n) {
      if (seen[u]) continue;
      if (dfs(b, u)) return {false, vector<T>()};
    }
    return {true, move(x)};
  }
};


int main() {
  int n, m; cin >> n >> m;
  vector<P> E;
  V c(n+1);
  rep(i, m) {
    int u, v; cin >> u >> v;
    E.emplace_back(u, v);
    ++c[u];
  }

  LinearSystemIncidence<int> LSI(n+1, E, true);
  auto sol = LSI.solve(c);

  if (sol.first) {
    rep(i, m) {
      if (sol.second[i]) swap(E[i].first, E[i].second);
      cout << E[i].first << " " << E[i].second << "\n";
    }
  }
  else cout << -1 << "\n";
  return 0;
}

Measured memory_bytes: 11764
#include<bits/stdc++.h>
using namespace std;
const int N = 200010 ;

int n ;
int res ;
int ans ;
int t[N] ;
int s[N] ;
int _odd[N] ;
int _eve[N] ;
int base[N] ;

bool compo(int x, int y){
    return _odd[x] > _odd[y] ;
}
bool compe(int x, int y){
    return _eve[x] > _eve[y] ;
}
int main(){
    cin >> n ; res = n ;
    for (int i = 1 ; i <= n ; ++ i){
        cin >> base[i] ;
        if (i & 1) _odd[base[i]] ++ ;
        else _eve[base[i]] ++ ;
    }
    for (int i = 1 ; i < N ; ++ i) s[i] = t[i] = i ;
    sort(s + 1, s + N, compo) ;
    sort(t + 1, t + N, compe) ;
    ans = n / 2 - _odd[s[1]] ;
    for (int i = 1 ; i < N ; ++ i)
        if (t[i] != s[1]){ ans += n / 2 - _eve[t[i]] ; break ; }
    res = min(res, ans) ;
    ans = n / 2 - _eve[t[1]] ;
    for (int i = 1 ; i < N ; ++ i)
        if (s[i] != t[1]){ ans += n / 2 - _odd[s[i]] ; break ; }
    res = min(res, ans) ;
    cout << res << endl ; return 0 ;
}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;
int count = 0;


// int dfs(int i, bool use){
//     if(i == s.size()+1){
        
//     }
// }
int main(){
    string s; cin >> s;
    // int two = 1;
    // rep(i,s.size()) two *= 2;
    ll len = s.size();
    ll ans = 0;
    rep(i,(1 << (len-1))){
       ll cur = 0;
       ll sum = 0;
       cur += s[0]-'0';
       rep(j,len-1){
           ll d = s[j+1]-'0';
           if(1 & (i >> j)){
               sum += cur;
               cur = d;
            //    cout << 1 << ' ' << cur << ' ' << sum << endl;
           }
           else{
               cur = cur * 10 + d;
            //    cout << 0 << ' ' << cur << ' ' << sum << endl;
           }
       }
       sum += cur;
       ans += sum;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)
#define IN(a) for (auto &it : a) cin >> it

const int N = 1e6 + 1;

void solve() {
    ints(n);
    vector<int> v(n);
    map<int, int> fq;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        fq[v[i]]++;
    }
    int cnt = 0;
    vector<int> mark(N);
    for (auto [x, y] : fq) {
        if (y == 1 && !mark[x]) cnt++;
        if (!mark[x]) for (int i = x; i < N; i += x) mark[i] = 1; 
    }
    show(cnt);
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}




Measured memory_bytes: 17020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define MAXN  1<<17
#define MOD   1000000007
#define int long long
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef gp_hash_table<int, int, hash<int > > ht;
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int b[n]={0};
  for(int i=1;i<n;i++){
    if(a[i]<=a[i-1])
        b[i]=b[i-1]+1;
  }
  int ma=0;
  for(int i=0;i<n;i++)
    ma=max(ma,b[i]);
  cout<<ma;




  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    long long int n,ans;
    cin >> n;
    ans = 0;

    for (int i = 1; i < n + 1; i++){
        if(i % 3 != 0 && i % 5 != 0){
        ans += i;
        }
    }

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n&&n){
    int sum=(n==1?0:1);
    for(int i=2;i*i<n;++i){
      if(n%i==0){
	sum+=i;
	sum+=(n/i);
      }
      if(sum>n) break;
    }
    if(sum==n) cout<<"perfect number"<<endl;
    else if(sum<n) cout<<"deficient number"<<endl;
    else cout<<"abundant number"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
N = int(input())
topA = [int(i) for i in input().split()]
bottomA = [int(i) for i in input().split()]

total = [0] * N
for i in range(1, N):
    top_sum = sum(topA[:i + 1])
    bottom_sum = sum(bottomA[i:])
    total[i] = top_sum + bottom_sum
L = topA[0] + sum(bottomA)
R = sum(topA) + bottomA[N - 1]
print(max(L, R, max(total)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h;cin>>h;
    int n;cin>>n;
    int sum=0;
    rep(i,0,n){
        int a;cin>>a;
        sum+=a;
        
    }
    if(sum>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 


 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
ll n,t;
  cin>>n>>t;
ll past;
  cin>>past;
ll ans=0;
for(int i=0;i<n-1;i++){
  ll now;
    cin>>now;
  ans+=min(now-past,t);
past=now;
}
cout<<ans+t<<endl;
}

Measured memory_bytes: 256