akhauriyash/Code-Regression huggingface dataset:
import numpy as np

n, W = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())
ndp = np.zeros(W + 1, dtype=np.int64)

for w, v in zip(w, v):
    # [:w]は品物の重量がナップサックの空きよりも重いので更新しない。
    # ndp[w:] は通常DPでのdp[i][w]=dp[i-1][w]。そのままでの更新。
    # ndp[:-w] + v は[:-w]が[w-weight]に相当。
    np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:])

print(ndp[-1])


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i <= N; i += 4) {
    if ((N - i) % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, x = na()
m = []
for _ in range(n):
    m.append(ni())

print(n + (x - sum(m))//min(m))

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)


def dfs(v):
    for u, w in e[v]:
        if c[u] != -1:
            continue
        c[u] = (c[v] + w) % 2
        dfs(u)


n = int(input())
e = tuple(set() for _ in range(n))
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    e[u].add((v, w))
    e[v].add((u, w))

c = [-1] * n
c[0] = 0

dfs(0)

print(*c, sep='\n')


Measured memory_bytes: 90740
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int n;
  std::vector< int > vi;
  std::vector< int > vs;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    std::cin >> tmp; 
    vi.push_back(tmp);
    vs.push_back(tmp);
  }

  std::sort(vs.begin(), vs.end());
  
  int index1 = (int)(n / 2);
  int index2 = index1 - 1;
  //std::cout << index1 << " " << vs[index1] << std::endl;
  //std::cout << index2 << " " << vs[index2] << std::endl;

  std::vector< int >::iterator it;
  for (it = vi.begin(); it != vi.end(); it++) {
    if (*it <= vs[index2]) {
      std::cout << vs[index1] << std::endl;
    } else {
      std::cout << vs[index2] << std::endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3948
n = int(input())
c2=0
c3=0
c4=0

c1 = int(n/25)
n = n - 25*c1
if n > 0:
    c2 = int(n/10)
    n = n - 10*c2
    
if n > 0:
    c3 = int(n/5)
    n = n - 5*c3
    
if n > 0:
    c4 = n

print(c1+c2+c3+c4)


Measured memory_bytes: 5592
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 ; 

int n ;
string ar [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	cout << 0 << endl ;
	cin >> ar [ 0 ] ; 
	if ( ar [ 0 ] == "Vacant" )
		return 0 ;
	int lo = 0 , hi = n ;
	while ( 1 ) {
		int mid = ( hi + lo ) >> 1 ;
		cout << mid << endl ;
		cin >> ar [ mid ] ;
		if ( ar [ mid ] == "Vacant" )
			return 0 ; 
		if ( ar [ mid ] == ar [ lo ] ) {
			if ( ( mid - lo ) % 2 == 0 )
				lo = mid ; 
			else
				hi = mid ; 
		}
		else {
			if ( ( mid - lo ) % 2 == 0 )
				hi = mid ;
			else
				lo = mid ; 
		}
	}
}


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

int main(){
   int a,b,c,x,y;
   cin >>a >>b >>c >>x >>y;
   int ans=0;
   int min;
   if(c*2<=a+b){
   if(x>=y){
         ans+=c*y*2;
         if(c*2>a)ans+=(x-y)*a;
         else ans+=(x-y)*c*2;
   }
   else{
         ans+=c*x*2;
         if(2*c>b)ans+=(y-x)*b;
         else ans+=(y-x)*2*c;
   }
   }
   if(c*2>a+b){
      ans+=a*x+b*y;
   }
   cout <<ans <<endl;
}

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

using namespace std;

int main(){
  int n, l;
  cin >> n;
  cin >> l;
  vector<string> s = {};
  for(int i = 0; i < n; i ++){
    string str;
    cin >> str;
    s.push_back(str);
  }
  sort(s.begin(), s.end());
  
  for(string str : s){
    cout << str;
  }
  
  return 0;
}

Measured memory_bytes: 256
s = input()

s_list=list(s)

C_num=-1

if (s_list[0]!="A"):
  print("WA")
else:
  nagasa=len(s_list)

  num=0
  for i in range(2,nagasa-1):
    if s_list[i]=="C":
      num += 1
      C_num=i

  if num!=1:
    print("WA")
  else:
    del s_list[0]
    del s_list[C_num-1]
    mojiretu = ''.join(s_list)
    if(mojiretu.islower()==True):
      print("AC")
    else:
      print("WA")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n,i,j,s=0,maxv=0;
	cin>>n;
	int a[3][n+1];
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		s=0;
		for(int j=1;j<=i;j++)
		s+=a[1][j];
		for(int j=i;j<=n;j++)
		s+=a[2][j];
		if(s>=maxv) maxv=s;
	}
	cout<<maxv;
	return 0;
}

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

string s1, s2, s3;

char toup(char c) {
	return c - 'a' + 'A';
}

int main() {
	cin >> s1 >> s2 >> s3;
	cout << toup(s1[0]) << toup(s2[0]) << toup(s3[0]) << endl;
	return 0;
}

Measured memory_bytes: 256
def s()
    gets().chomp
  end
  def i()
    gets.to_i
  end
  def li()
    gets.split.map(&:to_i)
  end
  def ls()
    gets.split
  end
  def ili()
    n = gets.to_i
    as = gets.split.map(&:to_i)
    [n, as]
  end
  def inli()
    n = gets.to_i
    as = []
    n.times {
      as << gets.split.map(&:to_i)
    }
    [n, as]
  end
  class Array
    def sum
      total = 0
      self.each do |item|
        total += item
      end
      total
    end
  end
  
  def eratosthenes(size)
    prime_list = []
    is_prime = Array.new(size, true)
    is_prime[0] = false
    is_prime[1] = false
  
    2.upto(size-1){|i|
      if is_prime[i]
        prime_list << i
        (2).upto((size.to_f/i).ceil-1){|j|
          is_prime[j*i] = false
        }
      end
    }
    [prime_list, is_prime]
  end
  
  def dijkstra(s, e, cost)
    size = cost.length
    if s==e
      return 0
    end
    dp = {}
    dp[s] = 0
    undefined_node = {}
    size.times{|i|
      if i != s
        undefined_node[i] = cost[s][i]
      end
    }
    while undefined_node.length != 0
      min = undefined_node.min_by{|_, v| v}
      stock = {}
      temp = undefined_node.clone
      temp.each{|k, v|
        if min[1] == v
          undefined_node.delete(k)
          if k == e
            return v
          end
          dp[k] = v
          stock[k] = v
        end
      }
  
      stock.each{|k, v|
        undefined_node.each{|k2, v2|
          undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
        }
      }
    end
  end
  
  def get_bits(len)
    res =  []
    (2**len).times{|i|
      res << i.to_s(2).rjust(len, '0')
    }
    res
  end
  
  def get_GCD(m, n)
    tmp = [n, m].max
    n = [n, m].min
    m = tmp
    while n != 0
      tmp = m % n
      m = n
      n = tmp
    end
    m
  end
  
  def matrix(n, m=n, init=0)
    Array.new(n).map{Array.new(m,init)}
  end


S = s()
n = i()
qs = []
n.times{
    qs << ls()
} 
is_reversed = false
tail = ""
head = ""
qs.each{ |q|
  if q[0] == "1" 
    is_reversed = !is_reversed
  else
    if is_reversed 
        if q[1] == "1" 
            tail << q[2]
        else
            head << q[2]
        end
    else
        if q[1] == "1" 
            head << q[2]
        else
            tail << q[2]
        end
    end
  end
}
res = head.reverse + S + tail
if is_reversed
    puts res.reverse
else
    puts res
end

Measured memory_bytes: 51836
def Binary_Search_Small_Count(A,x,sort=True,equal=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()
        
    N=len(A)
    if A[-1]<x:
        return N
    elif x<A[0] or (not equal and x==A[0]):
        return 0

    L,R=0,N
    while R-L>1:
        C=L+(R-L)//2
        if x<A[C] or (not equal and x==A[C]):
            R=C
        else:
            L=C
    return R
#=======================================
N=int(input())
L=list(map(lambda x:int(x),input().split()))
inf=float("inf")

T={}
for i in range(N):
    x=L[i]
    if x in T:
        T[x]+=1
    else:
        T[x]=0
        
    L[i]=(x,T[L[i]])
L.sort()

D=0
for i in range(N):
    (b,y)=L[i]
    for j in range(i+1,N):
        (c,z)=L[j]

        X=Binary_Search_Small_Count(L,(b,y),False,False)
        Y=Binary_Search_Small_Count(L,(c-b,inf),False,True)

        D+=max(0,X-Y)
print(D)


Measured memory_bytes: 76504
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = (int)Math.ceil((double)b / a);
		
		System.out.println(ans);
		
		sc.close();
	}

}



