akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


void solve(){
    int n; cin >> n;
    int l = n/100;
    int r = n%100;

    if(l > 0 && l <= 12){
        if(r > 0 && r <= 12){
            cout << "AMBIGUOUS\n";
        }else{
            cout << "MMYY\n";
        }
    }else{
        if(r > 0 && r <= 12){
            cout << "YYMM\n";
        }else{
            cout << "NA\n";
        }
    }
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
int h,w,As,Ds,Cho[510][510],A[510][510];
struct gao{   int a,b,c,d;   }Ans[510*510];
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
    while(b!='-'&&(b<'0'||b>'9'))b=getchar();
    if(b=='-')c=-1,b=getchar();
    while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
    return a*c;
}
inline void out()
{   printf("%d\n",As);
    for(rg int i=1;i<=As;i++) printf("%d %d %d %d\n",Ans[i].a,Ans[i].b,Ans[i].c,Ans[i].d);   
}
int main()
{   h=Read(),w=Read();
    for(rg int i=1;i<=h;i++)
	for(rg int j=1;j<=w;j++)
	{   A[i][j]=Read();   if(A[i][j]%2) Ds++;   }
    for(rg int i=1,li=0,lj=0;i<=h;i++)
    {   for(rg int j=1;j<=w;j++)
	{   if(A[i][j]%2&&!li) li=i,lj=j,A[i][j]=0;
	    //if(Ds<=1) {   out(); return 0;}
	    if(li&&(li!=i||lj!=j)&&A[i][j]%2) Ans[++As]=(gao){li,lj,i,j},li=lj=0,Ds-=2;
	    if(li&&(li!=i||lj!=j)) Ans[++As]=(gao){li,lj,i,j},li=i,lj=j;
	}
	i++;   if(i>h) {out();return 0;}
	for(rg int j=w;j>=1;j--)
	{   if(A[i][j]%2&&!li) li=i,lj=j,A[i][j]=0;
	    
	    //if(Ds<=1) {out();  return 0;}
	    if(li&&(li!=i||lj!=j)&&A[i][j]%2) Ans[++As]=(gao){li,lj,i,j},li=lj=0,Ds-=2;
	    if(li&&(li!=i||lj!=j)) Ans[++As]=(gao){li,lj,i,j},li=i,lj=j;
	}
    }
    out();
}


Measured memory_bytes: 7040
X = raw_input()
S1 = []
S2 = []
total = 0
for i, x in enumerate(X):
    if x == '\\':
        S1.append(i)
    elif x == '/' and len(S1) > 0:
        left = S1.pop()
        s = i - left
        total += s
        while len(S2) > 0:
            prev = S2.pop()
            if prev[0] < left:
                S2.append(prev)
                break
            else:
                s += prev[1]
        S2.append((left, s))
print total
result = [len(S2)]
for i in S2:
    result.append(i[1])
print ' '.join(map(str, result))

Measured memory_bytes: 5004
input()
X_vec = map(float, input().split())
Y_vec = map(float, input().split())
pair = list(zip(X_vec, Y_vec))
D1 = sum(abs(x-y) for x,y in pair)
D2 = (sum((x-y)**2 for x,y in pair)) ** .5
D3 = (sum(abs(x-y)**3 for x,y in pair)) ** (1/3)
Dinf = max(abs(x-y) for x,y in pair)
print("{0:.6f}\n{1:.6f}\n{2:.6f}\n{3:.6f}\n".format(D1,D2,D3,Dinf))

Measured memory_bytes: 7640
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if 2*max(L[i],L[j],L[k]) < L[i]+L[j]+L[k]:
                    ans += 1
                
print(ans)

Measured memory_bytes: 9140
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i;
    string s;
    cin>>n>>k;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(i==(k-1))
            cout<<char(tolower(s[i]));
        else
            cout<<s[i];
    }
    return 0;
}


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

