akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
	mod            = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	dp := make([][4]int, n+1)
	dp[0][0] = 1
	for i := 1; i <= n; i++ {
		dp[i][0] = dp[i-1][0] * 8
		dp[i][1] = dp[i-1][0] + dp[i-1][1]*9
		dp[i][2] = dp[i-1][0] + dp[i-1][2]*9
		dp[i][3] = dp[i-1][1] + dp[i-1][2] + dp[i-1][3]*10
		for j := range dp[i] {
			dp[i][j] %= mod
		}
	}

	puts(dp[n][3])
}


Measured memory_bytes: 34100
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
ll a[n],b[n-1];
f(i,0,n-1)
cin>>b[i];
a[0]=b[0];
a[1]=b[0];
f(i,1,n-1)
{
    a[i+1]=b[i];
    a[i]=min(a[i],b[i]);
}
ll su=0;
f(i,0,n)
su+=a[i];
c(su);
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


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

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

using namespace std;

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

  map<char, int> m;
  rep(i,s.size()){
    m[s[i]]++;
  }
  rep(i,26){
    if(!m['a'+i]){
      cout<<(char)('a'+i);
      return 0;
    }
  }
  cout<<"None";

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long D=1e9+7;

long long pow2(long long x,long long y){
    if(y==0)return 1;
    long long ret=pow2(x,y/2);
    return ret*ret%D*(y%2==1 ? x:1)%D;
}

char a[105][105];
int n,m;
int dp[105][105];
int s[105][105];

bool b[102][102][102][102];
bool f(int x,int y,int xx,int yy){
    if(x==0 || y==0 || x>xx || y>yy)return 0;
    return b[x][y][xx][yy];
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int i,j;
    cin>>n>>m;
    for(i=0 ; i<=n ; i++)for(j=0 ; j<=m ; j++)dp[i][j]=1e9;
    for(i=1 ;i<=n ; i++)cin>>a[i]+1;

    dp[1][0]=dp[0][1]=0;

    for(i=1 ; i<=n ; i++)for(j=1 ; j<=m ; j++)s[i][j]=s[i][j-1]+s[i-1][j]+(a[i][j]=='#')-s[i-1][j-1];

    for(i=1 ; i<=n ; i++){
        for(j=1 ; j<=m ; j++){
            if(a[i][j]=='#')b[i][j][i][j]=1;
            for(int ii=i ; ii<=n ; ii++){
                for(int jj=j ; jj<=m ; jj++){
                    if(ii==i &&jj==j)continue;
                    b[i][j][ii][jj]=((b[i][j][ii-1][jj]|b[i][j][ii][jj-1])&(a[ii][jj]=='#'));
                    ///cout<<i<<" "<<j<<" "<<ii<<" "<<jj<<" "<<b[i][j][ii][jj]<<"\n";
                }
            }
        }
    }
    for(i=1 ; i<=n ; i++){
        for(j=1 ; j<=m ; j++){
            dp[i][j]=min({dp[i][j],dp[i-1][j]+(a[i][j]=='#'),dp[i][j-1]+(a[i][j]=='#')});
            for(int ii=0 ; ii<=i ; ii++){
                for(int jj=0 ; jj<=j ; jj++){
                    if(f(ii+1,jj,i,j) || f(ii,jj+1,i,j))
                        dp[i][j]=min(dp[i][j],dp[ii][jj]+1);
                }
            }
        }
    }
    cout<<dp[n][m];
    return 0;
}


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

long long cul(string S, int i){
    long long x = 0, y = 0;
    int keta = 0, kurai = S.size() - 1;
    while(kurai >= 0){
        if(i & 1 == 1){
            //足し算
            x += pow(10, keta) * (S[kurai] - '0');
            y += x;
            x = 0;
            kurai--;
            keta = 0;
            //printf("exadd: x = %lld, y = %lld\n", x, y);
        }else{
            //足し算なし
            x += pow(10, keta) * (S[kurai] - '0');
            keta++;
            kurai--;
            //printf("notadd: x = %lld, y = %lld, ", x, y);
            //printf("keta = %d, kurai = %d\n", keta, kurai);
        }
        i /= 2;
    }
    //printf("add %lld\n\n", x + y);
    return x + y;
}