Measured memory_bytes: 26332
#include<algorithm>
#include<iostream>

using namespace std;
int main(){
	int n, max;
	int *score;

	while(1){
		cin >> n;
		if(n==0){
			break;
		}else{
			max = 0;
			score = new int[n];
			for(int i=0; i<n; i++){
				cin >> score[i];
			}
			sort(score, score+n);
			for(int i=1; i<n-1; i++){
				max += score[i];
			}
			cout << max/(n-2) << endl;

			delete [] score;
		}
	}

	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define MOD ll(1000000007)

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	ll i, n, j, t, m, x, y, z, k;

	ll ans=0;

	cin>>n>>x>>t;

	ans=t*(n/x);
	ans+=n%x?t:0;

	cout<<ans;
	cout<<"\n";



	return 0;
}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll a, b, x; std::cin >> a >> b >> x;
    std::cout << b/x - (a > 1 ? (a-1)/x : 0) + (a == 0) << "\n";
}


Measured memory_bytes: 256
package main

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

const MAXN=2000
const MAXQ=200000
type Query struct {
	x1,y1,x2,y2 int
}
var cin *bufio.Reader
var cout *bufio.Writer
var sum,sumh,suml [MAXN+5][MAXN+5]int
func query(sum *[MAXN+5][MAXN+5]int,x1,y1,x2,y2 int) int {
	if x2<x1 {return 0}
	if y2<y1 {return 0}
	return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1]
}
func main() {
	cin =bufio.NewReader(os.Stdin)
	cout=bufio.NewWriter(os.Stdout)
	var a [5 + MAXQ]Query
	var n,m,q int
	fmt.Fscanln(cin,&n,&m,&q)
	var s [MAXN+5]string
	for i:=0; i<n; i++ {
		fmt.Fscanln(cin,&s[i])
		for j:=0; j<m; j++ {
			sum[i+1][j+1]=int(s[i][j]-'0')
		}
	}
	for i:=1; i<=n; i++ {
		for j:=1; j<=m; j++ {
			if sum[i][j]>0 {
				if sum[i][j+1]>0 {
					suml[i][j]=1
				}
				if sum[i+1][j]>0 {
					sumh[i][j]=1
				}
			}
		}
	}
	for i:=1; i<=n; i++ {
		for j:=1; j<=m; j++ {
			sum[i][j]=sum[i][j]-sum[i-1][j-1]+sum[i][j-1]+sum[i-1][j]
			sumh[i][j]=sumh[i][j]-sumh[i-1][j-1]+sumh[i][j-1]+sumh[i-1][j]
			suml[i][j]=suml[i][j]-suml[i-1][j-1]+suml[i][j-1]+suml[i-1][j]
		}
	}
	/*for i:=1; i<=n; i++ {
		for j:=1; j<=m; j++ {
			fmt.Print(suml[i][j])
		}
		fmt.Println()
	}*/
	for i:=1; i<=q; i++ {
		fmt.Fscan(cin,&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2)
	}
	for i:=1; i<=q; i++ {
		x1,y1,x2,y2:=a[i].x1,a[i].y1,a[i].x2,a[i].y2
		//fmt.Println(query(&sum,x1,y1,x2,y2),query(&sumh,x1,y1,x2,y2-1),query(&suml,x1,y1,x2-1,y2))
		ans:=query(&sum,x1,y1,x2,y2)-query(&suml,x1,y1,x2,y2-1)-query(&sumh,x1,y1,x2-1,y2)
		fmt.Fprintln(cout,ans)
	}
	cout.Flush();
}