int main()
{
    int input;
    int syou = 0;
    int result = 0;
    int hash = 0;

    scanf("%d", &input);

    syou = input / 2;
    if(syou > 1) {
        hash = input % 2;
        if(hash == 0) {
            result = input / 2 - 1;
        } else {
            result = input / 2;
        }
    }
    printf("%d\n", result);
    return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define fr(i,n) for(i=0;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(x,a) memset(x,a,sizeof(x))
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ods;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth element.(0-based)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());      // Use mt19937_64 for 64 bit random nos.
ll myrand(ll n){ return rng()%n;}

ll mod = 1e9+7;
void add(ll &a,ll b,ll md=mod){ a+=b; if( a>=md)a-=md;if(a<0)a+=md;}
ll mul(ll a,ll b){ return (a*b)%mod;}
ll mulmod(ll a,ll b,ll M){ a%=M;b%=M;if(M<=mod)return mul(a,b);ll res=0;while(a>0){
    if (a&1ll){res+=b;if(res>=M)res-=M;}a>>=1;b<<=1;if(b>=M)b-=M;}return res;
}ll ffmod(ll b,ll exp,ll md=mod){ll res =1;while(exp){
    if(exp&1ll)res=(res*b)%md;b =(b*b)%md;exp/=2ll;}return res;
}ll powmod(ll b,ll exp,ll md=mod){ll res =1;while(exp){
        if(exp&1ll)res=mulmod(res,b,md);b =mulmod(b,b,md);exp/=2ll;}return res;
}void mxupd(pii &a,pii b){if(a.f > b.f)a.s=max(a.s,b.f);else{a.s=max(a.f,b.s);a.f=b.f;}
}


const int N = 200010;
const int M = 200010;
const int LN = 20;


string s,t;
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,k,x,q;
	cin >> s;
	cin >> t;
	int fl = 0;
	for(int i=0;i<26;i++){
		string m = s;
		m += (i+'a');
		if( m== t){
			fl=1;
			break;
		}
	}
	if(fl)cout<<"Yes\n";
	else cout<<"No\n";


    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

int main(void)
{
	int numOfWords[1000] = {0};
	int lenOfWords[1000] = {0};
	int mostWord = 0;
	int mostWordIndex;
	int longWord = 0;
	int longWordIndex;
	char words[1000][1001];
	char word[1001];
	int i;
	int tailIndex = 0;
	
	while( scanf("%s", word) != EOF )
	{
		for( i = 0; i < tailIndex; i++ )
		{
			if( strcmp( words[i], word ) == 0 )
			{
				numOfWords[i]++;
				lenOfWords[i] = strlen( word );
			}
		}
		if( i == tailIndex )
		{
			strcpy( words[tailIndex], word );
			numOfWords[tailIndex]++;
			lenOfWords[tailIndex] = strlen( word );
			tailIndex++;
		}
	}
	
	for( i = 0; i < 1000; i++ )
	{
		if( numOfWords[i] > mostWord )
		{
			mostWord = numOfWords[i];
			mostWordIndex = i;
		}
		if( lenOfWords[i] > longWord )
		{
			longWord = lenOfWords[i];
			longWordIndex = i;
		}
	}
	printf( "%s %s\n", words[mostWordIndex], words[longWordIndex] );
	
	return (0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, m, x, ans;
	scanf( "%d%d%d", &n, &m, &x );
	if( n < m )
		n = m;
	ans = x / n;
	if( x % n )
		++ans;
	printf( "%d", ans );
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nDays := scanInt(sc)
	hps := make([][]int, nDays)
	for i := 0; i < nDays; i++ {
		hps[i] = []int{
			scanInt(sc),
			scanInt(sc),
			scanInt(sc),
		}
	}

	sums := make([][]int, nDays)
	sums[0] = hps[0]

	for i := 1; i < nDays; i++ {
		prev := sums[i-1]
		sums[i] = []int{
			hps[i][0] + max(prev[1], prev[2]),
			hps[i][1] + max(prev[0], prev[2]),
			hps[i][2] + max(prev[0], prev[1]),
		}
	}

	last := sums[nDays-1]
	maxH := max(last[0], max(last[1], last[2]))
	fmt.Println(maxH)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 12032
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int M,N;
int p[MAXN],d[MAXN];

pair<int,int> Find(int x){
    if(x==p[x]) return make_pair(p[x],d[x]);
    pair<int,int> tmp=Find(p[x]);
    p[x]=tmp.first;
    d[x]+=tmp.second;
    return make_pair(p[x],d[x]);
}

int same(int u,int v){
    return Find(u)==Find(v);
}

void unite(int u,int v,int w){
    pair<int,int> x=Find(u);
    pair<int,int> y=Find(v);
    if(x.first!=y.first){
        d[x.first]=w+y.second-x.second;
        p[x.first]=y.first;
    }
}

void work(){
    while(~scanf("%d%d",&N,&M)){
        if(N==0&&M==0) break;
        for(int i=1;i<=N;i++) p[i]=i,d[i]=0;
        while(M--){
            char s[10];
            int x,y,z;
            scanf("%s%d%d",s,&x,&y);
            if(s[0]=='!'){
                scanf("%d",&z);
                unite(x,y,z);
            }
            else{
                pair<int,int> t1=Find(x);
                pair<int,int> t2=Find(y);
                if(t1.first!=t2.first) printf("UNKNOWN\n");
                else printf("%d\n",t1.second-t2.second);
            }
        }
    }
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 4948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, k;

int main(){
	cin >> n >> k;
	ll num = k;
	REP(i, n - 1){
		num *= (k - 1);
	}
	cout << num << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  a-=b;
  cout<<max<ll>(0,c-a)<<endl;

  
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

def main():

    input = stdin.readline

    A,B,H,M = map(int,input().split())
    
    n_12 = H % 12

    m_rad = M * 360 / 60

    n_rad = (n_12 * 360 / 12) + (M * 30 / 60)

    radi = abs(m_rad - n_rad) if abs(m_rad - n_rad) < 180 else abs(360 - abs(m_rad - n_rad))

    ans = math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(radi))))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <numeric>
using namespace std;

typedef long long ll;
struct edge{
    int to, cost;
};
vector<edge> G[100005];
bool used[100005];
int ans[100005];

// c = 0 or 1
void dfs(int v, int c, ll sum){
    for(int i = 0; i < G[v].size(); ++i){
        edge e = G[v][i];
        if(used[e.to])      continue;
        
        used[e.to] = true;
        if((sum + e.cost) % 2 == 0){
            ans[e.to] = c;
        }
        dfs(e.to, c, sum + e.cost);
    }
    
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        G[u].push_back((edge){v, w});
        G[v].push_back((edge){u, w});
    }
    
    ans[0] = 1;
    used[0] = true;
    dfs(0, 1, 0);
    
    for(int i = 0; i < n; ++i){
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n;
  cin>>n;
  long long a[n+1],b[n];
  REP(i,n+1){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  
  long long m;
  long long ans=0;
  for(int i=n;i>=1;i--){
    m = min(b[i-1],a[i]);
    a[i] -= m;
    b[i-1] -= m;
    ans += m;
    m = min(b[i-1],a[i-1]);
    a[i-1] -= m;
    b[i-1] -= m;
    ans += m;
  }
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 1792
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x, y = find(x), find(y)
    if x == y: return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

N, Q = map(int, input().split())
par = [-1]*N
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        unite(u, v)
    else:
        if find(u)==find(v):
            print(1)
        else:
            print(0)

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int scores[2] = {};
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            if (a > b) {
                scores[0] += a + b;
            } else if (a < b) {
                scores[1] += a + b;
            } else {
                scores[0] += a;
                scores[1] += b;
            }
        }
        cout << scores[0] << " " << scores[1] << endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    ll b,c,n,x,y,m=-1,k,w,sum=1,ans=0,Max=-1e9,Min=1e9+1;
    string s,t,u;
    bool count=false,ok=true;
    cin >> n;
    map<int,int> a;
    rep(i,n){
        cin >> x;
        a.insert(make_pair(i+1,x));
        if(a.find(x) != a.end()){
            if(a.find(x)->second==i+1){
                ans++;
            }
        }

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

Measured memory_bytes: 4992
#include<stdio.h>
int main(){
	int i,n,x,y,h,w,l,L,W;
	long long sum=0;
	for(;scanf("%d",&n)&&n;sum=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&x,&y,&h,&w);
			l=x+y+h;
			if(l<=60)L=0;else if(l<=80)L=1;else if(l<=100)L=2;else if(l<=120)L=3;else if(l<=140)L=4;else if(l<=160)L=5;else L=6;
			if(w<=2)W=0;else if(w<=5)W=1;else if(w<=10)W=2;else if(w<=15)W=3;else if(w<=20)W=4;else if(w<=25)W=5;else W=6;
			if(L<W)L=W;
			if(L==0)sum+=(long long)600;else if(L==1)sum+=(long long)800;else if(L==2)sum+=(long long)1000;else if(L==3)sum+=(long long)1200;else if(L==4)sum+=(long long)1400;else if(L==5)sum+=(long long)1600;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {

	public static int gcd(int a,int b) {
		
		if(a<b) return gcd(b,a);
		if(b==0) return a;
		
		return gcd(b,a%b);
	}
	
	public static int gcd2(int a,int c) {
		if(a<c) return gcd2(c,a);
		if(c==0) return a;
		
		return gcd2(c,a%c);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin = new Scanner(System.in);
		int K = cin.nextInt();
		
		int sum = 0;
		int a = 0;;
		for(int i = 0;i<K;i++)
			for(int j = 0;j<K;j++) {
				a = gcd(i+1,j+1);
				for(int n= 0;n<K;n++) {
					sum+=gcd(a,n+1);
				}
			}
		System.out.println(sum);

	}

}

Measured memory_bytes: 35864
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n;
L bu1[100010],bu2[100010];
L root1,root2;
vector<L>v1[100010],v2[100010];
L chk1[100010],chk2[100010];

void E(){
	puts("IMPOSSIBLE");
	exit(0);
}

vector<L>v[100010];
L ans[100010];

L dfs1(L now){
	if(now==-1) return 0;
	L i;
	vector<L>get;
	for(i=0;i<v1[now].size();i++)
	{
		if(!chk1[v1[now][i]])
		{
			chk1[v1[now][i]]=1;
			L temp=dfs1(v1[now][i]);
			if(temp>0) get.push_back(temp);
		}
	}
	if(v1[now].size()%2) get.push_back(now);
	/*printf("now %lld\n",now);
	for(i=0;i<get.size();i++)
	{
		printf("%lld ",get[i]);
	}
	puts("");*/
	for(i=0;i+1<get.size();i+=2)
	{
		v[get[i]].push_back(get[i+1]);
		v[get[i+1]].push_back(get[i]);
	}
	if(get.size()%2)
	{
		return get[get.size()-1];
	}
	else return 0;
}

L dfs2(L now){
	if(now==-1) return 0;
	L i;
	vector<L>get;
	for(i=0;i<v2[now].size();i++)
	{
		if(!chk2[v2[now][i]])
		{
			chk2[v2[now][i]]=1;
			L temp=dfs2(v2[now][i]);
			if(temp>0) get.push_back(temp);
		}
	}
	if(v2[now].size()%2) get.push_back(now);
	/*printf("now %lld\n",now);
	for(i=0;i<get.size();i++)
	{
		printf("%lld ",get[i]);
	}
	puts("");*/
	for(i=0;i+1<get.size();i+=2)
	{
		v[get[i]].push_back(get[i+1]);
		v[get[i+1]].push_back(get[i]);
	}
	if(get.size()%2)
	{
		return get[get.size()-1];
	}
	else return 0;
}

void dfs3(L x,L color){
	L i;
	for(i=0;i<v[x].size();i++)
	{
		if(!ans[v[x][i]])
		{
			ans[v[x][i]]=-color;
			dfs3(v[x][i],-color);
		}
	}
}

int main()
{
	scanf("%lld",&n);
	L i,j;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&bu1[i]);
		if(bu1[i]!=-1)
		{
			v1[bu1[i]].push_back(i);
			v1[i].push_back(bu1[i]);
		}
		else
		{
			v1[i].push_back(-1);
			root1=i;
		}
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&bu2[i]);
		if(bu2[i]!=-1)
		{
			v2[bu2[i]].push_back(i);
			v2[i].push_back(bu2[i]);
		}
		else
		{
			v2[i].push_back(-1);
			root2=i;
		}
	}
	for(i=1;i<=n;i++)
	{
		L temp1=v1[i].size(),temp2=v2[i].size();
		if((temp1-temp2)%2) E();
	}
	chk1[root1]=1;
	dfs1(root1);
	chk2[root2]=1;
	dfs2(root2);
	for(i=1;i<=n;i++)
	{
		/*for(j=0;j<v[i].size();j++)
		{
			printf("%lld ",v[i][j]);
		}
		puts("");*/
		if(v1[i].size()%2)
		{
			if(!ans[i])
			{
				ans[i]=1;
				dfs3(i,1);
			}
		}
	}
	puts("POSSIBLE"); 
	for(i=1;i<=n;i++)
	{
		printf("%lld ",ans[i]);
	}
}

Measured memory_bytes: 25940
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int max_count = 0;
    for (int i = 1; i < n - 1; i++)
    {
        set<char> left, right;
        for (int j = 0; j < i; j++)
        {
            left.insert(s[j]);
        }
        for (int j = i; j < n; j++)
        {
            right.insert(s[j]);
        }
        int count = 0;
        for (auto ch : left)
        {
            if (right.find(ch) != right.end())
            {
                count++;
            }
        }
        max_count = max(max_count, count);
    }
    cout << max_count << endl;
}


Measured memory_bytes: 256
n = int(input())
xy_lis = []
for i in range(n):
    xy_lis.append(list(map(int, input().split())))
dis_sum = 0
for i in range(n):
    for j in range(i):
        dis_sum += ((xy_lis[i][0] - xy_lis[j][0]) ** 2 + (xy_lis[i][1] - xy_lis[j][1]) ** 2) ** (1 / 2)
print(dis_sum * 2 / n)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int N,K;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> K;
    vector<int> a(N),b(N);
    REP(i,N) cin >> a[i];
    deque<int> dq;
    for(int i = 0; i < N; ++i){
        // 後ろが今見てるのより小さくなるまで
        while(!dq.empty() && a[dq.back()] >= a[i]) dq.pop_back();
        dq.push_back(i);

        if(i - K + 1 >= 0){
            b[i - K + 1] = a[dq.front()];
            if(dq.front() == i - K + 1) dq.pop_front();
        }
    }

    for(int i = 0; i <= N-K; ++i) cout << b[i] << (i==N-K ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 10764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#define INF 1000000007
#define inf 100000000000000000
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,t,d[15][15],cost,x,y,k,i,j;
int main()
{
    while(scanf("%d",&n)!=EOF&&n!=0)
    {
        memset(d,INF,sizeof(d));t=0;
        P mi;mi.second=INF;
        for(i=0;i<n;i++)
        {
            scanf("%d%d%d",&x,&y,&cost);
            d[x][y]=d[y][x]=cost;
            t=max(t,max(x,y));
        }
        for(i=0;i<=t;i++)d[i][i]=0;
        for(k=0;k<=t;k++)
        {
            for(i=0;i<=t;i++)
            {
                for(j=0;j<=t;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
        for(i=0;i<=t;i++)
        {
            P p;p.first=i;p.second=0;
            for(j=0;j<=t;j++)
            {
                if(i==j)continue;
                p.second+=d[i][j];
            }
            if(mi.second>p.second)mi=p;
        }
        printf("%d %d\n",mi.first,mi.second);
    }
    return 0;
}

Measured memory_bytes: 3188
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), K = getint();
	int dp[101], h[101] = {};
	dp[K] = 0;
	rep(i, K) dp[i] = 1e9;
	h[K] = getint();

	int k[101];
	rep(i, K + 1) k[i] = i;
	rep(i, N - 1) {
		rep(j, K) swap(k[j], k[j + 1]);
		h[k[K]] = getint();
		dp[k[K]] = 1e9;
		rep(j, K) chmin(dp[k[K]], dp[k[j]] + abs(h[k[j]] - h[k[K]]));
	}

	printf("%d", dp[k[K]]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<queue>
#define sqr(x) (x)*(x)
using namespace std;
int dx[5]={0,0,0,-1,1},dy[5]={0,-1,1,0,0};
int n,m,i,j,cnt,dis[55][55];
char mp[55][55];
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
		{
			cin>>mp[i][j];
			if (mp[i][j]=='.') cnt++;
		}
	}
	memset(dis,22,sizeof(dis));
	dis[1][1]=1;
	queue<int> qx,qy;
	qx.push(1);
	qy.push(1);
	while (!qx.empty())
	{
		int x=qx.front(),y=qy.front();
		qx.pop();qy.pop();
		for (i=1;i<=4;i++)
		{
			int xx=x+dx[i],yy=y+dy[i];
			if (xx<1||yy<1||xx>n||yy>m) continue; 
			if (mp[xx][yy]=='#') continue;
			if (dis[xx][yy]>dis[x][y]+1)
			{
				dis[xx][yy]=dis[x][y]+1;
				qx.push(xx);
				qy.push(yy);
			}
		}
	}
	if (dis[n][m]>n*m)
	{
		cout<<-1;
		return 0;
	}
	cout<<cnt-dis[n][m];
	return 0;
}

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

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mkp make_pair
#define mkt make_tuple
#define pi 3.14159265358979323846264
#define d7 1000000007
#define l7 998244353

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

//some definitions and global variables >>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}

void srihrg(){
    //code starts
    ll n,k;
    cin>>n>>k;
    if(k==1){cout<<0;}
    else{
        cout<<min(n%k,(k-n%k));
    }
    
    //code ends
}

int main(int argc, const char * argv[]) {
#ifdef KR1shna
    cout<<"||ओ३म्||"<<endl;
#endif
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now

    ll t=1;
    //cin>>t;
    ll nt=1;
    while(t--){
        //cout<<"Case #"<<nt<<": ";
        srihrg();
        //nt++;
        cout<<endl;
    }
    
//code ends
    return 0;
}


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

using namespace std;

const int MAX_N = 1e5 + 200;

int n, m;
priority_queue<long long> pq;

int main()
{
    scanf("%d%d", &n, &m);
    long long ans = 0;
    for (int i = 1, tmp; i <= n; i++)
        scanf("%d", &tmp), pq.push(tmp), ans += tmp;
    while (m--)
    {
        long long tp = pq.top();
        pq.pop();
        long long tmp = tp >> 1;
        pq.push(tmp), ans -= (tp - tmp);
    }
    printf("%lld", ans);
    return 0;
}

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

using namespace std;

const int N=55;
int n;
long long a,b,c,d,l,r;

int main(){
	cin>>n>>a>>b>>c>>d;
	for(int i=1;i<n;i++){
		l=a+i*c, r=a+i*d;
		l-=(n-1-i)*d, r-=(n-1-i)*c;
		if(l<=b && r>=b)
			puts("YES"), exit(0);
	}
	puts ("NO");
	return 0;
}

Measured memory_bytes: 256
import sys

SUITS = ('S', 'H', 'C', 'D')
cards = {suit:{i for i in range(1, 14)} for suit in SUITS}

input()

for line in sys.stdin:
    suit, number = line.split()
    cards[suit].discard(int(number))

for suit in SUITS:
    for i in cards[suit]:
        print(suit, i)







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

int main() {
    int n,y;
    ll res;
    cin>>n>>y;
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n-i; j++) {
            int k=n-i-j;
            res=10000*i+5000*j+1000*k;
            if (res==y) {
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	string s;
	int n;
	cin>>s>>n;
	rep(0,i,s.size()){
		if(s[i]>49){
			if(i<n)c(s[i])
			else c(1)	
			return 0;
		}
	}
	c(1)		
}	


Measured memory_bytes: 256
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+7;

const int mod = 1e9+7;

int n;
int ar[N];

vector < int > primeFactors(long long num){
    vector < int > prm;
    while (num % 2 == 0){
        prm.push_back(2);
        num = num/2;
    }
    for (long long i = 3; i*i <= num; i = i + 2){
        while (num % i == 0){
            prm.push_back(i);
            num = num/i;
        }
    }
    if (num > 2)
        prm.push_back(num);
    return prm;
}

int mxF[N];

int fastP(int b, int e){
    if(!e)
        return 1;
    if(e & 1)
        return b * 1ll * fastP(b * 1ll * b % mod, e >> 1) % mod;
    return fastP(b * 1ll * b % mod, e >> 1) % mod;
}

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
        map < int , int > cntF;
        vector < int > prmF = primeFactors(ar[i]);
        for(auto v : prmF){
            cntF[v]++;
        }
        for(auto v : cntF){
            mxF[v.first] = max(mxF[v.first] , v.second);
        }
    }
    int sum = 0;
    long long LCM = 1;
    for(int i = 1; i <= 1e6; i++){
        while(mxF[i]--){
            LCM = LCM * i % mod;
        }
    }
    for(int i = 1; i <= n; i++){
        sum = (sum + LCM * fastP(ar[i] , mod - 2)) % mod;
    }
    printf("%d\n" , sum);
}


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

int a[100100];
int b[100100];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "AC") a[p]++;
        else {
            if(a[p] == 0) b[p]++;
        }
    }
    int ans1 = 0;
    int ans2 = 0;
    rep(i, n) {
        if(a[i] != 0) ans1++;
        if(b[i] != 0 && a[i] != 0) ans2 += b[i];
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    Vl ans;
    Vl sub;
    for (int i = 0; i < n; ++i) {
        ll x,y;cin >>x>>y;
        ans.push_back(x+y);
        sub.push_back(x-y);
    }
    sort(all(ans));
    sort(all(sub));
    ll res=max(ans.back()-ans[0],sub.back()-sub[0]);
    cout <<res<<endl;
}