int main()
{
    string S;
    cin >> S;
    int n = S.size() - 1;
    long long ans = 0;
    REP(i, (1<<n)){
        //printf("i = %d\n", i);
        ans += cul(S, i);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    vector<int> m(n,0);
    rep(i,n-1){
        int a; cin>>a;
        a--;
        m[a]++;
    }
    rep(i,n){
        cout<<m[i]<<endl;
    }
}

Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> bfs(int s, int N, vector<vector<int>> &graph){
  vector<int> dist(N, INF);
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(dist[v] != INF) continue;
      dist[v] = dist[p]+1;
      q.push(v);
    }
  }
  return dist;
}

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

  if(N == 1){
    cout << "First" << "\n";
    return 0;
  }

  vector<vector<int>> graph(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }

  auto to = bfs(0, N, graph);

  int root = -1;
  int MAX = 0;
  REP(i, N){
    if(chmax(MAX, to[i])) root = i;
  }

  auto dist = bfs(root, N, graph);

  REP(i, N){
    chmax(MAX, dist[i]);
  }

  if(MAX%3 == 1) cout << "Second" << "\n";
  else cout << "First" << "\n";

  return 0;
}

Measured memory_bytes: 17520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		if(S.contains("A")&&(S.contains("B"))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    vector<ll> sx(n+1,0), sy(m+1,0);
    for(int i = 0; i < n; i++)  cin >> x[i], sx[i+1] = sx[i]+x[i];
    for(int i = 0; i < m; i++)  cin >> y[i], sy[i+1] = sy[i]+y[i];
    ll xsum = 0, ysum = 0;
    for(int i = 1; i < n; i++){
        xsum += (ll)x[i]*i-sx[i];
        xsum %= mod;
    }
    for(int i = 1; i < m; i++){
        ysum += (ll)y[i]*i-sy[i];
        ysum %= mod;
    }
    cout << (xsum*ysum)%mod << endl;
    return 0;
}

Measured memory_bytes: 2560
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)5e3;

ll fast(ll a, ll p){
    if(p == 0) return (ll)1;
    ll res = fast(a, p>>1);
    res = (res * res) % MOD;
    if(p&1) res = (res * a) % MOD;
    return res;
}

ll dp[2][N+5];

char s[N+5];
int main(){
    // input
    int n; scanf("%d", &n);
    scanf("%s", s); int len = strlen(s);
    //
    REP(j,0,N) dp[0][j] = 0; dp[0][0] = 1;
    //
    REP(i,1,n){
        int idx = i % 2;
        int prev = (i-1) % 2;
        //
        REP(j,0,N){
            ll& res = dp[idx][j];  res = 0;
            if(j >  0) res += 2 * dp[prev][j-1];
            if(j == 0) res += dp[prev][j-0];
            if(j <  N) res += dp[prev][j+1];
            res %= MOD;
        }
    }
    //
    ll res = (dp[n%2][len] * fast(2, (MOD-2) * (ll)len)) % MOD;
    printf("%lld\n", res);
    return 0;
}


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

int main() 
{
   string s;
   cin>>s;
   int size=s.size();
   if(s[size-1]=='s')
   cout<<s+"es"<<"\n";
   else
   cout<<s+"s"<<"\n";
   
   
   
   
   return 0;
}

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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;

    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

for a in A:
    if a % 2 == 0:
        if (a % 3 == 0) or (a % 5 == 0):
            continue
        else:
            print ('DENIED')
            exit()
    else:
        continue

print ('APPROVED')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int H, W, N;

char nums[1000][1000];

int px, py;

int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int cnt = 0;

