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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back


ll mod_exp(ll a, ll b, ll mod)
{
	ll prod=1;
	while(b>0)
	{
		if(b%2!=0)
		{
			prod=(a%mod*prod%mod)%mod;
		}
		b/=2;
		a=(a%mod*a%mod)%mod;
	}
	prod=prod%mod;
	return prod;
}

ll dividing(ll a, ll mod)
{
	ll ans = a;
	while(a)
	{
		a/=2;
		ans=(a%mod+ans%mod)%mod;
	}
	return ans;
}

void diff(vector<ll>& tot, ll k, ll ind)
{
	// ll ind = 
	int i=2;
	while(i* ind<=k)
	{	
		tot[ind]-=tot[i*ind];
		i++; 
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin>>n>>k;
	ll mod=1000000007;
	// ll ans = 0;	



	vector<ll> tot(k+1, 0);
	ll ans = 0;
	for(int i = 1; i <= k; i++)
	{
		int div = k/i;
		ll seq = mod_exp(div, n, mod);
		tot[i]=seq;
		// cout<<seq<<" ";
		// seq = (seq%mod)%mod;
		// ll temp = dividing(seq, mod);
		// cout<<temp<<endl;
	}
	for(int i = k; i >= 1; i--)
	{
		// if()
		diff(tot, k, i);
	}
	for(int i = 1; i <= k; i++)
	{
		// ans
		ans = (ans%mod+(i%mod*tot[i]%mod)%mod)%mod;
		// cout<<tot[i]<<" ";
	}
	// cout<<endl;
	// cout<<endl;
	cout<<ans<<endl;

}

Measured memory_bytes: 3992
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

//#include "pch.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define print(v,n) for(i=0;i<n;i++) cout<<v[i]<<" ";
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define PI 3.14159265   ;
ll mod =1000000007;
bool isPrime(int n)
{
	// Corner cases 
	if (n <= 1)  return false;
	if (n <= 3)  return true;

	// This is checked so that we can skip  
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) return false;

	for (int i = 5; i*i <= n; i = i + 6)
		if (n%i == 0 || n % (i + 2) == 0)
			return false;

	return true;
}

ll powe(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) res =( res * x)%mod;
		y = y >> 1;
		x = (x * x)%mod;
	}
	return res;
}
struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void solve()
{
	ll i, x, y, j, k, h, l, n, w, r, k1, k2, q;
	cin >> n;
	ll ans=powe(10,n);
	k=(powe(9,n)*2)%mod;
	l=(powe(8,n))%mod;
	ans=(ans-k+l+mod)%mod;
	cout<<ans<<ee;
}

int main() {
	fast;
	ll i, j, l, k, t, n;
	t=1;
	for (i = 1; i <= t; i++)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
}
// 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
     int wa=0,tl=0,re=0,ac=0;
    while(t--)
    {
         string a;
         cin>>a;

         if(a=="AC")ac++;
         else if(a=="WA")wa++;
         else if(a=="TLE")tl++;
         else if(a=="RE")re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tl<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;

}


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

