akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

combination table(1e6);

int N, K;

lint balls(int b, int r){
    if(K < b || N - K < r){
        return 0;
    }
    if(N - K == 0 && r == 0){
        return table.C(K - 1, K - b);
    }else{
        return table.C(K - 1, K - b) * table.C((N - K) - 1, (N - K) - r) % mod;
    }
}

int main(){
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        cout << (balls(i, i - 1) + balls(i, i) * 2 + balls(i, i + 1)) % mod << endl;
    }
}

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

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int n;
	int a[110];
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	qsort(a, n, sizeof(int), asc);
	cout << abs(a[0]-a[n-1]) << endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	int A,B;
  scanf("%d %d\n", &A, &B);
  if(B%A==0){
    printf("%d\n",A+B);
  }
  else{
    printf("%d\n",B-A);
  }
	return 0;
}

Measured memory_bytes: 128
from itertools import combinations as comb
N, K = map(int, input().split())
ans = (2 * 10 ** 9) ** 2 + 1
choice = min(K, 4)
xs = [0] * N
ys = [0] * N
for i in range(N):
	xs[i], ys[i] = map(int, input().split())

for idxs in comb(range(N), choice):
	x_mx = y_mx = - 10 ** 9
	x_mn = y_mn = 10 ** 9
	for i in idxs:
		x_mx = max(x_mx, xs[i])
		y_mx = max(y_mx, ys[i])
		x_mn = min(x_mn, xs[i])
		y_mn = min(y_mn, ys[i])
	in_num = sum(x_mn <= xs[i] <= x_mx and y_mn <= ys[i] <= y_mx for i in range(N))
	area = (x_mx - x_mn) * (y_mx - y_mn)
	if in_num >= K and area < ans:
		ans = area
print(ans)


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