void bfs(int a, int b, int index) {
	vector<vector<int> > points{{a, b}};
	int level = 0;
	unordered_set<int> s;
	s.insert(1000 * a + b);
	while (true) {
		level++;
		vector<vector<int> > temp = points;
		points.clear();
		for (vector<int> p: temp) {
			for (int i = 0; i < 4; i++) {
				int tx = dx[i] + p[0];
				int ty = dy[i] + p[1];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W) {
					if (nums[tx][ty] == '0' + index) {
						px = tx;
						py = ty;
						cnt += level;
						//cout << index << endl;
						return;
					}
					if (nums[tx][ty] != 'X' && !s.count(1000 * tx + ty)) {
						s.insert(1000 * tx + ty);
						points.push_back({tx, ty});
					}
				}
			}
		}
	}
}

int main() {
	cin >> H;
	cin >> W;
	cin >> N;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> nums[i][j];
			if (nums[i][j] == 'S') {
				px = i;
				py = j;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		bfs(px, py, i + 1);
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 21516
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
    "sort"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
    N := getStdinInt()
    A := getStdinIntArr()
    sort.Ints(A)

    list := make([]int, A[N-1]+1)
    list, _ = fill(list, 1, 0, A[N-1]+1)

    count := make([]int, A[N-1]+1)
    count, _ = fill(count, 0, 0, A[N-1]+1)
    for i := 0; i < N; i++ {
        count[A[i]]++
    }

    ans := 0

    for i := 0; i < N; i++ {
        if list[A[i]] == 1 {
            if count[A[i]] == 1 {
                ans++
            }
            for j := 2; A[i] * j <= A[N-1]; j++ {
                list[A[i] * j] = 0
            }
        }
    }

    fmt.Println(ans)
}

func contains(s []int, e int) bool {
    for _, v := range s {
        if e == v {
            return true
        }
    }
    return false
}

// slice[start:end+1] = val
func fill(slice []int, val, start, end int) ([]int, error) {
    if len(slice) < start || len(slice) < end {
        return nil, fmt.Errorf("Error")
    }
    for i := start; i < end; i++ {
        slice[i] = val
    }
    return slice, nil
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinIntArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinArr() []string {
    str := getStdin()
    list := strings.Split(str, " ")
    return list
}
func getStdinIntArr64() []int64 {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int64, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.ParseInt(v, 10, 64)
    }
    return res
}
func readLine() string {
    buf := make([]byte, 0, 0)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s, t;
  cin >> s >> t;

  if (t.substr(0,sz(s)) == s) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 10000000

int main() {
    int taro_n, hana_n;
    while (cin >> taro_n >> hana_n, taro_n|hana_n) {
        vi taro_cards(taro_n);
        vi hana_cards(hana_n);
        REP(i, taro_n) cin >> taro_cards[i];
        REP(i, hana_n) cin >> hana_cards[i];

        int min_sum = INF;
        int min_taro_card = INF, min_hana_card = INF;

        int tmp;
        REP(i, taro_n) {
            REP(j, hana_n) {
                tmp = taro_cards[i];
                taro_cards[i] = hana_cards[j];
                hana_cards[j] = tmp;

                int taro_sum = 0, hana_sum = 0;
                REP(k, taro_n) taro_sum += taro_cards[k];
                REP(k, hana_n) hana_sum += hana_cards[k];

                if (taro_sum == hana_sum) {
                    if (min_sum > taro_sum + hana_sum) {
                        min_sum = taro_sum + hana_sum;
                        // swap
                        min_taro_card = hana_cards[j];
                        min_hana_card = taro_cards[i];
                    }
                }

                tmp = taro_cards[i];
                taro_cards[i] = hana_cards[j];
                hana_cards[j] = tmp;
            }
        }

        if (min_sum != INF) {
            cout << min_taro_card << " " << min_hana_card << endl;
        } else {
            cout << "-1" << endl;
        }
    }
}

Measured memory_bytes: 1196
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, AS):
    sum = 0
    sumSq = 0
    for i in range(N):
        sum += AS[i]
        sum %= MOD
        sumSq += AS[i] * AS[i]
        sumSq %= MOD

    ret = (sum * sum - sumSq) % MOD
    if ret % 2 == 0:
        return ret // 2
    else:
        return (ret + MOD) // 2


def main():
    # parse input
    N = int(input())
    AS = list(map(int, input().split()))
    print(solve(N, AS))


# tests
T1 = """
3
1 2 3
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
11
"""

T2 = """
4
141421356 17320508 22360679 244949
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
437235829
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 100720
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e9;
  
int main() 
{
    data();                              
    string s;
   	string t;
   	cin >> s >> t;
   	int ans = 1e9;
   	for (int i = 0; i <= s.size() - t.size(); i++)
   	{
   		int mn = 0;
   		for (int j = 0; j < t.size(); j++)
   		{
   			if (s[i + j] != t[j])
   			{
   				mn++;
   			}
   		}
   	//	cout << i << " " << mn << '\n';
   		ans = min(ans, mn);
   	}
   	cout << ans;
}
//21

Measured memory_bytes: 3612
import sys

N, Q = map(int,input().split())
S = input()

cnt = [0]*(N+1)
wasA = False

for i in range(0,N):
  if wasA and S[i] == "C":
    cnt[i+1] = cnt[i] + 1
    wasA = False
  elif S[i] == "A":
    cnt[i+1] = cnt[i]
    wasA = True
  else:
    cnt[i+1] = cnt[i]
    wasA = False

#print(cnt)    

for i in range(0,Q):
  l, r = map(int,input().split())
  print(cnt[r]-cnt[l])

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

#define int long long
 

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
  
    bool same(int a, int b){
      if(find(a)==find(b)) return true;
      else return false;
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

void solve(){
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    
    while(Q--){
        int k, x, y;
        cin >> k >> x >> y;
        if(k==0) uf.unite(x,y);
        else{
            if(uf.same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



Measured memory_bytes: 3188
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  const int MAX_P = 200000;
  static bool p[MAX_P];

  for (int i = 0; i < MAX_P; ++i)
    p[i] = true;
  p[0] = p[1] = false;
  for (int i = 2; i*i < MAX_P+1; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_P; j += i)
	p[j] = false;
    }
  }

  vector<int> prime;
  for (int i = 0; i < MAX_P; ++i) {
    if (p[i])
      prime.push_back(i);
  }

  int N, P;
  while (scanf("%d %d", &N, &P) != EOF) {
    if (N == -1 && P == -1)
      break;

    vector<int> ans;
    int p1 = 0, p2 = 0;
    for (vector<int>::iterator it = upper_bound(prime.begin(), prime.end(), N); it != prime.end() && p1 < P; ++it, ++p1) {
      p2 = 0;
      for (vector<int>::iterator jt = lower_bound(prime.begin(), prime.end(), *it); jt != prime.end() && p2 < P; ++jt, ++p2)
	ans.push_back((*it)+(*jt));
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans[P-1]);
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+1>=c){
        cout<<b+c<<endl;
    }
    else{
        cout<<a+b+b+1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int x[22][22];

signed main() {

    int n, d;

    cin >> n >> d;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int sum = 0;

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            double t = 0;
            for(int k = 0; k < d; k++) {
                t += pow(x[i][k] - x[j][k], 2.0);
            }
            t = sqrt(t);
            if((int)t == t) sum++;
        }
    }

    cout << sum << endl;
    


  
    return 0;
}



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

int main(int argc, const char * argv[]) {
    // insert code here...
    /*string s = "bdiafgeh";
    sort(s.begin(), s.end());
    cout << s << endl;*/
    
    /*string t = "abcde";
    string r = "zyxwv";
    bool b = (t < r);
    cout << b << endl;*/
    
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#if _WIN32
#include <locale>
#endif

using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;

struct Monster {
  i32 hp;
  i32 atk;
  bool is_alive() const {
    return this->hp > 0;
  }
  bool is_dead() const {
    return this->hp <= 0;
  }
  void attack(Monster &enemy) const {
    enemy.hp -= this-> atk;
  }
};

int main() {
  using namespace std;
  #if _WIN32
  locale::global(locale(""));
  #endif
  Monster takahashi, aoki;
  cin >> takahashi.hp >> takahashi.atk >> aoki.hp >> aoki.atk;
  while(true) {
    takahashi.attack(aoki);
    if(aoki.is_dead()) break;
    aoki.attack(takahashi);
    if(takahashi.is_dead()) break;
  }
  cout << (takahashi.is_alive() ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main() {
	char n[4];
	scanf("%s", &n);
	REP(i, 3) {
		if (n[i] == '1') {
			n[i] = '9';
		}
		else {
			n[i] = '1';
		}
	}
	puts(n);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    int N; cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    ll ans = 0;

    REP(i, N){
        if(i%2==0 && a[i]%2!=0)ans++;
    }
    cout << ans << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> a(n+1);
    vector<int> b(m+1);

    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= m; ++i) cin >> b[i];

    vector<LL> dpa(n + 1, 0);
    vector<LL> dpb(m + 1, 0);

    for(int i = 1; i <= n; ++i){
        dpa[i] = dpa[i - 1] + a[i];
    }

    for(int i = 1; i <= m; ++i){
        dpb[i] = dpb[i - 1] + b[i];
    }

    int ans = 0, bi = m;
    for(int ai = 0; ai <= n; ++ai){
        if(dpa[ai] > k){
            break;
        }

        while(bi >= 0 && dpa[ai] + dpb[bi] > k){
            bi--;
        }
        if(bi < 0){
            break;
        }

        ans = max(ans , ai + bi);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long,long>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a,b) get<a>(b)
#define INF (ll)1e18+5
#define ull unsigned long long
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
const int N = 2e6+5;
/*ll parent[N];
ll siz[N];
vector<pair<ll, pair<ll, ll> > > v;
void make(){
    REP(i, 0, N){
        parent[i]=i;
        siz[i] = 1;
    }
}
ll find(ll x){
    while(parent[x] != x){
        x = parent[x];
    }
    return x;
}
void unite(ll a, ll b){
    a = find(a);
    b = find(b);
    if(a != b){
        if(siz[a] < siz[b]){
            swap(a, b);}
        parent[b] = a;
        if(siz[a] == siz[b]){
            siz[a]++;
        }
    }
}*/
const double pi = acos(-1) ;
ll n, k;
ll a[N], f[N];
ll bins(ll fi){
    ll ret=0;
    REP(i, 0, n){
        ll z = fi/f[i];
        if(z <= a[i]){
            ret += a[i]-z;
        } 
    }
    return ret;
} 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>k;
    REP(i, 0, n){cin>>a[i];}
    REP(i, 0, n){cin>>f[i];}
    sort(a, a+n);
    sort(f, f+n);
    reverse(f, f+n);

    ll left = 0, right = (ll)1e16;
    ll ans=0;
    while(left <= right){
        ll mid = left+(right-left)/2;
        if(bins(mid) <= k){
            ans = mid;
            right = mid-1;
        }else{
            left = mid+1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  int x;
  cin>>x;
  int ans = -1;
  for(int b = 1;b <= 1000;b++) {
    for(int p = 2;p <= 10;p++) {
      int t = pow(b,p);
      if(t <= x) ans = max(ans, t);
    }
  }
  cout<<ans;
}

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

public class ABC
{

    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        //全部#にしてしまう
        int allsharp = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == '.') allsharp++;
        }

        int sum = allsharp;
        int white = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == '.') allsharp--;
            else white++;
            if (sum > allsharp + white) sum = allsharp + white;

        }
        Console.WriteLine(sum);
        
    }
}

Measured memory_bytes: 11616
n=int(input())
w_list=list(map(int,input().split()))
sum_list=[]
ans=0
for i in range(n):
    ans=abs(sum(w_list[:i-1])-sum(w_list[i-1:]))
    sum_list.append(ans)
    
ans =min([i for i in sum_list if i >= 0]) 

print(ans)

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

int main() {
    int n;
    cin >> n;
    long ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        if (ans >= pow(10,9)+7) {
            int x = ans/(pow(10,9)+7);
            ans -= x*(pow(10,9)+7);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    // input
    int N; cin >> N;
    
    // compute
    bool can = false;
    for (int i = 0; i <= 25; i++){
        for (int j=0; j <= 15; j++){
            if (N == 4 * i + 7 * j){
                can = true;
            }
        }
    }

    // output
    cout << (can ? "Yes":"No") << endl;
}



Measured memory_bytes: 256
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using int_t = int;

int main() {
    string toppings;
    cin >> toppings;
    int pay = 700;
    for (int i = 0; i < 3; i++) {
        if (toppings[i] == 'o') {
            pay += 100;
        }
    }
    printf("%d", pay);
    printf("\n");
    return 0;
}



Measured memory_bytes: 256
#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>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, m, k;
double ans;

void dfs(int sum, double p, int cnt) {
    if(cnt == n) {
        ans += p * max((ll)1, sum-k);
    }
    else {
        repq(i,1,m) {
            dfs(sum+i, p * 1.0/m, cnt+1);
        }
    }
}

signed main() {
    while(cin >> n >> m >> k, n || m || k) {
        ans = 0.0;
        dfs(0, 1.0, 0);
        printf("%.12f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3192
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        M:usize,
        ABC:[(Usize1,Usize1,isize);M]
    }

    let INF = 1000000;

    let mut G = GraphWarshallFloyd::new(N,INF);

    for &(a,b,c) in &ABC{
        G.set(a,b,c);
        G.set(b,a,c);
    }
    G.run();

    let ans = ABC.iter().filter(|&&(a,b,c)| G.get(a,b) != c).count();
    println!("{}",ans);
}

struct GraphWarshallFloyd{
    N:usize,
    Dist:Vec<Vec<isize>>,
    INF:isize
}

impl GraphWarshallFloyd {
    fn new(N:usize,INF:isize) -> GraphWarshallFloyd{
        let mut ret = GraphWarshallFloyd{N:N,Dist:Vec::new(),INF:INF};
        ret.Dist = vec![vec![INF;N];N];
        for i in 0..N{
            ret.Dist[i][i] = 0;
        }
        ret
    }
    fn set(&mut self,from:usize,to:usize,dist:isize){
        self.Dist[from][to] = dist;
    }
    fn get(&self,from:usize,to:usize)->isize{
        self.Dist[from][to]
    }
    fn run(&mut self){
        let N = self.N;
        for k in 0..N{
            for i in 0..N{
                for j in 0..N{
                    self.Dist[i][j] = min(self.Dist[i][j],self.Dist[i][k]+self.Dist[k][j]);
                }
            }
        }
    }
}

Measured memory_bytes: 2200
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int sum=0;
	sort(arr,arr+n);
	for(int i=0;i<k;i++)
	sum+=arr[i];
	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n;
    cin>>n;

    vector< pair<int,int> > p;

    rep(i,0,n)
    {
        int x;
        cin>>x;
        p.pb(mp(x,i+1));
    }

    sort(all(p));

    rep(i,0,p.size())
    {
        cout<<p[i].sd<<" ";
    }

    cout<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
int main() {

    int N;
    cin >> N;
    int A[N+1],B[N+1];
    int C[N];
    for(int i=1;i<=N;i++)cin >> A[i];
    for(int i=1;i<=N;i++)cin >> B[i];
    for(int i=1;i<N;i++)cin >> C[i];
    int Ans =B[A[1]];
    for(int i=2;i<=N;i++){
        Ans+=B[A[i]];
        if(A[i-1]+1==A[i])Ans+=C[A[i-1]];
    }
    cout << Ans << endl;
}


Measured memory_bytes: 3528
import java.io.*;
import java.lang.*;
import java.util.*;

class Main {
	static int[] parent;
	static int[] rank;

	static void makeSet(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	static void union(int x, int y) {
		link(findSet(x), findSet(y));
	}

	static void link(int x, int y) {
		if(rank[x] > rank[y]) {
			parent[y] = x;
		} else {
			parent[x] = y;

			if(rank[x] == rank[y]) {
				rank[y] += 1;
			}
		}
	}

	static int findSet(int x) {
		if (x != parent[x]) {
			parent[x] = findSet(parent[x]);
		}

		return parent[x];
	}

	static boolean same(int x, int y) {
		return findSet(x) == findSet(y);
	}

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

		List<Integer> results = new ArrayList<>();

		int num_items = scanner.nextInt();
		int num_queries = scanner.nextInt();

		parent = new int[num_items];
		rank = new int[num_items];

		for (int i = 0; i < num_items; i++) {
			makeSet(i);
		}

		for (int i = 0; i < num_queries; i++) {
			int type = scanner.nextInt();
			int x = scanner.nextInt();
			int y = scanner.nextInt();

			if (type == 0) {
				union(x, y);
			} else {
				results.add(same(x,y) ? 1 : 0);
			}
		}

		for (Integer r : results) {
			System.out.println(r);
		}
	}
}


Measured memory_bytes: 100572
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

vector<int> tree[100000];
bool visited[100000];
int N;

vector<int> dfs(int root){
    vector<int> ans;
    if(visited[root])return ans;
    visited[root]=true;
    if(root==N-1){
        ans.push_back(N-1);
        return ans;
    }

    REP(i,tree[root].size()){
        if(visited[tree[root][i]])continue;
        ans=dfs(tree[root][i]);
        if(ans.size()>0){
            ans.push_back(root);
            return ans;
        }
    }
    return ans;
}

int main(){

    cin>>N;
    fill_n(visited,N,false);

    REP(i,N-1){
        int a,b;
        cin>>a>>b;
        tree[--a].push_back(--b);
        tree[b].push_back(a);
    }

    vector<int> path=dfs(0);
    int num = (path.size()-1)/2 +1;
    fill_n(visited,N,false);
    visited[path[path.size()-1-num]]=true;

    path =dfs(0);

    int cnt=-1;
    REP(i,N){
        if(visited[i])cnt++;
    }

    if(cnt*2 >N){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }

    return 0;
}

Measured memory_bytes: 14204
import math
N, K = map(int,input().split())

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


for i in range(K):
    if N-K < i:
        print(0)
    else:
        print(comb(N-K+1, i+1)*comb(K-1, i) % 1000000007)

Measured memory_bytes: 3316
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    
    string s;
    cin>>s;
    printf("%c%lu%c\n",s[0],s.size()-2,s[s.size()-1]);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;


int main(){
  int n;
  cin >> n;
  string com;
  long long num;
  list<long long>lst;
  for(int i=0; i < n; i++){
    cin >> com;
    if(com == "insert"){
      cin >> num;
      lst.push_front(num);
    }else if(com == "delete"){
      cin >> num;
      for(list<long long> :: iterator itr = lst.begin(); itr != lst.end(); itr++){
        if(*itr == num){
          lst.erase(itr);
          break;
        }
      }
    }else if(com == "deleteFirst"){
      lst.pop_front();
    }else{
      lst.pop_back();
    }
  }
  for(list<long long>::iterator itr = lst.begin(); itr != lst.end(); itr++){
    if(itr != lst.begin()){
      cout << ' ';
    }
    cout << *itr;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 34392