akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int x,n;
  cin >> x >> n;
  
  vector<int> p(n);
  for ( int i = 0; i < n; i++){
    cin >> p[i];
  }
  
  int kyori = 1000,memo,hantei;
  
  for ( int i = -1; i <= 101; i++){
    hantei = 1;
    for ( int j = 0; j < n; j++){
      if ( i == p[j] ){
        hantei = 0;
      }
    }
    if ( hantei == 0 ){
      continue;
    }else{
      if ( kyori > abs(x-i) ){
        kyori = abs(x-i);
        memo = i;
      }
    }
  }
  
  
  cout << memo << endl; 
  
}

Measured memory_bytes: 3568
fn main() {
    let l = read::<f64>();
    let a = l / 3.0;
    println!("{}", a*a*a);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> vect;
    rep(i, n){
        ll input;
        cin >> input;
        vect.push_back(make_pair(input, i +1));
    }

    sort(vect.begin(), vect.end());

    rep(i, n){
        if(i == n-1){
            cout << vect[i].second << endl;
        }else{
            cout << vect[i].second << " ";
        }
    }
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;

signed main()
{

    cin >> n;

    int ans = 0;
    rep(i, n)
    {
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	vector<int> x,y;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		x.pb(tmp);
	}
	for(int i=0;i<m;i++){
		int tmp;
		cin>>tmp;
		y.pb(tmp);
	}
	ll xsum=0,ysum=0;
	for(int i=0;i<n-1;i++){
		xsum += ( (x[i+1]-x[i]) * (i+1) * (n-i-1) ) % inf;
		xsum %= inf;
	}
	for(int i=0;i<m-1;i++){
		ysum += ( (y[i+1]-y[i]) * (i+1) * (m-i-1) ) % inf;
		ysum %= inf;
	}
	ll ans = (xsum * ysum) % inf;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, W; cin >> N >> W;
    vec w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    int w0 = w[0];
    REP(i, N) w[i] -= w0;
    int X = 3 * N;

    mat dp(N + 1, vec(X + 1, 0));
    REP(i, N){
        mat tmp = dp;
        REP(n, N){
            REP(u, X + 1 - w[i]){
                tmp[n + 1][u + w[i]] = max(tmp[n + 1][u + w[i]], dp[n][u] + v[i]);
            }
        }
        dp = tmp;
    }
    int ans = 0;
    REP(n, N + 1){
        int Wmax = min(X, W - n * w0);
        if(Wmax >= 0) ans = max(ans, dp[n][Wmax]);
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

typedef long long ll;
const int TOF = 10;

ll q, a, b;

bool ok(int cnt, int a, int b) {
	ll s = 1LL * a * b - 1;
	for (int i = max(1, (cnt >> 1) - TOF); i <= min(cnt + 1, (cnt >> 1) + TOF); i++) {
		ll x = i < a? i: i + 1;
		ll y;
		if(cnt < b)
			y = b - i;
		else if(i <= cnt + 1 - b)
			y = cnt + 1 - i + 1;
		else
			y = cnt + 1 - i + 1 - 1;
		if(x * y > s)
			return false;
	}
	return true;
}

int solve(int a, int b) {
	ll l = 0, r = a + b - 1;
	while(r - l > 1) {
		ll c = (l + r) >> 1;
		if(ok(c, a, b))
			l = c;
		else
			r = c;
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> q;
	while(q--) {
		cin >> a >> b;
		cout << max(solve(a, b), solve(b, a)) << '\n';
	}
	return 0;
}

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

int K, S;

signed main() {
	int res = 0;
	cin >> K >> S;
	rep(i,K+1)
	{
		rep(j,K+1)
		{
			if (0 <= S - i - j && S - i - j <= K)
				res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	double a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if(a!=b&&w>=v) cout << "NO" << endl;
	else{
		if(abs(a-b)/abs(w-v)<=t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
} 

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0; i<n; i++) cin >> w[i];
  
  ll diff = 1e9;
  for(int i=1; i<n; i++){
    ll sum1 = accumulate(w.begin(), w.begin()+i, 0);
    ll sum2 = accumulate(w.begin()+i, w.end(), 0);
    diff = min(diff, abs(sum2 - sum1));
    //cout << sum1 << " " << sum2 << endl;
  }
  
  cout << diff << endl;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 0;i<N-1;i+=2){
        sum -= 2*A[i];
    }
    sum = A[N-1] - (sum/2);
    //sum *= 2;
    rep(i,N){
        cout << sum*2 << " ";
        sum = A[i]-sum;
    }
    cout << endl;

    /*
    ll L = 0, R = A[0]+1;
    while(L+1 < R){
        ll s = (L + R)/2;
        ll t = s;
        bool flag = false;
        rep(i,N){
            t = A[i] - t;
            if(t<0){
                if(i % 2 != 0){
                    L = s;
                }else{
                    R = s;
                }
                flag = true;
                continue;
            }
        }
        if(flag)continue;
        if(t + s == A[0]){
            break;
        }else if(t + s < A[0]){
            R = s;
        }else{
            L = s;
        }
    }
    ll t = L;
    rep(i,N){
        cout << 2*t << " ";
        t = A[i] - t;
    }
    cout << endl;*/
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    string m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) cout << 1;
    else cout << 0;
}

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	cnt := 0
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
N = gets.to_i
B = gets.split.map(&:to_i)

a = []
a[N-1] = B.last
(N-1).times.reverse_each do |i|
  a[i] = B[i]
  a[i+1] = [B[i], a[i+1]].min
end
p a.inject(:+)

Measured memory_bytes: 1788
import java.util.*;
public class Main
{
 public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    long X=sc.nextLong();
    if(X>=500)
    {
      int h=(int)(X/500);
      int r=(int)((X-(h*500))/5);
      System.out.println((h*1000)+(r*5));
    }
    else if(X<500)
    {System.out.println(((int)(X/5))*5);
    }
  }
}

Measured memory_bytes: 22484
def calcurate_digit_sum(num):
    digit_sum = 0
    while num > 0:
        digit_sum += num % 10
        num = num // 10
    return digit_sum

def check_harshad(num):
    digit_sum = calcurate_digit_sum(num)
    if num % digit_sum == 0:
        return("Yes")
    return("No")

if __name__ == "__main__":
    N = int(input())
    print(check_harshad(N))

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(len(L)):
    for j in range(i+1, len(L)):
        for k in range(j+1, len(L)):
            # print(L[i] + L[j], L[i] + L[k], L[j] + L[k])
            if (L[i] + L[j] > L[k]) & (L[i] + L[k] > L[j]) & (L[j] + L[k] > L[i]) & (L[i] != L[j]) & (L[j] != L[k]) & (L[i] != L[k]):
                ans +=+1
print(ans)

Measured memory_bytes: 9212
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 2
#define N_MAX 1000000000000

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	long long N;
	fscanf(stdin,"%lld",&N);
	ASSERT_RANGE(N_MIN,N,N_MAX);

	long long sqN = (long long)sqrt(N);
	long long i;
	for (i = sqN; i >= 1;i--) {
		if ((N % i) == 0) {
			fprintf(stdout,"%lld\n",(i-1)+(N/i-1));
			return 0;
		}
	}
	assert(0);
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define ll long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define max(x,y) (x>y?x:y)
int maxfun(int ** day, int *a, int *b, int *c, int n,int act){
    if(day[n][act]!=-1)return day[n][act];
    if(act==0){
        day[n][act]=max(maxfun(day,a,b,c,n-1,1)+a[n],maxfun(day,a,b,c,n-1,2)+a[n]);
    }
    else if(act==1){
        day[n][act]=max(maxfun(day,a,b,c,n-1,0)+b[n],maxfun(day,a,b,c,n-1,2)+b[n]);
    }
    else if(act==2){
        day[n][act]=max(maxfun(day,a,b,c,n-1,1)+c[n],maxfun(day,a,b,c,n-1,0)+c[n]);
    }
    return day[n][act];
}

int main(){
    ll n;
    cin>>n;
    int *a=new int[n];
    int *b=new int[n];
    int *c=new int[n];
    int **day=new int*[n];
    loop(i,0,n){
        day[i]=new int[3];
        loop(j,0,3)day[i][j]=-1;
        cin>>a[i]>>b[i]>>c[i];
    }
    day[0][0]=a[0];
    day[0][1]=b[0];
    day[0][2]=c[0];
    cout<<max(max(maxfun(day,a,b,c,n-1,0),maxfun(day,a,b,c,n-1,1)),maxfun(day,a,b,c,n-1,2))<<endl;
}

Measured memory_bytes: 14720
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

 struct Node T[MAX];
int n,D[MAX];

void print(int);
int rec(int,int);

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p =  T[i].l =  T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
      for(j=0;j<d;j++){
	scanf("%d",&c);
	if(j==0) T[v].l=c;
	else T[l].r=c;
	l=c;
	T[c].p=v;
      }
  }
  for(i=0;i<n;i++){
    if (T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);
  
  return 0;
}

void print(int u){
  int i,c;
  printf("node %d:",u);
  printf(" parent = %d,",T[u].p);
  printf(" depth = %d,",D[u]);

  if(T[u].p == NIL) printf(" root, ");
  else if(T[u].l==NIL) printf(" leaf, ");
  else printf(" internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}



Measured memory_bytes: 6368
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

   if(a%b == 0)
    return b;
   else
    return gcd(b,a%b);

 }

 long long numbers[500005];

 int main(){

 long long n,m;
 cin>>n>>m;

 long long ans=0;

 if(m-2*n > 0){
    ans = n;
    ans += (m-n*2)/4;
 }
 else {
    ans += m/2;
 }

 cout<<ans<<endl;

 return 0;
 }

Measured memory_bytes: 3624
N,Q = map(int,input().split())
S = input()
ruisekiwa = [0]*(N+1)
mode = 0
now = 0
for i in range(N):
  if S[i:i+2] == "AC":
    now += 1
  ruisekiwa[i+1] = now
for i in range(Q):
  l,r = map(int,input().split())
  print(ruisekiwa[r-1]-ruisekiwa[l-1])

Measured memory_bytes: 11440
A=int(input())
import collections
B=list(map(int,input().split()))
B=collections.Counter(B)
C=list(B.keys())
D=list(B.values())
ans = 0
for i,j in zip(C,D):
    if i > j:
        ans+=j
    elif i < j:
        ans+=j-i
print(ans)

Measured memory_bytes: 18304
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    int res = 0, ans = 0;
    rep(i, n) {
        int a, b; cin >> a >> b;
        if(a == b) {
            res ++;
            chmax(ans, res);
        } else {
            res = 0;
        }
    }
    cout << (ans >= 3 ? "Yes" : "No") << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;


/**
 *
 * @author
 *
 *
 *
 */

public class Main {
    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        int n = scanner.nextInt();

        out.println(48-n);

        scanner.reader.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data  = nextStringArray();
            int[] a  = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data  = nextStringArray();
            Integer[] a  = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data  = nextStringArray();
            long[] a  = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}



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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    set<char> s[n];
    rep(i, n) {
        s[i].insert(a[i]);
        s[i].insert(b[i]);
        s[i].insert(c[i]);
    }

    ll ans = 0;
    rep(i, n) { ans += s[i].size() - 1; }

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



Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    for(int i = 0; i < h; i++){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import(
      "fmt"
)

func main(){

  var n,m int
  fmt.Scan(&n,&m)
  fmt.Println(abs(n-2)*abs(m-2))
}

//====  ↓↓↓ template functions ↓↓↓  ======================

func min(a, b int) int{
  if a < b {
    return a
  }
  return b
}

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

func abs(x int) int{
  if x < 0 {
    return -x
  }
  return x
}

func gcd(a, b int) int{
  if b == 0 {
    return a
  }else{
    return gcd(b, a%b)
  }
}

func lcm(a, b int) int{
  return a*b/gcd(a, b);
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
cnt_1 = 0
cnt_2 = 0
cnt_4 = 0
for i in range(N):
	if A[i] % 2 == 0:
		if A[i] % 4 == 0:
			cnt_4 += 1
		else:
			cnt_2 += 1
	else:
		cnt_1 += 1
#print(cnt_1,cnt_2,cnt_4)
if cnt_2 == 0:
	if cnt_1 <= cnt_4 + 1:
		print("Yes")
	else:
		print("No")
else:
	if cnt_1 <= cnt_4:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 14224
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

class union_find
{
	int  _setnum;
	vector<int> par, nume;
public:
	union_find(){
	}
	
	union_find(int x){
		par.resize(x);
		nume.resize(x);
		init();
	}
	
	~union_find(){
		//
		
	}
	
	void clear(){
		_setnum = 0;
		par.clear();
		nume.clear();
	}
	
	void init(){
		_setnum = par.size();
		for(int i = 0; i < par.size(); i++){
			par[i] = i;
			nume[i] = 1;
		}
	}
	
	void resize(int x){
		
		par.resize(x);
		nume.resize(x);
		init();
	}

	int find(int x){
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
	
		if(x == y)return;
		
		_setnum--;
		
		if(nume[x] > nume[y]) std::swap(x,y);
		
		par[x] = y;
		nume[y] += nume[x];
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	int numel(int x){
		return nume[find(x)];
	}
	
	int size(){
		return par.size();
	}
	
	int setnum(){
		return _setnum;
	}
};

int kruskal(vector<pair<int,pair<int,int>>>& edge, int V){
	union_find uf(V);
	vector<int> hoge;
	int res = 0, count = 0;
	
	sort(edge.begin(), edge.end());
	
	for(int i = 0; i < edge.size(); i++){
		if(!uf.same(edge[i].second.first, edge[i].second.second)){
			uf.unite(edge[i].second.first, edge[i].second.second);
			hoge.push_back(edge[i].first);
			res += edge[i].first;
			count++;
		}
	}
	
	sort(hoge.begin(), hoge.end());
	
	if(count == V-1) return hoge[(V-1)/2];
	return -1;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	while(true) {
		int n, m;
		vector<pair<int,pair<int,int>>> edge;
		
		cin>>n>>m;
		
		if(!n && !m) break;
	
	
		edge.resize(m);
		
		for(int i = 0; i < m; i++){
			cin>>edge[i].second.first>>edge[i].second.second>>edge[i].first;
			edge[i].second.first--;
			edge[i].second.second--;
		}
		cout<<kruskal(edge, n)<<endl;
		
	}
	
	
	return 0;
}


Measured memory_bytes: 3288
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int total = int.Parse(Reader.ReadLine());
        int ichien = int.Parse(Reader.ReadLine());

        string ans = "No";
        if((total%500)<=ichien) {
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




2018
218



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))
#define Abs(a) (((a) > 0)?(a):(-1)*(a))
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 400010

ll cnt[26] = {0}, sub[26] = {0}, l;

char T[SIZE];

int main() {
   scanf("%s", T);
   ll ans = 0;
   l = strlen(T);
   for (int i = 0 ; i < l ; ++i) {
      ++cnt[T[i] - 'a'];
   }
   for (int i = 0 ; i < 26 ; ++i) {
      ans -= cnt[i] * (cnt[i] - 1) / 2ll;
   }
   ans += l * (l - 1) / 2;
   printf("%lld\n", ans + 1);

   return 0;
}

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

int main() {
  double a, b, c;
  cin >> a >> b >> c;
  double radc = c * M_PI / 180.0;
  double area = a * b * sin(radc) / 2;
  double h = 2 * area / a;
  double d = sqrt(a * a + b * b - 2 * a * b * cos(radc));
  double l = a + b + d;
  cout << fixed << setprecision(8) << area << endl;
  cout << fixed << setprecision(8) << l << endl;
  cout << fixed << setprecision(8) << h << endl;
}


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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int dp[200000];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int h[n+1];
	h[0]=0;
	for (int i = 1; i <=n; i++) {
	    cin>>h[i];
	}
	dp[2] =fabs(h[2] - h[1]);
	for (int i = 3; i <=n; i++) {
	    dp[i] = min(dp[i-1] + fabs(h[i] - h[i-1]) , dp[i-2] + fabs(h[i-2] - h[i]));
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
#define max 999999
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)

typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}

class Range{
public:
	int a,b;
	Range(int an,int bn) : a(an),b(bn){}

	bool operator()(int n){
		return a<=n&&n<=b;
	}
	bool isCross(Range x){
		return x(a) || x(b);
	}
	bool contains(Range x){
		return this->a <= x.a && x.b <= this->b;
	}
};


int main(){
	while(1){
		int a,b;
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		int s[20][20],cons[20][20];
		memset(s,0,sizeof(s));
		memset(cons,0,sizeof(cons));
		s[1][1] = 1;
		int n;
		cin >> n;
		rep(i,n){
			int p,q;
			cin >> p >> q;
			cons[p][q] = -1;
		}
		for(int i = 1;i<=18;i++)for(int j = 1;j<=18;j++){
			if(i == 1 && j == 1)continue;
			if(cons[i][j] == -1)continue;
			s[i][j] = ((cons[i-1][j] == 0) ? s[i-1][j] : 0) + ((cons[i][j-1] == 0) ? s[i][j-1] : 0);
		}
		cout << s[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstring>
#define INF 111111111
using namespace std;

int n,m;
int a,b,c,d,cost[1000][1000][10];
int memo[1000];
int ans[1000][10];
int k,x,y,z;

void solve(){
  ans[x][z] = 0;

  while(true){
    int s = -1;

    for(int i=1;i<=m;i++){
      if(!memo[i] && (s == -1 || ans[i][z] < ans[s][z])) s = i;
    }

    if(s == -1) break;
    memo[s] = 1;

    for(int i=1;i<=m;i++) ans[i][z] = min(ans[i][z],ans[s][z] + cost[i][s][z]);
  }
}

int main(){

  while(true){
    cin >> n >> m;
    if(!n && !m) break;

    for(int i=0;i<1000;i++){
      for(int j=0;j<1000;j++) cost[i][j][0] = cost[i][j][1] = INF;
    }

    for(int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
     
      cost[a][b][0]= cost[b][a][0] = c;
      cost[a][b][1] = cost[b][a][1] = d;

    }

    cin >> k;

    for(int i=0;i<k;i++){
      cin >> x >> y >> z;

      memset(memo,0,sizeof(memo));
      for(int i=0;i<1000;i++) ans[i][0] = ans[i][1] = INF;

      solve();
      cout << ans[y][z] << endl;

    }
  }
}

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

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

int main(int argv, char *argc[]){
  unsigned char a;
  long long int N;
  long long int L[1000];
  long long int i;
  scanf("%lld", &N);
  for (i = 0; i < N; i++) {
    scanf("%lld", &L[i]);
  }

  qsort(L, N, sizeof(long long int), compare_int);
  long long int sum = 0;
  for (i = 0; i < N-1; i++) {
    //printf("%lld, ", L[i]);
    sum += L[i];
  }
  if (sum > L[N-1]) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
  /* scanf("%d", &X); */
  /* printf("%f\n", (float)T/X); */
  //a = 122;
  //printf("%lx\n",a);
  
}


Measured memory_bytes: 128
import Control.Monad
import qualified Data.ByteString.Char8 as C

main = sol . C.filter (liftM2 (||) ('p'==) ('g'==)) <$> C.getContents >>= print

sol = fst . C.foldl' f (0,0)

f (s,0) 'p' = (s-1,1) 
f (s,h) 'p' = (s,h-1)
f (s,0) 'g' = (s,1) 
f (s,h) 'g' = (s+1,h-1)


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

namespace Atcoder178
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 0)
            {
                Console.Write(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

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

int cnt(int k,int n,int s){
    int c=0;
    if(n==1&&s>=k&&s<=9) return 1;
    else if(n==1) return 0;
    for(int i=k;i<=9-n+1;i++){
        c+=cnt(i+1,n-1,s-i);
    }
    return c;
}

int main(){
    while(241){
        int n,s;
        cin>>n>>s;
        if(n==0&&s==0) return 0;
        cout<<cnt(0,n,s)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
x = int(input())

not_found = True
ans = None

if x >= 2 and x <= 10**5:
    for i in range(2, x):
        if (x % i) == 0:
            break
    else:
        ans = x

    x += 1

    while(ans == None):
        for i in range(2, x):
            if (x % i) == 0:
                x += 1
                break
        else:
            ans = x


    print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, l, r, res = 0;
	cin >> n;
	REP(i, n) {
		cin >> l >> r;
		res += r - l + 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    ll n, k;
    cin >> n >> k;
    ll q, r;
    ll res = 0;
    for(int i = k+1; i <= n; i++){
        r = n-n/i*i;
        q = n/i;
        res += q*(i-k);
        if(r >= k && k != 0){
            res += r-k+1;
        }
        if(k==0){
            res += r;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    l = list(map(int, sys.stdin.readline().split()))

    cnt = 0
    for i in range(N - 2):
        p1 = l[i]
        p2 = l[i + 1]
        p3 = l[i + 2]

        if p2 != max(p1,p2,p3) and p2 != min(p1,p2,p3) :
            cnt += 1
    print(cnt)


Measured memory_bytes: 5356
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &A[i])
	}

	A0, count := selectionSort(A, n)

	fmt.Fprintln(w, strings.Join(Itos(A0), " "))
	fmt.Fprintln(w, count)
}

func selectionSort(A []int, n int) ([]int, int) {
	count := 0
	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if A[j] < A[minj] {
				minj = j
			}
		}
		if i != minj {
			A[i], A[minj] = A[minj], A[i]
			count += 1
		}
	}
	return A, count
}

func Itos(A []int) []string {
	var s []string
	for _, k := range A {
		s = append(s, strconv.Itoa(k))
	}
	return s
}



Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int maxc = 26;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int read(){
    int f = 1,x = 0; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - 48;ch = getchar();}
    return f * x;
}
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll qw(ll x,ll y){ll ans = 1;while(y){if(y&1) ans *= x;x *= x;y >>= 1;}return ans;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool is_prime(ll x){if(x <= 1) return 0;for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;	}
int n,k,d,x,ans;
bool f[105];
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 1;i <= k;i++){
		cin >> d;
		while(d--){
			cin >> x;
			f[x] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		if(!f[i]) ans++;
	}	
	cout << ans << endl;
	return 0;	
}

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

const int N = 100005;

using namespace std;

string s;
int n, l[N], r[N], x[N], root[N], summ[N], sz[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if (s.size() == 1)
    {
        cout << "YES";
        return 0;
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    if (s.size() % 2 == 1)
    {
        int pos = s.size() / 2;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        string t = "";
        for (int i = 0; i < s.size(); i++) if (i != pos) t += s[i];
        s = t;
    }
    int len = s.size() / 2;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = s.size() - 1 - l[i];
            int ll = s.size() - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    string a = "", b = "";
    for (int i = 0; i < len; i++) a += s[i];
    for (int i = len; i < s.size(); i++) b += s[i];
    reverse(b.begin(), b.end());
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = (b[i] + 26 - a[i]) % 26;
    }
    //for (int i = 0; i <= len; i++)
    //{
    //    cout << x[i] << " ";
    //}
    //cout << endl;
    for (int i = len + 1; i > 0; i--)
    {
        x[i] = (x[i] - x[i - 1] + 26) % 26;
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    iota(root, root + len + 2, 0);
    fill(sz, sz + len + 2, 1);
    for (int i = 0; i < n; i++)
    {
        int a = l[i], b = r[i];
        while (a != root[a]) a = root[a];
        while (b != root[b]) b = root[b];
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            root[b] = a;
        }
    }
    for (int i = 1; i < len + 2; i++)
    {
        int j = i;
        while (j != root[j]) j = root[j];
        summ[j] += x[i];
    }
    int t = -1;
    for (int i = 0; i <= len; i++)
    {
        if (summ[i] % 26 != 0)
        {
            if (t == -1) t = i;
            else cout << "NO", exit(0);
        }
    }
    if (t == -1) cout << "YES", exit(0);
    int s = 0;
    while (s != root[s]) s = root[s];
    if (s == t) cout << "YES", exit(0);
    else cout << "NO", exit(0);
}


Measured memory_bytes: 2156
# author:  Taichicchi
# created: 27.09.2020 23:57:30

import sys

N = int(input())

t1, x1, y1 = 0, 0, 0

for i in range(N):
    t, x, y = map(int, input().split())
    dx = abs(x - x1)
    dy = abs(y - y1)
    dt = t - t1
    d = dx + dy
    # print(f"{dt=}{d=}")

    if (d <= dt) & (dt % 2 == d % 2):
        pass
    else:
        print("No")
        exit()

    t1, x1, y1 = t, x, y

print("Yes")


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

int main() {
    char c;
    std::cin >> c;

    switch (c) {
    case 'A': { std::cout << 'T' << std::endl; break; }
    case 'C': { std::cout << 'G' << std::endl; break; }
    case 'G': { std::cout << 'C' << std::endl; break; }
    case 'T': { std::cout << 'A' << std::endl; break; }
    default: {
    }
    }

    return 0;
}


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

int main(){
  vector<int>num(3);
  cin >> num[0] >> num[1] >> num[2];
  int k;
  cin >> k;
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());

  int ans = 0;
  ans = pow(2, k)*num[0] + num[1] + num[2];
  cout << ans << endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

void warshall_floyd(int n, vector<vector<ll>> &distances) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if (distances[i][j] == INF && (distances[i][k] == INF || distances[k][j] == INF)) {
                    distances[i][j] = INF;
                } else {
                    distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
                }
            }
        }
    }
}

struct Edge {
    int from, to, distance;

    friend std::istream &operator>>(std::istream &in, Edge &o) {
        int a, b, c;
        in >> a >> b >> c;
        a--;
        b--;
        o.from = a;
        o.to = b;
        o.distance = c;
        return in;
    }

};

int main() {
    int n, m;
    cin >> n >> m;
    vector<Edge> edges(m);
    rep(i, m) cin >> edges[i];

    vector<vector<ll>> distance(n, vector<ll>(n, INF));
    rep(i, n) distance[i][i] = 0;

    for (Edge edge : edges) distance[edge.from][edge.to] = edge.distance;
    for (Edge edge : edges) distance[edge.to][edge.from] = edge.distance;

    warshall_floyd(n, distance);

    int ans = 0;
    for (Edge edge : edges) if (distance[edge.from][edge.to] != edge.distance) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll dp[2*100010][5];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L;cin>>L;
  vll A(L+2,0);
  repeat(i,L){
    cin>>A[i+1];
  }
  repeat(j,4){
    dp[0][j+1]=INF;
  }
  repeat(i,L+1){
    repeat(j,5){
      dp[i+1][j] = dp[i][j];
      repeat(k,j){
        dp[i+1][j] = min(dp[i+1][j],dp[i][k]);
      }
      if(j%4==0){
        dp[i+1][j] += A[i+1];
      }else if(j&1){
        dp[i+1][j] += (A[i+1]&1) + ((!A[i+1])<<1);
      }else{
        dp[i+1][j] += !(A[i+1]&1);
      }
    }
  }
  /*
  repeat(i,L+2){
    debug(i);
    debugArray(dp[i],5);
  }
  */
  cout << dp[L+1][4] << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
    #define ll  long long int
    #define N 100000
    #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
    #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
    #define po pop_back
    #define pb push_back
    #define lb lower_bound
    #define fi first
    #define se second
    #define debug(x) cout << #x << " = " << x << endl
    #define ub upper_bound
    #define ibs ios_base::sync_with_stdio(false)
    #define cti cin.tie(0)
    #define all(x) x.begin(),x.end()
    #define PI 3.14159265
    #define cot cout.tie(0)
    using namespace std;
      /**
        * @author :: Sawlani
        *
        */
        int main()
        {
            //freopen("input.txt","r",stdin);
            ll n;
            cin >> n;

            ll a[n+1],dp[n+1];
            f(i,1,n) cin >> a[i];

            dp[1]=0;
            dp[2]=abs(a[1]-a[2]);

            f(i,3,n) dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);

            cout << dp[n] ;


        }


Measured memory_bytes: 1792
h, w=map(int, input().split())
a=[input() for _ in range(h)]
s=set()
t=set()
for i in range(h):
  if '#' in a[i]:
    s.add(i)
    for j in range(w):
      if a[i][j]=='#':
        t.add(j)
for i in s:
  l=''
  for j in t:
    l+=a[i][j]
  print(l)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する
// cぐらいから問題文を読み替える
// 読み替える


int main() {
  ll n,k,h,w;
  ll a,b;
  cin >> a >> b;
  // string s;
  // cin >> s;
  // vector<ll> a(n,0);
  // cin >> a;

  ll ans = 0;

  if (a < b){
    ans = 0;
  }else{
    ans = 10;
  }


  cout << ans <<endl;

  
  // cout << (true? "Yes":"No");


}




















Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.nextLine());
    int b = Integer.parseInt(sc.nextLine());
    int c = Integer.parseInt(sc.nextLine());
    int x = Integer.parseInt(sc.nextLine());

    int cnt = 0;
    for (int i = 0; i <= a; i++) {
      for (int ii = 0; ii <= b; ii++) {
        for (int iii = 0; iii <= c; iii++) {
          if (500 * i + 100 * ii + 50 * iii == x) cnt += 1;
        }
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for (long i = 0; i < n; ++i)
#define FOR(i, b, n) for (long i = b; i <= n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long N, long M, vector<long> a, vector<long> b) {
  vector<int> score(N + 1, 0);

  REP(i, M) {
    
    if (a[i] == 1 || a[i] == N)
      score[b[i]]++;

    if (b[i] == 1 || b[i] == N)
      score[a[i]]++;
  }

  FOR(i, 1, N) {
    // cout << i << " " << score[i] << endl;
    if (score[i] > 1) {
      cout << YES << endl;
      return;
    }
  }
  cout << NO << endl;
}

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

  long N, M;
  cin >> N >> M;
  vector<long> a(M);
  vector<long> b(M);
  REP(i, M)
    cin >> a[i] >> b[i];

  solve(N, M, move(a), move(b));
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,m=0;cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    m=max(A[i],m);
  }
  int l=1,r=m;
  int ans=m;
  for(int j=0;j<100;j++){
    if(l==r)break;
    int a=l+(r-l)/2;
    int M=0,k=0;
    bool ok=true;
    for(int i=0;i<N;i++){
      if(A[i]<=a)continue;
      k+=A[i]/a;
      //if(A[i]/a==0)ok=false;
    }
    if(ok&&k<=K){
      ans=min(a,ans);
      r=a;
    }else{
      l=a;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
string s;
cin >>s;
vector<bool>a(26,false);
for(int i=0;i<s.size();i++){
  a.at(s.at(i)-'a') = true;
}
for(int i=0;i<27;i++){
  if(i==26)cout <<"None"<<endl;
  else{
    if(a.at(i)==false){
      cout<<char('a'+i)<<endl;
      break;
    }
  }
}

}





Measured memory_bytes: 512