Measured memory_bytes: 114432
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<functional>
#include<algorithm>
using namespace std;
#define int long long

int a[55];
int amax(int s) {
	int b = a[0];
	for (int i = 0; i < s; i++) {
		b = max(b, a[i]);
	}
	return b;
}
signed main() {
	int k;
	cin >> k;
	for (int i = 0; i < k; i++)cin >> a[i];

	sort(a, a + k);
	reverse(a, a + k);
	int ans = 0;
	while (amax(k) >= k) {
		for (int i = 0; i <k; i++) {
			int m = a[i] / k;
			for (int j = 0; j < k; j++) {
				if (i != j) {
					a[j] += m;
				}
			}
			a[i] %= k;
			ans += m;
		}
	}
	cout << ans << endl;
	}

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

using namespace std;

typedef long long ll;
ll mod = 1000000007;


int main() {
    int n;
    scanf("%d", &n);
    vector<ll> a(n,0),b(n,0);
    ll sum, others;
    sum = others = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld",&a[i]);  
        sum += 2 * a[i];
        if (i % 2 != 0) others += 2 * a[i];
    }
    sum /= 2;
    b[0] = sum - others;
    printf("%lld ",b[0]);
    for (int i = 1; i < n; i++) {
        b[i] = 2 * a[i - 1] - b[i - 1];
        printf("%lld ",b[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2816
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(auto &it:v)cin>>it;
  sort(all(v));
  int ans=INT_MAX;
  //jump at intervals of k
  for(int i=0;i<n-k+1;i++){
	    if(v[i+k-1]-v[i]<ans)ans=v[i+k-1]-v[i];
    }
    cout<<ans<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

#define ll long long

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0 , -1};

const int INF = 100000;
int main() {
  
  int wcount = 0;
  char grid[100][100];
  int H, W;
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == '.') wcount++;
    }
  }
  
  
  int dp[100][100];
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = INF;
    }
  }
  
  dp[1][1] = 0;
  
  
  queue<pair<int,int>> que;
  pair<int, int> p = make_pair(1,1);
  que.push(p);
  
  while(que.size()) {
    pair<int, int> p = que.front(); 
    que.pop();
    
    int h = p.first, w = p.second;
    
    for (int i = 0; i < 4; i++) {
      int nh = h + dh[i], nw = w + dw[i];
      
      if (grid[nh][nw] == '.' && dp[nh][nw] == INF && nh >=1 && nh <= H && nw >= 1 && nw <= W) {
        dp[nh][nw] = dp[h][w] + 1;        
        pair<int, int> np = make_pair(nh,nw);
        que.push(np);
      }
    }
  }
  
  if (dp[H][W] == INF) {
    cout << -1 << endl;
  } else {
    cout << wcount - dp[H][W] - 1 << endl;
  }
  
  
  
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        a = a + (int)Math.pow(a , 2) + (int)Math.pow(a , 3);
        System.out.println(a);
    }
}


