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


int main() {

	int n;
	double d;
	cin>>n;
	cin>>d;
	int c=0;
	for(int i=0;i<n;i++){
		double x,y;
		cin>>x>>y;
		double z=sqrt(pow(x,2)+pow(y,2));

		if(z<=d) c++;

	}
	cout<<c<<endl;
}




Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll n;
    cin >> n;
    ll dp[18] = {0};
    if (n % 2)
    {
        cout << 0 << endl;
    }
    else
    {
        ll cnt = 0;
        ll i = 5;
        while (n >= 2 * i)
        {
            cnt += n / (2 * i);
            i *= 5;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

using namespace std;

int n;
int num[10];
string edge[10][10];
string tmp;

main(){
  vector<string> in;
  set<string> data;
  while(cin >> n && n){
    in.clear();
    data.clear();
    for(int i=0;i<n;i++){
      string str;
      cin >> str;
      in.push_back(str);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        if(in[i].size() >= in[j].size()){
          for(int k=0;k+in[j].size()<=in[i].size();k++){
            if(in[i].substr(k, in[j].size()) == in[j]) data.insert(in[j]);
          }
        }
      }
    }
    for(set<string>::iterator i=data.begin();i!=data.end();i++){
      for(vector<string>::iterator ite=in.begin();ite!=in.end();ite++){
        if(*ite == *i){
          in.erase(ite);
          n--;
          break;
        }
      }
    }
    for(int i=0;i<in.size();i++){
      for(int j=0;j<in.size();j++){
        if(i == j){
          continue;
        }
        int size = min(in[i].size(),in[j].size());
        for(int k=size-1;k>=0;k--){
          if(in[i].substr(in[i].size()-k, k) == in[j].substr(0, k)){
            edge[i][j] = in[j].substr(k);
            break;
          }
        }
      }
    }
    int valm = 100000;
    string ans = in[0];
    for(int i=0;i<10;i++) num[i] = i;
    do{
      tmp = in[num[0]];
      for(int i=1;i<n;i++){
        tmp += edge[num[i-1]][num[i]];
      }
      if(tmp.size() < valm){
        ans = tmp;
        valm = tmp.size();
      }else if(tmp.size() == valm){
        ans = min(ans, tmp);
      }
    }while(next_permutation(num, num+n));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 932
using System;
using System.Linq;
public class s
{
  public static void Main()
  {
    int n=int.Parse(Console.ReadLine());
    int[] a=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int ans=0;
    Array.Sort(a);
    for(int i=1;i<n;i++)
    {
      ans+=a[i]-a[i-1];
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll p[200005],inv[200005],hell=998244353;
ll exp(ll x,ll y){
	ll res=1;
	x%=hell;
	while(y>0){
		if(y&1)
		res=(res*x)%hell;
		y>>=1;
		x=(x*x)%hell;
	}
	return res;
}
ll bin(ll n,ll r){
	ll res=p[n];
	res*=inv[r];
	res%=hell;
	res*=inv[n-r];
	res%=hell;
	return res;
}
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	if(m==1){
		if(k==n-1)
		cout<<1;
		else
		cout<<0;
		exit(0);
	}
	ll res=0,val=1;
	for(ll i=1;i<n-k;i++)
	val=(val*(m-1))%hell;
	for(ll i=k;i>=0;i--){
		ll sum=(bin(n-1,i)*m)%hell;
		sum=(sum*val)%hell;
		val=(val*(m-1))%hell;
		res+=sum;
		res%=hell;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    p[0]=inv[0]=1;
    for(ll i=1;i<200005;i++){
        p[i]=(i*p[i-1])%hell;
        inv[i]=exp(p[i],hell-2);
    }
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 6776
try:
    N = int(input())
    if N>1 and N<51:
        S = input()
        A = S.split()
        A = list(map(float, A))
        A.sort()
        result = A[0]
        
        if all(len(A)==N and i > 0 and i < 1001 for i in A):
                for i in range(1, N):
                    result = (result+A[i])/2

    print(result)
                                        
except:
    print("Error")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
//#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int main(){
  int n;
  cin>>n;
  vector<int> v;
  REP(i,35000)v.PB(i*i);
  LOOP(i,1,35000){
    if(v[i]>n){
      cout<<v[i-1]<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (n & 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(arr, arr + n);
  cout << arr[n / 2] - arr[n / 2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100020
using namespace std;

int a[N];
int f[N];

int main(void)
{
    int n;
    int i;

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

    f[n - 1] = 0;
    for(i = n - 2; i > -1; i --)
        f[i] = a[i] >= a[i + 1] ? f[i + 1] + 1 : 0;
    printf("%d\n", *max_element(f, f + n));

    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        d1(a*b);
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

template <class T>
void print_array(T* xs, int n){
    for(int i = 0; i < n; ++i){
        if(i){
            printf(" %d", xs[i]);
        } else {
            printf("%d", xs[i]);
        }
    }
    cout << endl;
}

template<class T>
int merge(T* xs, int l, int m, int r){
    int cnt = 0;
    int temp[r-l];
    int c1 = l;
    int c2 = m;
    int idx = 0;
    while(c1 < m || c2 < r){
        if(c1 == m){
            temp[idx] = xs[c2++];
        } else if(c2 == r){
            temp[idx] = xs[c1++];
        } else if(xs[c1] < xs[c2]){
            temp[idx] = xs[c1++];
        } else {
            temp[idx] = xs[c2++];
        }
        ++cnt;
        ++idx;
    }
    for(int i = l; i < r; ++i){
        xs[i] = temp[i-l];
    }
    return cnt;
}

template<class T>
int merge_sort(T* xs, int l, int r){
    int cnt = 0;
    if(l+1 < r){
        int mid = (l+r)/2;
        cnt += merge_sort(xs, l, mid);
        cnt += merge_sort(xs, mid, r);
        cnt += merge(xs, l, mid, r);
    }
    return cnt;
}


int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        int tmp;
        scanf("%d", &tmp);
        xs[i] = tmp;
    }
    int cnt = merge_sort(xs, 0, n);
    print_array(xs, n);
    cout << cnt << endl;
}

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

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c;
  
  d = min({a,b,c});
  f = max({a,b,c});
  e = (a+b+c)-(d+f);
  
  cout << d << " " << e << " " << f << endl;
    
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    int i;
    double n,add=0;
    int s[1001];
    double bu=0,ave=0;
    while(1){
        scanf("%lf",&n);
        if(n==0){
            break;
        }
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            add+=s[i];
        }
        ave=add/n;
        for(i=0;i<n;i++){
            bu+=(s[i]-ave)*(s[i]-ave);
        }
        printf("%f\n",sqrt(bu/n));
        add=0;
        bu=0;
        ave=0;
        
    }
    return 0;
}

Measured memory_bytes: 1760
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a) (0<=(a)&&(a)<9)
using namespace std;
int pdx[]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2},pdy[]={-1,0,1,-2,2,-2,2,-2,2,-1,0,1},
sdx[]={-1,-1,-1,0,0,0,1,1,1},sdy[]={-1,0,1,-1,0,1,-1,0,1};

int main(){
	int x,y,n;
	while(cin>>x>>y,x||y){
		cin>>n; int sx[10],sy[10];
		rep(i,n)cin>>sx[i]>>sy[i];
		vector<pair<int,int> > pos,next;
		pos.push_back(make_pair(y,x));
		for(int i=0;i<n&&!pos.empty();i++){
			int safe[9][9]={0};
			rep(d,9)if(ck(sx[i]+sdx[d])&&ck(sy[i]+sdy[d]))
			safe[sy[i]+sdy[d]][sx[i]+sdx[d]]=1;
			rep(j,pos.size())rep(d,12)if(ck(pos[j].first+pdy[d])&&
				ck(pos[j].second+pdx[d])&&safe[pos[j].first+pdy[d]][pos[j].second+pdx[d]]
			)next.push_back(make_pair(pos[j].first+pdy[d],pos[j].second+pdx[d]));
			pos=next,next.clear();
		}
		cout<<(pos.empty()?"NA":"OK")<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <vector>
#include <set> 
#include <iterator> 

using namespace std;

int main() {
	// your code goes here
	int n,k, goLeft = 0,i;
	cin >> n;
	int value[n];
	int cost[n];
	for(i=0;i<n;i++){
		cin >> value[i];
	}
	for(i=0;i<n;i++){
		cin >> cost[i];
	}
	int ans = 0;
	for(i=0;i<n;i++){
		if(value[i]>cost[i]){
			ans = ans + value[i] - cost[i];
		}
	}
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
n = int(input())
k = int(input())
x_list = input().split()
x_list = [int(x) for x in x_list]

goukei = 0
for x in x_list:
    if abs(0-x) > abs(k-x):
        goukei += 2*abs(k-x)
    else:
        goukei += 2*abs(x)

print(goukei)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

string n;

int main(void)
{
	while(cin >> n && n != "")
	{
		int ans = 0;
		for (int i = n.find("JOI", 0); i != string::npos; i = n.find("JOI", (int)i + 2))
			ans++;
		cout << ans << endl;
		ans = 0;
		for (int i = n.find("IOI", 0); i != string::npos; i = n.find("IOI", (int)i + 2))
			ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>

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

using namespace std;

int main(){
    string S; cin >> S;
    int zero=0, one=0;
    for(int i = 0; i < S.size(); i++){
        (S[i] == '0') ? zero++ : one++;
    }
    cout << min(zero, one)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] ans = new int[n];
        for (int i = 0; i < q; i++) {
            ans[sc.nextInt() - 1]++;
        }

        for (int i = 0 ; i < n; i++) {
            int correct = ans[i];
            System.out.println(k - (q - correct) > 0 ? "Yes" : "No");
        }
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 58916
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;
  // ll N = 5000;
  // string S = "";
  // for (ll i = 0; i < N; ++i)
  // {
  //   S += 'a';
  // }
  ll ans = 0;
  for (ll i = 0; i < N - 1; ++i)
  {
    for (ll j = i + 1 + ans; j < N - ans; ++j)
    {
      if (S[i] == S[j])
      {
        ll temp = 0;
        for (ll k = 0; k < j - i; ++k)
        {
          if (S[i + k] == S[j + k])
          {
            temp += 1;
            continue;
          }
          break;
        }
        ans = max(ans, temp);
      }
    }
  }
  cout << ans << endl;
}


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

int main()
{
  int a,b,c,p,q,r;
  cin>>a>>b>>c;
  p=a*10+b+c;
  q=b*10+c+a;
  r=c*10+a+b;
  cout<<max(max(p,q),r)<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

//#include <unordered_map>
//#include <unordered_set>

using namespace std;

int input[200010];

int main()
{
	int i , j , n , l;
	while (scanf("%d%d" , &n , &l) != EOF)
	{
		int index = - 1;
		for (i = 1;i <= n;i ++)
			scanf("%d" , &input[i]);
		for (i = 1;i <= n - 1;i ++)
		{
			if (input[i] + input[i + 1] >= l)
			{
				index = i;
				break;
			}
		}
		if (index >= 0)
		{
			printf("Possible\n");
			// 如果存在可以的
			for (i = 1;i < index;i ++)
				printf("%d\n" , i);
			for (i = n - 1;i >= index;i --)
				printf("%d\n" , i);
		}
		else
			printf("Impossible\n");
	}
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int N,M;
vector<int> R[100010];
int dist[100010];
bool f1[100010];
bool f2[100010];
bool f3[100010];
int S,T;

void BFS() {
  queue<P> q;
  q.push(make_pair(S,0));

  while (!q.empty()) {
    P p = q.front();
    q.pop();
    for (int i = 0; i < R[p.first].size(); i++) {
      if (f1[R[p.first][i]]) {
        continue;
      } else {
        f1[R[p.first][i]] = true;
      }
      for (int j = 0; j < R[R[p.first][i]].size(); j++) {
        if (f2[R[R[p.first][i]][j]]) {
          continue;
        } else {
          f2[R[R[p.first][i]][j]] = true;
        }
        for (int k = 0; k < R[R[R[p.first][i]][j]].size(); k++) {
          if (f3[R[R[R[p.first][i]][j]][k]]) {
            continue;
          } else {
            f3[R[R[R[p.first][i]][j]][k]] = true;
          }
          if (dist[R[R[R[p.first][i]][j]][k]] == 99999999) {
            dist[R[R[R[p.first][i]][j]][k]] = p.second + 1;
            q.push(make_pair(R[R[R[p.first][i]][j]][k],p.second + 1));
          }
        }
      }
    }
  }
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int u,v;
    cin >> u >> v;
    u--; v--;
    R[u].push_back(v);
  }
  cin >> S >> T;
  S--; T--;
  for (int i = 0; i < 100010; i++) dist[i] = 99999999;
  BFS();

  if (dist[T] == 99999999) {
    cout << -1 << endl;
  } else {
    cout << dist[T] << endl;
  }
  return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  ll x = N % K;
  ll y = K - x;
  cout << min(x, y) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int s;
    cin >> s;
    int a = s / 100, b = s % 100;
    bool ba = false, bb = false;
    if(a >= 0 && a <= 99){
        if(b >= 1 && b <= 12){
            ba = true;
        }
    }
    if(a >= 1 && a <= 12){
        if(b >= 0 && b <= 99){
            bb = true;
        }
    }
    if(ba&&bb) cout << "AMBIGUOUS" << endl;
    else if(ba) cout << "YYMM" << endl;
    else if(bb) cout << "MMYY" << endl;
    else cout << "NA" << endl;

}

Measured memory_bytes: 384
//package abc136;
import java.io.*;
import java.util.*;

public class Main {
	// ------------------------
	
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		System.out.println(Math.max(0, c - (a - b)));
		// ------------------------
		out.close();
	}
	//------------------------
	
	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const ll infll = (1ll<<60);
const int mod = 1000000007;
using namespace std;

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

vector<edge> graph;

vector<int> checkgraph[3000];
bool besucht[3000];

void checkdfs( int punkt ){
	if( besucht[punkt] ) return;
	besucht[punkt] = true;
	for( auto nextp : checkgraph[punkt] ){
		checkdfs( nextp );
	}
}

int main(){
	int n, m; cin >> n >> m;
	const int s = 0, g = n-1;
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		graph.push_back( (edge){a, b, -c} );
		checkgraph[a].push_back(b);
	}
	checkdfs(0); 
	vector<ll> d(n);
	fill_n( d.begin(), n, infll );
	d[s] = 0;
	int k = n-1;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			d[e.to] = min(d[e.to], d[e.from]+e.cost);
		}
	}
	bool negativ[n];
	fill_n( negativ, n, false );
	for( auto e : graph ){
		if( !besucht[e.from] ) continue;
		if( d[e.to] > d[e.from]+e.cost ){
			d[e.to] = d[e.from]+e.cost;
			negativ[e.to] = true;
		}
	}
	k = n;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			if( negativ[e.from] ) negativ[e.to] = true;
		}
	}
	if( negativ[g] ) cout << "inf" << endl;
	else cout << -d[g] << endl;
	return 0;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let (n, m): (usize, usize) = util::get2();
    let es: Vec<(usize, usize, usize)> = (0..m)
        .map(|_| {
            let (a, b, c): (usize, usize, usize) = util::get3();
            (a - 1, b - 1, c)
        })
        .collect();

    let mut cost = vec![vec![usize::max_value() / 4; n]; n];

    for v in 0..n {
        cost[v][v] = 0;
    }

    for &(a, b, c) in &es {
        cost[a][b] = c;
        cost[b][a] = c;
    }

    for i in 0..n {
        for j in 0..n {
            for k in 0..n {
                cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
            }
        }
    }

    let ans = es.iter()
        .filter(|&&(a, b, c)| {
            for i in 0..n {
                if cost[a][i] == c + cost[b][i] || cost[b][i] == c + cost[a][i] {
                    return false;
                }
            }
            true
        })
        .count();

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


Measured memory_bytes: 4352
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using order_statistics_tree = tree<T,null_type,less<T>,rb_tree_tag,
  tree_order_statistics_node_update>;

typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here

order_statistics_tree<pii> ost;
vector<int> v,id;
signed main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.pb(x);id.pb(x);
    }
    lld N = ((lld)n*(n+1)/2+1)/2;
    //cout << N << endl;
    sort(all(id));id.erase(unique(all(id)),id.end());
    for(auto&i : v)i = lower_bound(all(id), i)-id.begin();
    int l = 0, r = id.size();
    while(l != r){
        int k = l+r>>1, s = 0;
        lld ans = 0;
        ost.clear();
        for(int i = 0; i < n; i++){
            ost.insert({s,i});
            ans += ost.order_of_key({s += (v[i]<k?-1:1),INT_MAX});
        }
        //cout << k << " " << ans << endl;
        if(ans >= N)l = k+1;
        else r = k;
    }
    //cout << l << endl;
    cout << id[l-1] << endl;
}


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

using namespace std;

const int N = 1e5 + 5;

int a[N], b[N], c[N], p[N];

int find(int x) {
  return p[x] < 0 ? x : p[x] = find(p[x]);
}

bool merge(int u, int v) {
  if ((u = find(u)) == (v = find(v)))
    return false;
  if (-p[u] > -p[v])
    swap(u, v);
  p[v] += p[u];
  p[u] = v;
  return true;
}

int main() {
  memset(p, -1, sizeof p);
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  int cnt = n;
  int tot = 0;
  for (int i = 0; i < q; ++i) {
    scanf("%d %d %d", a+i, b+i, c+i);
    if (c[i] == 0) {
      tot += merge(a[i], b[i]);
    }
  }
  cnt -= tot;
  set<int> st;
  for (int i = 0;i < q; ++i) {
    if (c[i]) {
      if (find(a[i]) == find(b[i])) {
        puts("No");
        return 0;
      }
      st.insert(find(a[i]));
      st.insert(find(b[i]));
    }
  }
  long long mini = tot + (int)st.size();
  long long maxi = tot + 1LL * cnt * (cnt - 1) / 2;
  puts((mini <= m && m <= maxi) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    vector<int> v;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
	  int x;
	  cin >> x;
	  v.push_back(x);	
    }  
   for(int i = n - 1; i >= 0 ; i--)
   {
	 if (i == 0) cout << v[i];
	 else cout << v[i] <<  " ";  
	 }
     cout << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3160
use strict;
use warnings;
use utf8;
use feature qw/say/;

chomp(my ($n, $k, $q) = split(/ /, <STDIN>));

my %user_id_to_count;
for (1..$q) {
    chomp(my $user_id = <STDIN>);
    if (exists $user_id_to_count{$user_id}) {
        $user_id_to_count{$user_id}++;
    } else {
        $user_id_to_count{$user_id} = 1;
    }
}

for (1..$n) {
    if ($k + ($user_id_to_count{$_} // 0) - $q > 0) {
        say "Yes";
    } else {
        say "No"
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << ((a % 2 != 0 && b % 2 != 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
x = len(S)
ans = [0] * (x+1)
for i in range(x):
    if S[i] == '<':
        ans[i+1] = ans[i] + 1 
for i in range(x-1,-1,-1):
    if S[i] == '>':
        ans[i] = max(ans[i],ans[i+1]+1)
print(sum(ans))

Measured memory_bytes: 46320
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n;
	cin >> n;

	cout << 3*n*n;	

	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    for i in range(10 ** 10):
        if n // pow(k, i) == 0:
            print(i)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38452
import java.util.Scanner;

class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int H = sc.nextInt();
      	int N = sc.nextInt();
      	int[] A = new int[N];
      	for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          //System.out.println(A[i]);
          H -= A[i];
        }
      	if(H <= 0){
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
      	
    }
}

Measured memory_bytes: 48480
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  ll n,x ;
  cin >> n >> x ;
  ll a[110] ,sum=0 ;
  cinf(n,a) ;
  for(int i=0;i<n;i++)
    sum += a[i] ;
  if(sum == x)
    cout << n << endl;
  else{
    ll cnt=0 ;
    sort(a,a+n,greater<int>()) ;
    for(int i=0;i<n;i++){
      sum -= a[i] ;
      cnt ++ ;
      if(sum <= x){
        cout << n- cnt << endl;
        break;
      }
    }
  }
}

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

unsigned long long int A, B, C, D, i;

int main(){
    scanf("%lld %lld", &A, &B);
    if(!(A ^ B))return 0 & puts("1");
    C = (1LL << 64 - __builtin_clzll(A ^ B)) - 1;
    A &= C;
    B &= C;
    i = 1LL << 63 - __builtin_clzll(A ^ B);
    B = (B - i) ? (1LL << 64 - __builtin_clzll(B - i)) - 1 : 0;
    C = (A > B) ? i * 2 + B - A * 2 + 1 : i * 2 - A;
    cout << C;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll r;cin>>r;
  if(r<1200){
    cout<<"ABC"<<endl;
  }else if(r<2800){
    cout<<"ARC"<<endl;
  }else{
  	cout<<"AGC"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========
fn warshall_floyd_next(adjm: &mut Vec<Vec<Option<i64>>>) {
    let n = adjm.len();

    // kを経て短くなる辺を全部短くする
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if let (Some(dik), Some(djk)) = (adjm[i][k], adjm[k][j]) {
                    if adjm[i][j].is_none() || adjm[i][j].unwrap() > dik + djk {
                        adjm[i][j] = Some(dik + djk);
                    }
                }
            }
        }
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        l: i64,
        edges: [(usize,usize,i64);m],
        q: usize,
        queries: [(usize,usize);q],
    }
    let mut adjm: Vec<Vec<Option<i64>>> = vec![vec![None; n]; n];
    for e in edges {
        adjm[e.0 - 1][e.1 - 1] = Some(e.2);
        adjm[e.1 - 1][e.0 - 1] = Some(e.2);
    }
    // 自分から自分はゼロ for 燃料判定
    for i in 0..n {
        adjm[i][i] = Some(0);
    }
    warshall_floyd_next(&mut adjm);
    let mut fuelm = vec![vec![None; n]; n];
    for i in 0..n {
        for j in 0..n {
            match adjm[i][j] {
                Some(d) => {
                    if d <= l {
                        fuelm[i][j] = Some(1);
                    }
                }
                None => (),
            }
        }
    }
    for i in 0..n {
        fuelm[i][i] = Some(0);
    }
    warshall_floyd_next(&mut fuelm);
    for q in queries {
        match fuelm[q.0 - 1][q.1 - 1] {
            Some(t) => println!("{:?}", t - 1),
            None => println!("{:?}", -1),
        }
    }
}


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

int main() 
{
   char b;
   cin >> b;

   if (b == 'A')
      cout << 'T' << endl;
   else if (b == 'T')
      cout << 'A' << endl;
   else if (b == 'C')
      cout << 'G' << endl;
   else
      cout << 'C' << endl;
}


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

using namespace std;

int main() {
    while(true) {
        int n, k;
        cin >> n >> k;
        if(!n && !k) break;
        vector<bool> v(n+1, false);

        bool wildcard = false;
        for(int i = 0; i < k; ++i) {
            int num;
            cin >> num;
            v[num] = true;
            if(num == 0) wildcard = true;
        }

        int prevlen = 0;
        int currlen = 0;
        int ans = 0;
        int i = 1;
        while(i <= n) {
            while(!v[i] && i <= n) ++i;
            if(i >= n+1) break;
            while(v[i++]) ++currlen;
            if(wildcard) {
                ans = max(ans, prevlen+currlen+1);
                if(i+1 <= n && v[i+1]) prevlen = currlen;
                else prevlen = 0;
            }
            else {
                ans = max(ans, currlen);
            }
            currlen = 0;
        }

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

Measured memory_bytes: 916
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sumation=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sumation+=a[i];
    }
    ll sum1=a[0], sum2=sumation-sum1;
    ll ans=llabs(sum1-sum2);
    for(int i=1; i<N-1; i++){
        sum1+=a[i];
        sum2-=a[i];
        ll tmp=llabs(sum1-sum2);
        ans=min(ans, tmp);
    }
    cout << ans << endl;
    
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    vector<int> A;
    rep(i,n){
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }
    int q; cin >> q;
    rep(i,q){
        int k; cin >> k;
        auto low_itr = lower_bound(A.begin(), A.end(), k);
        auto up_itr = upper_bound(A.begin(), A.end(), k);
        cout << distance(A.begin(), low_itr) << " " << distance(A.begin(), up_itr) << endl;
    }
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



int prime[1000003]; 
unordered_map<int, int> max_map; 
int power(int a, int n) { 
    if (n == 0)return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
}
void sieve() { 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < 1000003; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < 1000003; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
int lcmModuloM(const int* ar, int n) { 
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
        while (num > 1){ 
            int factor = prime[num];
            temp[factor]++;
            num /= factor; 
        } 
        for (auto it : temp)max_map[it.first] = max(max_map[it.first], it.second); 
    } 
    int ans = 1; 
    for (auto it : max_map)ans = (ans * power(it.F, it.S)) % mod; 
    return ans; 
} 
  
void solve(){
    int n, cnt, ans = 0;
    cin>>n;
    int a[n+10];
    f(i,n)cin>>a[i];
    sieve();
    cnt = lcmModuloM(a,n);
    f(i,n){
        int x = (1LL * cnt * power(a[i],mod - 2)) % mod;
        ans = (ans + x) % mod;
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 8576
import sys
import math
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    x=[0]*N
    y=[0]*N
    for i in range(N):
        x[i],y[i]=map(int,input().split())
    kaijou=1
    for i in range(1,N+1):
        kaijou*=i
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            ans+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
    print(ans*2/N)
    

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    string N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N.size(); i++) {
        sum += N[i] - '0';
    }
    cout << ((sum % 9 == 0) ?  "Yes" : "No") << endl;
}

Measured memory_bytes: 3720
n, m = map(int, input().split())
like = []

for i in range(n):
    temp = list(map(int, input().split()))
    k = temp[0]
    like.append(temp[1:k + 1])

ans = 0

for j in range(1, m + 1):
    c = 1
    for i in range(n):
        if not(j in like[i]):
            c = 0
    if c == 1:
        ans = ans + 1

print(ans)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)

def main():
    h,w = map(int,input().split())

    if h%3 == 0 or w%3 == 0:
        print(0)
        exit()

    ans = min(h,w)

    h2 = h//2
    for i in range(1,w):
        S = [h2 * i, (h - h2) * i, h * (w - i)]
        S.sort()
        ans = min(ans,S[-1] - S[0])
    
    w2 = w//2
    for i in range(1,h):
        S = [w2 * i, (w - w2) * i, w * (h - i)]
        S.sort()
        ans = min(ans,S[-1] - S[0])
    
    print(ans)
if __name__=='__main__':
    main() 

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 30
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int C[210000];
ll dp[210000],pre[210000];

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

    int N;
    cin>>N;
    vector<int> V;
    for(int i=0;i<N;i++) cin>>C[i];
    int now=C[0];
    V.push_back(-1);
    V.push_back(now);
    for(int i=1;i<N;i++){
        while(now==C[i]){
            i++;
        }
        if(i>=N) break;
        now=C[i];
        V.push_back(now);
    }
    N=(int)V.size();
    dp[0]=1;
    for(int i=1;i<=N;i++){
        dp[i]=dp[i-1]+pre[V[i]];
        dp[i]%=MOD;
        pre[V[i]]=dp[i];
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 5236
#include<iostream>

using namespace std;

int main()
{
    char c , tmp = '\0';
    int n;
    int i = 0;
    cin >> n;

    for(int j = 0; j < n; j++){
        cin >> c;
        if(c != tmp){
            i++;
            tmp = c;
        }
    }

    cout << i << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum)%MOD;
        sum = (sum * sum) % MOD;
        b >>= 1;
    }
    return res;
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> sq(H);
    REP(i, H){
        cin >> sq[i];
    }
    vector<vector<vector<int> > > count(4, vector<vector<int> >(H, vector<int>(W, 0)));
    REP(i, H){
        int nc = 0;
        REP(j, W){
            if(sq[i][j]=='#')nc = 0;
            count[0][i][j] = nc;
            ++nc;
            if(sq[i][j]=='#')nc = 0;
        }
        nc=0;
        for(int j = W-1;j>=0;--j){
            if(sq[i][j]=='#')nc = 0;
            count[1][i][j] = nc;
            ++nc;
            if(sq[i][j]=='#')nc = 0;
        }
    }
    REP(i, W){
        int nc = 0;
        REP(j, H){
            if(sq[j][i]=='#')nc = 0;
            count[2][j][i] = nc;
            ++nc;
            if(sq[j][i]=='#')nc = 0;
        }
        nc=0;
        for(int j = H-1;j>=0;--j){
            if(sq[j][i]=='#')nc = 0;
            count[3][j][i] = nc;
            ++nc;
            if(sq[j][i]=='#')nc = 0;
        }
    }
    int ans = 0;
    REP(i, H){
        REP(j, W){
            int c = 0;
            REP(k, 4){
                c += count[k][i][j];
            }
            ans = max(ans, c+1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 84736
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, C, res;
  rd(A);
  rd(B);
  rd(C);
  res =max_L(0, C - (A-B));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2
 
// --- original code ---
// {
//   int A, B, C, res;
//   rd(A, B, C);
//   res = max(0, C - (A-B));
//   wt(res);
// }

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(H: "List[int]", M: "List[int]", K: int):
    okiru=H[0]*60+M[0]
    neru=H[1]*60+M[1]
    print(neru-okiru-K)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    solve(H, M, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (n, k) = readInts()
    readLine()
    var x = 1 + (n - k) / (k - 1)
    if ((n - k) % (k - 1) != 0) x++
    println(x)
}


Measured memory_bytes: 41376