akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)
	if strings.HasPrefix(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> a(26);
    rep(i, h * w) {
        char c;
        cin >> c;
        a[c - 'a']++;
    }

    int p = 0, q = 0;
    rep(i, 26) {
        if (a[i] % 4 != 0) p++;
        if (a[i] % 2 == 1) q++;
    }

    int t = ((h % 2) * w + (w % 2) * h) / 2;
    if (q <= 1 && p <= t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(100000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int B = sc.nextInt();
        int R = N-B;



        for(int i=1; i<=B; i++){
            long ans = Mod.mults(Mod.combination(B-1, B-i),
                                 Mod.combination(R+1, i));
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

ll dp[1010][1010];
ll fac[1010],invfac[1010];

ll power(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if (b%2) ans*=a;
		b/=2;
		a*=a;
		if (a>=m) a%=m;
		if (ans>=m) ans%=m;
	}
	return ans;
}

int main()
{
	fac[0]=1;
	invfac[0]=1;
	REPP(i,1,1010){
		fac[i]=(fac[i-1]*i)%mod;
		invfac[i]=power(fac[i],mod-2,mod);
	}
	ll n,a,b,c,d,x,y,ans=0;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	dp[a-1][0]=1;
	REPP(i,a,b+1){
		REP(j,n+1){
			dp[i][j]+=dp[i-1][j];
			REPP(cnt,c,d+1){
				if (j<cnt*i) break;
				dp[i][j]+=(((dp[i-1][j-cnt*i]*power(invfac[i],cnt,mod))%mod)*invfac[cnt])%mod;
			}
			dp[i][j]%=mod;
		}
	}
	ans=(dp[b][n]*fac[n])%mod;
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
using Int = long long;

int main() {

	Int N;
	std::cin >> N;

	std::vector<int> A(N);
	for (Int i = 0; i < N; i++)std::cin >> A[i];

	Int ans = 0;
	int flag = 0;//0未定、1単調非増加中、2単調非減少中
	for (Int i = 0; i < N - 1; i++) {
		if (flag == 0) {
			if (A[i + 1] - A[i] > 0)flag = 2;
			else if (A[i + 1] - A[i] < 0)flag = 1;
		}
		else if (flag == 1) {
			if (A[i + 1] - A[i] > 0) {
				flag = 0;
				ans++;
			}

		}
		else if (flag == 2) {
			if (A[i + 1] - A[i] < 0) {
				flag = 0;
				ans++;
			}
		}

	}

	std::cout << ans+1 << std::endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m, c;
  cin >> n >> m >> c;
  
  int b[m];
  for (int i = 0; i < m; i++)
    cin >> b[i];
  
  int a[m];
  int count = 0;
  for (int i = 0; i < n; i++) {
    
    for (int j = 0; j < m; j++)
      cin >> a[j];
    
    int sum = 0;
    for (int j = 0; j < m; j++)
      sum += a[j] * b[j];
    sum += c;
      
    if (sum > 0)
      count ++;
  }
  
  cout << count << endl;      
  
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  string s,t;
  cin >> s >> t;
  int n,m;
  n=s.size();
  m=t.size();
  vector<char> p(n);
  vector<char> q(m);
  
  rep(i,n) {
  p[i]=s[i];
  }
  sort(all(p));
  string ss="";
  rep(i,n){
  ss+=p[i];
  }
  
  rep(i,m) {
  q[i]=t[i];
  }
  sort(all(q));
  reverse(all(q));
  string tt="";
  rep(i,m){
  tt+=q[i];
  }
  
  cout << (ss<tt?"Yes":"No") << endl;
  
}

Measured memory_bytes: 256
def minkowsuki(x, y, n):
    return sum(abs(x[i] - y[i]) ** n for i in range(len(x))) ** (1 / n)

n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))

print(minkowsuki(x, y, 1))
print(minkowsuki(x, y, 2))
print(minkowsuki(x, y, 3))
print(max(abs(x[i] - y[i]) for i in range(n)))

Measured memory_bytes: 6800
import sys
N = int(input())

for h in range(1, 3501):
	for n in range(h, 3501):
		if 4*h*n>N*(n+h):
			w=(N*h*n)/(4*h*n-N*(n+h))
			if w==int(w):
				w=int(w)
				print(h,n,w)
				sys.exit()
		

Measured memory_bytes: 3060
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string s, std::string t){
    if(t.substr(0, s.size()) == s){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


signed main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

int main(){
  int N, i, j, sum=0, max=0x80000000;
  scanf("%d", &N);
  int A[2][N];
  for(i=0;i<N;i++)scanf("%d", &A[0][i]);
  for(i=0;i<N;i++)scanf("%d", &A[1][i]);
    
  for(i=0;i<N;i++){
    sum=0;
    for(j=0;j<=i;j++)sum+=A[0][j];
    for(j=i;j< N;j++)sum+=A[1][j];
    if(sum>max)max=sum;
  }
    
  printf("%d\n", max);
}


Measured memory_bytes: 128
def num_combinations_mod(n, r, mod, num_max=10**6):
    # if this functions is called twice or more, init process should be placed before calling this function to
    # save time.
    if r > n:
        return 0
    elif r == n:
        return 1
    elif r < 0 or n < 0:
        return 0
    f_mod, f_mod_inv = num_combinations_mod_init(num_max, mod)
    return f_mod[n] * (f_mod_inv[r] * f_mod_inv[n-r] % mod) % mod


def num_combinations_mod_init(num_max, mod):
    factorials_mod = dict()
    factorials_mod_inv = dict()
    factorials_mod[0] = 1
    factorials_mod[1] = 1
    factorials_mod_inv[0] = 1
    factorials_mod_inv[1] = 1
    mod_inv = dict()
    mod_inv[1] = 1
    for i in range(2, num_max):
        factorials_mod[i] = factorials_mod[i - 1] * i % mod
        mod_inv[i] = mod - mod_inv[mod % i] * (mod // i) % mod
        factorials_mod_inv[i] = factorials_mod_inv[i - 1] * mod_inv[i] % mod
    return factorials_mod, factorials_mod_inv


def get(num1, num2):
    if num1 > num2:
        num = num2
    else:
        num = num1
    return num_combinations_mod(num1+num2, num, 10**9+7)


def main(X, Y):
    if (X + Y) % 3 != 0:
        return 0

    total = (X + Y) // 3
    n_moveB = (2 * X - Y) // 3
    n_moveA = total - n_moveB
    answer = get(n_moveA, n_moveB)

    return answer


X, Y = map(int, input().split(" "))
print(main(X, Y))

Measured memory_bytes: 277596
while 1:
 n=int(input())
 if n==0:break
 a=1;s='123456'
 for _ in[0]*n:
  s=[s[int(e)]for e in{'N':"152304",'E':"310542",'W':"215043",'S':"402351",'R':"024135",'L':"031425"}[input()[0]]]
  a+=int(s[0])
 print(a)


Measured memory_bytes: 5660
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c<=0) {
      cout << "Yes" << endl;
      break;
    }
    a-=d;
    if(a<=0) {
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
from bisect import *
mod = 10**9+7

H = int(input())
W = int(input())
N = int(input())
h, w = max(H, W), min(H, W)
cnt, ans = 0, 0
while cnt < N:
    cnt += h
    ans += 1
print(ans)


Measured memory_bytes: 3316
fun main(args: Array<String>) {
    a49(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a49(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val char = args[0][0]
    print(when (char) {
        'a', 'e', 'i', 'o', 'u' -> "vowel"
        else -> "consonant"
    })
}


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

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

	int sum = 0;
	int l = 0;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		sum += x;
		l = max(l, x);
	}

	if (sum - l > l) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

namespace A___Accepted
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var count = 0;
            foreach (var p in s)
            {
                if (p == '1')
                    count++;
            }
            Console.WriteLine (count);
        }
    }
}

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

int main(){
    ll l,r,m, ans=2018;
    cin >> l >> r;

    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            m = (i*j) %2019;

            if(ans > m) ans = m;
            if(ans==0){
                cout << 0 << endl;
                return  0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = 10**6
a = (N+1).times.map{0}
gets
gets.split do |s|
  a[s.to_i] += 1
end
ans = 0
(1..N).each do |i|
  next if a[i] == 0
  ans += 1 if a[i]==1
  j = i*2
  while j <= N
    a[j] = 0
    j += i
  end
end
p ans


Measured memory_bytes: 23784
from sys import stdin, setrecursionlimit


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

    def find(self, x):
        p = self.parent
        while p[x] >= 0:
            x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        p = self.parent
        if x != y:
            if x > y:
                x, y = y, x
            p[x], p[y] = p[x] + p[y], x

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

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


def main():
    input = stdin.buffer.readline
    n, m, k = map(int, input().split())

    f = UnionFindTree(n)

    f_or_b = [0] * n

    for _ in range(m):
        a, b = map(int, input().split())
        f.union(a - 1, b - 1)
        f_or_b[a - 1] += 1
        f_or_b[b - 1] += 1

    for _ in range(k):
        c, d = map(int, input().split())
        if f.same(c - 1, d - 1):
            f_or_b[c - 1] += 1
            f_or_b[d - 1] += 1

    print(*[f.size(i) - f_or_b[i] - 1 for i in range(n)])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 59228
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

char AbcNumToChar(ll a){
	if(a==0)return 'a';
	if(a==1)return 'b';
	if(a==2)return 'c';
	if(a==3)return 'd';
	if(a==4)return 'e';
	if(a==5)return 'f';
	if(a==6)return 'g';
	if(a==7)return 'h';
	if(a==8)return 'i';
	if(a==9)return 'j';
	if(a==10)return 'k';
	if(a==11)return 'l';
	if(a==12)return 'm';
	if(a==13)return 'n';
	if(a==14)return 'o';
	if(a==15)return 'p';
	if(a==16)return 'q';
	if(a==17)return 'r';
	if(a==18)return 's';
	if(a==19)return 't';
	if(a==20)return 'u';
	if(a==21)return 'v';
	if(a==22)return 'w';
	if(a==23)return 'x';
	if(a==24)return 'y';
	if(a==25)return 'z';
	return '0';
}


int main()
{
	ll N;
	vector<ll>V;
	cin>>N;
	for(;;){
		if(N>26){
			N=N-1;
			V.push_back(N%26);
			N=N/26;
		}
		else{
			N=N-1;
			V.push_back(N%26);
			break;
		}
	}
	reverse(V.begin(),V.end());
	rep(i,V.size()){
		cout<<AbcNumToChar(V[i]);
	}
	cout<<endl;
}

Measured memory_bytes: 3124
from collections import deque

K = int(input())

q = deque()

for i in range(1, 10):
    q.appendleft(i)


cnt = 0

while True:
    cnt += 1
    temp = q.pop()
    st = str(temp)
    med = temp*10 + int(st[-1])
    if temp % 10 != 0:
        q.appendleft(med - 1)
    q.appendleft(med)
    if temp % 10 != 9:
        q.appendleft(med + 1)

    if cnt == K:
        print(temp)
        break

Measured memory_bytes: 11984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxx=1010;

int main (){
	int dp[maxx][maxx];
	string s,p;
	int q;
	cin>>q;
	while(q--){
		cin>>s>>p;
		int a=s.size(),b=p.size();
		for(int i=1;i<=a;i++) dp[i][0]=0;
		for(int i=1;i<=b;i++) dp[0][i]=0;
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				if(s[i]==p[j]) dp[i+1][j+1]=dp[i][j]+1;
				else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
			}
		}
		cout<<dp[a][b]<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long int ll;

int main(){
	int n;
	string s;
	cin >> n >> s;
	queue<int> pos;
	for(int i = 0; i < n; i++){
		if(s[i]=='W'){
			pos.push(i);
		}
	}
	int res = 0;
	for(int i = n-1; i >= 0; i--){
		if(s[i]=='W') continue;
		if(pos.empty()){
			break;
		}
		int ind = pos.front();
		pos.pop();
		if(ind > i) break;
		else{
			swap(s[ind],s[i]);
			++res;
		}
	}
	cout << res << "\n";
	return 0;
}


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

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const int MAX = 510000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(int n, int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(int n){
        return fac[n];
    }
};

const ULLI MOD = 7;

struct D{
    int d;
    int idx;

    D(int d,int idx){
        this->d = d;
        this->idx = idx;
    }

    bool operator<(const D &l) const {
        return d < l.d;
    };
};

int main(){
    int N;
    string S;

    cin >> N >> S;

    if(N%2==1){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0;i<N/2;i++){
        if(S[i] != S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int s;
    cin>>s;
    int h,m,ss;
    h=s/3600;
    m=s/60%60;
    //m=s%60;
    ss=s%60;
    cout<<h<<":"<<m<<":"<<ss<<endl;
    return 0;
}



Measured memory_bytes: 3092
import java.util.Scanner;
 public class Main{

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a=new int[n];
        int min=1000000;
        int max=-1000000;
        long x=0;
        
        for( int i = 0; i<n; i++ ){
           a[i]=sc.nextInt();
            x+=a[i];
        	if(max<a[i]){
        		max=a[i];
            }
            if(min>a[i]){
        		min=a[i];
            }
          }
        System.out.println(min+" "+max+" "+x);
        
        sc.close();
	}
 }


Measured memory_bytes: 41916
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

int N;
string S;
cin >> N >> S;

int cnt = 0;
// xyzがSにあるかどうかをみる
rep(i,10) {
    rep(j,10) {
        rep(k,10) {
            char x = '0' + i;
            char y = '0' + j;
            char z = '0' + k;
            bool bx = false;
            bool by = false;
            bool bz = false;
            rep(p,N) {
               if(S[p] == x && !bx) {
                   bx = true;
                   continue;
               }
               if(S[p] == y && bx && !by) {
                   by = true;
                   continue;
               }
               if(S[p] == z && bx && by) {
                   bz = true;
                   break;
               }
            }
            if(bz && by && bz) cnt++;
        }
    }
}
cout << cnt << endl;
return 0;
}

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

int main(){
  int n,k; cin>>n>>k;
  set<int> dis;
  for(int i=0; i<k; ++i){int d; cin>>d; dis.insert(d);}

  bool ok=false;
  while(!ok){
    int m=n;
    bool flg=false;
    while(m!=0){
      int x=m%10;
      if(dis.find(x)!=dis.end())flg=true;
      m/=10;
    }
    if(!flg)ok=true;
    else ++n;
  }  
  cout<<n<<endl;
}


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

int main () {
    ll x;
    cin >> x;
    //xまでの和
    ll waX = (x + 1) * x / 2;
    //3の倍数のxまでの和
    ll wa3 = (x/3 + 1) * (x/3) / 2 * 3;
    //5の倍数のxまでの和
    ll wa5 = (x/5 + 1) * (x/5) / 2 * 5;
    //15の倍数のxまでの和
    ll wa15 = (x/15 + 1) * (x/15) / 2 * 15;

    // cout << waX << endl << wa3 << endl << wa5 << endl << wa15 << endl;

    cout << waX - wa3 - wa5 + wa15 << endl;

    // cout << ((x/3) + 1) * ^^^(x/3)^^^ / 2 * 3<< endl; ここのかっこをかかないとだめ
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n && n != 0) {
    int *a = new int[n];
    int max, t;
    for (int i = 0; i < n; i++) {
      cin >> t;
      a[i] = t;
    }
    max = -1000000;
    for (int j = 0; j < n; j++) {
      for (int k = j, t = 0; k < n; k++) {
        t += a[k];
        if (max < t) max = t;
      }
    }
    delete [] a;
    cout << max << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int even = 0, four = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            four++;
        } else if (a % 2 == 0) {
            even++;
        }
    }
    puts((max(2 * four + even, (four == 0 ? 0 : 2 * four + 1)) >= n ? "Yes" : "No"));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n; cin>>n;
 map<int,int> mp;
 REP(i,n){
     int a; cin>>a;
     if(mp[a]==1)mp[a]=0;
     else mp[a]=1;
 }
 int res=0;
 for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
  if(itr->second==1)res++;
 }
 cout<<res<<endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int k;
  cin>>k;
  ll ans=0;
  for(i=1;i<=k;i++){
    for(j=1;j<=k;j++){
      int g=gcd(i,j);
      for(int l=1;l<=k;l++){
        ans+=gcd(g,l);
      }
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3640
n, k, s = map(int, input().split())
a = []
if s == 1:
    for i in range(k):
        a.append(1)
    for i in range(n - k):
        a.append(2)
elif n == k:
    for i in range(n):
        a.append(s)
else:
    for i in range((k + 1)// 2):
        a.append(1)
        a.append(s - 1)
    if k % 2 == 0:
        a.append(1)
    for i in range(n - k):
        if s == 10 ** 9:
            a.append(s - 2)
        else:
            a.append(s + 1)
for i in range(n - 1):
    print(a[i], end = " ")
print(a[n - 1])

Measured memory_bytes: 8136
#include <bits/stdc++.h>
#define fi first
#define se second
#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 gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;


int main() {
  int n, l;
  scanf("%d%d",&n,&l);
  vi a(n);
  rep(i,n) {
    scanf("%d",&a[i]);
  }
  P p(0,0);
  rep(i,n-1) {
    maxs(p,P(a[i]+a[i+1], i+1));
  }
  if (p.fi < l) {
    cout<<"Impossible"<<endl;
    return 0;
  }
  puts("Possible");
  rrep(i,p.se-1) {
    printf("%d\n", i);
  }
  drep(i,n) {
    printf("%d\n", i);
    if (i == p.se) break;
  }
  return 0;
}










Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int count = 0;
    for(int i = 1; i < n-1; i++) {
        if(v[i] > v[i-1] && v[i] < v[i+1]) {
            count++;
        }
        else if(v[i] < v[i-1] && v[i] > v[i+1]) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#define INFTY 100000010
using namespace std;

vector<double> value;

int innerCompare(int a, int b) {
	if (value[a] >= value[b]) {
		if (value[a] == value[b]) {
			return 0;
		}
		else {
			return -1;
		}
	}
	else {
		return 1;
	}
}

void merge(vector<int> &A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1);
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	vector<int> R(n2 + 1);
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = INFTY;
	R[n2] = INFTY;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		int com = INFTY;
		if (R[j] != INFTY && L[i] != INFTY) com = innerCompare(L[i], R[j]);
		if (R[j] == INFTY || (L[i] != INFTY && com <= 0)) {
			A[k] = L[i];
			i = i + 1;
		}
		else {
			A[k] = R[j];
			j = j + 1;
		}
		//		cout << com << ": " << L[i] << endl;
	}

	//	for(int i = 0;i<data.length(); i++) cout << i << ": " << tree[i] << endl;

}

void mergeSort(vector<int> &A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int N, totalW;
	cin >> N >> totalW;
	vector<int> v(N), w(N), rank(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
		rank[i] = i;
		value.push_back((double)v[i] / w[i]);
	}

	mergeSort(rank, 0, N);

	double res = 0.0;
	int curweight = 0;

	for (int i = 0; i < N; i++) {
		if (curweight + w[rank[i]] < totalW) {
			res += (double)v[rank[i]];
			curweight += w[rank[i]];
		}
		else {
			res += (double)v[rank[i]] / w[rank[i]] * (totalW - curweight);
			break;
		}
	}
	cout << fixed << setprecision(8) << res << endl;


	return 0;
}


Measured memory_bytes: 5400
/*
      author : nishi5451
      created: 11.08.2020 00:44:33
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a+b>=10) cout<< "error" << endl;
    else cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 3628
def gcd(a,b):
    if a<b:
        return gcd(b,a)
    elif a%b==0:
        return b
    else:
        return gcd(b,a%b)

N=int(input())
ans=1
for _ in range(N):
    T=int(input())
    ans=(T*ans)//gcd(T,ans)
print(ans)


Measured memory_bytes: 38384
#include<stdio.h>
int main(){
    int N,i;
    int A[100];
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        scanf("%d",&A[i]);
    }
    long money = 1000;
    long kabu = 0;
    for(i=1;i<=N;i++){
        if(money>=A[i]){
            if(i!=N && A[i]<A[i+1]){
                kabu = kabu + money/A[i];
                money = money%A[i];
            }
        }else{
            if(i==N || (i!=N && A[i]>A[i+1])){
                money = money + A[i]*kabu;
                kabu = 0;
            }
        }
        //printf("%d日目,kabu = %d,money = %d\n",i,kabu,money);
    }
    printf("%ld\n",money);
    return 0;
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif
  ll x, y;
  cin >> x >> y;
  if (x % y == 0) {
    cout << -1 << '\n';
  } else {
    cout << x << '\n';
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    s+="D";
    ll n = s.length();
    string str;
    rep(i,n){
        if(s[i]=='A'){
            str+="o";
        }else if(s[i]=='B'&&s[i+1]=='C'){
            str+='x';
            i++;
        }else{
            str+='.';
        }
    }
    ll ans=0;
    stack<char> stk;
    rep(i,str.size()){
        if(str[i]==*"."){
            if(!stk.empty()){
                ll cnt = 0;
                while (!stk.empty()){
                    char &now = stk.top();
                    if(now==*"x"){
                        cnt++;
                    }else{
                        ans += cnt;
                    }
                    stk.pop();
                }
            }
        }else{
            stk.push(str[i]);
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 916
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int K, N;
    cin >> N >> K;
    vi a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    vector<double> b;
    rep(i, 0, N) {
        double res = 0;
        for (int j = 1; j <= a[i]; j++) {
            double c = (double)1/(double)a[i];
            res += (double)j * c;
        }
        b.push_back(res);
    }
    vector<double> s(N+1, 0);
    rep(i, 0, N) {
        s[i+1] = s[i] + b[i];
    }
    double res = -1;
    for (int i = 0; i+K <= N; ++i) {
        double sum;
        sum = s[i+K] - s[i];
        res = max(res, sum);
    }
    cout << fixed << setprecision(15);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4336
S = input()
T = input()
max_count = 0

for i in range(len(S) - len(T)):
  tmp = 0
  for j in range(len(T)):
    if S[j+i] == T[j]:
      tmp += 1
  if tmp > max_count:
    max_count = tmp

if len(S) == len(T):
  tmp = 0
  for j in range(len(T)):
    if S[j] == T[j]:
      tmp += 1
  if tmp > max_count:
    max_count = tmp

print(len(T) - max_count)

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

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX]; //i!%mod=fac[i]
long long finv[MAX]; //pow(i!,-1)%mod=finv[i]
long long inv[MAX]; //pow(i,-1)%mod=inv[i]

// テーブルを作る前処理
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modpow(int a,int b)
{
	if (b==0)
	{
		return 1LL;
	}
	long long ans=modpow(a,b/2);
	ans*=ans;
	ans%=mod;
	if (b%2==1)
	{
		ans*=a;
		ans%=mod;
	}
	return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long dp[2][200005]={};

int main(int argc, char const *argv[])
{
	cominit();
	int b,w;
	cin>>b>>w;
	for (int i = 0; i < b+w; ++i)
	{
		dp[0][i+1]=2LL*dp[0][i]%mod+com(i,b-1);
		dp[0][i+1]%=mod;
		dp[1][i+1]=2LL*dp[1][i]%mod+com(i,w-1);
		dp[1][i+1]%=mod;
	}
	for (int i = 0; i < b+w; ++i)
	{
		long long ans=(modpow(2,i)-dp[0][i]+dp[1][i]+mod)%mod;
		ans%=mod;
		ans*=modinv(modpow(2,i+1),mod);
		ans%=mod;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 17280
//In the name of God
#include<bits/stdc++.h>

using namespace std;

int n;
string s;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> s;
        n = s.size();
        for(int i=0 ; i < n-2 ; i++)
                if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2])
                        return cout << i+1 << ' ' << i+3 , 0;
        if(s[n-1] == s[n-2])
                cout << n-1 << ' ' << n;
        else
                cout <<-1 << ' ' << -1;
        return 0;
}


Measured memory_bytes: 512
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    let r: f64 = get_line().trim().parse().unwrap();

    println!("{area} {circum}",
        area=std::f64::consts::PI * r.powi(2),
        circum=2. * std::f64::consts::PI * r);
}



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

int main() {
  int H, W;
  cin >> H >> W;
  string S[2200];
  vector<vector<int> > vert(2200, vector<int>(2200));
  vector<vector<int> > hori(2200, vector<int>(2200));

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

  for (int i = 0; i < H; i++) {
    int cnt = 0, start = 0;
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        for (int k = start; k < j; k++) hori[i][k] = cnt;
        cnt = 0;
        start = j;
      }
      if (j == W - 1)
        for (int k = start; k < j + 1; k++) hori[i][k] = cnt;
    }
  }

  for (int j = 0; j < W; j++) {
    int cnt = 0, start = 0;
    for (int i = 0; i < H; i++) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        for (int k = start; k < i; k++) vert[k][j] = cnt;
        cnt = 0;
        start = i;
      }
      if (i == H - 1)
        for (int k = start; k < i + 1; k++) vert[k][j] = cnt;
    }
  }

  vector<vector<int> > ans(H, vector<int>(W));
  int answer = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] != '#') {
        ans[i][j] = vert[i][j] + hori[i][j];
        answer = max(answer, ans[i][j]);
      }
    }
  }

  cout << answer - 1 << endl;
  return 0;
}


Measured memory_bytes: 58112
c,i=30,k[30],x;main(n,a)
{
	for(;~scanf("%d",&a);)
	{
		k[__builtin_popcount(a^a-1)]=--n&&(x^=a);
	}
	for(;i--;)x&1<<i&&k[i+1]&&(c++,x^=(1<<i+1)-1);
	printf("%d",x?-1:c);
}

Measured memory_bytes: 128
import java.util.*;

// ABC 51-D
// https://abc051.contest.atcoder.jp/tasks/abc051_d

public class Main {

	static int N;
	static int[][] map;
	static int[][] usedEdges;
	static int numUsedEdges;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		N = in.nextInt();
		int M = in.nextInt();
		map = new int[N][N];
		usedEdges = new int[N][N];
		numUsedEdges = 0;
		
		for (int i = 0; i < M; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			int c = in.nextInt();
			
			map[a][b] = c;
			map[b][a] = c;
		}
		
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i != j) {
					dijkstra2(i);
				}
			}
		}
		System.out.println(M - numUsedEdges);
	}
	
	public static void dijkstra2(int start) {
		int[] dist = new int[N];
		Arrays.fill(dist, Integer.MAX_VALUE / 2 - 1);
		dist[start] = 0;
		
		ArrayList<ArrayList<Integer>> paths = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < N; i++) {
			paths.add(new ArrayList<Integer>());
		}
		
		int[] visited = new int[N];
		
		PriorityQueue<Custom_Pair> queue = new PriorityQueue<Custom_Pair>();
		Custom_Pair p = new Custom_Pair(start, 0);
		p.path.add(start);
		queue.add(p);
		
		while (queue.size() > 0) {
			p = queue.poll();
			
			if (visited[p.p] == 1) {
				continue;
			}
			
			for (int i = 0; i < N; i++) {
				if (map[p.p][i] > 0 && dist[i] > dist[p.p] + map[p.p][i]) {
					try {
						dist[i] = dist[p.p] + map[p.p][i];
						Custom_Pair newPair = (Custom_Pair) p.clone();
						newPair.p = i;
						newPair.cost = dist[i];
						newPair.path.add(i);
						paths.set(i, newPair.path);
						queue.add(newPair);
					} catch (Exception e) {
						
					}
				}
			}
			
			visited[p.p] = 1;
		}
		
		for (int i = 0; i < N; i++) {
			if (i != start) {
				ArrayList<Integer> path = paths.get(i);
				for (int j = 0; j < path.size() - 1; j++) {
					int a = path.get(j);
					int b = path.get(j + 1);
					if (usedEdges[a][b] == 0 && usedEdges[b][a] == 0) {
						usedEdges[a][b] = 1;
						usedEdges[b][a] = 1;
						numUsedEdges++;
					}
				}
			}
		}
	}
}

class Custom_Pair implements Comparable<Custom_Pair> {
	int p;
	int cost;
	ArrayList<Integer> path;
	
	public Custom_Pair(int p, int cost) {
		super();
		this.p = p;
		this.cost = cost;
		this.path = new ArrayList<Integer>();
	}

	@Override
	public int compareTo(Custom_Pair o) {
		return this.cost - o.cost;
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		Custom_Pair p = new Custom_Pair(this.p, this.cost);
		for (int i = 0; i < this.path.size(); i++) {
			p.path.add(this.path.get(i));
		}
		return p;
	}
}


Measured memory_bytes: 151132
n = int(input())
s = input()
a = [0]*(n+2)
b = [0]*(n+2)
for i in range(n):
    a[i+1] = a[i]
    b[-i-2] = b[-i-1]
    if s[i] == "W":
        a[i+1] += 1
    if s[-i-1] == "E":
        b[-i-2] += 1
b = b[2:n+2]
c = [a[i] + b[i] for i in range((n))]
print(min(c))

Measured memory_bytes: 30848
N, M = map(int, input().split())


class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        # 根への距離を管理
        self.weight = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


WUF = WeightedUnionFind(N)
for i in range(M):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    if WUF.same(l, r):
        if WUF.diff(l, r) != d:
            print("No")
            exit()
    else:
        WUF.union(l, r, d)

print("Yes")


Measured memory_bytes: 10176
import re

given = input("")

result = re.search(r"([0-9]+)\s([0-9]+)\s([0-9]+)", given)

a = int(result.group(1))
b = int(result.group(2))
c = int(result.group(3))

numlist= [a,b,c]
numlist.sort()

print(numlist[0], numlist[1], numlist[2])

Measured memory_bytes: 7832
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long n=sc.nextLong();
	  StringBuilder res=new StringBuilder();
	  while(n-- > 0) {
		  //System.out.println(n);
		  res.append((char)('a'+(n%26)));
		  n/=26;
	  }
	  System.out.println(res.reverse());
  }
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> colors;
  for (int i = 1; i <= 10000; i++) colors.push_back(i);
  for (int i = 0; i < n; i++) {
    colors.erase(remove(colors.begin(), colors.end(), a[i]), colors.end());
  }
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    if (a[i]==a[i+1]) {
      a[i+1] = colors[0];
      colors.erase(colors.begin());
      ans++;
    }
  }

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


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

int main() {
  ll N,C;
  cin >> N >> C;
  vector< pair<ll,ll> > s;
  vector<ll> cal(N,0);
  vector<ll> cal_r(N,0);
  vector<ll> cmax(N,0);
  vector<ll> cmax_r(N,0);
  ll ans = 0;
  REP(i,N) {
    ll x, v;
    cin >> x >> v;
    s.emplace_back(x,v);
    if ( i == 0 )  cal[i] = v-x;
    else  cal[i] = cal[i-1] + v-(x-s[i-1].first);
    ans = max(ans, cal[i]);
    cmax[i] = ans;
  }
  cal_r[0] = s[N-1].second - (C - s[N-1].first);
  cmax_r[0] = cal_r[0];
  for( int i=1;i<N;++i) {
    cal_r[i] = cal_r[i-1] + s[N-1-i].second - (s[N-i].first - s[N-1-i].first);
    cmax_r[i] = max(cmax_r[i-1], cal_r[i]);
    ans = max(ans, cmax_r[i]);
  }
//  REP(i,N) cout << i << " : " << cal[i] << " " << cmax[i] << endl;
//  REP(i,N) cout << i << " : " << cal_r[i] << " " << cmax_r[i] << endl;
  // 順方向に i+1 行ってから引き返す場合
  REP(i,N-1) {
    ll cal_t = cal[i] - s[i].first + cmax_r[N-1-(i+1)];
    ans = max(cal_t, ans);
//    cout << i << " : " << cal_t << endl;
  }
  // 逆方向に i+1 行ってから引き返す場合
  REP(i,N-1) {
    ll cal_t = cal_r[i] - (C-s[N-1-i].first) + cmax[N-1-(i+1)];
    ans = max(cal_t, ans);
//    cout << i << " : " << cal_t << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5620
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

a, b = map(int, input().split())
s = (input())

if s[a] != '-':
    print('No')
    exit()
for i in range(a):
    if not('0' <= s[i] and s[i] <= '9'):
        print('No')
        exit()
for i in range(a+1, a+b+1):
    if not('0' <= s[i] and s[i] <= '9'):
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3896