int main(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> v(1100);
    for(int i=0; i<q; i++){
        int a, t;
        cin >> a >> t;
        if(a == 0){
            int x;
            cin >> x;
            v[t].push_back(x);
        }else{
            if(a == 1){
                if(v[t].empty()){
                    cout << endl;
                }else{
                    for(int i=0; i<v[t].size()-1; i++) {
                        cout << v[t][i] << " ";
                    }
                    cout << v[t][v[t].size()-1] << endl;
                }
            }else{
                v[t].clear();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5876
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<Integer> red = new ArrayList<>();
    for(int i = 0; i < N; i++){
      String[] S = sc.nextLine().split(" ");
      int a = Integer.parseInt(S[0]);
      int b = Integer.parseInt(S[1]);
      int n = a * 1000 + b;
      red.add(n);
    }
    List<Integer> blue = new ArrayList<>();
    for(int i = 0; i < N; i++){
      String[] S = sc.nextLine().split(" ");
      int a = Integer.parseInt(S[0]);
      int b = Integer.parseInt(S[1]);
      int n = a * 1000 + b;
      blue.add(n);
    }
    Collections.sort(red, Collections.reverseOrder());
    Collections.sort(blue);
    
    for(int i = 0; i < blue.size(); i++){
      int ymax = -1;
      int temj = -1;
      for(int j = 0; j < red.size(); j++){
        int r = red.get(j);
        if(blue.get(i)-1000 > r){
          if(r % 1000 > ymax && r % 1000 < blue.get(i) % 1000){
            ymax = r % 1000;
            temj = j;
          }
        }
      }
      if(ymax >= 0){
        red.remove(temj);
        blue.remove(i);
        i--;
      }
    }
    System.out.println(N-blue.size());
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

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

	string S, T;
	cin >> S >> T;

	string ans;
	for (int i = 0; i < 2 * N;++i) {
		if (i % 2 == 0) ans += S[i / 2];
		else ans += T[i / 2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3192
# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def insr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


n, a, b = invr()
S = insr()
os = 0
jp = 0
for s in S:
    if s == "a":
        if jp+os < a+b:
            jp += 1
            print("Yes")
        else:
            print("No")
    elif s == "b":
        if os+1 <= b and os+jp < a+b:
            os += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4712
N, K = gets.chomp.split(" ").map(&:to_i)
Dice = gets.chomp.split(" ").map(&:to_i)
max, i = 0, 0
s = Dice[0..(K - 1)].inject(:+)
max = s

(N - K).times do
   s = s + Dice[K + i] - Dice[i]
   if s >= max
      max = s
   end
   i += 1
end

puts "#{(max+K).quo(2).to_f}"

Measured memory_bytes: 17540
import java.util.*;

public class Main {

	static int[] blockNumber = new int[31];
	static int maxBlock;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int input = sc.nextInt();
		while(input != 0) {
			maxBlock = input;
			searchBlock(0, maxBlock, maxBlock);
			input = sc.nextInt();
		}
	}
	
	public static void searchBlock(int depth, int nowCount, int nowBlock) {
		if (nowCount == 0) {
			if (nowBlock == 0) {
				showArray(depth);
			}
			return;
		}
		
		for(int b = nowCount; b >= 0; b--) {
			if (nowBlock - b >= 0) {
				blockNumber[depth] = b;
				searchBlock(depth + 1, b, nowBlock - b);
			}
		}
	}
	
	public static void showArray(int end) {
		if (end == 1) {
			System.out.println(blockNumber[0]);
			return;
		}
		
		System.out.print(blockNumber[0]);
		for(int i = 1; i < end - 1; i++) {
			System.out.print(" " + blockNumber[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 51732
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007
#define MAX 200005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;

long long fact[MAX], inv[MAX];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

ll initCombination() {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= MAX; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[MAX] = CalcPow(fact[MAX], MOD - 2);
	for (int i = MAX - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int main() {

	int H, W, A, B;
	cin >> H >> W >> A >> B;

	initCombination();

	//vector<vector<int>> tempTable(200005, vector<int>(200005, -1));

	ll ans = 0;
	for (int i = B; i < W; ++i) {
		ll temp = combination((H - A - 1) + i, H - A - 1);
		ans += ((temp * combination((A - 1) + (W - 1 - i), A - 1)) % MOD);
		ans %= MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int n,a[110],some[200];
	int nx,ny;
	int all=1,odd=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		all*=3;
		if(a[i]%2==0){
			odd*=2;
		}
	}
	cout<<all-odd<<endl;
	return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	double a , b;
	cin >> a>> b ;
	//税抜き価格を全探索
	for(int i = 0 ; i < 100010 ; i ++){
		double hati , juu ; //hati%のときの消費税とjuu%のと木庄勢
		hati = double(i) * 0.08 ; 
		juu =  double(i) * 0.1 ;
		hati = (int)hati ;
		juu = (int)juu;
		if(a==hati && b==juu) {
			cout <<i << endl;
			return 0 ;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b = map(int,input().split())
if a + b == 15:
  print("+")
elif a * b == 15:
  print("*")
else:
  print("x")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int t;
            cin >> t;
            mp[t]++;
        }
    }
    int ans = 0;
    rep(i, m + 1)
    {
        if (mp[i] == n)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  char c1 = toupper(s1[0]);
  char c2 = toupper(s2[0]);
  char c3 = toupper(s3[0]);
  cout << c1 << c2 << c3 << endl;

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let xs = read_vec_i64();
    println!("{}", if xs[0] <= xs[2] && xs[2] <= xs[0] + xs[1] { "YES" } else { "NO" });
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (H % h == 0 and W % w == 0) {
        Yes(0);
        return 0;
    }
    int num = H % h * w + W % w * h - (H % h) * (W % w);
    const int c = (H / h) * (W / w) / num + 1;
    assert(c * h * w <= 1000000000);
    vvi ans(H, vi(W, c));
    rep(i, H / h) rep(j, W / w) {
            ans[(i + 1) * h - 1][(j + 1) * w - 1] = -(c * (h * w - 1) + 1);
        }
    Yes(1);
    rep(i, H) rep(j, W) {
            cout << ans[i][j] << (j == W - 1 ? '\n' : ' ');
        }
}


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

int main(){
  int n;
  int cnt[6] = {};
  double s;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    double t = 165;
    bool f = false;
    for(int j=0;j<5;j++){
      if(!f && s<t){
	cnt[j]++;
	f = true;
      }
      t += 5;
    }
    if(!f)cnt[5]++;
  }

  for(int i=0;i<6;i++){
    cout << i+1 << ":";
    for(int j=0;j<cnt[i];j++)cout << "*";
    cout << endl;
  }
}

Measured memory_bytes: 1232
local N, K = io.read("n", "n")
local h = {}
for i=1, N do
    h[i] = io.read("n")
end
table.sort(h)
local lo = 1
local hi = K
local hmin, hmax = h[lo], h[hi]
local ugliness = hmax - hmin
local min_ugliness = ugliness
while hi + 1 <= N do
    local new_hmin = h[lo + 1]
    local new_hmax = h[hi + 1]
    local new_ugliness = new_hmax - new_hmin
    if new_ugliness < min_ugliness then
        min_ugliness = new_ugliness
    end
    lo = lo + 1
    hi = hi + 1
end
print(min_ugliness)


Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vsort(a);
    vsort(b);
    bool flag = false;
    for (int i = x + 1; i <= y && !flag; i++) {
        if (i > a[n-1] && i <= b[0]) {
            flag = true;
        }
    }
    if (flag) {
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}


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

color = [0] * 8
cnt = 0
for val in a:
    for i in range(8):
        if 400 * i <= val < 400 * (i + 1):
            color[i] = 1
    if val >= 3200:
            cnt += 1

if all([c == 0 for c in color]):
    s = 1
else:
    s = sum(color)
l = sum(color) + cnt

print(s, l)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

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

using namespace std;


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

    ll height = -1;
    rep(i, 101) {
        rep(j, 101) {
            rep(k, n) {
                if (h[k] != 0) {
                    if (height == -1) {
                        height = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    } else if (height != h[k] + abs(i - x[k]) + abs(j - y[k])) {
                        height = -2;
                        break;
                    }
                }
            }
            if (height == -2) {
                height = -1;
                continue;
            }


            rep(k, n){
                if(h[k] == 0){
                    if(height > abs(i - x[k]) + abs(j - y[k])){
                        height = -2;
                        break;
                    }
                }
            }

            if(height == -2) {
                height = -1;
                continue;
            }
            cout << i << " " << j << " " << height << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
	int k, n;
  	cin >> k >> n;
  	vector<int> A(n);
  	rep(i, n) cin >> A[i];
  	A.push_back(A[0] + k);
  
  	int maxi = 0;
  	rep(i, n){
    	maxi = max(maxi, A[i + 1] - A[i]);
    }
	  
  	cout << k - maxi << endl;
}

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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


int main(){
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    bool flag = false;
    for(int i=0;i<=n-1;i++){
        int x = i, y = n-1-i;

        long long lbx = a+c*x;
        long long ubx = a+d*x;
        long long lby = b+c*y;
        long long uby = b+d*y;
        if(ubx < lby || lbx > uby)
            continue;
        flag = true;
        break;
    }
    cout << (flag?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};
bool check(int n, int pos) {return n & (1<<pos);}
using namespace std;

void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid, test1, test2;
    for(int i = 0; i < h; i++){
        string s; cin >> s;
        grid.push_back(s);
    }
    ll ans = 0;
    // for(int msk1 = 0; msk1 < (1<<h); msk1++){
    //     test1 = grid;
    //     for(int i = 0; i < h; i++){
    //         if(check(msk1, i)){
    //             for(int j = 0; j < w; j++){
    //                 test1[i][j] = '0';
    //             }
    //         }
    //     }
    //     for(int msk2 = 0; msk2 < (1<<w); msk2++){
    //         test2 = test1l;
    //         for(int i = 0; i < w; i++){
    //             if(check(msk2, i)){
    //                 for(int j = 0; j < h; j++){
    //                     test2[j][i] = '0';
    //                 }
    //             }
    //         }


    //     }
    // }
    for(int msk1 = 0; msk1 < (1<<h); msk1++){
        for(int msk2 = 0; msk2 < (1<<w); msk2++){
            int kk = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(!check(msk1, i) && !check(msk2, j)){
                        if(grid[i][j] == '#') kk++;
                    }
                }
            }
            if(kk == k) ans++;
        }
    }
    cout << ans;
    
}
//new line is printed in main()

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        p: i64,
        v: [(usize1, usize1, i64); m]
    }
    let es: Vec<_> = v.iter().map(|x| (x.0, x.1, p - x.2)).collect();
    if let Some(d) = bellman_ford(n, &es, 0, n - 1) {
        println!("{}", max(0, - d));
    } else {
        println!("-1");
    }
}

fn bellman_ford(n: usize, es: &[(usize, usize, i64)], s: usize, t: usize) -> Option<i64> {
    let mut dist = vec![1 << 50; n];
    let mut reach = vec![false; n];
    let mut reach_inv = vec![false; n];
    dist[s] = 0;
    reach[s] = true;
    reach_inv[t] = true;
    for _ in 0..n - 1 {
        for &(u, v, w) in es {
            if dist[v] > dist[u] + w {
                dist[v] = dist[u] + w;
            }
            reach[v] |= reach[u];
            reach_inv[u] |= reach_inv[v];
        }
    }
    for &(u, v, w) in es {
        if reach[v] && reach_inv[v] && dist[v] > dist[u] + w {
            return None;
        }
    }
    Some(dist[t])
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
	}
	else {
		long long a = 1;
		long long pa = 2;
		long long ans = 0;

		for (int i = 2; i <= n; i++) {
			ans = a + pa;
			pa = a;
			a = ans;
		}
		cout << ans << endl;
	}
	
	
	

	return 0;
}

Measured memory_bytes: 256
import math
a, b, c, d = map(int, input().split())

s1 = (a-1) // c
s2 = (a-1) // d
s3 = (a-1) // (c*d//math.gcd(c,d))
S = (a-1) - (s1 + s2 -s3)

l1 = b // c
l2 = b // d
l3 = b // (c*d//math.gcd(c,d))
L = b - (l1 + l2 - l3)

print(L-S)

Measured memory_bytes: 9108
#include <stdio.h>
int main(){
  int minv,maxv,n,i,R[1000001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  minv = R[0];
  maxv = R[1]-R[0];
  
  for(i=1;i<n;i++){
    if(maxv >=  R[i]-minv) maxv = maxv;
    else maxv =  R[i]-minv;
    if(minv <=  R[i]) minv = minv;
    else minv =  R[i];
  }
 
  printf("%d\n",maxv);

  return 0;
} 

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

int main(){
	int n;
	ll a;
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%lld",&a);
		if(a&1){
			puts("first");
			return 0;
		}
	}
	puts("second");
	return 0;
}

Measured memory_bytes: 256
# 1 つの組を固定したとき、その他の置き方は (N*M-2)C(K-2) 通り
# x 座標が h 離れる組み合わせは、(N-h)*M*M 通り (h!=0)

def combination(n, r, mod=10**9+7):
    # nCr mod m
    # rがn/2に近いと非常に重くなる
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def main():
    N, M, K = map(int, input().split())
    mod = 10**9 + 7
    ans1 = 0
    for h in range(1, N):
        ans1 += (N - h) * h
    ans1 = ans1 * M * M % mod
    ans2 = 0
    for w in range(1, M):
        ans2 += (M - w) * w
    ans2 = ans2 * N * N % mod
    ans = (ans1 + ans2) * combination(N*M-2, K-2) % mod
    print(ans)

main()


Measured memory_bytes: 9204
/* Author - xorier4104 */

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>


using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define MOD 			(int) 1e9+7
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define mem(a,b)        memset(a,(b),sizeof(a))
#define max(a,b)        ((a)>(b) ? (a):(b))
#define min(a,b)        ((a)<(b) ? (a):(b))
#define abs(a)          ((a)>0 ? (a):(-(a)))
#define sq(a) 			((a)*(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int main(){ FastIO;
	
	int n;
	string s,t;
	cin>>n;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		cout<<s[i]<<t[i];
	}

return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
typedef long long ll;
int main() {
  ll N,i;
  scanf("%lld", &N);
  ll D[N], countD[N];
  for(i=0;i<N;i++){
    countD[i] = 0;
  }
  for(i=0;i<N;i++){
    scanf("%lld",&D[i]);
    countD[D[i]]++;
  }

  if(D[0]!=0){
    printf("0\n");
    return 0;
  }
  /*
  if(countD[0]!=1){
    printf("0\n");
    return 0;
  }
  for(i=1;i<N;i++){
    if(countD[i]!=0 && countD[i-1]==0){
      printf("0\n");
      return 0;
    }
  }
  */  
  ll ans=1;
  for(i=1;i<N;i++){
    if(D[i]==0){
      ans=0;
      break;
    }else{
      //    printf("%llu\n",countD[D[i]-1]);
      ans = ans * countD[D[i]-1] % 998244353;
    }
  }
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define us unsigned short int
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio                   \
    ios::sync_with_stdio(false); \
    cin.tie(0);
using namespace std;

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    ll freqa[n + 1], freqb[m + 1];
    freqa[0] = freqb[0] = 0;

    // for (ll &tmp : a) //0 based input
    //     cin >> tmp;
    // for (ll &tmp : b)
    //     cin >> tmp;

    for (ll i = 1; i <= n; i++)
    {
        scanf("%lld",&a[i-1]);
        freqa[i] = freqa[i - 1] + a[i - 1]; //1 based freqa
    }
        
    for (ll i = 1; i <= m; i++)
    {
        scanf("%lld",&b[i-1]);
        freqb[i] = freqb[i - 1] + b[i - 1];
    }
       
    ll ans = 0;

    for (ll i = 0; i <= n and freqa[i] <= k; i++)
    {
        ll j=lower_bound(freqb,freqb+m,k-freqa[i])-freqb;
        if(j>m or freqa[i]+freqb[j]>k) j--;
        ans=max(ans,i+j);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9984
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext())
			{
				int n = sc.nextInt();
				int count = 0;
				int result = 0;
				if(n == 1){System.out.println(0);continue;}
					for(int i = 3; i <= n; i+=2)
					{
						count = 0;
						for(int j = 3;j <= Math.sqrt(i) ;j+=2)
						{
							if(i % j == 0){count=1;break;}
						}
						
						if(count == 0)result++;
					}
				System.out.println(result+1);
			}
	}
}

Measured memory_bytes: 19140
import sys
N = int(input())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((b, a))
ab=sorted(ab, reverse = True)
time = ab[0][0]
flag = True
for i in range(N):
    b, a = ab[i]
    if ab[i][0]<time:
        time = b-a
    else:
        time -=a
    
if time>=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 68824
#include <iostream>

using namespace std;

int bubbleSort(int A[],int N) {
	int sw = 0;
	bool flag = 1;
	for(int i=0; flag; i++) {
		flag = 0;
		for(int j=N-1; j>=i+1; j--) {
			if(A[j] < A[j-1]) {
				swap(A[j], A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for(int i=0;i<N; i++) cin >> A[i];

	sw = bubbleSort(A,N);

	for(int i = 0; i < N; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}


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

int N,M;
bool A[8][8] = {0};
bool V[8] = {0};
int ans = 0;

void dfs(int s) {
    bool flag = true;
    for(int i=0; i<N; ++i) {
        if(V[i] == false) {
            flag = false;
            break;
        }
    }
    if(flag) {
        ++ans;
        return;
    }
    for(int i=0; i<N; ++i) {
        if(A[s][i] == true && V[i] == false) {
            V[i] = true;
            dfs(i);
            V[i] = false;
        }
    }
}

int main() {
    cin >> N >> M;
    int a,b;
    for(int i=0; i<M; ++i) {
        cin >> a >> b;
        A[a-1][b-1] = A[b-1][a-1] = true;
    }
    V[0] = true;
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

module Main where

-- import Debug.Trace
import Data.List
import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Word
import Data.Char
import Data.Bits
import Data.Array
-- import Data.Array.Unboxed
-- import Data.Array.IO
import Data.Maybe
-- import qualified Data.Map as M
import qualified Data.IntMap as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

size = 3
maxAdr = size*size -1

solver :: [[Int]] -> Int
solver lst = bfs start goalID where
    bfs start goalID = iter ((Seq.singleton (start, generateID start, 0)), M.empty) where
        iter (que, visited) = case Seq.viewr que of
            Seq.EmptyR -> error "No path found."
            que Seq.:> path@(b, bId, d)
                | bId == goalID -> d
                | otherwise -> iter (insertPaths que visited (nextPaths path)) where
                    insertPaths q v [] = (q, v)
                    insertPaths q v (p@(_,x,_):ps) = insertPaths (p Seq.<| q) (M.insert x () visited) ps
                    nextPaths path@(b, bId, d) = [(x, xId, d+1)| (x, xId) <- nextBoards, notVisited xId] where        
                        notVisited x = M.notMember x visited
                        boards = [swapAt (b !! q) b | q <- dest!p]
                        nextBoards = [(x, generateID x)| x <- boards]
                        p = fromJust $ elemIndex 0 b
    goalID= generateID [1,2,3,4,5,6,7,8,0]
    start = concat lst
    dest  = listArray (0, maxAdr) [[1,3],[0,2,4],[1,5],[0,4,6],[1,3,5,7],[2,4,8],[3,7],[4,6,8],[5,7]] 
    generateID board = foldl' (\b a-> shiftL b 4 .|. a) 0 board

swapAt :: Int -> [Int] -> [Int]
swapAt v = foldr (\a b -> case a of
    _   | a == 0 -> v:b
        | a == v -> 0:b
        | otherwise -> a:b
     ) [] 

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO() 
main = do
    l <- replicateM size readIntList
    print $ solver l



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

int N , M ;
cin >> N >> M ;
string S ;
cin >> S ;
vector<int> A(M) ;
vector<int> B(M) ;
rep(i,M) cin >> A.at(i) >> B.at(i) ;
//rep(i,M) cout << A.at(i) << B.at(i) ;
vector<int> C(N+1) ;
  for(int i = 1 ; i < N ; i++ ){
    if(S.at(i-1) == 'A' && S.at(i) == 'C' ) {
        C[i+1] = C[i] + 1 ; 
    }
    else  C[i+1] = C[i] ;
  }
  
  //rep(i,N+1) cout << C[i] << ' ' ;

  for(int i = 0 ; i < M ; i++ ){
      int ans = C[ B[i] ] - C[ A[i] ] ;
      cout << ans << endl;
  }
  
 }


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int sum=0, smax=0;
    for(int i=0; i<n; i++){
        sum += s[i]=='I' ? 1 : -1;
        smax = max(smax, sum);
    }

    cout << smax << endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
a1 = [0] + list(accumulate(a))
b1 = list(accumulate(b))

for i in range(n + 1):
  ren = k - a1[i]
  if ren < 0:
    break
  j = bisect.bisect_right(b1, ren)
  x = max (x, i + j)	
print (x)

Measured memory_bytes: 48980
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
using ull = unsigned long long;

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

int main()
{
    u32 n;
    cin >> n;
    bool flag = false;
    for (u32 i = 1; i <= 9; i++)
    {
        if (n % i == 0 && 1 <= n / i && n / i <= 9)
        {
            flag = true;
            break;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long mod = 1000000007;
		
		long ans = powmod(10,N)-powmod(9,N)-powmod(9,N)+powmod(8,N);
		ans %= mod;
		ans = (ans + mod) % mod;
		System.out.println(ans);
		
	}
	public static long powmod(long x, long n){
		long mod = 1000000007;
      	long res = 1;
      
		for(long i = 0; i < n; i++){
			res = res * x % mod;
		}
		return res;
	}
}


Measured memory_bytes: 35824
import sys
input = sys.stdin.readline

from itertools import accumulate

def main():
    N,X=map(int,input().split())
    A=[list(map(int,input().split())) for i in range(N)]

    A.sort(key=lambda x:x[2]*(X-x[0])+x[0]*x[1],reverse=True)
    ALL=[a[2]*(X-a[0])+a[0]*a[1] for a in A]



    SUM=[0]+list(accumulate(ALL))

    MAX=0
    MINUS=0

    for a,r,l in A:
        MAX+=a
        MINUS+=a*r

    OUT=-1

    def binsearch(score):

        alluse=score//X
        rest=score-alluse*X

        for ri in range(N):
            plus=0
            b,l,u=A[ri]
            
            if rest<b:
                plus+=rest*l
            else:
                plus+=rest*u+b*l-b*u

            if alluse<=ri:
                plus+=SUM[alluse]

            else:
                plus+=SUM[alluse+1]-ALL[ri]

            #print(score,ri,plus)

            if plus>=MINUS:
                return 1

        return 0


    while MAX-OUT>1:
        mid=(MAX+OUT)//2

        if binsearch(mid)==1:
            MAX=mid
        else:
            OUT=mid

    print(MAX)

main()


Measured memory_bytes: 40788
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

int N,M;
const int INF = 1LL << 55;

int main()
{
	cin >> N >> M;
	int g[101][101];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			g[i][j] = 1e9;
		}
	}

	int a[1001], b[1001], c[1001];
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (g[a[i]][b[i]] != c[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  set<string> s;
  string t;
  for(int i=0; i<n; i++) {
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;

}

// EOF


Measured memory_bytes: 19232
a, b = map(str, input().split())

num1 = ""
num2 = ""
for i in range(int(a)):
  num1 = num1 + b
for i in range(int(b)):
  num2 = num2 + a
list = [num1, num2]
list2 = sorted(list)
print (list2[0])

Measured memory_bytes: 2940
N, M = map(int, input().split())
H = list(map(int, input().split()))

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


d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node, par):
    global is_visit
    global ans
    d = [[node, par]]
    while d:
        node, par = d.pop()
        if is_visit[node]:
            continue
        is_visit[node] = True
        h = H[node]
        children = g[node]
        res = True
        for child in children:
            _h = H[child]
            res *= h > _h
            if not is_visit[child]:
                d.append([child, node])
        
        ans += res


for i in range(N):
    if not is_visit[i]:
        search(i, -1)

print(ans)

Measured memory_bytes: 37120
n,k = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
l1 = sorted(l,key=lambda x:x[1])
ans = float("INF")

for i in l:
    for j in l:
        if i[0] >= j[0]:
            continue
        for s in l1:
            count = 0
            for w,h in l1:
                if i[0] <= w <= j[0] and s[1] <= h:
                    count += 1
                if count==k:
                    ans = (min(ans,(j[0]-i[0])*(h-s[1])))
                    break
                
print(ans)


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

using namespace std;

const long long MOD=1000000007;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

long long inv_mod(long long x){
	if(x == 1) return 1;
	long long d = MOD/x+1;
	return d*inv_mod(x-(MOD%x))%MOD;
}

long long div_mod(long long x, long long y){
	return x*inv_mod(y)%MOD;
}


void solve(){
    int i,j;
    long long n,k;
    string str;
    cin >> n >> k;
    vector<long long> a(n);
    for(i = 0;i < n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<long long> c(n),cs(n);
    if(k == 1){
        cout << 0 << endl;
        return;
    }
    c[k-2] = 1;
    for(i = k-1;i < n;i++){
        c[i] = div_mod(mul_mod(c[i-1],i),i-k+2);
    }
    cs[k-2] = c[k-2];
    for(i = k-1;i <= n-2;i++){
        cs[i] = add_mod(cs[i-1],c[i]);
    }
    long long ans = 0;
    for(i = 1;i < n;i++){
        if(i+1 < k) continue;
        ans = add_mod(ans,mul_mod(a[i],cs[i-1]));
        ans = sub_mod(ans,mul_mod(a[n-i-1],cs[i-1]));
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 2560
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let n: u32 = input();
    for i in 0..(n/7+1) {
        if (n-i*7)%4==0 {
            println!("Yes");
            return
        }
    }
    println!("No");
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352