akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 1315
  Title:Gift from the Goddess of Programming
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define max(x,y) (((x)>(y))?(x):(y))

struct time_st {
  int hour;
  int min;
  int in_flag;} 
last_in[1000];
int acc[1000];

void dump()
{
  int i;
  for(i=0;i<1000;i++)
    if(acc[i])
      printf("acc[%d]=%d|",i,acc[i]);
  printf("\n");
}
main()
{
  int mm,d,h,m,p,i,j,n,max_;
  char e;

  while(scanf("%d",&n) && n)
    {
      memset(last_in,0,sizeof(last_in));
      memset(acc,0,sizeof(acc));
      for(i=0;i<n;i++)
	{
	  scanf("%d/%d %d:%d %c %d",&mm,&d,&h,&m,&e,&p);
#ifdef DEBUG
	  printf("%02d %02d %c %03d:",h,m,e,p);
#endif
	  if(e=='I')
	    {
	      if(p==0)
		{
		  last_in[0].in_flag=1;
		  for(j=1;j<1000;j++)
		    if(last_in[j].in_flag)
		      {
			last_in[j].hour=h;
			last_in[j].min =m;
		      }
		}
	      else
		{
		  if(last_in[0].in_flag)
		    {
		      last_in[p].hour=h;
		      last_in[p].min =m;
		    }
		  last_in[p].in_flag=1;
		}
	    }
	  if(e=='O')
	    {
	      if(p==0)
		{
		  last_in[0].in_flag=0;
		  for(j=1;j<1000;j++)
		    if(last_in[j].in_flag)
		      {
			acc[j] += 60*(h - last_in[j].hour)+(m-last_in[j].min);
		      }
		}
	      else
		{
		  if(last_in[0].in_flag)
		    {
		      acc[p] += 60*(h-last_in[p].hour)+(m-last_in[p].min);
		    }
		  last_in[p].in_flag=0;
		}
	    }
#ifdef DEBUG
	  dump();
#endif
	}
      max_=0;
      for(i=1;i<1000;i++)
	max_=max(max_,acc[i]);
      printf("%d\n",max_);
    }
  return(0);
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    float ans=(v[0]+v[1])/2.0;
    for(int i=2;i<n;i++){
        ans=(v[i]+ans)/2.0;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int S[13],H[13],C[13],D[13],n,d;
    char ch;
    for(int i=0;i<13;i++){
        S[i]=i+1;
         H[i]=i+1;
          C[i]=i+1;
           D[i]=i+1;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        scanf(" %c%d",&ch,&d);
        if(ch=='S') S[d-1]=0;
        if(ch=='H') H[d-1]=0;
        if(ch=='C') C[d-1]=0;
        if(ch=='D') D[d-1]=0;
    }
    for(int i=0;i<13;i++){
        if(S[i]==0)continue;
        else printf("S %d\n",S[i]);
    }
    for(int i=0;i<13;i++){
        if(H[i]==0)continue;
        else printf("H %d\n",H[i]);
    }
    for(int i=0;i<13;i++){
        if(C[i]==0)continue;
        else printf("C %d\n",C[i]);
    }
    for(int i=0;i<13;i++){
        if(D[i]==0)continue;
        else printf("D %d\n",D[i]);
    }
}



Measured memory_bytes: 3112
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<ll, P1> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int a, b;
	cin >> a >> b;
	int mult = 0;
	int tmp = b;
	while (tmp > 0)
	{
		tmp /= 10;
		mult++;
	}
	int t = 1;
	while (mult > 0)
	{
		t *= 10;
		mult--;
	}
	int v = a * t + b;
	//cout << v << endl;
	bool ok = false;
	for (int i = 1; i < 1000; i++)
	{
		if (i * i == v) { cout << "Yes" << endl; ok = true;  break; }
	}
	if (!ok) cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from numba import jit


@jit("i8, i8, i8[:]")
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 137136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int N;
    cin >> N;
    string C;
    cin >> C;

    int cnt = 0;
    int l = 0;
    int r = N - 1;
    while (l < r) {
        // 一番左のWを見つける
        while (C[l] != 'W' && l < N) l++;

        // 一番右のRを見つける
        while (C[r] != 'R' && r >= 0) r--;

        if (l >= r) break;
        if (l >= N) break;
        if (r < 0) break;

// cout << "l: " << l << ", r: " << r << endl;

        swap(C[l], C[r]);
        cnt++;
    }

    cout << cnt << endl;
    // cout << C << endl;
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int i, n, tmp=0;
    char x[10000];
    while (1) {
        scanf("%s",x );
        n=x[0]-'0';
        if (n==0) {
            break;
        }
        for (i=0; x[i]!='\0'; i++) {
            tmp+=x[i]-'0';
        }
        printf("%d\n", tmp);
        tmp=0;
    }
    
    return 0;
}