Measured memory_bytes: 35620
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll n; cin >> n;
	string ans = "Three";
	for (ll i = 0; i < n; ++i){
		char c; cin >> c;
		if (c == 'Y') ans = "Four";
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<bool> p(1e6+5,true);
void Furui(){
    for(int i=2;i<1111;i++){
        if(!p[i]) continue;
        for(int j=2*i;j<1e6+5;j+=i){
            p[j]=false;
        }
    }
}

long long GCD(long long a,long long b){
  return b?GCD(b,a%b):a;
}
int main(){
  long long a,b;
  cin >> a >> b ;
  long long c=GCD(a,b);
  Furui();
  long long ans=0;
  for(int i=2;i<=sqrt(c);i++){
    if(p[i]&&c%i==0)ans++;
    while(c%i==0)c/=i;
    //printf("%lld %d %d\n",ans,c,i);
  }
  if(c>1)ans++;
  cout << ans+1 << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int w, h, x, y;
	cin>>w>>h>>x>>y;
	ld ans = ld(w)*ld(h)/2;
	cout<<ans<<" ";
	if(2*x == w && 2*y == h)cout<<'1';
	else cout<<'0';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

template< typename T >
T mod_pow(T x, T n) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x);
    (x *= x);
    n >>= 1;
  }
  return ret;
}


ll a, b;
ll calc_num_1(ll n, ll num) {
    ll t2 = mod_pow(2LL, n);
    ll s = (num + 1) / (t2 * 2);
    ll a = (num + 1) % (t2 * 2);
    if (a < t2) return t2 * s;
    else return t2 * s + a - t2;
}

int main(void) {
    cin >> a >> b;

    ll ans = 0;


    ll aa = a, bb = b;
    if (a % 2 == 1) aa--;
    if (b % 2 == 1) bb++;

    if (((bb - aa) / 2) % 2 == 1) ans++;

    

    for (ll i = 1; i <= 41; i++) {
        if ((calc_num_1(i, b) - calc_num_1(i, a - 1)) % 2 == 1) ans += mod_pow(2LL, i);
    }

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

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {

            string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] input_p = Console.ReadLine().Split(' ');
            int[] p = new int[n];
            for(int i = 0;i < n;i++)
                p[i] = int.Parse(input_p[i]);

            int count = 0;
            
            for(int i = 0;i < n;i++)
            {
                if(p[i] != i + 1)
                    count++;
            }

            if( count == 2 || count == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }

Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

// ABC #172 problem D

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

    int n;
    cin >> n;
    vector<int> s(n + 1, 0);

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j += i) {
            s[j]++;
        }
    }

    unsigned long long ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (unsigned long long) i * s[i];
    }

    cout << ans;
}

/*
3 4 100000
60 90 120
80 150 80 150



 10 10 100
 20 20 20 20 20
 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1


 Algorithm:
 - primes
 - factorize current number: takes up to 32 per one number => we get number of multiples, then iterate from


 */