int a[10010];

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

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

  int s = 0;
  for(int i=0; i<m; i++) s+=a[i];
  
  if(s>n) cout << "-1";
  else cout << n-s;

}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int h, w; cin >> h >> w;
  int m[10][10];

  rep(i, 10) rep(j, 10) cin >> m[i][j];
  rep(k, 10) rep(i, 10) rep(j, 10) chmin(m[i][j],m[i][k]+m[k][j]);

  int ans = 0;
  rep(i, h) rep(j, w) {
    int a; cin >> a;
    if (a != -1) ans += m[a][1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#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 all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;



int main() {
    string S, T;
    cin >> S >> T;

    int cnt = 0;
    for (int i=0; i<S.size(); i++) {
        if (S[i] != T[i]) cnt++;
    }

    cout << cnt << endl;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  sort(A.begin(), A.end(), greater<int>());

  int cnt = 1;
  int long1 = 0, long2 = 0;

  for(int i = 1; i < N; i++) {
    if(A[i] == A[i-1]) {
      cnt++;
    } else {
      cnt = 1;
    }

    if(cnt == 2) {
      if(long1 == 0) {
        long1 = A[i];
        cnt -= 2;
      } else {
        long2 = A[i];
        break;
      }
    }
  }

  cout << (long long)long1 * long2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long n,z,x,x1,z1,p1,np1,p,np,s,c[100001],a[100001],b[100001];
string ss;
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(i%2==0)
            b[a[i]]++;
        else c[a[i]]++;
        if(b[a[i]]>p)
        {
            p=max(p,b[a[i]]);
            z=a[i];
        }
        if(c[a[i]]>np)
        {
            np=max(np,c[a[i]]);
            x=a[i];
        }
    }
    if(x==z)
    {

        if(p>np)
        {
            s+=(n/2)-p;
            for(int i=1; i<=n; i+=2)
            {
                if(a[i]!=z)
                {
                    if(c[a[i]]>np1)
                    {
                        np1=c[a[i]];
                        x1=a[i];
                    }
                }
            }
            s+=(n/2)-np1;
        }
        else if(p<np)
        {
            s+=(n/2)-np;
            for(int i=2; i<=n; i+=2)
            {
                if(a[i]!=x)
                {
                    if(b[a[i]]>p1)
                    {
                        p1=b[a[i]];
                        z1=a[i];
                    }
                }
            }
            s+=(n/2)-p1;
        }
        else
        {
            for(int i=2; i<=n; i+=2)
            {
                if(a[i]!=x)
                {
                    if(b[a[i]]>p1)
                    {
                        p1=b[a[i]];
                        z1=a[i];
                    }
                }
            }
            for(int i=1; i<=n; i+=2)
            {
                if(a[i]!=z)
                {
                    if(c[a[i]]>np1)
                    {
                        np1=c[a[i]];
                        x1=a[i];
                    }
                }
            }
            if(np1>p1)
            {
                s+=(n/2)-p;
                s+=(n/2)-np1;
            }
            else
            {
                s+=(n/2)-np;
                s+=(n/2)-p1;
            }
        }
    }
    else
    {
        s+=(n/2)-p;
        s+=(n/2)-np;
    }
    cout<<s<<endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

int x[123434];

void solve() {
	int n, a, b; scanf("%d%d%d", &n, &a, &b);
	for (int i = 0; i < n; ++i) {
		scanf("%d", x+i);
	}
	long long ans = 0;
	for (int i = 0; i < n-1; ++i) {
		ans += min((long long)(x[i+1]-x[i])*a, (long long)b);
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

namespace ConsoleApp1
{
    static class BOneClue
    {
        static void Main(string[] args)
        {
            var kx = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
            int k = kx[0];
            int x = kx[1];

            int point = x - k + 1;
            var answers = new List<int>();
            for (int i = 1; i < k * 2; i++)
            {
                answers.Add(point);
                point++;
            }

            Console.WriteLine(string.Join(" ", answers.Where(a => -1000000 <= a && a <= 1000000).ToList()));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13396
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    count[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d" %count[i][j][k], end="")
        print()
    if i < 3:
        print("#"*20)


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, w;
	cin >>n >>w;
	VI dp(w+4, -1); dp[0]=0;
	rep(i,n){
		ll g, v;
		cin >>g >>v;
		repr(j, w, 0) if(dp[j]>=0){
			if(j+g <=w) dp[j+g] = max(dp[j+g], dp[j] + v);
		}
	}
	rep(i,w+1) dp[i+1] = max(dp[i], dp[i+1]);
	cout << dp[w] <<"\n";
	return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl



int main(){
    int a,b;cin >> a >> b;
    int max=-10000000;
    if(a+b>max)max=a+b;
    if(a-b>max)max=a-b;
    if(a*b>max)max=a*b;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <memory>

int main()
{
    int64_t r, x, d;
    std::cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++) {
        x = r * x - d;
        std::cout << x << std::endl;
    }
    return 0;
}


Measured memory_bytes: 888
# -*- 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 functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


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

INF = 2**62-1


def read_int():
    return int(buff_readline())


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


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_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.time()
        ret = f(*args, **kwargs)
        e = time.time()

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

    return wrap


def eratosthenes(n):
    p = []
    t = [True] * n

    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i]:
            p.append(i)
            for j in range(2*i, n, i):
                t[j] = False

    for j in range(i+1, n):
        if t[j]:
            p.append(j)

    return p, t

P, T = eratosthenes(int(math.sqrt(10**6))+1)

def e(n):
    c = []
    for p in P:
        while n % p == 0:
            # c[p] += 1
            c.append(p)
            n //= p
        if n == 1:
            break
    if n != 1:
        # c[n] += 1
        c.append(n)
    return c


@mt
def slv(N, A):
    ans = 0
    A.sort()
    ac = Counter(A)
    for i in range(N):
        # print(i)
        a = A[i]
        if ac[a] >= 2:
            continue
        c = e(a)
        for j in range(len(c)):
            f = False
            for i in combinations(c, r=j):
                m = reduce(mul, i, 1)
                # error_print(a, m)
                if ac[m] >= 1:
                    # error_print('b', a)
                    break
            else:
                f = True
            if not f:
                break
        else:
            ans += 1

    return ans


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

    # from random import randint
    # N = 2* (10**5)
    # A = [randint(1, 10**6) for _ in range(N)]
    # print(slv(N, A))


if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    scanf("%d", &n);
    int *arr = new int[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    int q, k;
    int left = 0, right = n;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &k);

        int l = left, r = right;

        while (l < r)
        {
            int mid = (l + r) / 2;
            if (k < arr[mid])
            {
                r = mid;
            }
            else if (k > arr[mid])
            {
                l = mid + 1;
            }
            else
            {
                printf("%d\n", 1);
                break;
            }
        }
        if (l == r)
        {
            printf("%d\n", 0);
        }
    }

    return 0;
}



Measured memory_bytes: 3612
n = gets.to_i
nums = gets.chomp.chars.map(&:to_i)

res = 0
0.upto(9) do |x|
  x_bound = nums.find_index(x)
  next if x_bound.nil?
  x_righter_nums = nums[(x_bound + 1)..-1]
  next if x_righter_nums.nil?

  0.upto(9) do |y|
    y_bound = x_righter_nums.find_index(y)
    next if y_bound.nil?
    y_righter_nums = x_righter_nums[(y_bound + 1)..-1]
    next if y_righter_nums.nil?

    0.upto(9) do |z|
      z_bound = y_righter_nums.find_index(z)
      next if z_bound.nil?
      res += 1
    end
  end
end

puts res

Measured memory_bytes: 3452
othello = input()
bef = 0
sumall = 0
count = 0

for i in range(len(othello)):
    sumall += i
    if(othello[i] == 'B'):
        bef += i
        count += 1

sumelse = 0
for i in range(len(othello)-count):
    sumelse += i

aft = sumall - sumelse

print(aft - bef)

Measured memory_bytes: 9092
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    long int n, s[1001], i;
    double m, a2, a;
    cin >> n;
    
    while(n != 0){
        m = 0;
        a2 = 0;
        for(i=0; i<n; i++){
            cin >> s[i];
            m += s[i];
        }
        m = m/n;
        for(i=0; i<n; i++){
            a2 += (s[i] - m) * (s[i] - m);
        }
        a2 = a2/n;
        a = sqrt(a2);
        
        cout << fixed << setprecision(5) << a << endl;
        
        cin >> n;
    }
    return 0;
}



Measured memory_bytes: 3288
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP       (i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);

int main() {
	INIT;
	string s;
	cin >> s;

	int ans;
	if (s.size() % 2 != 0) {
		if (s.size() == 1) {
			cout << 1 << endl;
			return 0;
		}
		ans = s.size() / 2 + 1;
		int p = s.size() / 2 - 1;
		char c = s[s.size() / 2], l = s[p], r = s[p + 2];
		while (c == l&&l == r) {
			ans++;
			p--;
			if (p >= 0) {
				l = s[p];
				r = s[s.size() - 1 - p];
			}
			else break;
		}
	}
	else {
		int p = s.size() / 2;
		ans = s.size() / 2;
		char l = s[p - 1], r = s[p], c = l;
		while (c == l&&l == r) {
			ans++;
			p++;
			if (p < s.size()) {
				r = s[p];
				l = s[s.size() - 1 - p];
			}
			else break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <unordered_map>
#define NMAX 105
#define VALMAX 100005
using namespace std;
int n,w,j,i,sum;
int a[NMAX],b[NMAX],maxim,sol,d[VALMAX];
int main()
{
    cin>>n>>w;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        sum+=b[i];
    }
    for(i=1;i<=sum;i++)
        d[i]=w+1;
    for(i=1;i<=n;i++)
    {
        for(j=maxim;j>=0;j--)
        {
            if(d[j]+a[i]<=w)
            {
                maxim=max(maxim,j+b[i]);
                d[j+b[i]]=min(d[j+b[i]],d[j]+a[i]);
            }
        }
    }
    for(i=maxim;i>=1;i--)
    {
        if(d[i]<=w)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


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

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1; --i) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  cout << endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 32000

int main(){
	int limit;
	int* table = new int[NUM];
	int* work = new int[NUM];

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = NUM;

	for(int i=2;i<limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int index = 0;
	vector<int> PRIME;

	for(int i = 2; i < NUM; i++){
		if(table[i] == 1){
			PRIME.push_back(i);
		}
	}

	int left,right;
	scanf("%d %d",&left,&right);

	int* num_table = new int[right-left+1];
	int* count_table = new int[right-left+1];

	for(int num = left; num <= right; num++){
		num_table[num-left] = num;
		count_table[num-left] = 0;
	}

	limit = sqrt(right);
	int start;

	for(int i = 0; i < PRIME.size(); i++){
		if(PRIME[i] > limit)break;

		for(start = 0;start < right-left+1 && num_table[start]%PRIME[i] != 0; start++);

		for(int k = start; k < right-left+1;k += PRIME[i]){
			while(num_table[k] > 1 && num_table[k]%PRIME[i] == 0){
				num_table[k] /= PRIME[i];
				count_table[k]++;
			}
		}
	}

	int ans = 0;
	for(int num = left; num <= right; num++){
		if(num_table[num-left] != 1)count_table[num-left]++;
		if(table[count_table[num-left]] == 1)ans++;
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2000001;

int n, k, fact[N], inv[N], mod = 1e9 + 7;
string s;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    if(r > n) return 0;
    return 1LL * fact[n] * inv[n - r] % mod * inv[r] % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
    }
    inv[N - 1] = powlog(fact[N - 1], mod - 2);
    for(int i = N - 2 ; i >= 0 ; i--){
        inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
    }
    cin >> k >> s;
    n = s.size();
    int ans = 0;
    for(int i = 0 ; i <= k ; i++){
        ans = (ans + 1LL * powlog(25, k - i) * powlog(26, i) % mod * C(n - 1 + k - i, n - 1)) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 19860
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100005][3];
int a[100005];
int b[100005];
int c[100005];
int main()
{
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for (int i=2; i<=n; i++)
    {
        dp[i][1]+=max(dp[i-1][2], dp[i-1][3])+a[i];
        dp[i][2]+=max(dp[i-1][3], dp[i-1][1])+b[i];
        dp[i][3]+=max(dp[i-1][1], dp[i-1][2])+c[i];
    }
    cout<<max(dp[n][1], max(dp[n][2], dp[n][3]));
}

Measured memory_bytes: 2560
a,b=map(int,input().split())
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return set(a)
print(len(factorize(a)&factorize(b))+1)

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	long long N;
	cin >> N;
	vector<long long> V(N);
	for(int i = 0; i < N; i++) cin >> V[i];

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

	double ans = V[0];
	for(int i = 1; i < N; i++)
	{
		ans += (double)V[i];
		ans = (double)(ans / 2.0);
	}

	cout << setprecision(10) << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, ma, mb = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(n)]

    Cost = [[[5000] * 401 for _ in range(401)] for _ in range(n+1)]
    Cost[0][0][0] = 0

    for i in range(n):
        for j in range(400):
            for k in range(400):
                if j+A[i][0] <= 400 and k+A[i][1] <= 400:
                    Cost[i+1][j+A[i][0]][k+A[i][1]] = min(Cost[i+1][j+A[i][0]][k+A[i][1]], Cost[i][j][k]+A[i][2])
                Cost[i+1][j][k] = min(Cost[i+1][j][k], Cost[i][j][k])

    costmin = 5000
    for a in range(1,401):
        for b in range(1,401):
            if a * mb == b * ma:
                costmin = min(costmin, Cost[n][a][b])
    if costmin == 5000:
        print(-1)
    else:
        print(costmin)


resolve()

Measured memory_bytes: 96092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    map<char,string>arr;
    string aa,bb,cc;
    cin>>aa>>bb>>cc;
    reverse(aa.begin(),aa.end());
    reverse(bb.begin(),bb.end());
    reverse(cc.begin(),cc.end());
    arr['a']=aa;
    arr['b']=bb;
    arr['c']=cc;
    char cvar='a',temp;
    while(arr[cvar].length())
    {
        temp=arr[cvar].back();
        arr[cvar].pop_back();
        cvar=temp;
    }
    cout<<(char)(cvar-('a'-'A'));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  rep(i, m) cin >> l[i] >> r[i];
  int lm = l[0];
  int rm = r[0];
  rep(i, m) {
    if (lm < l[i]) lm = l[i];
    if (rm > r[i]) rm = r[i];
  }
  if (rm - lm + 1 < 0)
    cout << 0 << endl;
  else
    cout << rm - lm + 1 << endl;
  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;



int main(void){
    int n;
    cin >> n;
    pair <string , int> p[4];
    p[0].first="AC";
    p[1].first="WA";
    p[2].first="TLE";
    p[3].first="RE";
    REP(i,n){
        string s;
        cin >> s;
        REP(j,4){
            if(p[j].first==s)
                p[j].second++;
        }
    }
    REP(i,4){
        cout << p[i].first << " x " << p[i].second << endl;
    }

    
    return 0;
}


Measured memory_bytes: 3624
S=input()
if S[0]=='A':
    if S[2:-1].count('C')==1:
        i = S.index('C')
        tmp = S[1:i]+S[i+1:]
        tmp_low=tmp.lower()
        print('AC' if tmp==tmp_low else 'WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const   int MaxN=1e5+5;
int n,a[MaxN],K;
typedef long long ll;
ll f[MaxN];

void Xuli()
{
    f[1]=0;
    for(int i=2;i<=n;i++)
    {
        f[i]=1e15;
        for(int j=1;j<=K;j++)
            if (i-j>=1) f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
    }
    printf("%lld",f[n]);
}
int main()
{
    //freopen("FROG1.inp","r",stdin);
    //freopen("FROG1.out","w",stdout);
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    Xuli();
}


Measured memory_bytes: 1408
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
index = 1
tmp = 10**10
for i in range(n):
  if tmp > abs(a - (t - h[i] * 0.006)):
    index = i + 1
    tmp = abs(a - (t - h[i] * 0.006))
print(index)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
C - 白昼夢 / Daydream
https://atcoder.jp/contests/abc049/tasks/arc065_a

"""
import sys


def solve(S):
    while S:
        if S.endswith('dreamer'):
            S = S[:-7]
        elif S.endswith('eraser'):
            S = S[:-6]
        elif S.endswith('dream'):
            S = S[:-5]
        elif S.endswith('erase'):
            S = S[:-5]
        else:
            return 'NO'
    return 'YES'


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define in              insert
#define pb              push_back
#define mp              make_pair
#define lb              lower_bound
#define ub              upper_bound
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n]
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n; cin >> n;
	int act[n + 1][3];
	for (int i = 1; i <= n; i++)
		cin >> act[i][0] >> act[i][1] >> act[i][2];

	int dp[n + 1][3] = {};

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++)
			dp[i][j] = act[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
	}

	cout << max({dp[n][0], dp[n][1], dp[n][2]});

	return 0;
}

Measured memory_bytes: 8224
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

let fact = fix <| fun fact n -> if n=0 then 1 else n*fact(n-1)

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match dp.[x, y] with
    | None ->
      let v = f g x y
      dp.[x, y] <- Some v
      v
    | Some v -> v
  g
// start
let N = readStr().ToCharArray() |> Array.map (int >> (flip (-) (int '0')))
let K = readInt()
let n = N.Length

let count =
  let dp1 = memo2 104 5 <| fun dp1 i k ->
    if k=0 then 1
    elif i>=n then 0
    else 9*(dp1 (i+1) (k-1))+(dp1 (i+1) k)
  let dp = memo2 104 5 <| fun dp i k ->
    if k=0 then 1
    elif i>=n then 0
    else
      let v=N.[i]
      if v=0 then dp (i+1) k
      else (dp (i+1) (k-1))+(max 0 (v-1))*(dp1 (i+1) (k-1))+(dp1 (i+1) k)
  dp 0 K

count |> printfn "%d"

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

using namespace std;

long long prime = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ds(n);
    for (auto& d : ds) {
        cin >> d;
    }
    if (ds[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    int m = *max_element(ds.begin(), ds.end());
    vector<int> cs(m+1);
    for (auto& d : ds) {
        ++cs[d];
    }
    if (cs[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    long long total = 1;
    for (int i = 1; i <= m; ++i) {
        for (int j = 0; j < cs[i]; ++j) {
            total = total * cs[i-1] % prime;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int calc(int x) {
  if(x == 3) return 100000;
  if(x == 2) return 200000;
  if(x == 1) return 300000;
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, Y; cin >> X >> Y;
  int ans = calc(X);
  ans += calc(Y);
  if(X==1 && Y==1) ans+=400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
local n = io.read("*n")
local v1, v2, v3 = 0, 0, 0
local ret = 1
for i = 1, n do
  local a = io.read("*n")
  local c = 0
  if v1 == a then
    c = c + 1
  end
  if v2 == a then
    c = c + 1
  end
  if v3 == a then
    c = c + 1
  end
  ret = (ret * c) % 1000000007
  if v3 == a then
    v3 = v3 + 1
  elseif v2 == a then
    v2 = v2 + 1
  elseif v1 == a then
    v1 = v1 + 1
  end
end
print(ret)


Measured memory_bytes: 376
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Data.List (group)
import Debug.Trace

rmST :: [String] -> [String]
rmST [] = []
rmST [x] = [x]
rmST (s:t:ss) =
  if head s == 'S'
    then drop l s:drop l t:rmST ss
    else s: rmST (t:ss)
  where l = min (length s) (length t)

solve' s =
  if s' == s then s else solve' ((group.concat) s')
  where s' = rmST s

main = do
  ss <- group <$> getLine
  print $ sum $ map length $ solve' ss


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

int main() {
  int a,b;
  cin >> a >> b;
  
  int c = (a+b)%2;
  
  if(c == 0) cout << (a+b)/2 << endl;
  else cout << (a+b)/2+1 << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep (i, n) {
    cin >> a[i];
  }

  ll sum = 0;

  for (int i = 1; i < n; i++) {
    if (a[i-1] > a[i]) {
      sum += a[i-1] - a[i];
      a[i] += a[i-1] - a[i];
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 4768
#!/usr/bin python3
# -*- coding: utf-8 -*-

def factorization(n):
    primen, degree, primend = [], [], []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            primen.append(i)
            degree.append(cnt)
            primend.append([i,cnt])
    if temp!=1:
        primen.append(temp)
        degree.append(1)
        primend.append([temp,1])
    if primen==[]:
        primen.append(n)
        degree.append(1)
        primend.append([n,1])
    return primend

N = int(input())
pm = [0]*(1+N)

def main():
    for i in range(1,N+1):
        for x in factorization(i):
            pm[x[0]]+=x[1]
    ret = 1
    for j in pm[2:]:
        ret *= j+1
        ret %= 1000000007
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
from collections import deque

H, W, K = map(int, input().split())
A = [input() for _ in range(H)]

sx, sy = 0, 0
for y in range(H) :
    flag = False
    for x in range(W) :
        if A[y][x] == 'S' :
            sx, sy = x, y
            flag = True
            break
    
    if flag :
        break


dist = [[-1] * W for _ in range(H)]
dist[sy][sx] = 0
q = deque([(sy, sx)])
while q :
    y, x = q.popleft()
    if dist[y][x] == K :
        continue
    
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)) :
        nx, ny = x + dx, y + dy
        if 0 <= nx < W and 0 <= ny < H and dist[ny][nx] == -1 and A[ny][nx] == '.' :
            dist[ny][nx] = dist[y][x] + 1
            q.append((ny, nx))

ret = float('inf')
for y in range(H) :
    for x in range(W) :
        if dist[y][x] < 0 :
            continue
        
        ret = min(ret, 1 + (min(H - y, y + 1, W - x, x + 1) - 1 + K - 1) // K)
        
print(ret)

Measured memory_bytes: 59484
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;

 

 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int ans=0;
    string s;
    cin>>s;
    
    int n=s.size();
    char pc='A';
    for(int i=0; i<n; i++){
        if(pc!=s[i]){
            ans++;
            pc=s[i];
        }
        else{
            i++;
            pc='A';
            ans+=(i<n);
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 720
#include <stdio.h>

int main(){
  int n, d;
  int s;
  int ans;

  scanf("%d %d",&n, &d);

  for(int i=1;i<20;i++){
    s = (d * 2 + 1) * i;
    if(n <= s){
      ans = i;
      break;
    }
  }

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


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,k;
    cin >> n >> k;
    map<int,int> mp{};
    map<int, int>::iterator itr;
    rep(i,n){
        int a;
        cin >> a;
        auto itr =mp.find(a);
        if(itr!=mp.end()){
            int k;
            k=(itr->second)+1;
            mp[a]=k;
        }else{
            mp.emplace(a,1);
        }
    }
    vector<int> vec;
    for(itr = mp.begin() ; itr != mp.end() ; itr++){
        vec.push_back(itr->second);
    }
    sort(vec.begin(),vec.end());
    if(vec.size()<=k){
        cout << 0<<endl;
        return 0;
    }
    int s=vec.size()-k;
    int count=0;
    rep(i,s){
        count+=vec[i];
    }
    cout << count<<endl;


}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>
using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int lli;

int main()
{
    lli n;
    cin>>n;
    lli count = 0;
    if(n%2==0)
    {
        for (lli i = 5; n / i >= 1; i *= 5)
            count += (n / (2*i));
    }
    else
    {
        count=0;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
//AtCoder Begginner Contest 085 B
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int N;
	int d[110];
	cin >> N;
	for(int i=0;i<N;++i){
		cin >> d[i];
	}
	sort(d,d+N);
	int res = 1;
	for(int i=1;i<N;++i){
		if(d[i-1]<d[i]){
			++res;
		}
	}
	/*
	
	string res;
	if(amari<=A){
		res = "Yes";
	}else{
		res = "No";
	}
	*/
	cout << res << endl;
}


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

#define REP(i,j,k) for( int i = j; i < k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;


int main(){
	
	int N,M,C;
	
	vector<int> B(20);
	vector< vector<int> > A( 20, vector<int>(20) );
	
	cin >> N >> M >> C;
	
	rep(j,M) cin >> B[j];
	rep(i,N) rep(j,M) cin >> A[i][j];
	
	int cnt = 0;
	
	rep(i,N){
		
		int tmp = C;
		rep(j,M) tmp += A[i][j] * B[j];
		if(tmp>0) cnt++;
		
	}
	
	cout << cnt << endl;
	
	return 0;
	
}


Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  p, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  q, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  r, _ := strconv.Atoi(sc.Text())

  if p + q < q + r {
    if p + q < r + p {
      fmt.Println(p + q)
    } else {
      fmt.Println(r + p)
    }
  } else {
    if q + r < r + p {
      fmt.Println(q + r)
    } else {
      fmt.Println(r + p)
    }
  }

}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int n, x, m[100];
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> m[i];
    int counter = 0;
    int min = m[0];
    int min_i = 0;

    for (int i = 0; i < n; i++) {
        x -= m[i];
        ++counter;
        if (m[i] < min) {
            min = m[i];
            min_i = i;
        }
    }

    counter += x / m[min_i];
    cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n, k; cin >> n >> k;
	double ans = 0.0;
	for(double i=1;i<=n;i++){
		if(k<=i){
			ans += 1/n;
		}else{
			double x = i;
			double c = 1/n;
			while(x<k){
				c *= 0.5;
				x *= 2;
			}
			ans += c;
		}
	}
	//cout << ans << endl;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let n: i64 = vec[0].parse().unwrap_or(0);
    let y: i64 = vec[1].parse().unwrap_or(0);

    if y % 1000 != 0 {
        println!("-1 -1 -1");
        return;
    }

    for m10000 in 0..(y / 10000 + 1) {
        for m5000 in 0..((y - m10000 * 10000) / 5000 + 1) {
            let m1000 = (y - m10000 * 10000 - m5000 * 5000) / 1000;
            if m10000 + m5000 + m1000 == n {
                println!("{} {} {}", m10000, m5000, m1000);
                return;
            } 
            //println!("{} {} {} {}", m10000, m5000, m1000, m10000 + m5000 + m1000);
        } 
    }
    println!("-1 -1 -1");
    return;


}


Measured memory_bytes: 4352
N,A,B = map(int,input().split())

set_count  = int(N/(A+B))
if  N % (A+B) != 0:
    ans = set_count * A
    last_ball = N - (A+B)*set_count
    if last_ball <= A:
        ans += last_ball
    else:
        ans += A
else:
    ans = set_count * A
print(ans)

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

using namespace std;

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

    vector<int> w(N), e(N);
    w[0] = 0, e[N-1] = 0;
    for (int i = 1; i < N; ++i) {
        w[i] = w[i-1];
        if (S[i-1] == 'W') w[i] = w[i-1] + 1;

        e[N-i-1] = e[N-i];
        if (S[N-i] == 'E') e[N-i-1] = e[N-i] + 1;
    }

    int ans = 1e9;
    for (int i = 0; i < N; ++i) {
        ans = min(ans, w[i] + e[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

struct e{
	int f,t,c;
};

int main(){
	int n,m,x[2],y1,y2,a,b,c,d,cost;
	int di[20];
	e l[800];
	const int inf = 9999999;
	scanf("%d%d",&n,&m);
	rep(i,m){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--;
		b--;
		l[i*2].f=l[i*2+1].t=a;
		l[i*2].t=l[i*2+1].f=b;
		l[i*2].c=c;
		l[i*2+1].c=d;
	}
	scanf("%d,%d,%d,%d",x,x+1,&y1,&y2);
	cost=0;
	rep(i,2){
		rep(j,n)di[j]=inf;
		di[x[i]-1]=0;
		int f=1;
		while(f){
			f=0;
			rep(j,m*2){
				e t=l[j];
				if(di[t.f]<inf && di[t.t]>di[t.f]+t.c){
					di[t.t]=di[t.f]+t.c;
					f=1;
				}
			}
		}
		cost+=di[x[1-i]-1];
	}
	printf("%d\n",y1-y2-cost);
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<memory.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
        int N;
        scanf("%d",&N);

        if(N%2==0){
                N= N/2-1;
        }else{
                N=(double)N/2;
        }
        printf("%d",N);

        return 0;
}


Measured memory_bytes: 128
import heapq

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n = int(input())
xy = [list(map(int, input().split()))+[i] for i in range(n)]
"""
辺を結びたいがすべての点で結ぶと膨大になる
"""

edge = []
xy.sort()
for i, j in zip(range(n-1), range(1, n)):
    cost = xy[j][0] - xy[i][0]
    heapq.heappush(edge, [cost, xy[i][2], xy[j][2]])

xy.sort(key= lambda x: x[1])
for i, j in zip(range(n-1), range(1, n)):
    cost = xy[j][1] - xy[i][1]
    heapq.heappush(edge, [cost, xy[i][2], xy[j][2]])

uf = UnionFind(n)
ans = 0
while edge:
    c, a, b = heapq.heappop(edge)
    if uf.same(a, b): continue
    uf.union(a, b)
    ans += c

print(ans)


Measured memory_bytes: 56356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	int A, B;
	cin >> A >> B;
	int low = 0, high = 10000;
	int answer = -1;
	for (int i = 0; i <= 10000; i++) {
		int P1 = 0.08 * i;
		int P2 = 0.10 * i;
		if (P1 == A && P2 == B) {
			answer = i;
			break;
		}
	}
	//while (low <= high) {
		//int mid = low + (high - low) / 2;
		//int P1 = 0.08 * mid;
		//int P2 = 0.10 * mid;
		//if (P1 == A && P2 == B) {
			//answer = mid;
			//high = mid - 1;
		//} else if (P1 < A) {
			//low = mid + 1;
		//} else {
			//high = mid - 1;
		//}
	//}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256