Measured memory_bytes: 2116
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String str = br.readLine();
		String strlist[] = str.split(" ");
		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < N; i++){
			numList.add(Integer.parseInt(strlist[i]));
		}

		int counter = 0;
		while(true){
			boolean flg = false;
			for(int i = 0; i < N; i++){
				if(numList.get(i) % 2 != 0){
					flg = true;
				}
			}
			if(flg){
				break;
			}
			for(int i = 0; i < N; i++){
				numList.set(i, numList.get(i)/2);
			}
			counter++;
		}
		System.out.println(counter);
	}
}

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

int h, w, d[105][105];
char a[105][105];
int main() {
	int i, j;
	cin >> h >> w;
	for(i=0; i<h; i++) scanf("%s", &a[i]);
	d[0][0] = (a[0][0]=='#');
	for(i=0; i<h; i++) for(j=0; j<w; j++) {
		if(i+j==0) continue;
		d[i][j] = 1e9;
		if(i>0) d[i][j] = min(d[i][j], d[i-1][j] + (a[i-1][j]=='.' && a[i][j]=='#'));
		if(j>0) d[i][j] = min(d[i][j], d[i][j-1] + (a[i][j-1]=='.' && a[i][j]=='#'));
	}
	cout << d[h-1][w-1];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
  char id[11],idp[11];
  scanf("%s",id);
  scanf("%s",idp);
  int s;
    for (s = 0;id[s] != '\0';s++);
  for(int i=0;i<s;i++){
  if (id[i] != idp[i]){
    printf("No");
    break;}
    else if (i==s-1) printf("Yes");
  } 
  return 0;
}

Measured memory_bytes: 1708
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ');
            var ls = Console.ReadLine().Split(' ');

            var N = int.Parse(NK[0]);
            var K = int.Parse(NK[1]);

            var output = ls.Select(l => int.Parse(l))
                .OrderByDescending(l => l)
                .Take(K)
                .Sum();

            Console.Write(output);
        }
    }
}


Measured memory_bytes: 11348
n = STDIN.gets.split[0].to_i
h = Hash.new
n.times {
  line = STDIN.gets.split
  command = line[0]
  str = line[1]
  if command == 'insert'
    h[str] = true
  elsif command == 'find'
    if h[str]
      puts 'yes'
    else
      puts 'no'
    end
  end
}


Measured memory_bytes: 41068
#include <iostream>
#include <cstdio>
#include <algorithm>
#define for(i, x, y) for (int i = x; i <= y; i++) 
using namespace std;

int n;
int ans;

int Do(unsigned long long x) {
	int t = 0; 
	while (x) {
		if (!(x & 1)) {
			x >>= 1;
			t++;
		} else {
			return t;
		}
	}
}

int main() {
	scanf("%d", &n);
	for (i, 1, n) {
		unsigned long long x;
		scanf("%d", &x);
		ans += Do(x);
	}
	printf("%d", ans);
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] k = new int[M];
		int[][] s = new int[M][];
		for (int i = 0; i < M; i++) {
			k[i] = sc.nextInt();
			s[i] = new int[k[i]];
			for (int j = 0; j < k[i]; j++) {
				s[i][j] = sc.nextInt() - 1;
			}
		}

		int[] p = new int[M];
		for (int i = 0; i < M; i++) {
			p[i] = sc.nextInt();
		}

		sc.close();

		int ans = 0;

		for (int bit = 0; bit < (1 << N); bit++) {
//			System.err.println(Integer.toBinaryString(bit));
			int light = 1;
			// 電球iが点灯するか
			for (int i = 0; i < M; i++) {
				int n = 0;
				for (int j = 0; j < k[i]; j++) {
//					System.err.println("[[ " + j + "," + k[i]);
					if (((bit >> s[i][j]) & 1) == 1) {
						System.err.println(j + " switch on");
						n++;
					}
				}
				System.err.println("i=" + i + "  n=" + n + "  p[i]=" + p[i]);
				if (n % 2 != p[i]) {
//					System.err.println("x");
					light = 0;
				} else {
//					System.err.println("o");

				}
			}

			if (light == 1) {
				System.err.println("ok");

				ans++;
			}

		}

		out.println(ans);

	}

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


