akhauriyash/Code-Regression huggingface dataset:
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector a_s(n, 0);
    rep(i, n)
    {
        cin >> a_s[i];
    }

    int g = accumulate(a_s.begin(), a_s.end(), 0, [](int acc, int x) { return gcd(acc, x); });

    vector<bool> p_s(1000'000);
    auto ins = [&](int p) {
        if (p_s[p] == 1)
        {
            return false;
        }
        p_s[p] = 1;
        return true;
    };
    bool flag = true;
    for (auto a : a_s)
    {
        for (int p = 2; p * p <= a; ++p)
        {
            if (a % p == 0)
            {
                if (not ins(p))
                {
                    flag = false;
                }
                while (a % p == 0)
                {
                    a /= p;
                }
            }
        }
        if (a != 1)
        {
            if (not ins(a))
            {
                flag = false;
            }
        }
    }

    cout << (flag ? "pairwise coprime" : (g == 1 ? "setwise coprime" : "not coprime")) << endl;

    return 0;
}


Measured memory_bytes: 7384
#include<iostream>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;

int main()
{
    ll l, r, i, j, m, n;
    cin>>l>>r;
    ll min = 2019;
    if(l==0)
        cout<<0;
    else
    {
        for(i=l; i<r; i++)
        {
            int flag = 0;

            for(j=i+1; j<r+1; j++)
            {
                if((i*j)%2019 < min)
                {
                    min = (i*j)%2019;
                }

                if(min == 0)
                {
                    flag = 1;
                    break;
                }
            }

            if(flag == 1)
            {
                break;
            }
        }
        cout<<min;
    }
    return 0;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }
int f(int x){
  if(x == 0){
    return 0;
  }
  return 1 + (f(x%(__builtin_popcount(x))));
}
int32_t main()
{ 
   IOS

  int n;
  cin >> n;
  string x;
  cin >> x;
  int p = count(all(x),'1');

  if(p == 0 ){
    for(int i =  1;i<=n;i++ ){
      cout << 1 << endl;
    }
    return 0;
  }

  if(p == 1){
    for(int i = 0;i<n-1;i++){
      if(x[i] == '1')
        cout << 0 << endl;
      else 
        cout << 1 << endl;
    }
    if(x[n-1] == '0'){
      cout << 2 << endl;
    }
    else{
      cout << 0 << endl;
    }
    return 0;
  }
  int p1 = p - 1;
  int p2 = p + 1;

  int rem1 = 0;
  for(int i = 0;i<n;i++){
    rem1 = ((rem1*2) + (x[i]-'0'))%p1;
  }
  int rem2 = 0;
  for(int i = 0;i<n;i++){
    rem2 = ((rem2*2) + (x[i]-'0'))%p2;
  }
  trace(p1,p2);
  trace(rem1,rem2);

  for(int i =  0;i<n;i++){
    if(x[i] ==  '0'){
      mod = p2;
      int ans = (rem2 + power(2,n-i-1))%p2;
      cout << 1 + f(ans) << endl;
    }
    else{
      mod = p1;
      int ans = (rem1 - power(2,n-i-1) + p1)%p1;
      cout << 1 + f(ans) << endl;
    }
  }




  

  

  
  
  
  

  
  
  
    


  


  
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
typedef  long long ll;
const int MAX_N=106;
int main(){
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int a; cin>>a;
    cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3608
# 解説AC
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
C = [int(i) for i in input().split()]

C.sort()

M = sum(C[:-1])
d = [-1] * N

que = deque([0])
while que:
    v = que.popleft()
    d[v] = C.pop()
    for w in edge[v]:
        if d[w] < 0:
            que.append(w)

print(M)
print(*d)

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

int main(){
    int n;
    cin >> n;
    int x[n],y[n];
    for(int i=0; i < n; i++){
        cin >> x[i];
    }
    copy(x,x+n,y);
    sort(y,y+n);
    int left = y[n/2-1], right = y[n/2];
    for(int i=0; i<n; i++){
        if(x[i] <= left) cout << right << endl;
        else cout << left << endl;
    }
    return 0;
}


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

int main(){
    using namespace std;
    int n;
    cin >> n;
    vector<int> s(n);
    for(vector<int>::iterator it = s.begin(); it != s.end(); it++) cin >> *it;
    int q;
    cin >> q;
    vector<int> t(q);
    for(vector<int>::iterator it = t.begin(); it != t.end(); it++) cin >> *it;
    int res = 0;
    for(vector<int>::iterator it = t.begin(); it != t.end(); it++){
        int left = 0;
        int right = n-1;
        int mid;
        do{
            mid = left + (right - left)/2;
            if(s.at(mid) == *it){
                res++;
                break;
            }else if(s.at(mid) > *it){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }while(right >= left);
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    int N, a, ans = 0;
    cin >> N;
    vector<int> l(N);
    rep(i, N) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << "\n";
}

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

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

    vector <int> tele(N);

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

    int count = 0;
    int cycle = 0;
    int offset = 0;
    vector<int> used(N, -1);
    vector<int> vertex(N);

    deque <int> que;
    que.push_back(0);

    while (!que.empty()) {
        int now = que.front();
        que.pop_front();

        if (used[now] >= 0) {
            cycle = count-used[now];
            offset = used[now];
            break;
        }

        used[now] = count;
        vertex[count++] = now;

        que.push_back(tele[now]);
    }

    if (K <= offset) {
        cout << (vertex[K]+1) << endl;
    } else {
        K -= offset;
        K %= cycle;
        cout << (vertex[K+offset]+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5636
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  long long n,i,a;
  vector<long long> l;
  cin >> n;
  l.push_back(2);
  l.push_back(1);
  for(i=0;i<n-1;i++)
  {
    a=l[i]+l[i+1];
    l.push_back(a);
}
  cout << l[n];
  return 0;
}

Measured memory_bytes: 256
# ARC091C - Flip, Flip, and Flip...... (ABC090C)
def main():
    n, m = sorted(list(map(int, input().rstrip().split())))
    if (n, m) == (1, 1):
        print(1)
    elif n == 1:
        print(m - 2)
    elif n == 2:
        print(0)
    else:
        print((n - 2) * (m - 2))


if __name__ == "__main__":
    main()

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
}

Measured memory_bytes: 26552
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int a,b;cin >> a >> b;
      if(a == 1 && b == 1 || a == b)cout << "Draw";
      else if(a == 1)cout << "Alice";
      else if(b == 1)cout << "Bob";
      else if(a < b)cout << "Bob";
      else cout << "Alice";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    h,w = LI()
    s = SR(h)
    b = [[inf] * w for i in range(h)]
    q = [(s[0][0] == "#", (0, 0))]
    b[0][0] = s[0][0] == "#"
    while q:
        p, xy = heappop(q)
        y, x = xy
        z = s[y][x]
        for mx, my in [(0, 1), (1, 0)]:
            mx += x
            my += y
            if 0 <= mx < w and 0 <= my < h:
                if b[my][mx] > p + (z != s[my][mx] and s[my][mx] != "."):
                    b[my][mx] = p + (z != s[my][mx] and s[my][mx] != ".")
                    heappush(q, (p + (z != s[my][mx] and s[my][mx] != "."), (my, mx)))

    print(b[-1][-1] if b[-1][-1] else 0)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 63064
/*
 * Created by Dipta Das on 14-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int n = 5;
    vector<int> ar(n);
    for (int i = 0; i < n; ++i) {
        cin >> ar[i];
    }

    int ans = INT_MAX;

    int cnt;
    for (int i = 0; i < n; ++i) {
        cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            cnt += ar[j];
            if (cnt % 10) cnt = (cnt/10) * 10 + 10;
        }
        cnt += ar[i];
        ans = min (cnt, ans);
    }

    cout << ans << endl;




    return 0;
}



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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }


const ll inf = 1e18;
const int nax = 1e5 + 5;

void SolveTestCase()
{
	ll n,k;
	cin>>n>>k;
	
	ll ans = inf;
	
	ans = min({n%k,n%k+k,abs(n%k-k)});
	cout<<ans;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i,0,t)
	{
		SolveTestCase();
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#define PI 3.14159265
#define RAD (PI/180)

using namespace std;

int main() {
	
	int m, angle;
	double x=0, y=0, deg=90;

	while(1) {
		scanf("%d, %d", &m, &angle);
		if(m==0&&angle==0)
			break;
		x+=(double)m*cos(deg*RAD);
		y+=(double)m*sin(deg*RAD);
		deg-=(double)angle;
	}

	cout << (int)x << endl << (int)y << endl;

	return 0;

}

Measured memory_bytes: 0
n,m = map(int,input().split())
if n > 1 and m > 1:
    num_9 = (n-2) * (m-2)
    ans = num_9
elif (n == 1) ^ (m == 1):
    if n == 1:
        num = m
    else:
        num = n
    ans = num - 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long solve(long long a,long long b)
{
	if(b==0LL)
		return a;
	return solve(b,a%b);
}
int main()
{
	long long a,b;
	cin>>a>>b;
	cout<<a*b/solve(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int a = int.Parse (str[0]);
            int b = int.Parse (str[1]);
            int c = int.Parse (str[2]);

            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine (a + " " + b + " " + c);
                }
                else
                {
                    if (c < a)
                    {
                        Console.WriteLine (c + " " + a + " " + b);
                    }
                    else
                    {
                        Console.WriteLine (a + " " + c + " " + b);
                    }
                }
            }
            else
            {
                if (b < c)
                {
                    if (c < a)
                    {
                        Console.WriteLine (b + " " + c + " " + a);
                    }
                    else
                    {
                        Console.WriteLine (b + " " + a + " " + c);
                    }
                }
                else
                {
                    Console.WriteLine (c + " " + b + " " + a);
                }
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


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

using namespace std;
using ll=long long;

void solve() {
    int n, D;
    cin >> n >> D;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }

    vector<int> dist(n);
    dist[0] = D;
    for (int i = 1; i < n; i++) {
        if (dist[i-1] > a[i-1]/2) {
            dist[i] = abs(dist[i-1] - a[i-1]);
        } else dist[i] = dist[i-1];
    }
    vector<ll> lim(n);
    lim[n-1] = 1;
    for (int i = n-1; i >= 1; i--) {
        if (lim[i] <= a[i]/2) lim[i-1]=lim[i];
        else lim[i-1] = lim[i] + a[i];
    }

    int q; cin >> q;
    while (q--) {
        int i; cin >> i; i--;
        cout << (lim[i]<=dist[i]? "YES\n": "NO\n");
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n, m;
string s;
vector<int> buf;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  tRMQ(vector<T> &v, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < v.size())
      n <<= 1;
    data.resize(n * 4, u);
    for (int i = 0; i < v.size(); i++) {
      data[n + i - 1] = v[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

using pll = pair<ll, ll>;

tRMQ<pll> minrmq(int n) {
  return tRMQ<pll>(n, make_pair(10000000000000000LL, -1), [](pll r, pll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, -10000000000000000LL,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}

void solve() {
  buf.clear();
  auto r = minrmq(n + 1);
  r.update(n, make_pair(0, n));
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '1') continue;
    auto c = r.query(i + 1, i + m + 1);
    r.update(i, make_pair(c.first + 1, i));
  }
  if (r.query(0, 1).first > n) {
    cout << -1 << endl;
    return;
  }
  int now = 0;
  while (now < n) {
    auto next = r.query(now + 1, now + 1 + m);
    cout << next.second - now << " ";
    now = next.second;
  }
  cout << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m >> s;
  solve();
  return 0;
}


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

namespace atcoder
{
    class Program
    {
        const long MOD = 1000000007;
        const int N = 2005;

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ").Select(s => Int32.Parse(s)).ToList();

            int n = input[0];
            int k = input[1];

            Arrange_nCk();

            for (int i = 1; i <= k; i++)
            {
                long nck = nCk(k - 1, i - 1);
                long red = nCk(n - k + 1, i);
                long ans = (nck * red) % MOD;
                Console.WriteLine(ans);
            }
        }

        static long[, ] dp = new long[N, N];
        public static void Arrange_nCk()
        {
            dp = new long[N, N];
            dp[0, 0] = 1;
            for (int i = 1; i <= 2000; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (j == 0)dp[i, j] = 1;
                    else dp[i, j] = (dp[i - 1, j - 1] + dp[i - 1, j]) % MOD;
                }
            }
        }
        public static long nCk(long n, long k)
        {
            return dp[n, k];
        }
    }
}

Measured memory_bytes: 51280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Solve(int N, int M)
        {
            return (1900 * M + 100 * (N - M)) * (1 << M);
        }
        static void Main(string[] args)
        {
            int[] values = ReadInts();
            Console.WriteLine(Solve(values[0], values[1]));
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (99999999)
int main(){

  //-------データの入力------------
  int n;
  cin >> n;
  int row[n];
  int column[n];
  for(int i = 0; i < n; i++){
    cin >> row[i] >> column[i];
  }
  //-----------------------------

  //[始点][終点（始点+幅）]の最小コスト
  int dp[n][n];

  //INFで初期化
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      dp[i][j] = INF;
    }
  }

  //幅0はコスト0
  //dp[i][i+0] = 0
  for(int i = 0; i < n; i++){
    dp[i][i] = 0;
  }

  //幅:j = 0 から探索開始
  for(int j = 0; j < n; j++){
    //始点: i
    for(int i = 0; i < n - j; i++){
      //仕切りを置く位置: k
      // (M_0, M_1, M_2, M_3) | (M_4, M_5)
      for(int k = i + 1; k <= i + j; k++){
        //現在のdp[i][i+j]より小さければ更新
        dp[i][i+j] = min(dp[i][i+j], dp[i][k-1] + dp[k][i+j] + row[i] * column[k-1] * column[i+j]);
      }
    }
  }
  /*
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  //始点０、幅n-1の最小コスト=> n個の行列の連鎖の計算に最低限必要な乗算の回数　を出力
  cout << dp[0][n-1] << endl;
  return 0;
}

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

typedef long long ll;
ll k;

int main(){
    cin>>k;
    if (k == 7 || k == 1){
        printf("1");
        return 0;
    }
    if (k % 2 == 0 || k % 5 == 0){
        printf("-1");
        return 0;
    }
    if (k % 7 == 0) k /= 7;
    int r = 1, cnt = 1;
    while (r != 0){
        r = (r * 10 + 1) % k;
        ++cnt;
    }
    printf("%d", cnt);
}


Measured memory_bytes: 3732
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var A = K / 2;
            int B;
            if (K % 2 == 0)
            {
                B = A;
            }
            else
            {
                B = A + 1;
            }
            Console.WriteLine(A * B);
        }
    }
}

Measured memory_bytes: 11092
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b;
	scdd(a,b);
	while(a!=0 || b!=0)
	{
		forin(i,0,a)
		{
			forin(j,0,b)
			{
				if(i==0 || j==0 || j==b-1 || i==a-1)
				printf("#");
				else
				printf(".");
			}
			newline;
		}
		newline;
		scdd(a,b);
	}
	
	return 0;
}

Measured memory_bytes: 3156
// ダブリングとかいうの初めて知った
package main

import "fmt"

func main() {
	var N int
	var K int64
	fmt.Scan(&N, &K)
	A := make([]int, N+1)
	Double := make([][]int, 62) // 10^18≒2^60
	for i := 0; i < len(Double); i++ {
		Double[i] = make([]int, N+1)
	}
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		A[i+1] = V
		Double[0][i+1] = V
	}
	for i := 1; i < len(Double); i++ {
		for j := 1; j < N+1; j++ {
			Double[i][j] = Double[i-1][Double[i-1][j]]
		}
	}

	// わからん?>??>????>???>??
	// なんかデカい桁からみる==Kを2進表記した最上位桁からみるをして、ビットが立っていれば採用してるっぽいんだけど
	// なんでそれを採用したらいい具合になるのかさっっっっっっぱりわからん
	v := 1
	for i := len(Double) - 1; i >= 0; i-- {
		if (K>>int64(i))&1 == 1 {
			v = Double[i][v]
		}
	}
	fmt.Println(v)
}

// 10 5
// 4 7 2 8 5 3 4 7 2 1

// 12 6
// 8 4 2 10 6 9 1 11 2 12 6 5

// 8 4
// 4 5 8 2 7 3 6 7


Measured memory_bytes: 116980
// Problem : B - Uneven Numbers
// Contest : AtCoder Beginner Contest 136
// URL : https://atcoder.jp/contests/abc136/tasks/abc136_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin>>n;
int count=0;
for(int i=1;i<=n;i++)
{
	int x=i;int countt=0;
	while(x){
	countt++;x/=10;}
if(countt&1)
count++;
}
cout<<count;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from collections import deque

def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		
def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test():

if __name__ == '__main__':
	main()
	#test()

Measured memory_bytes: 598448
N = int(input())
words = [input() for i in range(N)]

from collections import Counter

word = list(set(words))

dict = Counter(words)

max = max(dict.values())

for a in word:
    if dict[a] == max:
        continue
    else:
        del dict[a]

dict2 = sorted(dict.keys())

for a in dict2:
    print(a)

Measured memory_bytes: 44896
#pragma GCC optimize("O2")
#include <iostream>

using namespace std;
int ans=10000;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin >> n >> t;
    for (int i=0;i<n;i++) {
        int a,b;
        cin >> a >> b;
        if (b<=t) ans = min(ans,a);
    }
    if (ans==10000) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

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

void solve() {
  string s;
  cin >> s;

  int N = s.size();

  vector<int> dpv(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    int increment = (s[i - 1] == '>') ? -1 : + 1;
    dpv[i] = dpv[i - 1] + increment;
  }

  int index = min_element(dpv.begin(), dpv.end()) - dpv.begin();
  
  vector<int> values(N + 1);
  values[index] = 0;
  for (int i = index + 1; i <= N; ++i) {
    int increment = (s[i - 1] == '>') ? -1 : 1;
    values[i] = values[i - 1] + increment;
  }
  for (int i = index - 1; i >= 0; --i) {
    int increment = (s[i] == '>') ? 1 : -1;
    values[i] = values[i + 1] + increment;
  }

  // Left to right pass.
  for (int i = 0; i <= N; ++i) {
    int left = (i == 0) ? -1 : values[i - 1];
    int right = (i == N) ? -1 : values[i + 1];
    int current = values[i];

    if (left < current && right < current) {
      values[i] = max(left, right) + 1;
    } else if (left > current && right > current) {
      values[i] = 0;
    } else {
      values[i] = min(left, right) + 1;
    }
  }

  // Right to left pass.
  for (int i = N; i >= 0; --i) {
    int left = (i == 0) ? -1 : values[i - 1];
    int right = (i == N) ? -1 : values[i + 1];
    int current = values[i];

    if (left < current && right < current) {
      values[i] = max(left, right) + 1;
    } else if (left > current && right > current) {
      values[i] = 0;
    } else {
      values[i] = min(left, right) + 1;
    }
  }

  // Calculate sum.
  long long sum = 0;
  for (int i = 0; i <= N; ++i) sum += values[i];

  cout << sum << endl;
}

int main() {
  solve();
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int k, x; cin >> k >> x;
    for (int i=x-k+1; i<=x+k-1; i++) {
        cout << i << endl;
    }
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>
#define imposs {cout<<"-1\n";return 0;}
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

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

  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v<=w) {
    cout << "NO\n";
    return 0;
  }
  ll tt = (abs(a-b)-1) / (v-w) + 1;
  cout << ((tt > t) ? "NO" : "YES") << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
const int INF=(1<<29);
int main()
{
   char a,b;
   cin >> a >>b;
   if(a=='H')
   {
       if(b=='H')
        printf("H\n");
        if(b=='D')
        printf("D\n");
   }
   if(a=='D')
   {
       if(b=='H')
        printf("D\n");
        if(b=='D')
        printf("H\n");
   }
   return 0;
}


Measured memory_bytes: 256
#2 Kleene Inversion
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7

a_out = [sum(bb > aa for bb in a ) for aa in a]
a_in = [sum(a[i] > a[j] for i in range(n) if i<j) for j in range(n)]

print( (sum(a_out)*k*(k-1)//2 + sum(a_in)*k)%mod )

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

int main() {
  int n;
  cin >> n;
  
  vector<string> r(n);
  for(int i=0; i<n; i++){
    cin >> r.at(i);
  }
  
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  
  for(int i=0; i<n; i++){
    if(r.at(i)=="AC"){
      a++;
    }
    else if(r.at(i)=="WA"){
      b++;
    }
    else if(r.at(i)=="TLE"){
      c++;
    }
    else if(r.at(i)=="RE"){
      d++;
    }
  }
  
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl; 
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\n";

int main()
{
  int n;
  cin >> n;
  cout << (n % 1000 == 0 ? 0 : 1000 - n % 1000) << el;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  ll dist = min(abs(x - a), abs(x - b));
  string ans = "B";
  if (dist == abs(x - a)) {
    ans = "A";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <complex>
#include <cstdio>
#include <cassert>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

int main(){
	int T,x1,y1,x2,y2;
	for(scanf("%d",&T);T--;){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L A(P(x1,y1),P(x2,y2));
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L B(P(x1,y1),P(x2,y2));
		printf("%d\n",intersectSS(A,B));
	}
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K;
std::string S;

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

  std::cin >> K >> S;

  if(S.size() <= K){
      std::cout << S << std::endl;
  }else{
      std::cout << S.substr(0, K) << "..." << std::endl;
  }
}


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

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

    vector<pair<int,pair<int, int>>> closed;
    for(int i=0; i<n; i++){
        int s, t, x;
        cin >> s >> t >> x;
        closed.push_back({s-x,{ 1,x}});// type :  1
        closed.push_back({t-x,{-1,x}});// type : -1
    }
    sort(closed.begin(),closed.end());// -1 < 1

    vector<int> d(q);
    for(int i=0; i<q; i++){
        cin >> d[i];
    }

    set<int> current;// set of closed points
    int j = 0;
    for(int i=0; i<q; i++){
        while(j < 2*n && closed[j].first <= d[i]){
            int type = closed[j].second.first;
            int x    = closed[j].second.second;
            if(type ==  1) current.insert(x);
            if(type == -1) current.erase(x);
            j += 1;
        }
        if(current.empty() == false) cout << *current.begin() << endl;
        if(current.empty() == true)  cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 18084
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

const int INF = 1e+9 + 7;
const int MAX_M = 1005;
const int MAX_N = 105;

int M, N;
int a[MAX_M], b[MAX_M], c[MAX_M];
int dp[MAX_N][MAX_N];
int via[MAX_N][MAX_N];
int ans, cnt;

void solve() {
	memset(via, -1, sizeof(via));
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_N; j++) {
			if (i != j) {
				dp[i][j] = INF;
			} else {
				dp[i][j] = 0;
			}
		}
	}
	for (int i = 0; i < M; i++) {
		dp[a[i] - 1][b[i] - 1] = c[i];
		dp[b[i] - 1][a[i] - 1] = c[i];
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (dp[i][k] + dp[k][j] < dp[i][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
					via[i][j] = k;
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			if (via[i][j] == -1) cnt++;
		}
	}
	ans = M - cnt / 2;
	cout << ans << endl;

	//_PA2(dp, 5, 5);
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	solve();
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll count=1;
  rep(i,n){
    if(a[i]==count) count++;
  }
  if(count==1) cout<<-1<<endl;
  else cout<<n-count+1<<endl;
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mem(x, y) memset(x, y, sizeof(x))
#define pii pair<int, int>
#define pli pair<LL, int>
#define mkp make_pair
#define ls u << 1
#define rs u << 1 | 1
const int N = 100005;
int n, m, a[N];
LL f[N << 2], d[N << 2];
bool mark[N << 2];

void pd(int u, int l, int r) {
    if(mark[u]) {
        int mid = (l + r) / 2;
        f[ls] += f[u], f[rs] += (f[u] + d[u] * (mid - l + 1));
        d[ls] += d[u], d[rs] += d[u];
        mark[ls] = mark[rs] = 1;
        f[u] = d[u] = mark[u] = 0;
    }
}

void upd(int u, int l, int r, int L, int R, int F, int D) {
    if(l == L && r == R) {
        f[u] += F;
        d[u] += D;
        mark[u] = 1;
        return;
    }
    pd(u, l, r);
    int mid = (l + r) / 2;
    if(R <= mid) upd(ls, l, mid, L, R, F, D);
    else if(L > mid) upd(rs, mid + 1, r, L, R, F, D);
    else {
        upd(ls, l, mid, L, mid, F, D);
        upd(rs, mid + 1, r, mid + 1, R, F + D * (mid + 1 - L), D);
    }
}

LL query(int u, int l, int r, int x) {
    if(l == r) return f[u];
    pd(u, l, r);
    int mid = (l + r) / 2;
    return x <= mid ? query(ls, l, mid, x) : query(rs, mid + 1, r, x);
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 2; i <= n; i++) {
        int last = a[i - 1], cur = a[i];
        if(last < cur) {
            upd(1, 1, m, last + 1, cur, cur - last, -1);
            upd(1, 1, m, 1, last, cur - last, 0);
            if(cur + 1 <= m) upd(1, 1, m, cur + 1, m, cur - last, 0);
        }
        else {
            int step = m - last + cur;
            if(last + 1 <= m) upd(1, 1, m, last + 1, m, step, -1);
            upd(1, 1, m, 1, cur, step - (m - last), -1);
            upd(1, 1, m, cur + 1, last, step, 0);
        }
    }
    LL ans = 1e18;
    for(int i = 1; i <= m; i++) ans = min(ans, query(1, 1, m, i));
    cout << ans << endl;
    return 0;
}



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

int N;
int t[101010],x[101010],y[101010];
int main(){
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    int t1 = 0,x1 = 0, y1 = 0;
    for(int i=0; i<N; i++){
        int t2,x2,y2;
        t2 = t[i];
        x2 = x[i];
        y2 = y[i];
        long long int d = abs( x2 - x1 ) + abs( y2 - y1 );
        if( d <= ( t2 - t1 ) && ( ( t2 - t1 )  % 2 == d % 2) ){
            t1 = t2;
            x1 = x2;
            y1 = y2;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
char a[100001];
long long ans;
int main(){
    scanf("%s",a+1);
    int len = strlen (a+1);
    for(int i=2;i<=len;i++){
        if(a[i]!=a[i-1])ans++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int main()
{
	// freopen("ARC096-C.in", "r", stdin); 
	int a, b, c, x, y, ans = 1e9; 
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y); 
	for (int i = 0; i <= 1e5; i++)
		ans = std::min(ans, c * (i << 1) + a * std::max(0, x - i) + b * std::max(0, y - i)); 
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	int ac=0,wa=0,tle=0,re=0;
	while(t--){
		string s;
		cin>>s;
		if(s=="AC") ++ac;
		else if(s=="WA") ++wa;
		else if(s=="TLE") ++tle;
		else ++re;
	}
	cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  double R;
  cin >> R;
  cout << 2 * 3.141592 * R << endl;
}


Measured memory_bytes: 3796
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
	return (a * b // gcd(a, b))

N = int(input())
t = int(input())
for i in range(N-1):
	T = int(input())
	t = lcm(t,T)
print(t)

Measured memory_bytes: 2940
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Integer a[] = new Integer[N];
    int ans = 0;
    for(int i=0; i<N; i++){
      a[i] = sc.nextInt();
      ans += a[i] -1;
    }
    System.out.println(ans);
    
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 26732