Measured memory_bytes: 42200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		int max, min;
		int score;
		int x;
		
		
		while(true){
			score=0;
			max=0;
			min=1000;
			x=sc.nextInt();
			if(x==0){
				break;
			}else{
				N=x;
			}
			for(int i=0;i<N;i++){
				x=sc.nextInt();
				score+=x;
				if(x>=max){max=x;}
				if(x<=min){min=x;}
			}
			score=(score-min-max)/(N-2);
			System.out.println(score);
			
		}

	}

}

Measured memory_bytes: 20936
N = int(input())
Ai = list(map(int, input().split()))
Aj = list(map(int, input().split()))

Ai_candies = [sum(Ai[:i+1]) for i in range(N)]
Aj_candies = [sum(Aj[j:]) for j in range(N)]

ans = 0
for k in range(N):
    ans = max(Ai_candies[k]+Aj_candies[k], ans)
print(ans)


Measured memory_bytes: 3064
H, W, N = map(int, input().split())


graph = {}
for _ in range(N):
    a, b = list(map(int, input().split()))
    for i in [-1, 0, 1]:
        for j in [-1, 0, 1]:
            na, nb = a-1+i, b-1+j
            if 1 <= na <= H-2 and 1 <= nb <= W-2:
                if not na in graph.keys():
                    graph[na] = {nb: 1}
                elif not nb in graph[na].keys():
                    graph[na][nb] = 1
                else:
                    graph[na][nb] += 1
#print(graph)
ans = [0 for _ in range(10)]
S = 0
for a, v_graph in graph.items():
    for b, v in v_graph.items():
        ans[v] += 1
        S += 1
ans[0] = (H-2)*(W-2) - S
for a in ans:
    print(a)

Measured memory_bytes: 142712
#include <iostream>
#include <cmath>

using namespace std;

int main () {
  int n;
  double xa, ya, ra, xb, yb, rb;
  double d;

  cin >> n;

  while(n--){
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    d = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));

    int out;

    if(ra + rb < d) out = 0;
    else if(ra + d < rb)  out = -2;
    else if(rb + d < ra)  out = 2;
    else  out = 1;

    cout << out << endl;
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

ll sign(ll a){
  if (a >= 0)
    return 0;

  return 1;
}

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  ll num = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    num += sign(a[i]);
  }


  if (num % 2){
    ll ans = 0;
    ll m = INF;
    for (int i = 0; i < n; i++){
      ans += abs(a[i]);
      m = min(m, abs(a[i]));
    }


    cout << ans - 2 * m << endl;
  }
  else {
    ll ans = 0;
    for (int i = 0; i < n; i++){
      ans += abs(a[i]);
    }

    cout << ans << endl;
  }
  

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int main() {
	string s, t;
	cin >> s >> t;
	vector <string> answers;
	int ssize = s.size();
	int tsize = t.size();
	rep(i, ssize-tsize+1) {
		bool possible = true;
		rep(j, tsize) {
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				possible = false;
				break;
			}
		}
		if (possible) {
			string str = "";
			char c;
			rep(j, ssize) {
				if (s[j] == '?') {
					if (i <= j && j < (i + tsize)) {
						c = t[j - i];
						str.pb(c);
					}
					else {
						c = 'a';
						str.pb(c);
					}
				}
				else {
					c = s[j];
					str.pb(c);
				}
			}
			answers.pb(str);
		}
	}
	if (!answers.size())print("UNRESTORABLE");
	else {
		sort(answers.begin(), answers.end());
		print(answers[0]);
	}
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll I_, O_, T_, J_, L_, S_, Z_;
    cin >> I_ >> O_ >> T_ >> J_ >> L_ >> S_ >> Z_;

    ll ans = 0;
    for(ll x=0; x<2; x++) {
        ll I = I_, O = O_, T = T_, J = J_, L = L_, S = S_, Z = Z_;
        if(min({I, J, L}) < x) continue;

        ll K = 0;
        
        // I, J, L 1 個ずつ
        {
            K += 6LL * x;
            I -= x, J -= x, L -= x;
        }
        
        // I を 2 個
        {
            K += 4LL * (I / 2);
            I %= 2;
        }
        
        // O を 1 個
        {
            K += 2LL * O;
            O = 0;
        }

        // J を 2 個
        {
            K += 4LL * (J / 2);
            J %= 2;
        }

        // L を 2 個
        {
            K += 4LL * (L / 2);
            L %= 2;
        }

        // I, J, L 1 個ずつ
        {
            ll mi = min({I, J, L});
            K += 6LL * mi;
            I -= mi, J -= mi, L -= mi;
        }
        chmax(ans, K / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  double ret = 0;
  for (int i = 0; i < n; ++i) {
    double x;
    cin >> x;
    ret += 1 / x;
  }
  cout << 1 / ret << endl;
  return 0;
}


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


int main () {
  int h1,m1,h2,m2,k; 
  cin >> h1>>m1>>h2>>m2>>k;
  
  int m=(h2*60+m2)-(h1*60+m1);
  
  cout << m-k << endl;
}


Measured memory_bytes: 3624
def main():
    n = int(input())
    h = [int(i) for i in input().split()]

    d1 = { }
    d2 = { }
    for j in range(n):
        dif = j - h[j]
        tot = j + h[j]
        if dif not in d1:
            d1[dif] = 0
        if tot not in d2:
            d2[tot] = 0

        d1[dif] += 1
        d2[tot] += 1

    npairs = 0
    # print(d1)
    # print(d2)
    for i in range(n):
        dif = i - h[i]
        tot = i + h[i]
        if tot in d1:
            npairs += d1[tot]
        if dif in d2:
            npairs += d2[dif]

    print(npairs // 2)

main()


Measured memory_bytes: 57428
#include<stdio.h>
#include<stdlib.h>

typedef struct {
  int id;
  char mark;
  int value;
} data;

void BubbleSort(data*, int);
void SelectionSort(data*, int);
//int StableJudge(data*, data*, int*, int);
int StableJudge2(data*, int);

void BubbleSort(data *C, int N) {
  int i,j;
  data temp;

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C[j].value < C[j-1].value){
        temp = C[j];
        C[j] = C[j-1];
        C[j-1] = temp;
      }
    }
  }
}