Measured memory_bytes: 40124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll a[1000010];

void solve(){

    long double r;
    long double PI=3.14159265358979323846;
    cin >> r;
    cout << 2*r*PI << endl;

}

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


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if ((-d<=b-a and b-a<=d and -d<=c-b and  c-b<=d) or (-d<=c-a and c-a<=d)){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
  
  
}

  













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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

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

    int more = 0, less = 0, cntl = 0;
    vector<int> sm, sl;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            more += a[i] - b[i];
            sm.pb(a[i] - b[i]);
        }
        if (b[i] > a[i]) {
                cntl++;
            less += b[i] - a[i];
            sl.pb(b[i] - a[i]);
        }
    }

    if (more < less) {
        cout << "-1\n";
        return 0;
    }

    sort(all(sm), greater<int>());
    sort(all(sl));

    int cntm = 0, i = 0;
    while (less > 0) {
        less -= sm[i++];
        cntm++;
    }

    cout << cntl + cntm << "\n";
    return 0;
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b;
  char c;
  cin >> a >> c >> b;

  if(c == '+'){
    printf("%d\n", a+b);
  }
  else printf("%d\n", a-b);
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
struct var
{
    int a, b;
    var(int x, int y)
    {
        a=x,b=y;
    }
};
vector<var> v;
int main()
{
    int n, m,a,b;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d",&a,&b);
        v.push_back(var(a,b));
    }
    int l=v[0].a,r=v[0].b;
    for(int i=1;i<v.size();++i)  l=max(l,v[i].a),r=min(r,v[i].b);
    if(r>=l) printf("%d",r-l+1);
    else printf("0");
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
int main()
{
	int n;
	int d,x;
	int a;
	cin >> n;
	cin >> d >> x;
	int res = n;
	for(int i = 0 ;i< n;i++)
	{
		cin >> a;
		int cnt = 0;
		for(int j = a+1;j<=d;j=j+a)
		{
//			cout << "j = " << j << endl;
			res++;
//			cnt++;
		}
		
//		cout << "cnt = " << cnt << endl;
//		cout << res << endl;
	}
	
	cout << res + x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

using Float = double;
using Point = complex<Float>;
struct Line{
	Point a,b;
	Line(Point a,Point b) : a(a),b(b){}
};
struct Segment : Line{ Segment(Point a,Point b) : Line(a,b){} };
struct Circle{ Point p; Float r; };

istream &operator>>(istream &is,Point &p){
	Float a,b;
	is >> a >> b;
	p = Point(a,b);
	return is;
}
inline bool eq(Float a,Float b) { return abs(a - b) < EPS; }
inline Float dot(const Point &a,const Point &b){ return real(conj(a) * b); }
inline Float cross(const Point &a,const Point &b){ return imag(conj(a) * b); }

namespace std{
	bool operator<(const Point &a,const Point &b){
		return eq(real(a),real(b)) ? imag(a) < imag(b) : real(a) < real(b);
	}
}

inline bool intersect(const Line &s,const Point &p){
	return abs(cross(s.a - p,s.b - p)) < EPS;
}

int ccw(const Point &a,Point b,Point c){
	b -= a; c -= a;
	if(cross(b,c) > EPS) return +1; //ccw
	if(cross(b,c) < -EPS) return -1; //cw
	if(dot(b,c) < 0) return -2; //c-a-b
	if(norm(b) < norm(c)) return +2; //a-b-c
	return 0; //a-c-b
}

int n,m;

void solve(){
	Point ps[210];
	for(int i = 0;i < n + m;i++) cin >> ps[i];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			int b = 0,w = 0;
			Point bma(-INF,-INF),bmi(INF,INF),wma = bma,wmi = bmi;
			bool isOK = true;
			for(int k = 0;k < n + m;k++){
				int c = ccw(ps[i],ps[n + j],ps[k]);
				if(abs(c) == 1){
					if(k < n){
						if(!b) b = c;
						else if(b != c) isOK = false;
					}else{
						if(!w) w = c;
						else if(w != c) isOK = false;
					}
				}else{
					if(k < n) chmax(bma,ps[k]),chmin(bmi,ps[k]);
					else chmax(wma,ps[k]),chmin(wmi,ps[k]);
				}
			}
			if(!(bma < wmi || wma < bmi) || (b && b == w)) isOK = false; 
			if(isOK){
				YES();
				return;
			}
		}
	}
	NO();
	return;
}

