akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CountingRoads
{
    public class Program
    {
        public static void Main(String[] args)
        {
            // N個の都市とM番目の道路
            string nm = Console.ReadLine();

            // 都市数
            int n = int.Parse(nm.Split(' ')[0]);
            // 道路
            int m = int.Parse(nm.Split(' ')[1]);

            int[] countArray = new int[n];

            for (int i = 0; i < m; i++)
            {
                string ab = Console.ReadLine();
                // 都市a
                int a = int.Parse(ab.Split(' ')[0]);
                // 都市b
                int b = int.Parse(ab.Split(' ')[1]);

                countArray[a - 1] = countArray[a - 1] + 1;
                countArray[b - 1] = countArray[b - 1] + 1;

            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(countArray[i]);
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    vi a(n);
    int ans = 0;
    rep(i,n){
        cin >> a[i];
        if(i%2==0){
            if(a[i]%2 ==1)
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e5);

vector<int> dp[MAXn];
vector<int> v[MAXn];
int sz[MAXn], k;

void dfs(int now, int f){
    dp[now].pb(0);
    sz[now] = 1;
    for (auto t : v[now]) if (t != f) {
        dfs(t, now);
        vector<int> ret;
        for(int i = 0;i < SZ(dp[now]);i ++) {
            if (SZ(ret) <= i) ret.pb(INF);
            ret[i] = min(ret[i], dp[now][i] + sz[t]);
            for(int j = 0;j < SZ(dp[t]);j++) {
                if (SZ(ret) <= j + 1)
                    ret.pb(INF);
                if (i + j + 1 <= k)
                    ret[max(i, j + 1)] = min(ret[max(i, j + 1)], dp[now][i] + dp[t][j]);
            }
        }
        dp[now] = ret;
        sz[now] += sz[t];
    }
}

int main()
{
    IOS();
    ll n;
    cin >> n >> k;
    for (int i = 1; i <= n - 1; i++) {
        int a, b;
        cin >> a >> b;
        v[a].pb({b});
        v[b].pb({a});
    }
    dfs(1, -1);
    ll mn = INF;
    for(int i = 1;i <= n;i ++)
        mn = min(mn, (n - sz[i]) + *min_element(ALL(dp[i])));
    cout << mn << endl;
    for(int i = 1;i <= n;i ++) debug(i, dp[i]);
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  string S;
  cin >> S;
  string A[3] = {"Sunny", "Cloudy", "Rainy"};
  string ans;
  if (S == A[0]) ans = A[1];
  if (S == A[1]) ans = A[2];
  if (S == A[2]) ans = A[0];
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0;
  rep(i, n) {
    cin >> v[i];
    sum += v[i];
  }
 
  sort(all(v), greater<int>());
 
  int alice = 0;
  for (int i = 0; i < n; i += 2) {
    alice += v[i];
  }
  cout << alice - (sum - alice) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<algorithm>
 using namespace std;
 #define N 100010
 int main(){
 int n,m,h[N],ma[N];
 cin>>n>>m;
 for(int i=1;i<=n;i++){
 cin>>h[i];
 ma[i]=0;
 }
 for(int i=0;i<m;i++){
 int a,b;
 cin>>a>>b;
 ma[a]=max(ma[a],h[b]);
 ma[b]=max(ma[b],h[a]);
 }
 int ans=0;
 for(int i=1;i<=n;i++){
 ans+=h[i]>ma[i];
 }
 cout<<ans<<endl;
 }

Measured memory_bytes: 4416
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c, id;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost, ll id){
    e[from].push_back({to, cost, id});
  }

  void run(ll start, ll ign){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(ip.id==ign)continue;
          if(d[ip.x]<=dc+ip.c){
            continue;
          }else{
            d[ip.x]= dc+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }
  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  dijkstra dijk(N);
  llvec a(M), b(M), c(M);
  rep(i, M){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;b[i]--;
    if(a[i]>b[i])swap(a[i], b[i]);
    dijk.add_edge(a[i], b[i], c[i], i);
    dijk.add_edge(b[i], a[i], c[i], i);
  }
  vector<llvec> stt(N, llvec(N, 1e10));
  rep(i, N){
    dijk.run(i, -100);
    rep(j, N){
      stt[i][j] = dijk.d[j];
    }
  }

  ll ans = 0;
  rep(k, M){
    bool flg=false;
    rep(i, N){
      rep(j, N){
        if(!flg and stt[i][j]==stt[i][a[k]]+c[k]+stt[b[k]][j]){
          ans++;
          flg=true;
          break;
        }
      }
      if(flg)break;
    }
  }

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


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
ll a,b;
int main() {
    cin>>a>>b;
    cout << a*b << endl;
    return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
static int D[10]; 
bool check(int n){
	int num=n;
	while(n){
		if(D[n%10]==1)	return true;
		n/=10;
	}
	cout<<num<<endl;
	return false;
}
int main()
{
	int N,K;
	int num;
	cin>>N>>K;
	for(int i=1;i<=K;i++){
		int num;
		cin>>num;
		D[num]=1;
	}
	num=N;
	while(check(num)){
		num++;
	}
		
}

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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 main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> x;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x[a[i]]++;
    }
    ll ans = 0;
    for (auto tmp : x) {
        ll k = tmp.second;
        ans += k * (k-1) / 2;
    }
    //cout << ans << endl;
    for (int i = 0; i < n; i++) {
        //cout << x[a[i]] << endl;
        cout << ans - x[a[i]] + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 8320
import math
n=math.factorial(int(input()))
i=2
res=1
MOD=1000000007
while i*i<=n:
	cnt=1
	while n%i==0:
		cnt+=1
		n//=i
	res*=cnt
	i+=1
if n!=1:res*=2
print(res%MOD)

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



int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool t=false;
    
    for(int i=1; K*i <= B; i++) {
        if(K*i >= A && K*i <= B) {
            t = true;
            break;
        }
    }
    
    if(t)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    
    return 0;
}


Measured memory_bytes: 3640
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

constexpr int64_t kLimit = 1000000000000000000;

int64_t Digits(const int64_t n) {
  int64_t value = n;
  int64_t digits = -1;
  do {
    digits++;
    value /= 10LL;
  } while (value > 0);
  return digits;
}

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

  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t N;
  cin >> N;
  int64_t result = 1;
  // cerr << "a " << Digits(10) << " " << Digits(1000000) << endl;

  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << "0" << endl;
      return 0;
    }
  }

  for (int64_t i = 0; i < N; ++i) {
    const int64_t a = A[i];
    if (Digits(a) + Digits(result) > 18) {
      result = -1;
      break;
    }
    if (a * (result / 100L) > kLimit) {
      result = -1;
      break;
    }
    if (a * (result / 10L) > kLimit) {
      result = -1;
      break;
    }
    if (a * (result / 4L) > kLimit) {
      result = -1;
      break;
    }
    if (a * (result / 2L) > kLimit) {
      result = -1;
      break;
    }
    if (a * result > kLimit) {
      result = -1;
      break;
    }
    result *= a;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
int N;
ll A[200000];
ll AA[200000];
int l = 0;
int r = 1;
int LL, RR, CC;
int main()
{
	int i, j, k;
	ll ans = 0;
	ll sum = 0;
	ll sum1;
	ll sum2;
	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		A[i + N] = A[i];
	}
	AA[0] = A[0];
	for (i = 1; i < 2 * N; i++)AA[i] = AA[i - 1] + A[i];
	while (l < N){
		if (l != 0)sum = AA[r-1] - AA[l - 1];
		else sum = AA[r-1];
		//printf("%d %d %lld\n", l, r,sum);
		if (sum > AA[N - 1] / 3){
			l++;
		}
		else{
			LL = r; RR = N + l;
			while (RR - LL>1){
				CC = (LL + RR) / 2;
				if (AA[CC] - AA[r-1] < sum)LL = CC;
				else RR = CC;
			}
			LL--;
			if (LL < 0)LL = 0;
			while (sum > AA[LL] - AA[r-1])LL++;
			sum1 = AA[LL] - AA[r-1];
			sum2 = AA[N + l - 1] - AA[LL];
			//printf(":%d %lld %lld\n", LL, sum1, sum2);
			if (sum <= sum1&&sum <= sum2){
				ans = max(ans, sum); r++;
			}
			else l++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long 
#define f first
#define s second
#define test ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define a auto
#define st string
#define len length
#define pb push_back
#define v vector<ll>
#define vp vector<ll,ll>
#define bs binary_search
#define lb lower_bound
#define fr(a,b) for(ll i=a;i<b;i++)
#define mp make_pair
#define mod 1000000007
int main()
{
    fast;  
    ll n,d;
    cin>>n>>d;
    ll count=0;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        double p=(x*x)+(y*y);
        double r=sqrt(p);
        
        if(r<=(double)d)
        {
            count++;
        }
    }
    cout<<count<<endl;
        
        
}

Measured memory_bytes: 3664
N = int(input())
res = []
for i in range(N):
    name,price = input().split()
    index = i+1
    res.append([index,name,int(price)])

res.sort(key = lambda x:x[2],reverse=True)
res.sort(key = lambda x:x[1])

for i in range(N):
    print(res[i][0])

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>

using namespace std;
     
const int MAX_N = 100001;
     
int N, Q;
int par[MAX_N]; 
bool marked[MAX_N];

void init() {
  for (int i = 0; i <= N; i++) {
    par[i] = i;
  }
}

int search(int x) {
  if (marked[x]) return x;
  else return search(par[x]);
}
  
int main()
{
  marked[1] = true;
  while(1){
    int num;
    char ope;
    long long int ans;
    
    scanf("%d %d", &N, &Q);
    if(N == 0 && Q == 0) break;
    init();
    ans = 0;
    
    for(int i = 2; i <= N; i++){
      scanf("%d", &num);
      par[i] = num;
      marked[i] = false;
    }

    for(int i = 0; i < Q; i++){
      scanf(" %c", &ope);
      scanf("%d", &num);
      if (ope == 'M') {
        marked[num] = true;
      }
      else if(ope == 'Q'){
        ans += search(num);
      }
    }
    
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  ///その数が現れる回数を数える
  vector<int> a(n, 0);
  map<int, int> num_count;
  int kind = 0;
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
    if(num_count.count(a[i]))
    {
      num_count[a[i]]++;
    }else{
      num_count[a[i]] = 1;
      kind++;
    }
  }
  ///配列の内容をユニークにする
  sort(a.begin(), a.end());
  auto itr = unique(a.begin(), a.end());
  a.erase(itr, a.end());
  /*
  * 場合分けで考える
  * 出現回数が3以上の奇数は自分たちだけで回数1になれる
  * 出現回数が3以上の偶数は他の数を一つ借りて回数1になれる
  * 出現回数が3未満の偶数は他の数を一つ借りて回数1になれる
  * 出現回数が偶数の数が偶数個あれば一つも減らすことなくできる
  */
  int odd_count = 0;
  for(auto e : a)
  {
    if(num_count[e] % 2 == 0)
    {
      odd_count++;
    }
  }
  if(odd_count % 2 == 0)
  {
    cout << kind << endl;
  }else{
    cout << kind - 1 << endl;
  }
  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    Int sum_a = 0;
    rep(i, n) {
        cin >> a[i];
        sum_a += a[i];
    }
    vector<int> m;
    vector<int> p;
    Int sum_b = 0;
    bool flg = true;
    rep(i, n) {
        cin >> b[i];
        sum_b += b[i];
        if (a[i] - b[i] < 0) {
            m.push_back((a[i] - b[i]) * -1);
            flg = false;
        }
        if (a[i] - b[i] > 0) p.push_back(a[i] - b[i]);
    }
    if (sum_a < sum_b) {
        cout << -1 << endl;
        return 0;
    }
    if (flg) {
        cout << 0 << endl;
        return 0;
    }
    sort(p.rbegin(), p.rend());
    int ans = 1;
    int i_p = 0;
    rep(i, m.size()) {
        while (m[i] > 0) {
            if (p[i_p] > m[i]) {
                p[i_p] -= m[i];
                m[i] = 0;
                ans++;
            }
            else if (p[i_p] == m[i]) {
                m[i] = 0;
                i_p++;
                ans++;
            }
            else {
                m[i] -= p[i_p];
                i_p++;
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int a[101];

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

  int cnt = 0;
  for( int i = 0; i < N - 1; i++ ){
    for( int j = N - 1; j >= 1; j-- ){
      if( a[j - 1]> a[j] ){
	int t = a[j - 1];
	a[j - 1] = a[j];
	a[j] = t;
	cnt++;
      }
    }
  }

  for( int i = 0; i < N; i++ ){
    cout << a[i];
    if( i == N - 1 ) cout << endl;
    else cout << " ";
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;

struct UnionFind
{
   vector<int> par;

   UnionFind(int N) : par(N)
   {
      for (int i = 0; i < N; i++)
         par[i] = i;
   }

   int root(int x)
   {
      if (par[x] == x)
         return x;
      return par[x]=root(par[x]);
   }

   void unite(int x, int y)
   {
      int rx = root(x);
      int ry = root(y);
      if (rx == ry)
         return;
      par[ry] = rx;
   };

   bool same(int x, int y)
   {
      if (root(x) == root(y))
         return true;
      return false;
   }
};

void Main()
{
   int N, M;
   std::cin >> N >> M;
   UnionFind uf(N);

   int x, y, z;
   for (int m = 0; m < M; m++)
   {
      std::cin >> x >> y >> z;
      uf.unite(x - 1, y - 1);
   }

   std::map<int, int> m;
   int res = 0;

   for (int n = 0; n < N; n++)
   {
      if (!m[uf.root(n)])
      {
         m[uf.root(n)] = 1;
         res++;
      }
   }

   cout << res << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



int main()
{

    ll n;
    cin>>n;
    if(n&1)
    {
        cout<<0<<nn;
    }
    else
    {
        ll ans=0;

        n/=2;
        while(n)
        {
            ans+=n/5;
            n/=5;
        }

        cout<<ans<<nn;



    }





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <list>
using namespace std;
const int MAX=3e2+5,mod=998244353,inf=0x3f3f3f3f;
#define X first
#define Y second
#define pb push_back
using ll=long long;
typedef pair < int , int > ii;
int n;
char s[MAX];
bool a[MAX],c[MAX][MAX][MAX];
int f[MAX][MAX][MAX];
int sum[MAX];
void check(){
    cout<<n<<'\n';
    ll ans1=1;
    for(int i=1;i<n;i++){
        for(int b=0;b<(1<<i);b++){
            int dem=n,mm=0,uu=0;
            for(int j=0;j<i;j++){
                if((b&(1<<j))!=0){
                    if(a[dem]){
                        dem--;
                    }
                    else uu++,mm++;
                }
                else {
                    if(!a[dem]){
                        dem--;
                    }
                    else uu++;
                }
            }
            if(c[dem][uu][mm]) ans1++;
        }
    }
    cout<<ans1<<'\n';
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>s+1;
    n=strlen(s+1);
    c[0][0][0]=1;
    a[1]=s[1]-'0';
    c[1][0][0]=1;

    for(int i=2;i<=n;i++){
        a[i]=s[i]-'0';
        c[i][0][0]=1;
        if(a[i]){
            for(int j=1;j<=i/2;j++){
                c[i][j][0]|=c[i-1][j][0];
                for(int k=1;k<=j;k++)
                    c[i][j][k]|=c[i-1][j][k] | c[i-2][j-1][k-1] | c[i-1][j][k-1];
            }
        }
        else{
            for(int j=1;j<=i/2;j++){
                c[i][j][j]|=c[i-1][j][j];
                for(int k=0;k<j;k++)
                    c[i][j][k]|=c[i-1][j][k] | c[i-2][j-1][k] | c[i-1][j][k+1];
            }
        }
        if(a[i-1]){
            for(int j=1;j<=i/2;j++)
                for(int k=1;k<=j;k++)
                    c[i][j][k]|=c[i-2][j-1][k-1];
        }
        else{
            for(int j=1;j<=i/2;j++)
                for(int k=0;k<j;k++)
                    c[i][j][k]|=c[i-2][j-1][k];
        }
    }
    ll ans=1;
    for(int i=n;i>0;i--){
        sum[i]=sum[i+1]+a[i];
    }
    f[n+1][n+1][0]=1;
    for(int i=n;i>1;i--){
        for(int k=n-i+1,j=n+1;k>=0;k--){
            if(a[j-1]) f[i][j][k]+=f[i+1][j][k];
            else if(k>0)f[i][j][k]+=f[i+1][j][k-1];
            if(f[i][j][k]>=mod) f[i][j][k]-=mod;
            //cout<<i<<' '<<j<<' '<<k<<' '<<f[i][j][k]<<'\n';
            if(c[j-1][j-i][k-sum[j]])
                    ans+=f[i][j][k];
        }
        for(int j=n;j>=i;j--){
            for(int k=n-i+1;k>=sum[j];k--){
                if(a[j]) f[i][j][k]=f[i+1][j+1][k-1];
                else f[i][j][k]=f[i+1][j+1][k];
                if(a[j-1]) f[i][j][k]+=f[i+1][j][k];
                else if(k>0)f[i][j][k]+=f[i+1][j][k-1];
                if(f[i][j][k]>=mod) f[i][j][k]-=mod;
                //cout<<i<<' '<<j<<' '<<k<<' '<<f[i][j][k]<<'\n';
                if(c[j-1][j-i][k-sum[j]])
                    ans+=f[i][j][k];
            }
        }
    }
    //check();
    //for(int i=1;i<=n;i++)for(int j=1;j<=i/2;j++)for(int k=0;k<=j;k++) cout<<i<<' '<<j<<' '<<k<<' '<<c[i][j][k]<<'\n';

    cout<<ans%mod;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m;
		while ((n = in.nextInt()) != 0 && (m = in.nextInt()) != 0) {
			int[] yasai = new int[n];
			for (int i = 0; i < n; i++) {
				yasai[i] = in.nextInt();
			}
			Arrays.sort(yasai);
			int price = 0;
			for (int i = 1; i <= n; i++) {
				if (i % m != 0) {
					price += yasai[n - i];
				}
			}
			System.out.println(price);
		}

	}
}

Measured memory_bytes: 54392
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll n;

int howKwta(int num){
	stringstream ss;
	ss << num;
	return ss.str().size();
}

int main() {
	cin >> n;
	// cout << howKwta(n) << endl;
	int ans = INF;
	for(int i = 1;i < sqrt(n) + 1;i++){
		if(n % i == 0){
			int now = max(howKwta(i), howKwta(n / i));
			ans = min(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	string s;
	cin >> s;
	bool ans = true;
	if(s[0] != 'A') ans = false;
	int c = 0;
	for(int i = 2;i < s.length()-1;i++){
		if(s[i] == 'C') c++;
	}
	if(c != 1) ans = false;
	c = 0;
	REP(i, s.length()){
		if(s[i] != 'A' && s[i] != 'C' && s[i] >= 65 && s[i] <= 90){
			ans = false;
		}
		if(s[i] == 'C') c++;
	}
	if(c != 1) ans = false;
	if(ans) cout << "AC" << endl;
	else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a, b, c,m;
	scanf("%d%d%d", &a, &b, &c);
	if (a > b) {
		m = a;
		a = b;
		b = m;
	}
	if (b > c) {
		m = b;
		b = c;
		c = m;
	}
	if (a > b) {
		m = a;
		a = b;
		b = m;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 1824
# -*- coding:utf-8 -*-
"""解説
2019で割った余りが同じであるような2数a, bにおいて、

a * c mod 2019
b * c mod 2019

は同じ値になる。

今求めたいのは、

(i*j) ≡ x (mod 2019)

のxの最小値である。

(例)
L=2020のとき、
mod 2019の世界では、2020は1と等価

よって、
2020 * 2021 は、
1 * 2 と等価

つまり、

(i*j) ≡ x (mod 2019) は、

(i%2019) * (j%2019) ≡ x (mod 2019) と同じ

そう考えると、i, jの調べる範囲は、

・R-L < 2019のとき、

L%2019 ≦ i < j ≦ R%2019

でよい。

・R-L >= 2019のとき、

 mod2019の1周分の範囲を取れるので、必ずiかjが0になり、そのとき最小値0になるから。


よって、(i, j)として調べる候補はたかだか2019**2 であり、全探索で間に合う。
"""

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    if R-L >= MOD:
        print(0)
        return

    L %= MOD
    R %= MOD
    ans = MOD
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%MOD)
            if ans == 0:
                print(ans)
                return
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();

    if (a+b >= x && a <= x) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
n = int(input())
ans = 0
for i in range(n):
    x = list(map(str,input().split()))
    a = x[0]
    b = x[1]
    if b == "JPY":
        ans += int(a)
    else:
        z = float(a)
        z *= 380000
        ans += z
print(ans)

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

int main() {
	int n, m;
	string s;
	cin >> n >> m >> s;
	vector<int> g(n+1, -1);
	queue<int> q;
	int back = 0;
	for(int i = 1; i <= n; i++) {
		if (s[i] == '1') continue;
		while(i - back > m) {
			if (q.empty()) {
				cout << -1 << endl;
				return 0;
			}
			back = q.front();
			q.pop();
		}
		g[i] = back;
		q.push(i);
	}
	vector<int> ans;
	for(int current = n; current != 0; current = g[current]) {
		ans.push_back(current-g[current]);
	}
	reverse(ans.begin(), ans.end());
	for(int i: ans) {
		cout << i << ' ';
	}
	cout << endl;
}


Measured memory_bytes: 1528
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll power1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}

ll h[100005];
ll dp[100005];
ll ans(ll n)
{
    if(n==1)
        return 0;
    if(n==2)
        return abs(h[1]-h[0]);
    if(dp[n]!=-1)
        return dp[n];
    return dp[n]= min(ans(n-1)+abs(h[n-1]-h[n-2]),ans(n-2)+abs(h[n-1]-h[n-3]));
}

int main()
{
   SPEED
   ll n,i;
   cin>>n;
   memset(dp,-1,sizeof(dp));
   for(i=0;i<n;i++)
    cin>>h[i];
   cout<<ans(n);
}







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

class Program
{
    void Run()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();

        int i = 0;
        while (n > 0)
        {
            n /= k;
            i++;
        }

        Console.WriteLine(i == 0 ? 1 : i);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def possible(i):
    A_ = [A[i] for i in range(N)]
    rest = M*(V-1)
    A_[i] += M
    for j in range(i+1,N):
        if A_[j] <= A_[i]:
            d = min(rest,A_[i]-A_[j])
            A_[j] += d
            rest -= d
        else:
            d = min(rest,M)
            A_[j] += d
            rest -= d
        if rest == 0:
            break
    for j in range(i):
        d = min(rest,M)
        A_[j] += d
        rest -= d
        if rest == 0:
            break
    for j in range(N-1,i,-1):
        if A_[j] == A_[i]:
            d = min(rest,A[j]+M-A_[j])
            A_[j] += d
            rest -= d
        if rest == 0:
            break
    c = A_[i]
    A_.sort(reverse=True)
    return A_[P-1] <= c

l = 0
r = N-1
m = (l+r)//2
for i in range(20):
    if possible(m):
        r = m
    else:
        l = m
    m = (l+r)//2
if possible(m):
    ans = N-m
else:
    ans = N-m-1
print(ans)

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

int f(int n){
  int a[5];
  for(int i = 0; i < 5; i++){
    a[i] = n % 10;
    n /= 10;
  }
  if(a[0] == a[4] && a[1] == a[3]) return 1;
  else return 0;
}

int main(){
  int a, b;
  cin >> a >> b;
  int num = 0;
  for(int i = a; i <= b; i++)
    num += f(i);
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	cin >> N >> M;
	vll A(N, vl(M));
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	vl F(M,1);
	ll cnt = M;
	ans = INF;
	while (cnt > 0) {
		vl C(M, 0); vl B(N, 0);
		for (i = 0; i < N; i++) {
			while (!F[A[i][B[i]]]) B[i]++;
		}
		for (i = 0; i < N; i++) {
			C[A[i][B[i]]]++;
		}
		ll pre = 0;
		ll big = -1;
		for (i = 0; i < M; i++) {
			if (C[i] >= pre) {
				big = i; pre = C[i];
			}
		}
		ans = min(ans, pre);
		if (cnt == 1) break;
		F[big] = 0;
		//debug(F);
		cnt--;
	}
	cout << ans;
}

Measured memory_bytes: 4356
n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b
dd = [(k, v) for k, v in d.items()]
dd = sorted(dd, key=lambda x: x[0])
cur = 0
tmp = -1
for a, b in dd:
    if cur >= k:
        break
    cur += b
    tmp = a
print(tmp)

Measured memory_bytes: 15584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  set<int> num;
  for (int i = 0; i < N; ++i)
  {
    int a;
    cin >> a;
    
    if (num.count(a) == 1)
    {
      cout << "NO" << endl;
      return 0;
    }
    else num.insert(a);
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=2e5+9;
using namespace std;
int main()
{
	ll n,a[maxn]={0},ans;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll dp[maxn][3]={0},k=n/2;
	if(n&1)
	{
		for(int i=1;i<=k;i++)
		{
			dp[i][0]=dp[i-1][0]+a[i*2-1];
			dp[i][1]=max(dp[i-1][0],dp[i-1][1])+a[i*2];
			dp[i][2]=max(dp[i-1][0],max(dp[i-1][2],dp[i-1][1]))+a[i*2+1];
		}
		ans=max(max(dp[k][0],dp[k][1]),dp[k][2]);	
	}
	else
	{
		for(int i=1;i<=k;i++)
		{
			dp[i][0]=dp[i-1][0]+a[i*2-1];
			dp[i][1]=max(dp[i-1][0],dp[i-1][1])+a[i*2];
		}
		ans=max(dp[k][0],dp[k][1]);
	}
	printf("%lld\n",ans);
	
	
}

Measured memory_bytes: 10084
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<string>> a(n,vector<string>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void debug(auto a);

signed main(){
    vec(a,4);
    REP(i,4){
        cin >> a[i];
    }
    Sort(a);
    if(a[0]==1 && a[1]==4 && a[2] == 7 && a[3]==9){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}
void debug(auto a){
    cout << "{ ";
    int len = a.size();
    REP(i,len){
        cout << a[i] << " ";
    }
    
    cout << "}" << endl;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 256
def solve(n, k, v):
    best = 0
    r = min(n, k)
    for a in range(r+1):
        for b in range(r+1-a):
            w = v[:a]
            if b > 0:
                w += v[-b:]
            w = sorted(w)
            m = min(k-a-b, len(w))
            for i in range(m):
                if w[i] < 0:
                    w[i] = 0
            best = max(best, sum(w))
    return best

n, k = map(int, input().split())
v = list(map(int, input().split()))
print(solve(n, k, v))

Measured memory_bytes: 3064
N = int(input())
S = input()
Ans = set([])

for i in range(10):
    if str(i) in S:
        a = S.index(str(i))
        S1 = S[a+1:]
        for j in range(10):
            if str(j) in S1:
                b = S1.index(str(j))
                S2 = S1[b+1:]
                for k in range(10):
                    if str(k) in S2:
                        Ans.add(str(100*i + 10*j + k))

print(len(Ans))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;


// この手の問題は累積とか尺取りとかあるけど、単純に求めたの引いてくだけなら累積、区間の数とかもとめるなら尺取りが
// いいと思う。しかし今回は入力に関係がなく規則的に数列が決まるため、数列の和から調べる区間等を考えることが必要
// 今回の様なケースの場合に遭遇したらまず数列の和からはいっていったほうがいい。
int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            pair<int, int> ans;
            FOR(i, 1, sqrt(2 * n) + 1){
                if((2 * n) % i == 0){
                    int a = ((2 * n / i) - i + 1);
                    if(a % 2 == 0 and a / 2 >= 1) ans = make_pair(a / 2 , i );
                }
            }
            cout << ans.first << " " << ans.second << endl;
        }
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	int a1,a2,a3;cin>>a1>>a2>>a3;
	
	int ans1=0,ans2=0,ans3=0;
	
	ans1=abs(a2-a1)+abs(a3-a1);
	ans2=abs(a3-a2)+abs(a1-a2);
	ans3=abs(a2-a3)+abs(a1-a3);
	
	cout<<min(ans1,min(ans2,ans3))<<endl;
	return 0;
}

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

public class Main{
	static int maxTime=11;
	static int w,h;
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			//input
			w=scan.nextInt();
			h=scan.nextInt();
			int stoneh=-1;
			int stonew=-1;
			maxTime=11;
			if(w==0 && h==0)break;
			int[][] object=new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					object[i][j]=scan.nextInt();
					if(object[i][j]==2){
						stoneh=i;
						stonew=j;
					}
					//System.out.print(object[i][j]);
				}
			}
			//System.out.println(stoneh+" "+stonew);
			move(0,stoneh,stonew,object);
			if(maxTime==11)maxTime=-1;
			System.out.println(maxTime);
		}
	}
	//stoneH,W---stone's place
	//board------play data
	public static void move(int time,int stoneH,int stoneW,int[][] board){
		if(time<maxTime){
			//System.out.println(maxTime);
			//go Up
			int i;
			int temp;
			if(stoneH!=0 && board[stoneH-1][stoneW]!=1){
				for(i=stoneH-1;i>-1;i--){
					if(board[i][stoneW]==1)break;
					if(board[i][stoneW]==3){
						maxTime=time+1;
						break;
					}
				}
				if(i!=-1){
					temp=board[i][stoneW];
					board[i][stoneW]=0;
					move(time+1,i+1,stoneW,board);
					board[i][stoneW]=temp;
				}
			}
			//go down
			if(stoneH!=h-1 && board[stoneH+1][stoneW]!=1){
				for(i=stoneH+1;i<h;i++){
					if(board[i][stoneW]==1)break;
					if(board[i][stoneW]==3){
						maxTime=time+1;
						break;
					}
				}
				if(i!=h){
					temp=board[i][stoneW];
					board[i][stoneW]=0;
					move(time+1,i-1,stoneW,board);
					board[i][stoneW]=temp;
				}
			}
			//go left
			if(stoneW!=0 && board[stoneH][stoneW-1]!=1){
				for(i=stoneW-1;i>-1;i--){
					if(board[stoneH][i]==1)break;
					if(board[stoneH][i]==3){
						maxTime=time+1;
						break;
					}
				}
				if(i!=-1){
					temp=board[stoneH][i];
					board[stoneH][i]=0;
					move(time+1,stoneH,i+1,board);
					board[stoneH][i]=temp;
				}
			}
			//go right
			if(stoneW!=w-1 && board[stoneH][stoneW+1]!=1){
				for(i=stoneW+1;i<w;i++){
					if(board[stoneH][i]==1)break;
					if(board[stoneH][i]==3){
						maxTime=time+1;
						break;
					}
				}
				if(i!=w){
					temp=board[stoneH][i];
					board[stoneH][i]=0;
					move(time+1,stoneH,i-1,board);
					board[stoneH][i]=temp;
				}
			}
		}
	}
}

Measured memory_bytes: 41840
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll n,k,num,ans=0;
    cin >> n >> k;
    if(k%2==1){
        ll num=n/k;
        ans = num*num*num;
    }
    else{
        ll cnt1=0,cnt2=0;
        for(ll i=1;i<=n;i++){
            if(i%k==(k/2))  cnt1++;
            else if(i%k==0) cnt2++;
        }
        ans = cnt1*cnt1*cnt1+cnt2*cnt2*cnt2;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int uni[100000],n,m,r[100000];
int find(int a){
	if(a!=uni[a])a=find(uni[a]);
	return a;
}
bool same(int a,int b){
	return find(a)==find(b);
}
void unit(int a,int b){
	int c=find(a),d=find(b);
	if(r[c]>r[d])uni[c]=d;
	else{uni[d]=c;
		if(r[c]==r[d])r[d]++;
	}
}
int main() {
	cin>>n>>m;
	for(int i=0;i<n;i++){uni[i]=i;r[i]=0;}
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>c>>a>>b;
		if(c)cout<<(same(a,b)?1:0)<<endl;
		else unit(a,b);
	}
}

Measured memory_bytes: 3184
// Aizu Vol-0 0099: Surf Smelt Fishing Contest II
// 2017.8.19 bal4u@uu
// ????????????????????£????????\???

#include <stdio.h>

#define QSIZE 110000

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key, c; } QUE;
QUE que[QSIZE + 5];
int qsize;

#define MAX 1000000
typedef struct { int f, c; } T;
T tbl[MAX + 5];

void max_heapify(int i)
{
	int l, r, largest;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize &&
		(que[l].key > que[i].key || (que[l].key == que[i].key && que[l].id < que[i].id)))
		largest = l;
	else largest = i;
	if (r < qsize &&
		(que[r].key > que[largest].key ||
			(que[r].key == que[largest].key && que[r].id < que[largest].id)))
		largest = r;
//	else largest = i;
	if (largest != i) {
		QUE t = que[i]; que[i] = que[largest], que[largest] = t;
		max_heapify(largest);
	}
}

void deq(void)
{
	if (qsize == 0) return;
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(void)
{
	int i, max;
	i = qsize++;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

int main()
{
	int n, q, a, v;

	scanf("%d%d", &n, &q);
	qsize = 0;
	while (q--) {
		scanf("%d%d", &a, &v);
		tbl[a].f += v, tbl[a].c++;
		que[qsize].id = a, que[qsize].key = tbl[a].f, que[qsize].c = tbl[a].c;
		enq();

		while (1) {
			a = que[0].id;
			if (tbl[a].c == que[0].c) {
				printf("%d %d\n", que[0].id, que[0].key);
				break;
			}
			deq();
		}
	}
	return 0;
}

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

using namespace std;

int n, k, ta;
bool b[10];

bool ok(int a) {
	while (a) {
		if (b[a % 10])
			return 0;
		a /= 10;
	}
	return 1;
}

int main() {
	scanf("%d%d", &n, &k);
	while (k--) {
		scanf("%d", &ta);
		b[ta] = 1;
	}
	while (!ok(n))
		n++;
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    
    if ( ( ( a * b ) & 1 ) == 1 ) {
        cout << "Odd" << endl;
    }
    else {
        cout << "Even" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ( A+B > C+D ) cout << "Left" << endl;
  if ( A+B < C+D ) cout << "Right" << endl;
  if ( A+B == C+D ) cout << "Balanced" << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

P = [0]*n
for i, a in enumerate(A):
    P[a-1] = i

import heapq
q = []
heapq.heapify(q)
R = [n-1]*n
for i, a in enumerate(A):
    while q and q[0]*(-1) > a:
        v = heapq.heappop(q)*(-1)
        R[v-1] = i-1
    heapq.heappush(q, a*(-1))

q = []
L = [0]*n
for j in range(n):
    i = n-1-j
    a = A[i]
    while q and q[0]*(-1) > a:
        v = heapq.heappop(q)*(-1)
        L[v-1] = i+1
    heapq.heappush(q, a*(-1))

#print(L)
#print(R)
ans = 0
for i in range(n):
    a = i+1
    l, r, p = L[i], R[i], P[i]
    ans += (p-l+1)*(r-p+1)*a
print(ans)

Measured memory_bytes: 41968