void SelectionSort(data *C, int N){
  int i, j, minj;
  data temp;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    if(C[i].value != C[minj].value){
      temp = C[i];
      C[i] = C[minj];
      C[minj] = temp;
    }
  }
}

/*int StableJudge(data *C, data *C_sort, int *list, int N){
  int i, j, n;
  int *mark_C, *mark_C_sort;
  int flag = 0; //is it necessary to free()?

  for(i=0;i<9;i++){
    // If there is the same number
    if(list[i] > 1){
      flag = 1;

      mark_C = (int *)malloc(sizeof(int) * list[i]);
      n = 0;
      for(j=0;j<N;j++){
        if(C[j].value == i+1){
          mark_C[n] = j;
          n++;
        }
        if(n == list[i]) break;
      }

      mark_C_sort = (int *)malloc(sizeof(int) * list[i]);
      n = 0;
      for(j=0;j<N;j++){
        if(C_sort[j].value == i+1){
          mark_C_sort[n] = j;
          n++;
        }
        if(n == list[i]) break;
      }

      for(j=0;j<n;j++){
        if(C[mark_C[j]].mark != C_sort[mark_C_sort[j]].mark) {
          printf("Not stable\n");
          return 0;
        }
      }
    }

  }

  if(flag){
    free(mark_C);
    free(mark_C_sort);
  }

  printf("Stable\n");
  return 0;
}
*/
int StableJudge2(data *C, int N){
  int i;
  for(i=1;i<N;i++){
    if(C[i-1].value == C[i].value){
      if(C[i-1].id > C[i].id){
        printf("Not stable\n");
        return 0;
      }
    }
  }
  printf("Stable\n");
  return 0;
}
int main(){
  int N, i;
  char inp[3];
  data *C, *C_bub, *C_sel;
  // to judge same number
  int list[9] = {0,0,0,0,0,0,0,0,0};

  // data set
  scanf("%d",&N);

  C = (data *)malloc(sizeof(data) * N);
  C_bub = (data *)malloc(sizeof(data) * N);
  C_sel = (data *)malloc(sizeof(data) * N);

  for(i=0;i<N;i++){
    scanf("%s",inp);
    C[i].id = C_bub[i].id = C_sel[i].id = i;
    C[i].mark = C_bub[i].mark = C_sel[i].mark = inp[0];
    C[i].value = C_bub[i].value = C_sel[i].value = atoi(&inp[1]);
  }

  // get same number list
  for(i=0;i<N;i++){
    list[C[i].value-1]++;
  }

  // sort
  BubbleSort(C_bub, N);
  SelectionSort(C_sel, N);

  // print
  for(i=0;i<N;i++){
      printf("%c%d",C_bub[i].mark ,C_bub[i].value);
      if(i != N-1) printf(" ");
      else printf("\n");
  }
  //StableJudge(C, C_bub, list, N);
  StableJudge2(C_bub, N);

  for(i=0;i<N;i++){
      printf("%c%d",C_sel[i].mark ,C_sel[i].value);
      if(i != N-1) printf(" ");
      else printf("\n");
  }
  //StableJudge(C, C_sel, list, N);
  StableJudge2(C_sel, N);

  return 0;
}



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

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

  int a, b, p;
  cin>>a;
  cin>>b;

  p = a * b;
  if(p % 2 == 1){
      cout<<"Odd"<<endl;
  }
  else{
    cout<<"Even"<<endl;
  }
}