signed main(){
	while(cin >> n >> m,n) solve();
}


Measured memory_bytes: 3032
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
  	if(n%m){
      cout<<1<<"\n";
    }
  	else
      cout<<0<<"\n";
}



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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;cin>>n>>k;
	int arr[n], dp[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i < n; ++i){
		dp[i] = INT_MAX;
		for(int j = 1; i-j>=0 && j<=k;++j){
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i - j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = (int) 2e5 + 123;

int n, m;
int a[N];
int cnt[N];
int p[N];

void run() {
    cin >> n >> m;
    read(a + 1, a + n + 1);
    rep(i, 1, n + 1) {
        cnt[a[i]]++;
    }
    rep(i, 1, n + 1) {
        p[max(1, i - cnt[i] + 1)]++;
        p[i + 1]--;
    }
    int len = 0;
    rep(i, 1, n + 1) {
        p[i] += p[i - 1];
        len += bool(p[i]);
    }
    
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        
        if (a[x] - cnt[a[x]] + 1 >= 1 && p[a[x] - cnt[a[x]] + 1] == 1) {
            len--;
        }
        if (a[x] - cnt[a[x]] + 1 >= 1) {
            p[a[x] - cnt[a[x]] + 1]--;
        }
        cnt[a[x]]--;
        
        if (y - cnt[y] >= 1 && p[y - cnt[y]] == 0) {
            len++;
        }
        if (y - cnt[y] >= 1) {
            p[y - cnt[y]]++;
        }
        a[x] = y;
        cnt[y]++;
        
        cout << (n - len) << "\n";
    }
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;

struct conflict{
  int a;
  int b;
};


int main(){
  int N, M;
  cin >> N >> M;

  vector<conflict> conflicts;

  for(int i=0; i<M;i++){
    int a,b;
    cin >> a >> b;
    conflicts.push_back({a,b});
  }

  sort(conflicts.begin(), conflicts.end(),
     [](const conflict& x, const conflict& y) { return (x.a != y.b) ? (x.a < y.a) : (x.b < y.b) ;});

  int result = 0; // 切る個数
  int left = conflicts[0].a;
  int right = conflicts[0].b;
  int num = 0; // 扱ったクエリの個数 = 現在のleftのindex
  while(num < M-1){
    if(right >= conflicts[num+1].b){
      left = conflicts[num+1].a;
      right = conflicts[num+1].b;
      num++;
    }else if(right <= conflicts[num+1].a){
      result++;
      left = conflicts[num+1].a;
      right = conflicts[num+1].b;
      num++;
    }else{
      left = conflicts[num+1].a;
      num++;
      /*
      while(num < M-1 && conflicts[num+1].a < right){
        left = conflicts[num+1].a;
        num++;
      }
      result++;
      left = conflicts[num+1].a;
      right = conflicts[num+1].b;
      num++;
      */
    }
  }
  result++;

/*
   for(int i=0; i<M;i++){
     cout << conflicts[i].a << " " << conflicts[i].b << endl;
   }
*/
   cout << result << endl;
  return 0;
}


Measured memory_bytes: 1400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class CSwitches {
public:
    bool light[11];
    vector<int> sw[11];
    int p[11];
    int N, M;

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        M0(light);
        FOR(i, 1, M) {
            int k; in >> k;
            FOR(j, 1, k) {
                int l; in >> l;
                sw[i].push_back(l);
            }
        }
        FOR(i, 1, M) {
            in >> p[i];
        }
        OUT(dfs(1));
    }

    int dfs(int now) {
        if (now == N+1) {
            FOR(i, 1, M) {
                int num = 0;
                FOREACH(s, sw[i]) {
                    if (light[s]) num++;
                }
                if (num % 2 != p[i]) return 0;
            }
            return 1;
        } else {
            bool tmp = light[now];
            int x = dfs(now+1);
            light[now] = !tmp;
            int y = dfs(now+1);
            light[now] = tmp;
            return x + y;
        }
    }
};


int main() {
    CSwitches solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 50+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
int d[N];

int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> d[i];
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++) {
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

p1 = [2,4,5,7,9]
p2 = [0,1,6,8]
p3 = [3]
if n%10 in p1:
    print("hon")
elif n%10 in p2:
    print("pon")
elif n%10 in p3:
    print("bon")

Measured memory_bytes: 9112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MOD 1000000007
#define MAXN 1000000
#define INF 1000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
    LL x=0,F=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*F;
}

int n,m,nxt,res;LL l,r;
char s[MAXN+5],t[MAXN+5];
int f[MAXN+5],cnt[MAXN+5][30];

void getfail(int *fail){
    for(int i=2,j=0;i<=n;i++){
        while(j&&t[i]!=t[j+1])j=fail[j];
        j+=(t[i]==t[j+1]);
        fail[i]=j;
    }
}
LL getres(LL p,int c){
    if(p<=n)return cnt[p][c];
    LL res0=cnt[m][c],res1=cnt[n][c],L0=m,L1=n,tmp;
    while(L0+L1<p){
        tmp=L1,L1+=L0,L0=tmp;
        tmp=res1,res1+=res0,res0=tmp;
    }
    return res1+getres(p-L1,c);
}

int main(){
    scanf("%s",t+1);l=read(),r=read();
    n=strlen(t+1)/2;
    getfail(f),m=n-f[n];
    for(int c=0;c<26;c++)
        for(int i=1;i<=n;i++)
        cnt[i][c]=cnt[i-1][c]+(t[i]==c+'a');
    for(int x=0;x<26;x++)
    printf("%lld ",getres(r,x)-getres(l-1,x));
}


Measured memory_bytes: 15540
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    D, T, S = map(int, readline().split())
    
    if D / S <= T:
        print('Yes')
    else:
        print('No')
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61688
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 500000
long double t[MN+5],st[MN+5];
long long l[MN+5],sl[MN+5];
int z[MN+5],zn;
int main()
{
	int n=read(),L=read(),i,p=1;
	for(i=1;i<=n;++i)
	{
		t[i]=read();l[i]=read();t[i]*=l[i];
		for(;zn&&t[i]*l[z[zn]]<=t[z[zn]]*l[i];--zn)
		{
			t[i]+=t[z[zn]];l[i]+=l[z[zn]];
			if(l[i]>L)t[i]-=t[z[zn]]*(l[i]-L)/l[z[zn]],l[i]=L;
		}
		z[++zn]=i;st[zn]=st[zn-1]+t[i];sl[zn]=sl[zn-1]+l[i];
		if(zn<p)p=zn;
		while(sl[zn]-sl[p]>=L)++p;
		printf("%.7lf\n",double((t[z[p]]*(L-sl[zn]+sl[p])/l[z[p]]+st[zn]-st[p])/L));
	}
}

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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s.at(0) < t.at(0)) {
        cout << "Yes" << endl;
    } else if ((s == t.substr(0, s.size())) and s.size() < t.size()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, A[100000], B[100000], uf[100000][2];
ll res[100000];

int T(int x) {
	if (uf[x][0] == x)
		return x;
	else
		return T(uf[x][0]);
}

ll U(int x, int y) {
	x = T(x);
	y = T(y);
	if (x == y)
		return 0;
	ll a = (ll)uf[x][1] * uf[y][1];
	if (uf[x][1] > uf[y][1]) {
		uf[x][1] += uf[y][1];
		uf[y][0] = x;
	}
	else {
		uf[y][1] += uf[x][1];
		uf[x][0] = y;
	}
	return a;
}


int main() {
	cin >> N >> M;
	for (int i = 0; i != M; ++i) {
		cin >> A[i] >> B[i];
	}
	for (int i = 0; i != N; ++i) {
		uf[i][0] = i;
		uf[i][1] = 1;
	}
	res[M - 1] = (ll)N*(N - 1) / 2;
	for (int i = M - 1; i ; --i) {
		res[i - 1] = res[i] - U(A[i]-1, B[i]-1);
	}
	for (int i = 0; i != M; ++i)
		cout << res[i] << endl;
	return 0;
}

Measured memory_bytes: 3712
n=int(input())
a=list(map(int,input().split()))

ans=[0, 0]
if a[0]!=0:
    sm=a[0]
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[0]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1

    if a[0]>0:
        sm=-1
    else:
        sm=1
    ans[1]+=abs(a[0])+1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[1]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1
if a[0]==0:
    sm=1
    ans[0]+=1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[0]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1

    sm=-1
    ans[1]+=1
    for i in range(n-1):
        sm1=sm+a[i+1]
        if sm*sm1>=0:
            ans[1]+=abs(sm1)+1
            if sm>0:
                sm=-1
            else:
                sm=1
        else:
            sm=sm1
print(min(ans))

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

    for (int i; i < A.size(); i++) cin >> A.at(i);

    int counter = 0;
    bool dividable = true;
    while (dividable) {
        for (int i = 0; i < A.size(); i++) {
            int a = A[i];
            if (a % 2 == 0) {
                a /= 2;
                A[i] = a;
            } else {
                dividable = false;
                break;
            }
        }
        if (dividable) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <queue>
using namespace std;

int main() {
  priority_queue<int> que;
  char str[128];
  while(scanf("%s", str) && str[2] != 'd') {
    if(str[0] == 'i') {
      int key;
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\n", que.top());
      que.pop();
    }
  }
}

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

const long long INF = 1e18;

int main() {
  int n, m;
  cin >> n >> m;
  long long a[n][3];
  for ( int i = 0; i < n; i++ ) {
    for ( int k = 0; k < 3; k++ ) { cin >> a[i][k]; }
  }

  long long ans = -INF;
  for ( int bit = 0; bit < 8; bit++ ) {
    vector<long long> tmp;
    for ( int i = 0; i < n; i++ ) {
      long long sm = 0;
      for ( int k = 0; k < 3; k++ ) {
        if ( bit & (1<<k) ) {
          sm += a[i][k];
        } else {
          sm -= a[i][k];
        }
      }
      tmp.push_back(sm);
    }
    sort(tmp.begin(), tmp.end(), greater<long long>());
    long long val = 0;
    for ( int i = 0; i < m; i++ ) { val += tmp[i]; }
    ans = max(ans, val);
  }

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


Measured memory_bytes: 3660
#include<stdio.h>
int main()
{
   long long int N,K,Q,a[1000000],b[1000000],c[1000000],i,x;
   scanf("%lld%lld%lld",&N,&K,&Q);
   x=Q-K;
   for(i=0;i<N;i++)
   {
     c[i]=0;
   }
   for(i=0;i<Q;i++)
   {
     scanf("%lld",&b[i]);
     c[b[i]-1]=c[b[i]-1]+1;
   }
   for(i=0;i<N;i++)
   {
     if(c[i]>x)
     {
        printf("Yes\n");
     }
     else
     {
        printf("No\n");
     }
   }
   return 0;
}


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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    if(K == 1){
        cout << 0 << endl;
    }else{
        cout << N-K << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ul unsigned long long
#define pb(x) push_back(int x)
#define pop() pop_back()
using namespace std;

int main()
{
    ll n,i,k,j;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int x=n-k;
    if(x%(k-1)==0) j=x/(k-1);
    else  j=x/(k-1)+1;
    cout<<j+1<<endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  map<int,int>cnt;
  map<int,int>::iterator I;;
   int a,b,c,f=0;
   cin>>a>>b>>c;
   cnt[a]++;
   cnt[b]++;
    cnt[c]++;
for(I=cnt.begin();I!=cnt.end();I++)
{
   if(I->first==5&&I->second==2)
        f=1;

  else if(I->first==7&&I->second==1)
        f=2;

}
if(f==2)
    cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;

return 0;
}


Measured memory_bytes: 256
# Hopcroft-Karp Algorithm
from collections import deque
class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        N = self.N; G = self.G
        bfs = self.bfs; dfs = self.dfs
        while bfs():
            *self.it, = map(iter, G)
            while dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]


import sys
readline = sys.stdin.readline
write = sys.stdout.write

X, Y, E = map(int, readline().split())

hc = HopcroftKarp(X, Y)
for i in range(E):
    x, y = map(int, readline().split())
    hc.add_edge(x, y)

write("%d\n" % hc.flow())



Measured memory_bytes: 7976
import sys
n = int(input())
a = list(map(int, input().split()))

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1, i+2+1):
    if(j<n):
      dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]))