Measured memory_bytes: 6636
n = int(input())
a = [int(i) for i in input().split()]
x = [0] * n

not_x0 = 0
for i in range(1, n, 2):
    not_x0 += 2*a[i]

x[0] = sum(a) - not_x0
for i in range(1, n):
    x[i] = 2*a[i - 1] - x[i - 1]

for i in range(n):
    print(x[i], end=' ')

Measured memory_bytes: 14024
#include<bits/stdc++.h>
using namespace std;
typedef pair<long,long> vec;
int main(){
  int N;cin>>N;
  vector<long>X(N),Y(N);for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
  vector<vec> vecs(N*N-N,vec(0,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i!=j){
        vecs.push_back(vec(X[i]-X[j],Y[i]-Y[j]));
      }
    }
  }
  sort(vecs.begin(),vecs.end());
  int max=0,count=1;
  for(int i=1;i<N*N-N;i++){
    if(vecs[i]==vecs[i-1]){
      count++;
    }
    else{
      if(count>max)max=count;
      count=1;
    }
  }
  cout<<N-max;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 62);
vector<int> to[1005];
vector<int> from[1005];
vector<tuple<int64_t, int64_t, int64_t>> edges;
bool used[1005];

bool isReachableFrom1[1005];
void dfs(int v)
{
  if (isReachableFrom1[v])
  {
    return;
  }
  isReachableFrom1[v] = true;
  for (int u : to[v])
  {
    dfs(u);
  }
}