Measured memory_bytes: 256
def divisors_of(num)
  ans = []
  1.upto(Math.sqrt(num)) do |i|
    next unless num % i == 0

    ans << i
    ans << num / i
  end
  ans
end

n = gets.to_i

ans = 0
1.step(n, 2) do |i|
  ans += 1 if divisors_of(i).length == 8
end

puts ans


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

ll dp[10001][101][2];

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

    string s;
    int D;
    cin >> s >> D;
    int N = s.length();
    dp[0][0][1] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            int num = s[i] - '0';
            dp[i + 1][(j + num) % D][1] += dp[i][j][1];
            dp[i + 1][(j + num) % D][1] %= MOD;
            for (int k = 0; k < num; k++)
            {
                dp[i + 1][(j + k) % D][0] += dp[i][j][1];
                dp[i + 1][(j + k) % D][0] %= MOD;
            }
            for (int k = 0; k <= 9; k++)
            {
                dp[i + 1][(j + k) % D][0] += dp[i][j][0];
                dp[i + 1][(j + k) % D][0] %= MOD;
            }
        }
    }
    ll res = dp[N][0][0] + dp[N][0][1] - 1;
    res = (res + MOD) % MOD;
    cout << res << endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, sum = 0;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int ans = 1e18;
	int cur = 0;
	for(int i = 1; i <= n - 1; i++)
	{
		cur += a[i];
		ans = min(ans, abs(cur - (sum - cur)));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5140
// i wanna find something i wanted all along
// somewhere i belong

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
//#define int ll

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int MAX=2e5+10,sq=10;

int n,m,dp[MAX];
bool mark[MAX];
vector <int> adj[MAX];

void dfs(int v)
{
    mark[v]=1;
    for(int i=0;i<adj[v].size();i++)
    {
        int u = adj[v][i];
        if(!mark[u])
        {
            dfs(u);
        }
    }
    int mx = 0;
    for(int i=0;i<adj[v].size();i++)
    {
        int u = adj[v][i];
        mx=max(mx,dp[u]);
    }
    dp[v]=mx+1;
}
main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    while(m--)
    {
        int x,y;
        cin >> x >> y;
        adj[x].pb(y);
    }
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        if(!mark[i]) dfs(i);
        mx=max(mx,dp[i]);
    }
    cout << mx-1;
    return -0;
}


Measured memory_bytes: 10624
def main():
  n = input()
  t, a = map(int, input().split())
  h = list(map(lambda x: abs(a-(t-x*0.006)), map(int, input().split())))
  print(sorted(range(len(h)), key=lambda k: h[k])[0]+1)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ld A,B,H,M;
    cin >> A >> B >> H >> M;
    ld phi = 2*M_PI*(H*60+M);
    ld thetaA = phi/720;
    ld thetaB = phi/60;
    
    ld x = A*A + B*B - 2*A*B*cos(thetaA-thetaB);
    outset(13);
    cout << sqrt(x) << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 4184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int,string> P;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
string a[16],b[16];
string y, d;

string parse(string s, string A, string B){
  //  cout << s << " " << A << " " << B << endl;
  rep(i, s.size()){
    if(i + A.size() <= s.size() && s.substr(i, A.size()) == A){
      //      cout << i << endl;
      s.replace(s.begin()+i, s.begin()+i+A.size(), B);
      i += B.size()-1;
      //      i++;
    }
  }
  // cout << s << endl;
  return s;
}

int bfs(){
  queue<P>q;
  q.push(P(0, y));
  set<string>s;
  s.insert(y);
  while(!q.empty()){
    P p = q.front(); q.pop();
    string cur = p.second;
    //    cout << cur << endl;
    if(cur == d) return p.first;
    rep(i,N){
      string tar = parse(cur, a[i], b[i]);
      //      cout << tar << endl;
      if(s.find(tar) != s.end() || tar.size() > d.size()) continue;
      q.push(P(p.first+1, tar));
      s.insert(tar);
    }
  }
  return -1;
}