print(dp[n-1])


Measured memory_bytes: 13928
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::BTreeMap;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u32; n]
    }

    let mut m: BTreeMap<u32, u32> = BTreeMap::new();

    for &i in a.iter() {
        *m.entry(i).or_insert(0) += 1;
    }

    let mut values: Vec<u32> = m.values().cloned().collect();
    values.sort();

    let d = values.len().saturating_sub(k);
    let ans = values[0..d].iter().sum::<u32>();
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx=1e6;
int main()
{
int i,j,k,n,ans=0;
cin>>n;
int a[n+1],b[n+1],c[n+1];
for(i=1;i<=n;i++)
    cin>>a[i];
for(i=1;i<=n;i++)
    cin>>b[i];
for(i=1;i<=n-1;i++)
    cin>>c[i];
for(i=1;i<=n;i++)
{
    ans+=b[a[i]];
    if(i>0&&a[i]==a[i-1]+1)
        ans+=c[a[i-1]];
}
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n >= m:
    print(0)
else:
    x.sort()
    y = []
    for i in range(len(x)-1):
        y.append(x[i+1]-x[i])
    y.sort()
    number = 0
    for i in range(len(y)-n+1):
        number = number + y[i]
    print(number)

Measured memory_bytes: 13960
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    if (op.equals("+")){
      System.out.println(a+b);
    } else {
      System.out.println(a-b);
    }
  }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>