bool isReachableToN[1005];
void rdfs(int v)
{
  if (isReachableToN[v])
  {
    return;
  }
  isReachableToN[v] = true;
  for (int u : from[v])
  {
    rdfs(u);
  }
}

int main()
{
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    int64_t a, b, c;
    cin >> a >> b >> c;
    edges.emplace_back(a - 1, b - 1, -c);
    to[a - 1].push_back(b - 1);
    from[b - 1].push_back(a - 1);
  }
  dfs(0);
  rdfs(N - 1);
  for (int i = 0; i < N; i++)
  {
    used[i] = isReachableFrom1[i] && isReachableToN[i];
  }
  vector<int64_t> d(N, INF);
  d[0] = 0;
  bool upd = true;
  int64_t step = 0;
  while (upd)
  {
    upd = false;
    for (int i = 0; i < M; i++)
    {
      int64_t a, b, c;
      tie(a, b, c) = edges[i];
      if (!used[a] || !used[b])
        continue;
      int64_t newD = d[a] + c;
      if (newD < d[b])
      {
        upd = true;
        d[b] = newD;
      }
    }
    step++;
    if (step > N)
    {
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -d[N - 1] << endl;
}

Measured memory_bytes: 3748
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let abc: Vec<(usize, usize, i64)> = (0..m)
        .map(|_| {
            let a = input();
            let b = input();
            let c = input();
            (a, b, c)
        })
        .collect();

    let mut cost = vec![vec![i32::max_value() as i64; n + 1]; n + 1];
    for i in 1..n + 1 {
        cost[i][i] = 0;
    }
    for i in 0..m {
        let (a, b, c) = abc[i];
        cost[a][b] = c;
        cost[b][a] = c;
    }

    for k in 1..n + 1 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                cost[i][j] = std::cmp::min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..m {
        let (a, b, c) = abc[i];
        let mut ok = false;
        for x in 1..n + 1 {
            if cost[x][a] + c == cost[x][b] || cost[x][b] + c == cost[x][a] {
                ok = true;
                break;
            }
        }
        if !ok {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9;
vector<int>G[100000];
int d[100000],n,p[100000],prv=-1;
void dfs(int v){
    for(int i=0;i<G[v].size();i++){
        if(G[v][i]!=p[v]&&G[v][i]!=prv){
            d[G[v][i]]=d[v]+1;
            p[G[v][i]]=v;
            dfs(G[v][i]);
        }
    }
}
void dist(int v){
    for(int i=0;i<n;i++)
        d[i]=inf;
    d[v]=0,p[v]=-1;
    dfs(v);
}
signed main(){
    int u,a,b,v;
    cin>>n>>u>>v;
    u--,v--;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dist(u);
    int mid;
    for(mid=v;d[mid]!=(d[v]-1)/2;prv=mid,mid=p[mid]);
    dist(mid);
    int ans=0,maxe=-1;
    for(int i=0;i<n;i++){
        if(d[i]!=inf&&ans<d[i]){
            ans=d[i];
            maxe=i;
        }
    }
    if(maxe==-1)
        maxe=prv;
    else
        maxe=p[maxe];
    prv=-1;
    dist(v);
    cout<<d[maxe]<<endl;
}


Measured memory_bytes: 11264
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: i64, c: i64,
    }
    println!("{}", (a - b + 1) * (a - c + 1));
}


Measured memory_bytes: 2136
#include<iostream>

using namespace std;

int main(void)
{
  char s1[3],s2[3],s3[3];
  
  for(int i=0;i<3;i++){cin>>s1[i];}
  for(int i=0;i<3;i++){cin>>s2[i];}
  for(int i=0;i<3;i++){cin>>s3[i];}
  
  cout<<s1[0]<<s2[1]<<s3[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#パクリ

def main():
    N, M = map(int, input().split())
    inf = int(1e10)
    #print(inf)
    dp = [inf] * (2**N) #1をNだけシフトする 2**B
    
    
    #鍵をビットで表す　dp[i]は鍵の状態iにできる最小費用を
    dp[0] = 0
    bits = set()
    bits.add(0)
    #print(dp)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        # cを状態keyに変換
        key = 0
        for t in c:
            key += 1 << (t - 1)
        ##print(c,">>",key)
        # bits内のbitとkeyのORを更新
        # 更新したbitはbitsに追加
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            #print("key>>",key,"bit>>",bit,"tmp>>",tmp)
            #print("dp>>",dp)
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        #print("bits>>",bits)
        #print("addadd_bits>>",bits)

        bits = add_bits|bits
        #print(">>>bits>>",bits)
    
    if dp[(1 << N) - 1] == inf:
        print(-1)
    else:
        print(dp[(1 << N) - 1])
    #print(dp)

if __name__ == "__main__":
    main()


Measured memory_bytes: 4168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int k;
int main() {
	int a, b;

	cin >> k;
	cin >> a >> b;
	bool res = false;
	for (int x = a; x <= b; ++x) {
		if (x % k == 0) {
			res = true;
			break;
		}
	}
	if (res) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 3640
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		if(s[1]<s[2]){Console.WriteLine("{0}",s[2]-s[0]-s[1]<1?0:s[2]-s[0]-s[1]);}
		else{Console.WriteLine("{0}",s[1]-s[0]-s[2]<1?0:s[1]-s[0]-s[2]);}
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    string s, t, c;
    int a, b;
    cin >> s >> t >> a >> b >> c;
    if (c == s)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#define SIZE 20002 
typedef long long ll;
using namespace std;


int main(){
    int N,ans=0;
    string S;
    unordered_map<string,int> mp;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> S;
        if(mp[S] == 0){
            mp[S] = i+100;
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 17720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q,c,a,n,count=0;
  cin >> q;
  for(int i=0; i<q; i++){
    count = 0;
    cin >> c >> a >> n;
    while(1){
    if(c>=1 && a>=1 && n>=1){
	c--; a--; n--;
	count++; 
    }
    else if(c>=2 && a>=1){
	c-=2;
	a-=1;
	count++;
    }
    else if(c>=3){
	c-=3;
	count++;
    }
    else break;
    }
  cout << count << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

const int max_k = 160 * 80;
bool dp[81][81][max_k+1];

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

	int h, w;
	cin >> h >> w;

	int a[h][w];
	rep(i, h) rep(j, w) cin >> a[i][j];

	int b[h][w];
	rep(i, h) rep(j, w) cin >> b[i][j];

	rep(i, 81) rep(j, 81) rep(k, max_k+1) dp[i][j][k] = false;
	dp[0][1][0] = true;
	dp[1][0][0] = true;

	rep(i, h) rep(j, w) rep(k, max_k+1){
		int d = abs(a[i][j] - b[i][j]);

		if(k + d <= max_k) dp[i+1][j+1][k + d] |= dp[i+1][j][k];
		if(abs(k - d) <= max_k) dp[i+1][j+1][abs(k - d)] |= dp[i+1][j][k];
		if(k + d <= max_k) dp[i+1][j+1][k + d] |= dp[i][j+1][k];
		if(abs(k - d) <= max_k) dp[i+1][j+1][abs(k - d)] |= dp[i][j+1][k];

	}

	rep(k, max_k + 1) {
		if(dp[h][w][k]) {
			cout << k << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 82304
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
num = 1
for i in range(D):
  print(num)
  if(num == 26):
    num = 1
  else:
    num += 1

Measured memory_bytes: 9416
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    int len;
    
    getline(cin, str);
    
    len = str.size();
    for (int i = 0; i < len; i++){
        if ('a' <= str[i] && str[i] <= 'z'){
            str[i] = str[i] - ('a' - 'A');
        }
    }
    
    cout << str << endl;
}

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

int main() {
    long a;cin>>a;
    long ans=0;
  	for (long i=1;i<=a;i++) {
 		if (i % 3 != 0&& i % 5 != 0) {
	       ans+=i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588