int main(){
  while(cin >> N, N){
    rep(i,N) cin >> a[i] >> b[i];
    cin >> y >> d;

    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1460
n    = gets.to_i
aryA = gets.split.map(&:to_i)
aryB = []

n.times do |i|
  if i % 2 == 0
    aryB.unshift(aryA.shift)
  else
    aryB.push(aryA.shift)
  end
end

if n % 2 == 0
  aryB.reverse!
end

puts aryB.join(" ")


Measured memory_bytes: 25444
#include <cstdio>

int main(){
    for(int i = 1;;i++) {
        int x, y;
        scanf("%d %d",&x ,&y);
        if(x == 0 && y == 0){
            break;
        }
        if(x <= y){
            printf("%d %d\n",x ,y);
        }
        else if(x >= y){
            printf("%d %d\n",y ,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vvi G(n,vi(n,inf));
	rep(i,n)G[i][i]=0;
	vvi in(m,vi(3));
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		G[a-1][b-1]=G[b-1][a-1]=c;
		in[i][0]=a-1;
		in[i][1]=b-1;
		in[i][2]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
	int out=0;
	rep(q,m){
		int a=in[q][0],b=in[q][1];
		bool h=true;
		rep(i,n)rep(j,n)if(i!=j){
			if(G[i][a]+in[q][2]+G[b][j]==G[i][j])h=false;
		}
		out+=h;
	}
	cout<<out<<endl;
}










Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  if(n%1000 == 0){
  int a = n/1000 ;
  int b = 1000*a - n;
  cout << b << endl;}
  else{
    int c =n/1000 + 1;
    int d =1000*c - n;
  cout << d << endl;
  }

}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;

    bool ans = true;

    ans = ans && s[2] == s[3];
    ans = ans && s[4] == s[5];

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

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res){
    int A,B; cin >> A >> B;
    string s; cin >> s;
    if(count(s.begin(),s.end(),'-')!=1)return "No";
    if(s[A] == '-') return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<string>("") << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())

chars = [chr(i) for i in range(ord('a'), ord('z')+1)]

def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        # a, b, c ..., mx
        for i in range(ord('a'), mx+1):
            ns = s + chr(i)
            if i == mx:
                nmx = i + 1
            else:
                nmx = mx

            dfs(ns, nmx)


dfs("", ord('a'))

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

int f(int x, int y){
	cout << x << "x" << y << "=" << x*y << endl;
	return 0;
}

int main(){
	int i;
	int j;
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			f(i, j);
		}
	}
	return 0;
}

Measured memory_bytes: 2972
// 累積和くんｗ
// map でやればおしまい！ｗ
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;

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

	ll sum = 0;
	map<ll, int>mi; mi[sum] = -1;
	map<ll, int>ma; ma[sum] = -1;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		sum += x;
		if (mi.find(sum) == mi.end())mi[sum] = i;
		ma[sum] = i;
	}

	int ret = 0;
	for (auto x : mi) {
		ret = max(ret, ma[x.first] - mi[x.first]);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 28068
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205;
const int mod = 998244353;

int n;
int x[MAXN], y[MAXN];

int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

long long inv(long long x) {
  return binpow(x, mod - 2) % mod;
}

int main() { 

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

  long long ans = binpow(2, n);
  ans = subMod(ans, n + 1);
  // cerr << ans << endl;

  set < pair<int, int> > st;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int mnA = i, mnB = j;
      int cnt = 2;
      for (int k = 0; k < n; k++) {
        if (i == k || j == k) {
          continue;
        }
        if (1ll * (y[j] - y[i]) * (x[k] - x[i]) == 1ll * (x[j] - x[i]) * (y[k] - y[i])) {
          cnt++;
          if (k < mnA) {
            mnB = mnA; mnA = k;
          } else if (k < mnB) {
            mnB = k;
          }
        }
      }
      if (st.count({mnA, mnB}) == 0) {
        st.insert({mnA, mnB});
        // cerr << cnt << endl;
        long long rem = subMod(binpow(2, cnt), cnt);
        rem = subMod(rem, 1);
        ans = subMod(ans, rem);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
n = int(input())
prime5 = []
for i in range(1,5600):
  a = i * 10 + 1
  flag = True
  for j in range(3,int(a**0.5) + 1):
    if a % j == 0:
      flag = False
  if flag: prime5.append(a)
print(*prime5[:n])

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

string S;

int main()
{
    cin>>S;
    if(S=="RRR"){
        cout<<3<<endl;
    }else if(S=="SRR" || S=="RRS"){ 
        cout<<2<<endl;
    }else if(S=="SSS"){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    
    vector<int> dp(3);
    for(int i = 0; i  <n; i++){
        vector<int> c(3);
        vector<int> new_dp(3, 0);
        for(int i = 0; i < 3; i++){
            cin >> c[i];
        }
        
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(i!=j)
                    new_dp[j] = max(new_dp[j], dp[i] + c[i]);
            }
        }
        dp = new_dp;
    }
    cout << max({dp[0], dp[1], dp[2]});
}


Measured memory_bytes: 256