using namespace std;

struct edge{
  int src, dst, w;
  edge(int src, int dst, int w):src(src),dst(dst),w(w){}
  bool operator<(const edge &t)const{
    if( w != t.w ) return w > t.w;
    if( src != t.src ) return src < t.src;
    return dst < t.dst;
  }
};
typedef vector<edge> edges;
typedef vector<edges> graph;

const int N = 10010;
const int INF = 800000010;

double mst_prim(const graph &g, int r, bool ran[N]){
  const int n = g.size();
  double ret = 0;
  bool vis[n];
  
  fill(vis,vis+n,false);
  priority_queue<edge> Q;
  Q.push( edge(-1,r,10000) );
  ran[r] = true;
  while(!Q.empty()){
    edge e = Q.top(); Q.pop();
    if( vis[e.dst] ) continue;
    //cout << e.w << ' ' << -e.w + 10000 << ' ' << ret << endl;
    ret += sqrt(-e.w+10000);
    vis[e.dst] = true;
    ran[e.dst] = true;
    for(int i = 0; i < (int)g[e.dst].size(); ++i){
      if( !vis[g[e.dst][i].dst] ) Q.push( g[e.dst][i] );
    }
  }
  return ret;
}

#define SQ(a) ((a)*(a))

int main()
{
  int n,m;
  while(EOF!=scanf("%d%d",&n,&m)){
    int x[n],y[n];
    bool ran[N];
    double total = 0;
    graph g(n);

    for(int i = 0; i < n; ++i){
      scanf("%d%d", &x[i], &y[i]);
    }
    fill(ran,ran+n,false);
    
    for(int i = 0; i < m; ++i){
      int p,q;
      scanf("%d%d", &p, &q);
      --p;
      --q;
      int w = SQ(abs(x[p]-x[q])) + SQ(abs(y[p]-y[q]));
      total += sqrt(w);
      g[p].push_back( edge(p,q,10000-w) );
      g[q].push_back( edge(q,p,10000-w) );
    }

    double rem = 0;
    for(int i = 0; i < n; ++i){
      if(!ran[i]){
	double tmp = mst_prim(g,i,ran);
	//cout << tmp << endl;
	rem += tmp;
      }
    }
    printf("%.12lf\n", total-rem);
    
  }
  return 0;
}

Measured memory_bytes: 2472
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[110];
double y[110];
double z[110];
double ABS(double a){return max(a,-a);}
int main(){
	int t;scanf("%d",&t);
	while(t--){
		double X,Y,Z;scanf("%lf%lf%lf",&X,&Y,&Z);
		int a;scanf("%d",&a);
		for(int i=0;i<a;i++)scanf("%lf%lf%lf",x+i,y+i,z+i);
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)for(int k=0;k<a;k++){
			if(i==j||j==k||k==i)continue;
			double A=sqrt((x[j]-x[k])*(x[j]-x[k])+(y[j]-y[k])*(y[j]-y[k])+(z[j]-z[k])*(z[j]-z[k]));
			double B=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]));
			double C=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])+(z[j]-z[i])*(z[j]-z[i]));
			double t=A/X;
			if(ABS(Y*t/B-1)<0.0005&&ABS(Z*t/C-1)<0.0005)printf("%d %d %d\n",i+1,j+1,k+1);
		}
	}
}

Measured memory_bytes: 1072
<?php
list($d, $g) = explode(" ", trim(fgets(STDIN)));

for($i = 0; $i < $d; $i++){
    $map[$i] = explode(" ", trim(fgets(STDIN)));
    $flag[$i] = 0;
}

echo dfs($flag, $d);
function dfs($flag, $l){
    global $d, $map, $g;
    if($l > 0){
        $v1 = dfs($flag, $l-1);
        $flag[$l - 1] = true;
        $v2 = dfs($flag, $l-1);
        return min($v1, $v2);
    }else{
        $s = 0;
        $c = 0;
        for($i = 0; $i < $d; $i++){
            $s+=$flag[$i]*$map[$i][1];
            $s+=$flag[$i]*$map[$i][0] * 100 * ($i+1);
            $c+=$flag[$i]*$map[$i][0];
        }
        if($s >= $g){
            return $c;
        }else{
            for($i = $d - 1; $i >= 0; $i--){
                if($flag[$i] == 0){
                    $needed = ceil(($g - $s) / ($i + 1)/100);
                    if($map[$i][0] > $needed){
                        return $c + $needed;
                    }else{
                        $s += $map[$i][0] * ($i + 1) * 100;
                        $c += $map[$i][0];
                    }
                }
            }
            return $c;
        }
    }
}

Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#define LL long long
LL N;
int A[100010];
LL sum;

int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		scanf("%d",&A[i]);
		sum += A[i];
		if (i == 0)A[0] = A[N];
	}
	LL D = ((N + 1)*N) / 2;
	if (sum%D) {
		printf("%s\n", "NO");
		return 0;
	}
	int ave = sum / D;
	for (int i = 1; i < N; i++) {
		int tmp = A[i] - A[i + 1] + ave;
		if (tmp < 0 || tmp % N) {
			printf("%s\n", "NO");
			return 0;
		}
	}
	printf("%s\n", "YES");
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
int main() {
	int a, b, c, x, y, ans[3];
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	ans[0] = a*x + b*y;
	ans[1] = x < y ? 2 * c*x + b*(y - x) : 2 * c*y + a*(x - y);
	ans[2] = 2 * c*std::max(x, y);
	std::sort(ans, ans + 3);
	printf("%d", ans[0]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	string s;
	cin >> s;
	int n = s.size();
	
	for(int i = 1; i < n; ++i){
		if(s[i - 1] == s[i]){
			printf("%d %d\n", i, i + 1);
			return;
		}
	}
	for(int i = 2; i < n; ++i){
		if(s[i - 2] == s[i]){
			printf("%d %d\n", i - 1, i + 1);
			return;
		}
	}
	puts("-1 -1");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 512
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    a.sort()

    idx = 0

    tmp_size = a[0]
    for i in range(1, n):
        if tmp_size < (a[i] + 1) // 2:
            idx = i
        tmp_size += a[i]

    print(n - idx)


if __name__ == '__main__':
    main()


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

int main(){
  int A,B;
  cin >> A >> B;
  rep(i, 4){
    if(0 == i || i == A || i == B){
      continue;
    }else{
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int rr = 1<<30;
	for (int i = 1; i < N; ++ i) {
		int a = i;
		int b = N - i;
		int r = 0;
		while (a > 0) { r += a % 10; a /= 10; }
		while (b > 0) { r += b % 10; b /= 10; }
		rr = min(rr, r);
	}
	cout << rr << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,c=0;
	cin>>n;
	int d1[n],d2[n];
	for(i=0;i<n;i++)
	{
		cin>>d1[i]>>d2[i];
	}
	for(i=0;i<n-2;i++)
	{
		if(d1[i]==d2[i])
		{
			if(d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2])
			{
				c=1;
				break;
			}
		}

		else 
		{c=0;
		}
		
	}
	if (c==0)
	{
		cout<<"No";
		
	}
	else
	{
		cout<<"Yes";
	}
}

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

int main(){
    int n,m;
    cin >> n>> m;
    vector<int>a(m);
    vector<int>b(m);
    int minans=0,maxans=1e9;
    for(int i=0;i<m;i++){
        cin >> a[i];
        cin >> b[i];
        minans = max(minans,a[i]);
        maxans = min(maxans,b[i]);
    }
    int ans = maxans - minans+1;
   // cout << ans << endl;
    if(ans < 0)cout << 0 << endl;
    else cout << ans << endl;

}


Measured memory_bytes: 1024